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

```asm
<fnmatch>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x8(%rbp)
L546:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0xa(%rbp)
  movsbl -0xa(%rbp),%eax
  cmp    $0x5c,%eax
  je     L317
  cmp    $0x5c,%eax
  jg     L284
  cmp    $0x5b,%eax
  je     L311
  cmp    $0x5b,%eax
  jg     L284
  cmp    $0x3f,%eax
  je     L174
  cmp    $0x3f,%eax
  jg     L284
  test   %eax,%eax
  je     L248
  cmp    $0x2a,%eax
  je     L82
  jmp    L284
L248:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L283
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L283:
  mov    $0x0,%eax
  jmp    L19
L174:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L5
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L5:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jne    L540
  mov    D187(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  je     L540
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L540:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L618
  mov    D94(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  je     L618
  mov    -0x20(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  je     L585
  mov    D187(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  je     L618
  mov    -0x20(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jne    L618
L585:
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L618:
  addq   $0x1,-0x20(%rbp)
  jmp    L179
L82:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0xa(%rbp)
  jmp    L78
L617:
  addq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0xa(%rbp)
L78:
  cmpb   $0x2a,-0xa(%rbp)
  je     L617
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L414
  mov    D94(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  je     L414
  mov    -0x20(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  je     L34
  mov    D187(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  je     L414
  mov    -0x20(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jne    L414
L34:
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L414:
  cmpb   $0x0,-0xa(%rbp)
  jne    L107
  mov    D187(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  je     L8
  mov    -0x20(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <index@plt>
  test   %rax,%rax
  je     L381
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L381:
  mov    $0x0,%eax
  jmp    L19
L8:
  mov    $0x0,%eax
  jmp    L19
L107:
  cmpb   $0x2f,-0xa(%rbp)
  jne    L69
  mov    D187(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  je     L69
  mov    -0x20(%rbp),%rax
  mov    $0x2f,%esi
  mov    %rax,%rdi
  call   <index@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L434
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L186:
  mov    D94(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    -0x24(%rbp),%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fnmatch>
  test   %eax,%eax
  jne    L443
  mov    $0x0,%eax
  jmp    L19
L443:
  cmpb   $0x2f,-0x9(%rbp)
  jne    L170
  mov    D187(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  jne    L50
L170:
  addq   $0x1,-0x20(%rbp)
L69:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0x9(%rbp)
  cmpb   $0x0,-0x9(%rbp)
  jne    L186
  jmp    L560
L50:
  nop
L560:
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L311:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L191
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L191:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2f,%al
  jne    L549
  mov    D187(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  je     L549
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L549:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%ecx
  mov    -0x24(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <rangematch@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L165
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L165:
  addq   $0x1,-0x20(%rbp)
  jmp    L179
L317:
  mov    D163(%rip),%rax
  mov    (%rax),%eax
  and    -0x24(%rbp),%eax
  test   %eax,%eax
  jne    L284
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0xa(%rbp)
  cmpb   $0x0,-0xa(%rbp)
  jne    L284
  movb   $0x5c,-0xa(%rbp)
  subq   $0x1,-0x18(%rbp)
L284:
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movzbl (%rax),%eax
  cmp    %al,-0xa(%rbp)
  je     L167
  mov    D157(%rip),%rax
  mov    (%rax),%eax
  jmp    L19
L434:
  nop
  jmp    L546
L167:
  nop
L179:
  jmp    L546
L19:
  leave
  ret
```

assistant: ```c
int fnmatch(const char *pattern, const char *string, int flags) {
  const char *stringstart = string;
  char c;
  char test;
  for (;;) {
    switch (c = *pattern++) {
    case '\0':
      return (*string == '\0' ? 0 : FNM_NOMATCH);
    case '?':
      if (*string == '\0') {
        return (FNM_NOMATCH);
      }
      if (*string == '/' && (flags & FNM_PATHNAME)) {
        return (FNM_NOMATCH);
      }
      if (*string == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) {
        return (FNM_NOMATCH);
      }
      ++string;
      break;
    case '*':
      c = *pattern;
      while (c == '*') {
        c = *++pattern;
      }
      if (*string == '.' && (flags & FNM_PERIOD) && (string == stringstart || ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) {
        return (FNM_NOMATCH);
      }
      if (c == '\0') {
        if (flags & FNM_PATHNAME) {
          return (index(string, '/') == NULL ? 0 : FNM_NOMATCH);
        } else {
          return (0);
        }
      } else if (c == '/' && flags & FNM_PATHNAME) {
        if ((string = index(string, '/')) == NULL) {
          return (FNM_NOMATCH);
        }
        break;
      }
      while ((test = *string) != '\0') {
        if (!fnmatch(pattern, string, flags & ~FNM_PERIOD)) {
          return (0);
        }
        if (test == '/' && flags & FNM_PATHNAME) {
          break;
        }
        ++string;
      }
      return (FNM_NOMATCH);
    case '[':
      if (*string == '\0') {
        return (FNM_NOMATCH);
      }
      if (*string == '/' && flags & FNM_PATHNAME) {
        return (FNM_NOMATCH);
      }
      if ((pattern = rangematch(pattern, *string, flags)) == NULL) {
        return (FNM_NOMATCH);
      }
      ++string;
      break;
    case '\\':
      if (!(flags & FNM_NOESCAPE)) {
        if ((c = *pattern++) == '\0') {
          c = '\\';
          --pattern;
        }
      }
    default:
      if (c != *string++) {
        return (FNM_NOMATCH);
      }
      break;
    }
  }
}
```