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

```asm
<fnmatch>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  movzbl (%rdi),%r12d
  mov    %rsi,0x20(%rsp)
  mov    %edx,0x18(%rsp)
  test   %r12b,%r12b
  je     L473
  mov    %edx,%eax
  mov    %rsi,%rbx
  lea    0x1(%rdi),%rdx
  mov    %rdi,%r15
  mov    %eax,%esi
  mov    %eax,%ebp
  mov    %rbx,0x10(%rsp)
  mov    %rdx,%r13
  and    $0x2,%esi
  and    $0x10,%ebp
  mov    %esi,0x1c(%rsp)
  mov    %eax,%esi
  shr    $0x2,%eax
  mov    %esi,%r14d
  and    $0x1,%eax
  shr    %r14d
  mov    %al,0x2e(%rsp)
  mov    %esi,%eax
  xor    $0x1,%r14d
  mov    %r14d,%esi
  and    $0x1,%esi
  mov    %sil,0x2c(%rsp)
  mov    %eax,%esi
  and    $0x1,%eax
  and    $0x1,%esi
  mov    %eax,0x28(%rsp)
  mov    %sil,0x2d(%rsp)
L592:
  test   %ebp,%ebp
  je     L415
  movzbl %r12b,%edi
  mov    %edi,0xc(%rsp)
  call   <isupper@plt>
  test   %eax,%eax
  je     L1034
  mov    0xc(%rsp),%edi
  call   <tolower@plt>
  mov    %eax,%r12d
L1034:
  cmp    $0x5b,%r12b
  je     L293
  jg     L739
  cmp    $0x2a,%r12b
  je     L749
  cmp    $0x3f,%r12b
  jne    L351
L38:
  mov    0x10(%rsp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L1016
  cmp    $0x2f,%al
  jne    L1092
  cmpb   $0x0,0x2d(%rsp)
  jne    L1016
L1092:
  cmpb   $0x0,0x2e(%rsp)
  je     L1183
  cmp    $0x2e,%al
  je     L1235
L1183:
  mov    %r13,%r15
L117:
  movzbl (%r15),%r12d
  addq   $0x1,0x10(%rsp)
  lea    0x1(%r15),%r13
  test   %r12b,%r12b
  jne    L592
  mov    0x10(%rsp),%rbx
L451:
  movzbl (%rbx),%edx
  xor    %eax,%eax
  test   %dl,%dl
  je     L1118
  mov    0x18(%rsp),%r13d
  shr    $0x3,%r13d
  cmp    $0x2f,%dl
  sete   %al
  and    %r13d,%eax
  xor    $0x1,%eax
  movzbl %al,%eax
  jmp    L1118
  xchg   %ax,%ax
L739:
  cmp    $0x5c,%r12b
  jne    L351
  cmpl   $0x0,0x1c(%rsp)
  jne    L891
  movsbl 0x1(%r15),%r13d
  lea    0x2(%r15),%r12
  movzbl %r13b,%r15d
  mov    %r15d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L1180
  mov    %r15d,%edi
  call   <tolower@plt>
  movsbl %al,%r13d
L1180:
  mov    %r12,%r15
L740:
  mov    0x10(%rsp),%rax
  movzbl (%rax),%r12d
  mov    %r12d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L1203
  mov    %r12d,%edi
  call   <tolower@plt>
  mov    %eax,%r12d
  jmp    L1203
  cs nopw 0x0(%rax,%rax,1)
L415:
  cmp    $0x5b,%r12b
  je     L293
  jg     L675
  cmp    $0x2a,%r12b
  je     L749
  cmp    $0x3f,%r12b
  je     L38
L517:
  mov    0x10(%rsp),%rax
  movsbl %r12b,%r12d
  movzbl (%rax),%r15d
L1010:
  cmp    %r12d,%r15d
  je     L1183
  cs nopw 0x0(%rax,%rax,1)
L1016:
  mov    $0x1,%eax
L1118:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L675:
  cmp    $0x5c,%r12b
  jne    L517
  mov    0x1c(%rsp),%eax
  test   %eax,%eax
  je     L555
  mov    0x10(%rsp),%rax
  mov    %r13,%r15
  mov    $0x5c,%r13d
  movzbl (%rax),%r12d
L1203:
  cmp    %r13d,%r12d
  je     L117
  jmp    L1016
  nopw   0x0(%rax,%rax,1)
L293:
  mov    0x10(%rsp),%rdx
  movzbl (%rdx),%r12d
  test   %r12b,%r12b
  je     L1016
  cmpb   $0x0,0x2e(%rsp)
  je     L1171
  cmp    $0x2e,%r12b
  jne    L1171
  cmp    %rdx,0x20(%rsp)
  je     L1016
  mov    0x28(%rsp),%esi
  mov    %esi,%eax
  test   %esi,%esi
  jne    L1163
L1171:
  movzbl 0x1(%r15),%eax
  lea    0x2(%r15),%rcx
  cmp    $0x21,%al
  sete   %dl
  cmp    $0x5e,%al
  sete   %al
  or     %al,%dl
  cmovne %rcx,%r13
  mov    %dl,0x2f(%rsp)
  lea    0x1(%r13),%r15
  movzbl 0x0(%r13),%r13d
  jmp    L1108
  nopl   0x0(%rax,%rax,1)
L399:
  mov    %r12d,%edi
  mov    %cl,0xc(%rsp)
  call   <isupper@plt>
  movzbl 0xc(%rsp),%ecx
  test   %eax,%eax
  je     L1055
  mov    %r12d,%edi
  call   <tolower@plt>
  movzbl 0xc(%rsp),%ecx
  cmp    %r14d,%eax
  mov    %eax,%ebx
  jl     L807
L402:
  movsbl %cl,%ecx
  cmp    %ebx,%ecx
  jge    L1160
L807:
  cmp    $0x5d,%r13b
  je     L664
L1108:
  cmp    $0x5c,%r13b
  jne    L565
  cmpb   $0x0,0x2c(%rsp)
  jne    L1195
L565:
  test   %ebp,%ebp
  je     L614
  movzbl %r13b,%edi
  mov    %edi,0xc(%rsp)
  call   <isupper@plt>
  test   %eax,%eax
  je     L1115
  mov    0xc(%rsp),%edi
L1099:
  call   <tolower@plt>
  mov    %r15,%rbx
  movsbl %al,%r14d
L894:
  test   %r13b,%r13b
  je     L1016
L309:
  movzbl (%rbx),%edi
  lea    0x1(%rbx),%r15
  mov    %edi,0xc(%rsp)
  mov    %edi,%r13d
  call   <isupper@plt>
  mov    0xc(%rsp),%edi
  test   %eax,%eax
  je     L520
  call   <tolower@plt>
  mov    %eax,%r13d
L520:
  cmp    $0x2f,%r13b
  jne    L183
  cmpb   $0x0,0x2d(%rsp)
  jne    L1016
L183:
  mov    %r14d,%ecx
  cmp    $0x2d,%r13b
  je     L483
L1061:
  mov    %r12d,%ebx
  test   %ebp,%ebp
  jne    L399
L1055:
  cmp    %r12d,%r14d
  jle    L402
  cmp    $0x5d,%r13b
  jne    L1108
L664:
  cmpb   $0x0,0x2f(%rsp)
  jne    L117
  jmp    L1016
  nopl   0x0(%rax)
L614:
  test   %r13b,%r13b
  je     L1016
L886:
  movzbl (%r15),%eax
  mov    %r15,%rbx
  movsbl %r13b,%r14d
  add    $0x1,%r15
  mov    %eax,%r13d
  jmp    L520
  nopl   (%rax)
L483:
  movzbl 0x1(%rbx),%ecx
  cmp    $0x5d,%cl
  je     L481
  lea    0x2(%rbx),%r13
  cmp    $0x5c,%cl
  jne    L930
  cmpb   $0x0,0x2c(%rsp)
  jne    L238
L930:
  test   %cl,%cl
  je     L1016
  test   %ebp,%ebp
  je     L2
  movzbl %cl,%r15d
  mov    %cl,0xc(%rsp)
  mov    %r15d,%edi
  call   <isupper@plt>
  movzbl 0xc(%rsp),%ecx
  test   %eax,%eax
  je     L2
  mov    %r15d,%edi
  call   <tolower@plt>
  mov    %eax,%ecx
L2:
  lea    0x1(%r13),%r15
  movzbl 0x0(%r13),%r13d
  jmp    L1061
  nopw   0x0(%rax,%rax,1)
L1115:
  mov    %r15,%rbx
  movsbl %r13b,%r14d
  jmp    L894
  nopl   0x0(%rax)
L1195:
  movsbl (%r15),%r14d
  lea    0x1(%r15),%rbx
  test   %ebp,%ebp
  jne    L225
  mov    %r14d,%r13d
  mov    %rbx,%r15
  jmp    L886
  nop
L481:
  mov    %r14d,%ecx
  jmp    L1061
  nopl   0x0(%rax,%rax,1)
L225:
  movzbl %r14b,%edi
  mov    %edi,0xc(%rsp)
  call   <isupper@plt>
  mov    0xc(%rsp),%edi
  test   %eax,%eax
  je     L309
  mov    %rbx,%r15
  jmp    L1099
  nopl   0x0(%rax)
L749:
  mov    0x10(%rsp),%rbx
  mov    %r15,%r13
  testb  $0x4,0x18(%rsp)
  je     L1017
  cmpb   $0x2e,(%rbx)
  je     L287
L1017:
  movzbl 0x1(%r13),%r12d
  lea    0x2(%r13),%r14
  cmp    $0x3f,%r12b
  je     L247
  cmp    $0x2a,%r12b
  jne    L587
L247:
  mov    0x18(%rsp),%eax
  and    $0x1,%eax
  nopl   0x0(%rax)
L874:
  test   %eax,%eax
  je     L645
  cmpb   $0x2f,(%rbx)
  je     L1118
L645:
  cmp    $0x3f,%r12b
  je     L493
L40:
  movzbl (%r14),%r12d
  add    $0x1,%r14
  add    $0x1,%rbx
  cmp    $0x3f,%r12b
  je     L874
  cmp    $0x2a,%r12b
  je     L874
L587:
  xor    %eax,%eax
  test   %r12b,%r12b
  je     L1118
  testb  $0x2,0x18(%rsp)
  jne    L1119
  cmp    $0x5c,%r12b
  je     L358
L1119:
  mov    %r12d,%r15d
L583:
  test   %ebp,%ebp
  je     L420
  movzbl %r15b,%edi
  mov    %edi,0xc(%rsp)
  call   <isupper@plt>
  test   %eax,%eax
  jne    L901
L420:
  movzbl (%rbx),%eax
  sub    $0x1,%r14
  test   %al,%al
  je     L1016
  mov    0x18(%rsp),%r13d
  mov    %r15b,0xc(%rsp)
  mov    %rbx,%r15
  and    $0xfffffffb,%r13d
  jmp    L964
  nopl   0x0(%rax)
L582:
  movzbl 0x1(%r15),%eax
  add    $0x1,%r15
  test   %al,%al
  je     L1016
L964:
  cmp    $0x5b,%r12b
  je     L436
  movzbl %al,%ebx
  test   %ebp,%ebp
  je     L670
  mov    %ebx,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L670
  mov    %ebx,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
L670:
  movsbl 0xc(%rsp),%eax
  cmp    %ebx,%eax
  jne    L582
L436:
  xor    %eax,%eax
  mov    %r13d,%edx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <fnmatch>
  test   %eax,%eax
  jne    L582
  jmp    L1118
  nopl   0x0(%rax)
L493:
  cmpb   $0x0,(%rbx)
  jne    L40
  jmp    L1016
  cs nopw 0x0(%rax,%rax,1)
L238:
  movzbl 0x2(%rbx),%ecx
  lea    0x3(%rbx),%r13
  jmp    L930
  nopl   (%rax)
L351:
  mov    0x10(%rsp),%rax
  movsbl %r12b,%r12d
  movzbl (%rax),%r15d
  mov    %r15d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L1010
  mov    %r15d,%edi
  call   <tolower@plt>
  mov    %eax,%r15d
  cmp    %r12d,%r15d
  je     L1183
  jmp    L1016
  cs nopw 0x0(%rax,%rax,1)
L555:
  mov    0x10(%rsp),%rax
  movsbl 0x1(%r15),%r13d
  add    $0x2,%r15
  movzbl (%rax),%r12d
  jmp    L1203
  nopw   0x0(%rax,%rax,1)
L1163:
  cmpb   $0x2f,-0x1(%rdx)
  jne    L1171
  jmp    L1118
  nop
L287:
  cmp    %rbx,0x20(%rsp)
  je     L1016
  mov    0x18(%rsp),%eax
  and    $0x1,%eax
  je     L1017
  cmpb   $0x2f,-0x1(%rbx)
  jne    L1017
  jmp    L1118
  nopw   0x0(%rax,%rax,1)
L1235:
  mov    0x10(%rsp),%rax
  cmp    %rax,0x20(%rsp)
  je     L1016
  cmpb   $0x0,0x2d(%rsp)
  je     L1183
  cmpb   $0x2f,-0x1(%rax)
  jne    L1183
  jmp    L1016
  nopw   0x0(%rax,%rax,1)
L1160:
  cmp    $0x5d,%r13b
  je     L234
  test   %r13b,%r13b
  je     L1016
  movzbl 0x2c(%rsp),%ecx
  jmp    L387
  cs nopw 0x0(%rax,%rax,1)
L435:
  mov    %rdx,%r15
L1048:
  cmp    $0x5d,%al
  je     L234
  test   %al,%al
  je     L1016
L387:
  movzbl (%r15),%eax
  lea    0x1(%r15),%rdx
  cmp    $0x5c,%al
  jne    L435
  test   %cl,%cl
  je     L435
L967:
  movzbl 0x2(%r15),%eax
  lea    0x2(%r15),%rdx
  cmp    $0x5c,%al
  je     L836
  add    $0x3,%r15
  jmp    L1048
L901:
  mov    0xc(%rsp),%edi
  call   <tolower@plt>
  mov    %eax,%r15d
  jmp    L420
L234:
  cmpb   $0x0,0x2f(%rsp)
  je     L117
  jmp    L1016
  nopl   0x0(%rax,%rax,1)
L358:
  movzbl (%r14),%r15d
  jmp    L583
L473:
  mov    0x20(%rsp),%rbx
  jmp    L451
L836:
  mov    %rdx,%r15
  jmp    L967
L891:
  mov    %r13,%r15
  mov    $0x5c,%r13d
  jmp    L740
```

