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

```asm
<wildmatch>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  mov    %edx,%eax
  or     $0x2,%eax
  test   $0x40,%dl
  cmovne %eax,%r12d
  mov    %r12d,%eax
  and    $0x4,%eax
  mov    %eax,0xc(%rsp)
L515:
  movzbl (%r14),%ebx
  lea    0x1(%r14),%rbp
  cmp    $0x3f,%bl
  je     L429
L395:
  jg     L445
  test   %bl,%bl
  je     L604
  cmp    $0x2a,%bl
  jne    L676
  movzbl 0x1(%r14),%eax
  test   $0x40,%r12b
  je     L364
  cmp    $0x2a,%al
  je     L201
  movzbl (%r15),%ebx
  cmp    $0x2e,%bl
  je     L229
L697:
  test   %al,%al
  je     L160
  cmp    $0x2f,%al
  je     L597
L570:
  test   %bl,%bl
  je     L79
L719:
  mov    %r12d,%r13d
  and    $0x2,%r12d
  and    $0xfffffffb,%r13d
  jmp    L238
  nopl   0x0(%rax,%rax,1)
L840:
  movzbl 0x1(%r15),%ebx
  add    $0x1,%r15
  test   %bl,%bl
  je     L79
L238:
  mov    %r13d,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <wildmatch>
  test   %eax,%eax
  je     L56
  cmp    $0x2f,%bl
  jne    L840
  test   %r12d,%r12d
  je     L840
  nopl   (%rax)
L79:
  mov    $0x1,%eax
  jmp    L488
  nopw   0x0(%rax,%rax,1)
L495:
  movzbl 0x1(%rbp),%eax
  add    $0x1,%rbp
L364:
  cmp    $0x2a,%al
  je     L495
  movzbl (%r15),%ebx
  cmp    $0x2e,%bl
  jne    L697
L229:
  test   $0x4,%r12b
  je     L697
  cmp    %r13,%r15
  je     L79
  test   $0x2,%r12b
  je     L793
  cmpb   $0x2f,-0x1(%r15)
  je     L79
  test   %al,%al
  je     L434
  cmp    $0x2f,%al
  jne    L719
  nopl   (%rax)
L597:
  test   $0x2,%r12b
  je     L570
  mov    %r15,%rdi
  mov    $0x2f,%esi
  call   <strchr@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L79
L518:
  movzbl (%r15),%ebx
  jmp    L570
L445:
  cmp    $0x5b,%bl
  je     L117
  cmp    $0x5c,%bl
  jne    L676
  test   $0x1,%r12b
  je     L517
L676:
  mov    %rbp,%r14
L694:
  cmp    %bl,(%r15)
  je     L121
  test   $0x10,%r12b
  je     L79
  movzbl %bl,%edi
  call   <tolower@plt>
  movzbl (%r15),%edi
  mov    %eax,%ebx
  call   <tolower@plt>
  cmp    %eax,%ebx
  jne    L79
L121:
  movzbl (%r14),%ebx
  add    $0x1,%r15
  lea    0x1(%r14),%rbp
  cmp    $0x3f,%bl
  jne    L395
L429:
  movzbl (%r15),%eax
  test   %al,%al
  je     L79
  cmp    $0x2f,%al
  je     L399
  cmp    $0x2e,%al
  jne    L763
  mov    0xc(%rsp),%edx
  test   %edx,%edx
  je     L763
  cmp    %r13,%r15
  je     L79
  test   $0x2,%r12b
  je     L763
  cmpb   $0x2f,-0x1(%r15)
  je     L79
  nopl   0x0(%rax)
L763:
  add    $0x1,%r15
  mov    %rbp,%r14
  jmp    L515
  nopl   0x0(%rax)
L517:
  movzbl 0x1(%r14),%eax
  test   %al,%al
  jne    L647
  cmpb   $0x0,0x1(%r15)
  jne    L676
  jmp    L79
  nopl   (%rax)
L604:
  and    $0x8,%r12d
  movzbl (%r15),%eax
  je     L713
  cmp    $0x2f,%al
  je     L56
L713:
  test   %al,%al
  setne  %al
  movzbl %al,%eax
L488:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L543
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L267:
  test   %al,%al
  jne    L79
  cmp    $0x2f,%dl
  jne    L160
L56:
  xor    %eax,%eax
  jmp    L488
  cs nopw 0x0(%rax,%rax,1)
L117:
  movsbl (%r15),%esi
  test   %sil,%sil
  je     L79
  cmp    $0x2f,%sil
  je     L684
  cmp    $0x2e,%sil
  jne    L23
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  je     L23
  cmp    %r13,%r15
  je     L79
  test   $0x2,%r12b
  je     L23
  cmpb   $0x2f,-0x1(%r15)
  je     L79
  nop
L23:
  lea    0x10(%rsp),%rcx
  mov    %r12d,%edx
  mov    %rbp,%rdi
  call   <rangematch@plt>
  test   %eax,%eax
  je     L79
  cmp    $0x1,%eax
  je     L856
  cmp    $0xffffffff,%eax
  jne    L763
  add    $0x1,%r15
  mov    %rbp,%r14
  jmp    L694
  cs nopw 0x0(%rax,%rax,1)
L160:
  test   $0x2,%r12b
  je     L56
L434:
  and    $0x8,%r12d
  jne    L56
  mov    $0x2f,%esi
  mov    %r15,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  setne  %al
  movzbl %al,%eax
  jmp    L488
  nop
L647:
  add    $0x2,%r14
  mov    %eax,%ebx
  jmp    L694
  nopl   0x0(%rax,%rax,1)
L201:
  movzbl -0x1(%r14),%edx
  nopl   (%rax)
L13:
  movzbl 0x1(%rbp),%eax
  add    $0x1,%rbp
  cmp    $0x2a,%al
  je     L13
  cmp    $0x2f,%al
  jne    L267
  nopl   0x0(%rax)
L398:
  cmpb   $0x2a,0x1(%rbp)
  lea    0x1(%rbp),%rbx
  jne    L467
  movzbl 0x2(%rbp),%eax
  cmp    $0x2a,%al
  je     L859
  jmp    L467
  nopl   0x0(%rax,%rax,1)
L90:
  movzbl 0x1(%rbx),%eax
L859:
  add    $0x1,%rbx
  cmp    $0x2a,%al
  je     L90
  cmp    $0x2f,%al
  jne    L655
  mov    %rbx,%rbp
  jmp    L398
  nopl   (%rax)
L684:
  test   $0x2,%r12b
  je     L23
  jmp    L79
  nopw   0x0(%rax,%rax,1)
L399:
  test   $0x2,%r12b
  jne    L79
  add    $0x1,%r15
  mov    %rbp,%r14
  jmp    L515
  cs nopw 0x0(%rax,%rax,1)
L856:
  mov    0x10(%rsp),%rbp
  add    $0x1,%r15
  mov    %rbp,%r14
  jmp    L515
L655:
  test   %al,%al
  jne    L79
  jmp    L56
L793:
  test   %al,%al
  jne    L719
  xor    %eax,%eax
  jmp    L488
L467:
  mov    %r12d,%edx
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <wildmatch>
  test   %eax,%eax
  je     L56
  mov    $0x2f,%esi
  mov    %r13,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L79
L874:
  lea    0x1(%rax),%r13
  mov    %r12d,%edx
  mov    %rbx,%rdi
  mov    %r13,%rsi
  call   <wildmatch>
  test   %eax,%eax
  je     L56
  mov    $0x2f,%esi
  mov    %r13,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L874
  jmp    L518
L543:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int wildmatch(const char *pattern, const char *string, int flags) {
  const char *stringstart;
  const char *newp;
  const char *slash;
  char c, test;
  char prev;
  int wild = 0;
  if (((flags) & (0x40))) {
    flags |= 0x02;
  }
  for (stringstart = string;;) {
    switch (c = *pattern++) {
    case '\0':
      if (((flags) & (0x08)) && *string == '/')
        return 0;
      return (*string == '\0') ? 0 : 1;
    case '?':
      if (*string == '\0')
        return 1;
      if (*string == '/' && ((flags) & (0x02)))
        return 1;
      if (*string == '.' && ((flags) & (0x04)) && (string == stringstart || (((flags) & (0x02)) && *(string - 1) == '/')))
        return 1;
      ++string;
      break;
    case '*':
      c = *pattern;
      wild = ((flags) & (0x40)) && c == '*';
      if (wild) {
        prev = pattern[-2];
        while (c == '*') {
          c = *++pattern;
        }
        while (c == '/' && pattern[1] == '*' && pattern[2] == '*') {
          prev = c;
          c = *++pattern;
          while (c == '*') {
            c = *++pattern;
          }
        }
        if (c == '/' && wildmatch(pattern + 1, string, flags) == 0) {
          return 0;
        }
      } else {
        while (c == '*') {
          c = *++pattern;
        }
      }
      if (!wild && *string == '.' && ((flags) & (0x04)) && (string == stringstart || (((flags) & (0x02)) && *(string - 1) == '/'))) {
        return 1;
      }
      if (c == '\0') {
        if (wild && prev == '/') {
          return 0;
        }
        if (((flags) & (0x02))) {
          return (((flags) & (0x08)) || strchr(string, '/') == NULL ? 0 : 1);
        } else {
          return 0;
        }
      } else if (c == '/') {
        if (wild) {
          slash = strchr(stringstart, '/');
          if (!slash) {
            return 1;
          }
          while (slash) {
            if (wildmatch(pattern + 1, slash + 1, flags) == 0) {
              return 0;
            }
            slash = strchr(slash + 1, '/');
          }
        } else {
          if (((flags) & (0x02))) {
            if ((string = strchr(string, '/')) == NULL) {
              return 1;
            }
          }
        }
      } else if (wild) {
        return 1;
      }
      while ((test = *string) != '\0') {
        if (!wildmatch(pattern, string, flags & ~0x04))
          return 0;
        if (test == '/' && ((flags) & (0x02)))
          break;
        ++string;
      }
      return 1;
    case '[':
      if (*string == '\0')
        return 1;
      if (*string == '/' && ((flags) & (0x02)))
        return 1;
      if (*string == '.' && ((flags) & (0x04)) && (string == stringstart || (((flags) & (0x02)) && *(string - 1) == '/')))
        return 1;
      switch (rangematch(pattern, *string, flags, &newp)) {
      case -1:
        ++string;
        goto normal;
      case 1:
        pattern = newp;
        break;
      case 0:
        return (1);
      }
      ++string;
      break;
    case '\\':
      if (!((flags) & (0x01))) {
        if ((c = *pattern++) == '\0') {
          c = '\\';
          --pattern;
          if (*(string + 1) == '\0') {
            return 1;
          }
        }
      }
    default:
    normal:
      if (c != *string && !(((flags) & (0x10)) && (tolower((unsigned char)c) == tolower((unsigned char)*string))))
        return 1;
      ++string;
      break;
    }
  }
}
```