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

```asm
<glob_to_regex>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    D19(%rip),%rdi
  call   <strdup@plt>
  mov    %rax,0x8(%rsp)
  movq   $0x1,0x10(%rsp)
  movzbl (%rbx),%esi
  test   %sil,%sil
  je     L24
  lea    D21(%rip),%r12
  lea    0x10(%rsp),%rbp
  lea    D32(%rip),%r13
  lea    D10(%rip),%r14
  jmp    L288
L261:
  lea    0x8(%rsp),%rdi
  mov    $0x5c,%edx
  mov    %rbp,%rsi
  call   <strappendch@plt>
  test   %rax,%rax
  jne    L198
  mov    %rbx,%r15
L83:
  lea    0x1(%r15),%rbx
  movsbl (%r15),%edx
  lea    0x8(%rsp),%rdi
  mov    %rbp,%rsi
  call   <strappendch@plt>
  test   %rax,%rax
  jne    L198
L233:
  movzbl (%rbx),%esi
  test   %sil,%sil
  je     L24
L288:
  movsbl %sil,%esi
  mov    %r12,%rdi
  call   <char_is_one_of@plt>
  test   %rax,%rax
  je     L113
  cmpb   $0x5e,(%rbx)
  jne    L261
  mov    0x8(%rsp),%rdx
  mov    0x10(%rsp),%rax
  cmpb   $0x5b,-0x1(%rdx,%rax,1)
  jne    L261
  mov    %rbx,%r15
  jmp    L83
L113:
  movzbl (%rbx),%eax
  cmp    $0x21,%al
  je     L111
  cmp    $0x5c,%al
  je     L263
  cmp    $0x3f,%al
  je     L120
  cmp    $0x2a,%al
  jne    L195
  cmpq   $0x1,0x10(%rsp)
  je     L238
  lea    0x8(%rsp),%rdi
  mov    %r13,%rdx
  mov    %rbp,%rsi
  call   <strappend@plt>
  test   %rax,%rax
  jne    L198
L273:
  add    $0x1,%rbx
  jmp    L233
L111:
  mov    %rbx,%r15
  mov    0x8(%rsp),%rdx
  mov    0x10(%rsp),%rax
  cmpb   $0x5b,-0x1(%rdx,%rax,1)
  jne    L83
  lea    0x8(%rsp),%rdi
  mov    $0x5e,%edx
  mov    %rbp,%rsi
  call   <strappendch@plt>
  test   %rax,%rax
  jne    L198
  jmp    L233
L263:
  lea    0x1(%rbx),%r15
  lea    0x8(%rsp),%rdi
  mov    $0x5c,%edx
  mov    %rbp,%rsi
  call   <strappendch@plt>
  test   %rax,%rax
  je     L83
  mov    %r15,%rbx
  jmp    L198
L120:
  lea    0x8(%rsp),%rdi
  mov    $0x2e,%edx
  mov    %rbp,%rsi
  call   <strappendch@plt>
  test   %rax,%rax
  je     L58
L198:
  cmpb   $0x0,(%rbx)
  jne    L1
L24:
  lea    0x10(%rsp),%rsi
  lea    0x8(%rsp),%rdi
  mov    $0x24,%edx
  call   <strappendch@plt>
  mov    %rax,%rdx
  mov    0x8(%rsp),%rax
  test   %rdx,%rdx
  jne    L1
L26:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L163
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L58:
  add    $0x1,%rbx
  jmp    L233
L238:
  lea    0x8(%rsp),%rdi
  mov    %r14,%rdx
  mov    %rbp,%rsi
  call   <strappend@plt>
  test   %rax,%rax
  jne    L198
  jmp    L273
L195:
  mov    %rbx,%r15
  jmp    L83
L1:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L26
L163:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: label: D19
datatype: string
name: parse_data
arguments: label: D21
datatype: string
name: parse_data
arguments: label: D32
datatype: string
name: parse_data
arguments: label: D10
datatype: string

tool: D19: ^$

tool: D21: ^.$()|+{

tool: D32: .*

tool: D10: [^.].*

assistant: ```c
char *glob_to_regex(const char glob[]) {
  static const char CHARS_TO_ESCAPE[] = "^.$()|+{";
  char *result = strdup("^$");
  size_t result_len = 1;
  while (*glob != '\0') {
    if (char_is_one_of(CHARS_TO_ESCAPE, *glob)) {
      if (*glob != '^' || result[result_len - 1] != '[') {
        if (strappendch(&result, &result_len, '\\') != 0) {
          break;
        }
      }
    } else if (*glob == '!' && result[result_len - 1] == '[') {
      if (strappendch(&result, &result_len, '^') != 0) {
        break;
      }
      continue;
    } else if (*glob == '\\') {
      if (strappendch(&result, &result_len, *glob++) != 0) {
        break;
      }
    } else if (*glob == '?') {
      if (strappendch(&result, &result_len, '.') != 0) {
        break;
      }
      ++glob;
      continue;
    } else if (*glob == '*') {
      if (result_len == 1) {
        if (strappend(&result, &result_len, "[^.].*") != 0) {
          break;
        }
      } else {
        if (strappend(&result, &result_len, ".*") != 0) {
          break;
        }
      }
      ++glob;
      continue;
    }
    if (strappendch(&result, &result_len, *glob++) != 0) {
      break;
    }
  }
  if (*glob != '\0' || strappendch(&result, &result_len, '$') != 0) {
    free(result);
    return NULL;
  }
  return result;
}
```