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,0x28(%rsp)
  test   %bl,%bl
  je     L1407
  mov    %edx,%eax
  mov    %edx,%r15d
  and    $0x2,%edx
  mov    %rsi,0x10(%rsp)
  mov    %edx,0x1c(%rsp)
  mov    %eax,%edx
  shr    $0x2,%eax
  lea    0x1(%rdi),%r14
  and    $0x1,%edx
  and    $0x1,%eax
  and    $0x10,%r15d
  mov    %rdi,%rbp
  mov    %edx,0x18(%rsp)
  mov    %r14,%r13
  mov    %al,0x2e(%rsp)
  mov    %dl,0x2d(%rsp)
L766:
  movsbl %bl,%r12d
  test   %r15d,%r15d
  je     L1170
  mov    %r12d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L158
  mov    %r12d,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  movsbl %al,%r12d
L158:
  cmp    $0x5b,%bl
  je     L1412
  jg     L22
  cmp    $0x2a,%bl
  je     L1344
  cmp    $0x3f,%bl
  jne    L624
L174:
  mov    0x10(%rsp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L1358
  cmp    $0x2f,%al
  jne    L1006
  cmpb   $0x0,0x2d(%rsp)
  jne    L1358
L1006:
  cmpb   $0x0,0x2e(%rsp)
  je     L956
  cmp    $0x2e,%al
  je     L924
L956:
  mov    %r13,%rbp
L566:
  movzbl 0x0(%rbp),%ebx
  addq   $0x1,0x10(%rsp)
  lea    0x1(%rbp),%r13
  test   %bl,%bl
  jne    L766
  mov    0x10(%rsp),%rbp
L353:
  movzbl 0x0(%rbp),%eax
  movl   $0x0,0x18(%rsp)
  test   %al,%al
  je     L146
  mov    0x28(%rsp),%edx
  shr    $0x3,%edx
  cmp    $0x2f,%al
  sete   %al
  and    %edx,%eax
  xor    $0x1,%eax
  movzbl %al,%eax
  mov    %eax,0x18(%rsp)
  jmp    L146
  nopw   0x0(%rax,%rax,1)
L22:
  cmp    $0x5c,%bl
  jne    L624
  mov    0x1c(%rsp),%eax
  mov    $0x5c,%r14d
  test   %eax,%eax
  je     L1164
L394:
  mov    0x10(%rsp),%rax
  mov    %r13,%rbp
  movsbl (%rax),%r12d
  mov    %r12d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L1100
  mov    %r12d,%edi
  call   <tolower@plt>
  mov    %eax,%r12d
L1100:
  cmp    %r14d,%r12d
  je     L566
  nopw   0x0(%rax,%rax,1)
L1358:
  movl   $0x1,0x18(%rsp)
L146:
  mov    0x18(%rsp),%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L1170:
  cmp    $0x5b,%bl
  je     L1412
  jg     L363
  cmp    $0x2a,%bl
  je     L1344
  cmp    $0x3f,%bl
  je     L174
  nopl   0x0(%rax)
L1248:
  mov    0x10(%rsp),%rax
  movsbl (%rax),%r14d
L239:
  cmp    %r12d,%r14d
  je     L956
  jmp    L1358
  nopl   0x0(%rax)
L363:
  cmp    $0x5c,%bl
  jne    L1248
  cmpl   $0x0,0x1c(%rsp)
  jne    L611
  mov    0x10(%rsp),%rax
  movsbl 0x1(%rbp),%r14d
  add    $0x2,%rbp
  movsbl (%rax),%r12d
  cmp    %r14d,%r12d
  je     L566
  jmp    L1358
  nopl   0x0(%rax,%rax,1)
L1412:
  mov    0x10(%rsp),%rsi
  movzbl (%rsi),%eax
  mov    %al,0xf(%rsp)
  test   %al,%al
  je     L1358
  cmpb   $0x0,0x2e(%rsp)
  je     L29
  cmp    $0x2e,%al
  jne    L29
  cmp    %rsi,0x20(%rsp)
  je     L1358
  mov    0x18(%rsp),%ecx
  test   %ecx,%ecx
  jne    L618
L29:
  movzbl 0x1(%rbp),%eax
  lea    0x2(%rbp),%rcx
  movsbl 0xf(%rsp),%r12d
  cmp    $0x21,%al
  sete   %dl
  cmp    $0x5e,%al
  sete   %al
  or     %al,%dl
  cmovne %rcx,%r13
  mov    %dl,0x2f(%rsp)
  mov    0x1c(%rsp),%edx
  lea    0x1(%r13),%rbp
  movzbl 0x0(%r13),%r13d
  test   %edx,%edx
  sete   0x2c(%rsp)
  mov    %r13d,%r14d
  jmp    L423
  nopl   0x0(%rax)
L240:
  mov    %r12d,%edi
  mov    %cl,0x8(%rsp)
  call   <isupper@plt>
  movsbl 0x8(%rsp),%ecx
  test   %eax,%eax
  je     L1401
  mov    %r12d,%edi
  call   <tolower@plt>
  movsbl 0x8(%rsp),%ecx
  cmp    %ebx,%eax
  mov    %eax,%r13d
  jl     L889
L151:
  cmp    %r13d,%ecx
  jge    L532
L889:
  cmp    $0x5d,%r14b
  je     L1128
L423:
  cmp    $0x5c,%r14b
  jne    L104
  cmpb   $0x0,0x2c(%rsp)
  jne    L475
L104:
  test   %r15d,%r15d
  je     L15
  movsbl %r14b,%edi
  mov    %edi,0x8(%rsp)
  call   <isupper@plt>
  test   %eax,%eax
  je     L780
  mov    0x8(%rsp),%edi
L109:
  call   <tolower@plt>
  mov    %rbp,%r13
  movsbl %al,%ebx
L1394:
  test   %r14b,%r14b
  je     L1358
L302:
  movsbl 0x0(%r13),%edi
  lea    0x1(%r13),%rbp
  mov    %edi,0x8(%rsp)
  mov    %edi,%r14d
  call   <isupper@plt>
  mov    0x8(%rsp),%edi
  test   %eax,%eax
  je     L166
  call   <tolower@plt>
  mov    %eax,%r14d
L166:
  cmp    $0x2f,%r14b
  jne    L58
  cmpb   $0x0,0x2d(%rsp)
  jne    L1358
L58:
  movsbl %bl,%ecx
  cmp    $0x2d,%r14b
  je     L1143
L433:
  mov    %r12d,%r13d
  test   %r15d,%r15d
  jne    L240
L1401:
  cmp    %bl,0xf(%rsp)
  jge    L151
  cmp    $0x5d,%r14b
  jne    L423
L1128:
  cmpb   $0x0,0x2f(%rsp)
  jne    L566
  jmp    L1358
  xchg   %ax,%ax
L15:
  test   %r14b,%r14b
  je     L1358
L145:
  movzbl 0x0(%rbp),%eax
  mov    %rbp,%r13
  movsbl %r14b,%ebx
  add    $0x1,%rbp
  mov    %eax,%r14d
  jmp    L166
  nopl   (%rax)
L1143:
  movsbl 0x1(%r13),%ecx
  cmp    $0x5d,%cl
  je     L784
  lea    0x2(%r13),%r14
  cmp    $0x5c,%cl
  jne    L94
  cmpb   $0x0,0x2c(%rsp)
  jne    L997
L94:
  test   %cl,%cl
  je     L1358
  test   %r15d,%r15d
  je     L418
  movsbl %cl,%ebp
  mov    %cl,0x8(%rsp)
  mov    %ebp,%edi
  call   <isupper@plt>
  movsbl 0x8(%rsp),%ecx
  test   %eax,%eax
  je     L418
  mov    %ebp,%edi
  call   <tolower@plt>
  movsbl %al,%ecx
L418:
  lea    0x1(%r14),%rbp
  movzbl (%r14),%r14d
  jmp    L433
  nopl   (%rax)
L780:
  mov    %rbp,%r13
  movsbl %r14b,%ebx
  jmp    L1394
  nopl   0x0(%rax)
L475:
  movsbl 0x0(%rbp),%ebx
  lea    0x1(%rbp),%r13
  test   %r15d,%r15d
  jne    L667
  mov    %ebx,%r14d
  mov    %r13,%rbp
  jmp    L145
  nopl   0x0(%rax,%rax,1)
L784:
  movsbl %bl,%ecx
  jmp    L433
  nopl   0x0(%rax,%rax,1)
L667:
  movsbl %bl,%edi
  mov    %edi,0x8(%rsp)
  call   <isupper@plt>
  mov    0x8(%rsp),%edi
  test   %eax,%eax
  je     L302
  mov    %r13,%rbp
  jmp    L109
L1344:
  mov    %rbp,%r13
  mov    0x10(%rsp),%rbp
  testb  $0x4,0x28(%rsp)
  jne    L683
L194:
  lea    0x2(%r13),%rbx
  movzbl 0x1(%r13),%r13d
  cmp    $0x3f,%r13b
  je     L1276
  cmp    $0x2a,%r13b
  jne    L791
L1276:
  mov    0x18(%rsp),%edi
  test   %edi,%edi
  jne    L1186
L51:
  cmp    $0x3f,%r13b
  je     L946
L322:
  movzbl (%rbx),%r13d
  add    $0x1,%rbx
  add    $0x1,%rbp
  cmp    $0x2a,%r13b
  je     L51
  cmp    $0x3f,%r13b
  jne    L791
L946:
  cmpb   $0x0,0x0(%rbp)
  jne    L322
  jmp    L1358
  nopl   (%rax)
L683:
  cmpb   $0x2e,0x0(%rbp)
  jne    L194
  cmp    %rbp,0x20(%rsp)
  je     L1358
  mov    0x18(%rsp),%r8d
  test   %r8d,%r8d
  je     L735
  cmpb   $0x2f,-0x1(%rbp)
  je     L146
  lea    0x2(%r13),%rbx
  movzbl 0x1(%r13),%r13d
  cmp    $0x2a,%r13b
  je     L1186
  cmp    $0x3f,%r13b
  jne    L791
  xchg   %ax,%ax
L1186:
  movzbl 0x0(%rbp),%eax
  cmp    $0x2f,%al
  je     L1358
  cmp    $0x3f,%r13b
  je     L1003
L638:
  movzbl (%rbx),%r13d
  add    $0x1,%rbx
  add    $0x1,%rbp
  cmp    $0x3f,%r13b
  je     L1186
  cmp    $0x2a,%r13b
  je     L1186
L791:
  movl   $0x0,0x18(%rsp)
  test   %r13b,%r13b
  je     L146
  mov    0x1c(%rsp),%esi
  test   %esi,%esi
  jne    L277
  cmp    $0x5c,%r13b
  je     L860
L277:
  mov    %r13d,%r14d
L1091:
  test   %r15d,%r15d
  je     L703
  movsbl %r14b,%r12d
  mov    %r12d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  jne    L770
L703:
  movzbl 0x0(%rbp),%eax
  sub    $0x1,%rbx
  test   %al,%al
  je     L1358
  cmp    $0x5b,%r13b
  je     L1055
  test   %r15d,%r15d
  je     L1011
  mov    0x28(%rsp),%r13d
  movsbl %r14b,%r12d
  and    $0xfffffffb,%r13d
  jmp    L957
  nop
L1219:
  movzbl 0x1(%rbp),%eax
  add    $0x1,%rbp
  test   %al,%al
  je     L1358
L957:
  movsbl %al,%r14d
  mov    %r14d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L404
  mov    %r14d,%edi
  call   <tolower@plt>
  mov    %eax,%r14d
L404:
  cmp    %r14d,%r12d
  jne    L1219
  xor    %eax,%eax
  mov    %r13d,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <fnmatch>
  test   %eax,%eax
  jne    L1219
L301:
  mov    %eax,0x18(%rsp)
  jmp    L146
  nopl   (%rax)
L1003:
  test   %al,%al
  jne    L638
  jmp    L1358
  nopl   (%rax)
L997:
  movsbl 0x2(%r13),%ecx
  lea    0x3(%r13),%r14
  jmp    L94
  xchg   %ax,%ax
L624:
  mov    0x10(%rsp),%rax
  movsbl (%rax),%r14d
  mov    %r14d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L239
  mov    %r14d,%edi
  call   <tolower@plt>
  mov    %eax,%r14d
  jmp    L239
  nopl   0x0(%rax)
L1164:
  movsbl 0x1(%rbp),%r14d
  lea    0x2(%rbp),%r13
  mov    %r14d,%edi
  call   <isupper@plt>
  test   %eax,%eax
  je     L394
  mov    %r14d,%edi
  call   <tolower@plt>
  movsbl %al,%r14d
  jmp    L394
  nopw   0x0(%rax,%rax,1)
L618:
  cmpb   $0x2f,-0x1(%rsi)
  jne    L29
  jmp    L146
  nop
L924:
  mov    0x10(%rsp),%rax
  cmp    %rax,0x20(%rsp)
  je     L1358
  mov    0x18(%rsp),%r9d
  test   %r9d,%r9d
  je     L956
  cmpb   $0x2f,-0x1(%rax)
  jne    L956
  jmp    L146
  nopl   (%rax)
L611:
  mov    0x10(%rsp),%rax
  mov    $0x5c,%r14d
  mov    %r13,%rbp
  movsbl (%rax),%r12d
  cmp    %r14d,%r12d
  je     L566
  jmp    L1358
L532:
  cmp    $0x5d,%r14b
  je     L637
  test   %r14b,%r14b
  je     L1358
  movzbl 0x2c(%rsp),%ecx
  jmp    L1030
  nopw   0x0(%rax,%rax,1)
L95:
  mov    %rdx,%rbp
L1141:
  cmp    $0x5d,%al
  je     L637
  test   %al,%al
  je     L1358
L1030:
  movzbl 0x0(%rbp),%eax
  lea    0x1(%rbp),%rdx
  cmp    $0x5c,%al
  jne    L95
  test   %cl,%cl
  je     L95
L799:
  movzbl 0x2(%rbp),%eax
  lea    0x2(%rbp),%rdx
  cmp    $0x5c,%al
  je     L1327
  add    $0x3,%rbp
  jmp    L1141
L1011:
  mov    0x28(%rsp),%r12d
  and    $0xfffffffb,%r12d
  jmp    L53
  nopl   0x0(%rax)
L504:
  movzbl 0x1(%rbp),%eax
  add    $0x1,%rbp
  test   %al,%al
  je     L1358
L53:
  cmp    %al,%r14b
  jne    L504
  xor    %eax,%eax
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <fnmatch>
  test   %eax,%eax
  jne    L504
  jmp    L301
L770:
  mov    %r12d,%edi
  call   <tolower@plt>
  mov    %eax,%r14d
  jmp    L703
L735:
  lea    0x2(%r13),%rbx
  movzbl 0x1(%r13),%r13d
  cmp    $0x3f,%r13b
  je     L946
  cmp    $0x2a,%r13b
  je     L51
  jmp    L791
  nopl   0x0(%rax,%rax,1)
L637:
  cmpb   $0x0,0x2f(%rsp)
  je     L566
  jmp    L1358
L1055:
  mov    0x28(%rsp),%r12d
  and    $0xfffffffb,%r12d
  jmp    L63
  nopl   0x0(%rax,%rax,1)
L446:
  add    $0x1,%rbp
  cmpb   $0x0,0x0(%rbp)
  je     L1358
L63:
  xor    %eax,%eax
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <fnmatch>
  test   %eax,%eax
  jne    L446
  jmp    L301
L860:
  movzbl (%rbx),%r14d
  jmp    L1091
L1407:
  mov    %rsi,%rbp
  jmp    L353
L1327:
  mov    %rdx,%rbp
  jmp    L799
```

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;
}
```