user: Converte this assembly snippet into its equivalent C code:

```asm
<process_macros>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x150,%rsp
  mov    %rdi,-0x148(%rbp)
  mov    %rsi,-0x150(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x120(%rbp)
  mov    -0x148(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x134(%rbp)
  movl   $0x100,-0x130(%rbp)
  movl   $0x0,-0x12c(%rbp)
  movb   $0x0,-0x135(%rbp)
  jmp    L122
L195:
  mov    -0x148(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x148(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x136(%rbp)
  subl   $0x1,-0x134(%rbp)
  cmpl   $0x3,-0x12c(%rbp)
  je     L262
  cmpb   $0x5c,-0x136(%rbp)
  jne    L262
  cmpb   $0x5c,-0x135(%rbp)
  je     L262
  mov    -0x134(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x134(%rbp)
  test   %eax,%eax
  je     L361
  movzbl -0x136(%rbp),%eax
  mov    %al,-0x135(%rbp)
  mov    -0x148(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x148(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x136(%rbp)
L262:
  cmpl   $0x3,-0x12c(%rbp)
  je     L91
  cmpl   $0x3,-0x12c(%rbp)
  jg     L41
  cmpl   $0x2,-0x12c(%rbp)
  je     L434
  cmpl   $0x2,-0x12c(%rbp)
  jg     L41
  cmpl   $0x0,-0x12c(%rbp)
  je     L228
  cmpl   $0x1,-0x12c(%rbp)
  je     L20
  jmp    L41
L228:
  cmpb   $0x27,-0x136(%rbp)
  jne    L341
  cmpb   $0x5c,-0x135(%rbp)
  je     L341
  movl   $0x3,-0x12c(%rbp)
  jmp    L41
L341:
  cmpb   $0x24,-0x136(%rbp)
  jne    L153
  cmpb   $0x5c,-0x135(%rbp)
  je     L153
  addl   $0x1,-0x12c(%rbp)
  jmp    L41
L153:
  mov    -0x150(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x150(%rbp)
  movzbl -0x136(%rbp),%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x130(%rbp)
  jmp    L41
L20:
  cmpb   $0x28,-0x136(%rbp)
  je     L175
  cmpb   $0x7b,-0x136(%rbp)
  jne    L114
L175:
  addl   $0x1,-0x12c(%rbp)
  mov    -0x148(%rbp),%rax
  mov    %rax,-0x120(%rbp)
  jmp    L234
L114:
  movl   $0x0,-0x12c(%rbp)
  mov    -0x150(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x150(%rbp)
  movb   $0x24,(%rax)
  subl   $0x1,-0x130(%rbp)
  cmpl   $0x0,-0x130(%rbp)
  je     L234
  mov    -0x150(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x150(%rbp)
  movzbl -0x136(%rbp),%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x130(%rbp)
  jmp    L234
L434:
  cmpb   $0x29,-0x136(%rbp)
  je     L436
  cmpb   $0x7d,-0x136(%rbp)
  jne    L266
L436:
  movq   $0x0,-0x118(%rbp)
  mov    -0x148(%rbp),%rax
  sub    -0x120(%rbp),%rax
  sub    $0x1,%eax
  mov    %eax,-0x124(%rbp)
  movl   $0x0,-0x128(%rbp)
  jmp    L131
L354:
  mov    -0x128(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x120(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x128(%rbp),%eax
  cltq
  mov    %dl,-0x110(%rbp,%rax,1)
  addl   $0x1,-0x128(%rbp)
L131:
  mov    -0x128(%rbp),%eax
  cmp    -0x124(%rbp),%eax
  jl     L354
  mov    -0x128(%rbp),%eax
  cltq
  movb   $0x0,-0x110(%rbp,%rax,1)
  cmpq   $0x0,-0x118(%rbp)
  je     L237
  jmp    L382
L257:
  mov    -0x118(%rbp),%rdx
  lea    0x1(%rdx),%rax
  mov    %rax,-0x118(%rbp)
  mov    -0x150(%rbp),%rax
  lea    0x1(%rax),%rcx
  mov    %rcx,-0x150(%rbp)
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x130(%rbp)
L382:
  mov    -0x118(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L237
  cmpl   $0x0,-0x130(%rbp)
  jne    L257
L237:
  movl   $0x0,-0x12c(%rbp)
  jmp    L266
L91:
  cmpb   $0x27,-0x136(%rbp)
  jne    L23
  cmpb   $0x5c,-0x135(%rbp)
  je     L23
  movl   $0x0,-0x12c(%rbp)
  jmp    L41
L23:
  mov    -0x150(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x150(%rbp)
  movzbl -0x136(%rbp),%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x130(%rbp)
  jmp    L41
L234:
  nop
  jmp    L41
L266:
  nop
L41:
  movzbl -0x136(%rbp),%eax
  mov    %al,-0x135(%rbp)
L122:
  cmpl   $0x0,-0x134(%rbp)
  je     L120
  cmpl   $0x0,-0x130(%rbp)
  jne    L195
  jmp    L120
L361:
  nop
L120:
  cmpl   $0x0,-0x130(%rbp)
  je     L90
  mov    -0x150(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L16
L90:
  mov    -0x150(%rbp),%rax
  sub    $0x1,%rax
  movb   $0x0,(%rax)
L16:
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L170
  call   <__stack_chk_fail@plt>
L170:
  leave
  ret
```

assistant: ```c
void process_macros(const char *input, char *output) {
  char c, prev;
  const char *varname_start = NULL;
  int inputcnt = strlen((char *)input);
  int outputcnt = 256;
  int state = 0;
  prev = '\0';
  while (inputcnt && outputcnt) {
    c = *input++;
    inputcnt--;
    if (state != 3) {
      if ((c == '\\') && (prev != '\\')) {
        if (inputcnt-- == 0)
          break;
        prev = c;
        c = *input++;
      }
    }
    switch (state) {
    case 0:
      if ((c == '\'') && (prev != '\\')) {
        state = 3;
        break;
      }
      if ((c == '$') && (prev != '\\')) {
        state++;
      } else {
        *(output++) = c;
        outputcnt--;
      }
      break;
    case 1:
      if (c == '(' || c == '{') {
        state++;
        varname_start = input;
      } else {
        state = 0;
        *(output++) = '$';
        outputcnt--;
        if (outputcnt) {
          *(output++) = c;
          outputcnt--;
        }
      }
      break;
    case 2:
      if (c == ')' || c == '}') {
        int i;
        char envname[256], *envval = 0;
        int envcnt = input - varname_start - 1;
        for (i = 0; i < envcnt; i++) {
          envname[i] = varname_start[i];
        }
        envname[i] = 0;
        if (envval != NULL)
          while ((*envval) && outputcnt) {
            *(output++) = *(envval++);
            outputcnt--;
          }
        state = 0;
      }
      break;
    case 3:
      if ((c == '\'') && (prev != '\\')) {
        state = 0;
      } else {
        *(output++) = c;
        outputcnt--;
      }
      break;
    }
    prev = c;
  }
  if (outputcnt)
    *output = 0;
  else
    *(output - 1) = 0;
}
```