x86-64 machine code (Linux), 97 bytes
0000000000000000 <oreo_asm>:
0: 56 push %rsi
1: 57 push %rdi
0000000000000002 <len>:
2: 48 ff c7 inc %rdi
5: 80 3f 00 cmpb $0x0,(%rdi)
8: 75 f8 jne 2 <len>
a: 49 89 fc mov %rdi,%r12
d: 5f pop %rdi
e: 49 29 fc sub %rdi,%r12
11: 4d 31 f6 xor %r14,%r14
14: eb 18 jmp 2e <outer_loop.skip>
0000000000000016 <extra>:
16: 41 c6 01 20 movb $0x20,(%r9)
1a: c6 03 20 movb $0x20,(%rbx)
1d: 49 ff ce dec %r14
20: eb 06 jmp 28 <outer_loop>
0000000000000022 <newline>:
22: c6 06 0a movb $0xa,(%rsi)
25: 48 ff c6 inc %rsi
0000000000000028 <outer_loop>:
28: 49 ff c6 inc %r14
2b: 48 ff c7 inc %rdi
000000000000002e <outer_loop.skip>:
2e: 44 8a 07 mov (%rdi),%r8b
31: 41 80 f8 65 cmp $0x65,%r8b
35: 74 df je 16 <extra>
37: 45 84 c0 test %r8b,%r8b
3a: 74 23 je 5f <done>
3c: 48 89 f3 mov %rsi,%rbx
000000000000003f <inner_loop>:
3f: 44 88 06 mov %r8b,(%rsi)
42: 49 89 f1 mov %rsi,%r9
45: 48 ff c6 inc %rsi
48: 48 31 d2 xor %rdx,%rdx
4b: 48 89 f0 mov %rsi,%rax
4e: 48 2b 04 24 sub (%rsp),%rax
52: 4c 29 f0 sub %r14,%rax
55: 49 f7 f4 div %r12
58: 48 85 d2 test %rdx,%rdx
5b: 74 c5 je 22 <newline>
5d: eb e0 jmp 3f <inner_loop>
000000000000005f <done>:
5f: 5e pop %rsi
60: c3 retq
This x86-64 function takes in the pointer to the input string in rsi and builds the output starting at the pointer in rdi (these are the registers used to pass the first two arguments from a C function on Linux). For convenience, I've written a C++ wrapper for this which also does nice input sanitization and prints the output. That code can be located here. This also shows the original nasm syntax assembly I wrote for this function (as well as the non-golfed version I got working first).
A few things to note is that this code doesn't respect any callee saved registers, which means that the C++ code likely will crash if run for a while after calling this function. On my machine it doesn't, but that's rather surprising. I also don't add a null byte to delimit the output string, and instead the space allocated for the output string is pre-filled with bytes. (If this isn't allowed I can add the null terminator at a cost of 3 bytes).
The logic for this code is essentially counting the length of the string, then building a line of this length for each 'o' and 'r' characters seen in the input string, and then for any 'e' character seen, replacing the first and last characters on the previous line with space characters.
I can't find anywhere online to compile and run a mix of C++ and nasm source code, so I might write some small wrapper code for this to prove it works. Otherwise you should be able to compile and run this with the makefile in the link I gave with the command:
$ make oreo ASM_FILE=oreo_golf.nasm
$ ./oreo oreoorererereoo --use_asm
I was able to format the assembly to something acceptable by gcc, so try it online!
re
should be now acceptable as1 or 2 spaces
, not necessarily 2? \$\endgroup\$