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

```asm
<parse_dollars>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %rdx,%rdi
  mov    (%r8),%rdx
  movzbl 0x1(%rcx,%rdx,1),%eax
  cmp    $0x28,%al
  je     L179
  lea    0x1(%rdx),%r10
  jg     L177
  cmp    $0x27,%al
  ja     L40
  movabs $0x8400000001,%rdx
  bt     %rax,%rdx
  jae    L40
  mov    $0x24,%ecx
  mov    %rdi,%rdx
  mov    (%rbx),%rdi
  call   <w_addchar@plt>
  mov    %rax,%rdx
  mov    %rax,(%rbx)
  mov    $0x0,%eax
  test   %rdx,%rdx
  jne    L139
  mov    D22(%rip),%rax
  mov    (%rax),%eax
  jmp    L139
L177:
  cmp    $0x5b,%al
  jne    L40
  add    $0x2,%rdx
  mov    %rdx,(%r8)
  sub    $0x8,%rsp
  push   $0x1
  mov    %rdi,%rdx
  mov    %rbx,%rdi
  call   <parse_arith@plt>
  add    $0x10,%rsp
L139:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L179:
  lea    0x2(%rdx),%r12
  cmpb   $0x28,0x2(%rcx,%rdx,1)
  je     L106
L24:
  mov    D13(%rip),%rax
  mov    %r9d,%edx
  and    (%rax),%edx
  jne    L142
  mov    %r12,(%r8)
  cmpl   $0x0,0x38(%rsp)
  mov    $0x0,%eax
  cmove  0x20(%rsp),%rax
  mov    %rax,0x20(%rsp)
  sub    $0x8,%rsp
  push   0x38(%rsp)
  push   0x38(%rsp)
  push   0x38(%rsp)
  mov    %rdi,%rdx
  mov    %rbx,%rdi
  call   <parse_comm@plt>
  add    $0x20,%rsp
  jmp    L139
L106:
  lea    0x3(%rdx),%r10d
  movslq %r10d,%r10
  movzbl (%rcx,%r10,1),%eax
  test   %al,%al
  je     L24
  cmp    $0x29,%al
  je     L138
  add    $0x1,%r10
  mov    $0x0,%r11d
  jmp    L159
L128:
  mov    %rbp,%r10
L159:
  cmp    $0x28,%al
  je     L28
  cmp    $0x29,%al
  sete   %al
  movzbl %al,%eax
  sub    %eax,%r11d
L165:
  movzbl (%rcx,%r10,1),%eax
  test   %al,%al
  je     L24
  lea    0x1(%r10),%rbp
  cmp    $0x29,%al
  jne    L128
  test   %r11d,%r11d
  jne    L128
L138:
  cmpb   $0x29,0x1(%rcx,%r10,1)
  jne    L24
  add    $0x3,%rdx
  mov    %rdx,(%r8)
  sub    $0x8,%rsp
  push   $0x0
  mov    %rdi,%rdx
  mov    %rbx,%rdi
  call   <parse_arith@plt>
  add    $0x10,%rsp
  jmp    L139
L28:
  add    $0x1,%r11d
  jmp    L165
L142:
  mov    D10(%rip),%rax
  mov    (%rax),%eax
  jmp    L139
L40:
  mov    %r10,(%r8)
  mov    0x38(%rsp),%eax
  push   %rax
  push   0x38(%rsp)
  push   0x38(%rsp)
  push   0x38(%rsp)
  mov    %rdi,%rdx
  mov    %rbx,%rdi
  call   <parse_param@plt>
  add    $0x20,%rsp
  jmp    L139
```

assistant: ```c
int parse_dollars(char **word, size_t *word_length, size_t *max_length, const char *words, size_t *offset, int flags, wordexp_t *pwordexp, const char *ifs, const char *ifs_white, int quoted) {
  switch (words[1 + *offset]) {
  case '"':
  case '\'':
  case 0:
    *word = w_addchar(*word, word_length, max_length, '$');
    return *word ? 0 : WRDE_NOSPACE;
  case '(':
    if (words[2 + *offset] == '(') {
      int i = 3 + *offset;
      int depth = 0;
      while (words[i] && !(depth == 0 && words[i] == ')')) {
        if (words[i] == '(')
          ++depth;
        else if (words[i] == ')')
          --depth;
        ++i;
      }
      if (words[i] == ')' && words[i + 1] == ')') {
        (*offset) += 3;
        return parse_arith(word, word_length, max_length, words, offset, flags, 0);
      }
    }
    if (flags & WRDE_NOCMD)
      return WRDE_CMDSUB;
    (*offset) += 2;
    return parse_comm(word, word_length, max_length, words, offset, flags, quoted ? NULL : pwordexp, ifs, ifs_white);
  case '[':
    (*offset) += 2;
    return parse_arith(word, word_length, max_length, words, offset, flags, 1);
  case '{':
  default:
    ++(*offset);
    return parse_param(word, word_length, max_length, words, offset, flags, pwordexp, ifs, ifs_white, quoted);
  }
}
```