assistant: ```c
int fnmatch(pattern, string, flags) const char *pattern;
const char *string;
int flags;
{
  register const char *p = pattern, *n = string;
  register char c;
  while ((c = *p++) != '\0') {
    c = ((flags & (1 << 4)) && (1 && isupper((unsigned char)c)) ? tolower((unsigned char)c) : ((unsigned char)c));
    switch (c) {
    case '?':
      if (*n == '\0')
        return 1;
      else if ((flags & (1 << 0)) && *n == '/')
        return 1;
      else if ((flags & (1 << 2)) && *n == '.' && (n == string || ((flags & (1 << 0)) && n[-1] == '/')))
        return 1;
      break;
    case '\\':
      if (!(flags & (1 << 1))) {
        c = *p++;
        c = ((flags & (1 << 4)) && (1 && isupper((unsigned char)c)) ? tolower((unsigned char)c) : ((unsigned char)c));
      }
      if (((flags & (1 << 4)) && (1 && isupper((unsigned char)*n)) ? tolower((unsigned char)*n) : ((unsigned char)*n)) != c)
        return 1;
      break;
    case '*':
      if ((flags & (1 << 2)) && *n == '.' && (n == string || ((flags & (1 << 0)) && n[-1] == '/')))
        return 1;
      for (c = *p++; c == '?' || c == '*'; c = *p++, ++n)
        if (((flags & (1 << 0)) && *n == '/') || (c == '?' && *n == '\0'))
          return 1;
      if (c == '\0')
        return 0;
      {
        char c1 = (!(flags & (1 << 1)) && c == '\\') ? *p : c;
        c1 = ((flags & (1 << 4)) && (1 && isupper((unsigned char)c1)) ? tolower((unsigned char)c1) : ((unsigned char)c1));
        for (--p; *n != '\0'; ++n)
          if ((c == '[' || ((flags & (1 << 4)) && (1 && isupper((unsigned char)*n)) ? tolower((unsigned char)*n) : ((unsigned char)*n)) == c1) && fnmatch(p, n, flags & ~(1 << 2)) == 0)
            return 0;
        return 1;
      }
    case '[': {
      register int not ;
      if (*n == '\0')
        return 1;
      if ((flags & (1 << 2)) && *n == '.' && (n == string || ((flags & (1 << 0)) && n[-1] == '/')))
        return 1;
      not = (*p == '!' || *p == '^');
      if (not )
        ++p;
      c = *p++;
      for (;;) {
        register char cstart = c, cend = c;
        if (!(flags & (1 << 1)) && c == '\\')
          cstart = cend = *p++;
        cstart = cend = ((flags & (1 << 4)) && (1 && isupper((unsigned char)cstart)) ? tolower((unsigned char)cstart) : ((unsigned char)cstart));
        if (c == '\0')
          return 1;
        c = *p++;
        c = ((flags & (1 << 4)) && (1 && isupper((unsigned char)c)) ? tolower((unsigned char)c) : ((unsigned char)c));
        if ((flags & (1 << 0)) && c == '/')
          return 1;
        if (c == '-' && *p != ']') {
          cend = *p++;
          if (!(flags & (1 << 1)) && cend == '\\')
            cend = *p++;
          if (cend == '\0')
            return 1;
          cend = ((flags & (1 << 4)) && (1 && isupper((unsigned char)cend)) ? tolower((unsigned char)cend) : ((unsigned char)cend));
          c = *p++;
        }
        if (((flags & (1 << 4)) && (1 && isupper((unsigned char)*n)) ? tolower((unsigned char)*n) : ((unsigned char)*n)) >= cstart && ((flags & (1 << 4)) && (1 && isupper((unsigned char)*n)) ? tolower((unsigned char)*n) : ((unsigned char)*n)) <= cend)
          goto matched;
        if (c == ']')
          break;
      }
      if (!not )
        return 1;
      break;
    matched:;
      while (c != ']') {
        if (c == '\0')
          return 1;
        c = *p++;
        if (!(flags & (1 << 1)) && c == '\\')
          ++p;
      }
      if (not )
        return 1;
    } break;
    default:
      if (c != ((flags & (1 << 4)) && (1 && isupper((unsigned char)*n)) ? tolower((unsigned char)*n) : ((unsigned char)*n)))
        return 1;
    }
    ++n;
  }
  if (*n == '\0')
    return 0;
  if ((flags & (1 << 3)) && *n == '/')
    return 0;
  return 1;
}
```