~:1+%,~:1+!"`"*+,~:1+!"`"*+,,
Try it online!
Outputs nothing for an empty input, otherwise outputs strings of length 3 separated by NUL characters.
Explanation:
~ Push character of input to stack
:1+ Duplicate input and add 1
% Modulo top 2 values of stack and push result
If input was -1 (end of stream), calculate -1%0 -> halt
Otherwise calculate input%(input+1) -> input
, Pop and output character
~ Push character of input to stack
:1+! Duplicate input, add 1 and perform logical NOT
"`"* Multiply by 96 (ASCII code for '`')
This returns 96 or 0 depending on the result of the NOT
+ Add the top 2 values from the stack and push the result
If the input was -1 (end of stream), pushes -1+96=95, or the ASCII code for '_'
Otherwise pushes input+0
, Pop and output character
~:1+!"`"*+, Same block again to handle the third character
, Output a NUL character (stack is empty, so popping from stack just returns 0)
The instruction pointer wraps around at the end, looping the entire line.