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),%ebx
  mov    %rsi,0x20(%rsp)
  mov    %edx,0x18(%rsp)
  test   %bl,%bl
  je     L162
  mov    %edx,%eax
  mov    %rsi,%rbp
  lea    0x1(%rdi),%rdx
  mov    %rdi,%r15
  mov    %eax,%esi
  mov    %eax,%r12d
  and    $0x2,%eax
  mov    %rbp,0x10(%rsp)
  mov    %eax,0x1c(%rsp)
  mov    %esi,%eax
  and    $0x10,%r12d
  mov    %rdx,%rbp
  shr    $0x2,%eax
  and    $0x1,%eax
  mov    %al,0x2e(%rsp)
  mov    %esi,%eax
  shr    %eax
  xor    $0x1,%eax
  and    $0x1,%eax
  mov    %al,0x2c(%rsp)
  mov    %esi,%eax
  and    $0x1,%esi
  and    $0x1,%eax
  mov    %esi,0x28(%rsp)
  mov    %al,0x2d(%rsp)
L347:
  movsbl %bl,%r13d
  test   %r12d,%r12d
  je     L376
  mov    %r13d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L180
  mov    %r13d,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  movsbl %al,%r13d
L180:
  cmp    $0x5b,%bl
  je     L1247
  jg     L1170
  cmp    $0x2a,%bl
  je     L922
  cmp    $0x3f,%bl
  jne    L1062
