user: Please show me the C implementation that matches the assembly code listed below:

```asm
<flip>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  lea    -0x1(%rdi),%rbx
  sub    $0x218,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x208(%rsp)
  xor    %eax,%eax
  movb   $0x0,(%rsp)
  movb   $0x0,0x100(%rsp)
  nopl   0x0(%rax,%rax,1)
L104:
  movsbl (%rbx),%edi
  sub    $0x1,%rbx
  call   <isspace@plt>
  test   %rax,%rax
  jne    L104
  movsbl 0x1(%rbx),%edi
  xor    %r13d,%r13d
  xor    %ebp,%ebp
  lea    0x1(%rbx),%r14
  cmp    $0x7b,%dil
  je     L11
  nopl   0x0(%rax,%rax,1)
L122:
  cmp    $0x7d,%dil
  je     L12
  test   %r13d,%r13d
  jne    L70
  call   <isspace@plt>
  test   %rax,%rax
  jne    L110
  cmpb   $0x24,0x1(%rbx)
  jne    L150
L110:
  movzbl 0x1(%r14),%edi
  lea    0x2(%rbx),%rbp
L79:
  cmp    $0x5c,%dil
  je     L101
  mov    %rsp,%r15
  cmp    $0x7b,%dil
  mov    %rbp,%rdi
  mov    %r15,%rsi
  je     L151
  call   <getword@plt>
  lea    0x100(%rsp),%r13
L59:
  movb   $0x0,0x0(%rbp)
  mov    %r12,%rdx
  lea    D2(%rip),%rsi
  xor    %eax,%eax
  mov    %r13,%rdi
  mov    %r15,%rcx
  call   <sprintf@plt>
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <strapp@plt>
  mov    0x208(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L128
  add    $0x218,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L12:
  add    $0x1,%r13d
L70:
  cmp    %r13d,%ebp
  jne    L150
  test   %ebp,%ebp
  jne    L162
L150:
  movsbl (%rbx),%edi
  sub    $0x1,%rbx
  lea    0x1(%rbx),%r14
  cmp    $0x7b,%dil
  jne    L122
L11:
  add    $0x1,%ebp
  cmp    %ebp,%r13d
  jge    L70
  jmp    L110
  nop
L151:
  call   <get_brace_arg@plt>
  lea    0x100(%rsp),%r13
  jmp    L59
  nopw   0x0(%rax,%rax,1)
L101:
  lea    0x100(%rsp),%r13
  lea    0x2(%r14),%rdi
  mov    %rsp,%r15
  mov    %r13,%rsi
  lea    0x1(%r14),%rbp
  call   <getword@plt>
  mov    %r13,%rdx
  mov    %r15,%rdi
  xor    %eax,%eax
  lea    D8(%rip),%rsi
  call   <sprintf@plt>
  jmp    L59
  nopl   0x0(%rax)
L162:
  mov    %r14,%rbp
  mov    %rbx,%r14
  jmp    L79
L128:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D2
type_guessed: string
name: disassemble_data
arguments: data_label: D8
type_guessed: string

tool: D2: \%s %s

tool: D8: \%s

assistant: ```c
char *flip(char *pout, char *w) {
  int lb = 0, rb = 0;
  char ww[250], tmp[250];
  ww[0] = '\0';
  tmp[0] = '\0';
  pout--;
  while (isspace(*pout))
    pout--;
  while (1) {
    if (*pout == '{') {
      lb++;
      if (lb > rb)
        break;
    }
    if (*pout == '}')
      rb++;
    if (rb == 0) {
      if (!isspace(*pout) && *pout != '$') {
        pout--;
        continue;
      } else
        break;
    }
    pout--;
    if (lb == rb && lb != 0)
      break;
  }
  pout++;
  if (*pout == '\\') {
    pout++;
    (void)getword(pout, tmp);
    sprintf(ww, "\\%s", tmp);
    pout--;
  } else if (*pout == '{')
    (void)get_brace_arg(pout, ww);
  else
    (void)getword(pout, ww);
  *pout = '\0';
  sprintf(tmp, "\\%s %s", w, ww);
  pout = strapp(pout, tmp);
  return (pout);
}
```