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

```asm
<fnmatch>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %edx,%eax
  and    $0x4,%eax
  mov    %eax,0x4(%rsp)
L623:
  movzbl (%rbx),%ebp
  movzbl (%r12),%r15d
  lea    0x1(%rbx),%rdi
  cmp    $0x3f,%bpl
  je     L6
  jg     L111
  test   %bpl,%bpl
  je     L62
  cmp    $0x2a,%bpl
  jne    L308
  movzbl 0x1(%rbx),%eax
  mov    %rdi,%rbx
  cmp    $0x2a,%al
  jne    L247
  nopl   (%rax)
L74:
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  cmp    $0x2a,%al
  je     L74
L247:
  cmp    $0x2e,%r15b
  je     L481
L297:
  test   %al,%al
  je     L92
  cmp    $0x2f,%al
  jne    L18
  test   $0x2,%r14b
  je     L18
  mov    %r12,%rdi
  mov    $0x2f,%esi
  call   <strchr@plt>
  mov    %rax,%r12
  test   %rax,%rax
  jne    L623
  nopl   (%rax)
L617:
  mov    $0x1,%eax
  jmp    L110
  nopw   0x0(%rax,%rax,1)
L111:
  cmp    $0x5b,%bpl
  je     L67
  cmp    $0x5c,%bpl
  jne    L308
  test   $0x1,%r14b
  je     L583
L308:
  mov    %rdi,%rbx
L184:
  cmp    %bpl,(%r12)
  je     L178
  test   $0x10,%r14b
  je     L617
  movzbl %bpl,%edi
  call   <tolower@plt>
  movzbl (%r12),%edi
  mov    %eax,%ebp
  call   <tolower@plt>
  cmp    %eax,%ebp
  jne    L617
L178:
  add    $0x1,%r12
  jmp    L623
  nopl   0x0(%rax,%rax,1)
L6:
  test   %r15b,%r15b
  je     L617
  cmp    $0x2f,%r15b
  je     L486
  cmp    $0x2e,%r15b
  jne    L571
  mov    0x4(%rsp),%ecx
  test   %ecx,%ecx
  je     L571
  cmp    %r13,%r12
  je     L617
  test   $0x2,%r14b
  je     L571
  cmpb   $0x2f,-0x1(%r12)
  jne    L571
  jmp    L617
  nopl   0x0(%rax)
L62:
  and    $0x8,%r14d
  jne    L83
L585:
  xor    %eax,%eax
  test   %r15b,%r15b
  setne  %al
L110:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L164
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L67:
  test   %r15b,%r15b
  je     L617
  cmp    $0x2f,%r15b
  je     L392
  cmp    $0x2e,%r15b
  jne    L255
  mov    0x4(%rsp),%eax
  test   %eax,%eax
  je     L255
  cmp    %r13,%r12
  je     L617
  test   $0x2,%r14b
  je     L255
  cmpb   $0x2f,-0x1(%r12)
  jne    L255
  jmp    L617
  nopl   (%rax)
L583:
  movzbl 0x1(%rbx),%eax
  test   %al,%al
  je     L308
  add    $0x2,%rbx
  mov    %eax,%ebp
  jmp    L184
  nopw   0x0(%rax,%rax,1)
L83:
  cmp    $0x2f,%r15b
  jne    L585
L307:
  xor    %eax,%eax
  jmp    L110
  nopl   0x0(%rax)
L481:
  mov    0x4(%rsp),%edx
  test   %edx,%edx
  je     L297
  cmp    %r13,%r12
  je     L617
  test   $0x2,%r14b
  je     L297
  cmpb   $0x2f,-0x1(%r12)
  jne    L297
  jmp    L617
  nopl   0x0(%rax,%rax,1)
L392:
  test   $0x2,%r14b
  jne    L617
L255:
  lea    0x10(%rsp),%rcx
  movsbl %r15b,%esi
  mov    %r14d,%edx
  mov    %rdi,0x8(%rsp)
  call   <rangematch@plt>
  test   %eax,%eax
  je     L617
  cmp    $0x1,%eax
  je     L335
  cmp    $0xffffffff,%eax
  mov    0x8(%rsp),%rdi
  je     L308
L571:
  add    $0x1,%r12
  mov    %rdi,%rbx
  jmp    L623
  nopw   0x0(%rax,%rax,1)
L486:
  test   $0x2,%r14b
  je     L571
  jmp    L617
  nopl   0x0(%rax,%rax,1)
L335:
  mov    0x10(%rsp),%rdi
  jmp    L571
L18:
  mov    %r14d,%r13d
  and    $0x2,%r14d
  and    $0xfffffffb,%r13d
  mov    %r14d,%ebp
  test   %r15b,%r15b
  jne    L300
  jmp    L617
  nop
L169:
  movzbl 0x1(%r12),%r15d
  add    $0x1,%r12
  test   %r15b,%r15b
  je     L617
L300:
  mov    %r13d,%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <fnmatch>
  test   %eax,%eax
  je     L307
  cmp    $0x2f,%r15b
  jne    L169
  test   %ebp,%ebp
  je     L169
  jmp    L617
L92:
  test   $0x2,%r14b
  je     L307
  and    $0x8,%r14d
  jne    L307
  mov    $0x2f,%esi
  mov    %r12,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  setne  %al
  movzbl %al,%eax
  jmp    L110
L164:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int fnmatch(const char *pattern, const char *string, int flags) {
  const char *stringstart;
  char *newp;
  char c, test;
  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;
      while (c == '*')
        c = *++pattern;
      if (*string == '.' && (flags & 0x04) && (string == stringstart || ((flags & 0x02) && *(string - 1) == '/')))
        return (1);
      if (c == '\0')
        if (flags & 0x02)
          return ((flags & 0x08) || strchr(string, '/') == NULL ? 0 : 1);
        else
          return (0);
      else if (c == '/' && flags & 0x02) {
        if ((string = strchr(string, '/')) == NULL)
          return (1);
        break;
      }
      while ((test = *string) != '\0') {
        if (!fnmatch(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):
        goto norm;
      case 1:
        pattern = newp;
        break;
      case 0:
        return (1);
      }
      ++string;
      break;
    case '\\':
      if (!(flags & 0x01)) {
        if ((c = *pattern++) == '\0') {
          c = '\\';
          --pattern;
        }
      }
    default:
    norm:
      if (c == *string)
        ;
      else if ((flags & 0x10) && (tolower((unsigned char)c) == tolower((unsigned char)*string)))
        ;
      else
        return (1);
      string++;
      break;
    }
}
```