L226:
  mov    0x10(%rsp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L1175
  cmp    $0x2f,%al
  jne    L855
  cmpb   $0x0,0x2d(%rsp)
  jne    L1175
L855:
  cmpb   $0x0,0x2e(%rsp)
  je     L810
  cmp    $0x2e,%al
  je     L955
L810:
  mov    %rbp,%r15
L1054:
  movzbl (%r15),%ebx
  addq   $0x1,0x10(%rsp)
  lea    0x1(%r15),%rbp
  test   %bl,%bl
  jne    L347
  mov    0x10(%rsp),%rbp
L1201:
  movzbl 0x0(%rbp),%ecx
  xor    %eax,%eax
  test   %cl,%cl
  je     L608
  mov    0x18(%rsp),%edx
  shr    $0x3,%edx
  cmp    $0x2f,%cl
  sete   %al
  and    %edx,%eax
  xor    $0x1,%eax
  movzbl %al,%eax
  jmp    L608
  nopl   0x0(%rax)
L1170:
  cmp    $0x5c,%bl
  jne    L1062
  mov    0x1c(%rsp),%eax
  mov    $0x5c,%r14d
  test   %eax,%eax
  je     L815
L489:
  mov    0x10(%rsp),%rax
  mov    %rbp,%r15
  movsbl (%rax),%r13d
  mov    %r13d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L878
  mov    %r13d,%edi
  call   <tolower@plt>
  mov    %eax,%r13d
L878:
  cmp    %r14d,%r13d
  je     L1054
  nopw   0x0(%rax,%rax,1)
L1175:
  mov    $0x1,%eax
L608:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L376:
  cmp    $0x5b,%bl
  je     L1247
  jg     L395
  cmp    $0x2a,%bl
  je     L922
  cmp    $0x3f,%bl
  je     L226
  nopl   0x0(%rax)
L225:
  mov    0x10(%rsp),%rax
  movsbl (%rax),%r14d
L467:
  cmp    %r13d,%r14d
  je     L810
  jmp    L1175
  nopl   0x0(%rax)
L395:
  cmp    $0x5c,%bl
  jne    L225
  cmpl   $0x0,0x1c(%rsp)
  jne    L1087
  mov    0x10(%rsp),%rax
  movsbl 0x1(%r15),%r14d
  add    $0x2,%r15
  movsbl (%rax),%r13d
  cmp    %r14d,%r13d
  je     L1054
  jmp    L1175
  nopl   (%rax)
L1247:
  mov    0x10(%rsp),%rdx
  movzbl (%rdx),%eax
  mov    %al,0xf(%rsp)
  test   %al,%al
  je     L1175
  cmpb   $0x0,0x2e(%rsp)
  je     L8
  cmp    $0x2e,%al
  jne    L8
  cmp    %rdx,0x20(%rsp)
  je     L1175
  mov    0x28(%rsp),%esi
  mov    %esi,%eax
  test   %esi,%esi
  jne    L191
L8:
  movzbl 0x1(%r15),%eax
  lea    0x2(%r15),%rcx
  movsbl 0xf(%rsp),%r13d
  cmp    $0x21,%al
  sete   %sil
  cmp    $0x5e,%al
  sete   %al
  or     %al,%sil
  cmovne %rcx,%rbp
  mov    %sil,0x2f(%rsp)
  movzbl 0x0(%rbp),%r14d
  lea    0x1(%rbp),%r15
  mov    %r14d,%ebp
  jmp    L638
  nopl   0x0(%rax)
L64:
  mov    %r13d,%edi
  mov    %cl,0x8(%rsp)
  call   <isupper@plt>
  movsbl 0x8(%rsp),%ecx
  test   %eax,%eax
  je     L459
  mov    %r13d,%edi
  call   <tolower@plt>
  movsbl 0x8(%rsp),%ecx
  cmp    %ebx,%eax
  mov    %eax,%r14d
  jl     L548
L154:
  cmp    %r14d,%ecx
  jge    L146
L548:
  cmp    $0x5d,%bpl
  je     L1255
L638:
  cmp    $0x5c,%bpl
  jne    L252
  cmpb   $0x0,0x2c(%rsp)
  jne    L433
L252:
  test   %r12d,%r12d
  je     L78
  movsbl %bpl,%edi
  mov    %edi,0x8(%rsp)
  call   <isupper@plt>
  test   %eax,%eax
  je     L1039
  mov    0x8(%rsp),%edi
L884:
  call   <tolower@plt>
  mov    %r15,%r14
  movsbl %al,%ebx
L212:
  test   %bpl,%bpl
  je     L1175
L466:
  movsbl (%r14),%edi
  lea    0x1(%r14),%r15
  mov    %edi,0x8(%rsp)
  mov    %edi,%ebp
  call   <isupper@plt>
  mov    0x8(%rsp),%edi
  test   %eax,%eax
  je     L417
  call   <tolower@plt>
  mov    %eax,%ebp
L417:
  cmp    $0x2f,%bpl
  jne    L1227
  cmpb   $0x0,0x2d(%rsp)
  jne    L1175
L1227:
  movsbl %bl,%ecx
  cmp    $0x2d,%bpl
  je     L1106
L293:
  mov    %r13d,%r14d
  test   %r12d,%r12d
  jne    L64
L459:
  cmp    %bl,0xf(%rsp)
  jge    L154
  cmp    $0x5d,%bpl
  jne    L638
L1255:
  cmpb   $0x0,0x2f(%rsp)
  jne    L1054
  jmp    L1175
  nopl   0x0(%rax,%rax,1)
L78:
  test   %bpl,%bpl
  je     L1175
L618:
  movzbl (%r15),%eax
  mov    %r15,%r14
  movsbl %bpl,%ebx
  add    $0x1,%r15
  mov    %eax,%ebp
  jmp    L417
  nopl   0x0(%rax)
L1106:
  movsbl 0x1(%r14),%ecx
  cmp    $0x5d,%cl
  je     L1080
  lea    0x2(%r14),%rbp
  cmp    $0x5c,%cl
  jne    L148
  cmpb   $0x0,0x2c(%rsp)
  jne    L585
L148:
  test   %cl,%cl
  je     L1175
  test   %r12d,%r12d
  je     L232
  movsbl %cl,%r15d
  mov    %cl,0x8(%rsp)
  mov    %r15d,%edi
  call   <isupper@plt>
  movsbl 0x8(%rsp),%ecx
  test   %eax,%eax
  je     L232
  mov    %r15d,%edi
  call   <tolower@plt>
  movsbl %al,%ecx
L232:
  lea    0x1(%rbp),%r15
  movzbl 0x0(%rbp),%ebp
  jmp    L293
  nopl   0x0(%rax)
L1039:
  mov    %r15,%r14
  movsbl %bpl,%ebx
  jmp    L212
  nopl   0x0(%rax)
L433:
  movsbl (%r15),%ebx
  lea    0x1(%r15),%r14
  test   %r12d,%r12d
  jne    L65
  mov    %ebx,%ebp
  mov    %r14,%r15
  jmp    L618
  nop
L1080:
  movsbl %bl,%ecx
  jmp    L293
  nopl   0x0(%rax,%rax,1)
L65:
  movsbl %bl,%edi
  mov    %edi,0x8(%rsp)
  call   <isupper@plt>
  mov    0x8(%rsp),%edi
  test   %eax,%eax
  je     L466
  mov    %r14,%r15
  jmp    L884
L922:
  mov    0x10(%rsp),%rbp
  testb  $0x4,0x18(%rsp)
  je     L1115
  cmpb   $0x2e,0x0(%rbp)
  je     L389
L1115:
  lea    0x2(%r15),%rbx
  movzbl 0x1(%r15),%r15d
  cmp    $0x3f,%r15b
  je     L542
  cmp    $0x2a,%r15b
  jne    L643
L542:
  mov    0x18(%rsp),%eax
  and    $0x1,%eax
  nopw   0x0(%rax,%rax,1)
L594:
  test   %eax,%eax
  je     L1231
  cmpb   $0x2f,0x0(%rbp)
  je     L608
L1231:
  cmp    $0x3f,%r15b
  je     L1095
L298:
  movzbl (%rbx),%r15d
  add    $0x1,%rbx
  add    $0x1,%rbp
  cmp    $0x3f,%r15b
  je     L594
  cmp    $0x2a,%r15b
  je     L594
L643:
  xor    %eax,%eax
  test   %r15b,%r15b
  je     L608
  testb  $0x2,0x18(%rsp)
  jne    L617
  cmp    $0x5c,%r15b
  je     L609
L617:
  mov    %r15d,%r13d
L863:
  test   %r12d,%r12d
  je     L445
  movsbl %r13b,%r14d
  mov    %r14d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  jne    L178
L445:
  movzbl 0x0(%rbp),%eax
  sub    $0x1,%rbx
  test   %al,%al
  je     L1175
  mov    0x18(%rsp),%r14d
  mov    %r13b,0x8(%rsp)
  mov    %rbp,%r13
  and    $0xfffffffb,%r14d
  jmp    L877
  nopl   0x0(%rax,%rax,1)
L566:
  movzbl 0x1(%r13),%eax
  add    $0x1,%r13
  test   %al,%al
  je     L1175
L877:
  cmp    $0x5b,%r15b
  je     L1218
  movsbl %al,%ebp
  test   %r12d,%r12d
  je     L544
  mov    %ebp,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L544
  mov    %ebp,%edi
  call   <tolower@plt>
  mov    %eax,%ebp
L544:
  movsbl 0x8(%rsp),%eax
  cmp    %ebp,%eax
  jne    L566
L1218:
  xor    %eax,%eax
  mov    %r14d,%edx
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <fnmatch>
  test   %eax,%eax
  jne    L566
  jmp    L608
  nopl   (%rax)
L1095:
  cmpb   $0x0,0x0(%rbp)
  jne    L298
  jmp    L1175
  nop
L585:
  movsbl 0x2(%r14),%ecx
  lea    0x3(%r14),%rbp
  jmp    L148
  xchg   %ax,%ax
L1062:
  mov    0x10(%rsp),%rax
  movsbl (%rax),%r14d
  mov    %r14d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L467
  mov    %r14d,%edi
  call   <tolower@plt>
  mov    %eax,%r14d
  cmp    %r13d,%r14d
  je     L810
  jmp    L1175
  nopw   0x0(%rax,%rax,1)
L815:
  movsbl 0x1(%r15),%r14d
  lea    0x2(%r15),%rbp
  mov    %r14d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L489
  mov    %r14d,%edi
  call   <tolower@plt>
  movsbl %al,%r14d
  jmp    L489
  nopw   0x0(%rax,%rax,1)
L191:
  cmpb   $0x2f,-0x1(%rdx)
  jne    L8
  jmp    L608
  nopw   0x0(%rax,%rax,1)
L389:
  cmp    %rbp,0x20(%rsp)
  je     L1175
  mov    0x18(%rsp),%eax
  and    $0x1,%eax
  je     L1115
  cmpb   $0x2f,-0x1(%rbp)
  jne    L1115
  jmp    L608
  nopw   0x0(%rax,%rax,1)
L955:
  mov    0x10(%rsp),%rax
  cmp    %rax,0x20(%rsp)
  je     L1175
  cmpb   $0x0,0x2d(%rsp)
  je     L810
  cmpb   $0x2f,-0x1(%rax)
  jne    L810
  jmp    L1175
  nopw   0x0(%rax,%rax,1)
L1087:
  mov    0x10(%rsp),%rax
  mov    $0x5c,%r14d
  mov    %rbp,%r15
  movsbl (%rax),%r13d
  cmp    %r14d,%r13d
  je     L1054
  jmp    L1175
L146:
  cmp    $0x5d,%bpl
  je     L726
  test   %bpl,%bpl
  je     L1175
  movzbl 0x2c(%rsp),%ecx
  jmp    L641
  cs nopw 0x0(%rax,%rax,1)
L1112:
  mov    %rdx,%r15
L440:
  cmp    $0x5d,%al
  je     L726
  test   %al,%al
  je     L1175
L641:
  movzbl (%r15),%eax
  lea    0x1(%r15),%rdx
  cmp    $0x5c,%al
  jne    L1112
  test   %cl,%cl
  je     L1112
L734:
  movzbl 0x2(%r15),%eax
  lea    0x2(%r15),%rdx
  cmp    $0x5c,%al
  je     L787
  add    $0x3,%r15
  jmp    L440
L178:
  mov    %r14d,%edi
  call   <tolower@plt>
  mov    %eax,%r13d
  jmp    L445
L726:
  cmpb   $0x0,0x2f(%rsp)
  je     L1054
  jmp    L1175
  nopw   0x0(%rax,%rax,1)
L609:
  movzbl (%rbx),%r13d
  jmp    L863
L162:
  mov    0x20(%rsp),%rbp
  jmp    L1201
L787:
  mov    %rdx,%r15
  jmp    L734
```

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(c)) ? tolower(c) : (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(c)) ? tolower(c) : (c));
      }
      if (((flags & (1 << 4)) && (1 && isupper(*n)) ? tolower(*n) : (*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(c1)) ? tolower(c1) : (c1));
        for (--p; *n != '\0'; ++n)
          if ((c == '[' || ((flags & (1 << 4)) && (1 && isupper(*n)) ? tolower(*n) : (*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(cstart)) ? tolower(cstart) : (cstart));
        if (c == '\0')
          return 1;
        c = *p++;
        c = ((flags & (1 << 4)) && (1 && isupper(c)) ? tolower(c) : (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(cend)) ? tolower(cend) : (cend));
          c = *p++;
        }
        if (((flags & (1 << 4)) && (1 && isupper(*n)) ? tolower(*n) : (*n)) >= cstart && ((flags & (1 << 4)) && (1 && isupper(*n)) ? tolower(*n) : (*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(*n)) ? tolower(*n) : (*n)))
        return 1;
    }
    ++n;
  }
  if (*n == '\0')
    return 0;
  if ((flags & (1 << 3)) && *n == '/')
    return 0;
  return 1;
}
```