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

```asm
<fnmatch>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  and    $0x4,%ebp
  sub    $0x18,%rsp
  and    $0x2,%edx
  mov    %rdi,0x8(%rsp)
  mov    %rsi,(%rsp)
  je     L7
  mov    %rdi,%rax
  xor    %ebx,%ebx
  xor    %r13d,%r13d
  mov    %rsp,%r15
  cmpb   $0x2a,(%rax)
  lea    0x8(%rsp),%r14
  je     L252
L70:
  xor    %eax,%eax
  mov    %r12d,%edx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <fnmatch_helper@plt>
  test   %eax,%eax
  je     L226
L167:
  test   %r13,%r13
  je     L32
  test   %rbx,%rbx
  je     L32
  movzbl (%rbx),%eax
  test   %ebp,%ebp
  jne    L277
  cmp    $0x2e,%al
  je     L32
L277:
  cmp    $0x2f,%al
  je     L183
  test   %al,%al
  je     L32
  xchg   %ax,%ax
L25:
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  test   %al,%al
  je     L32
  cmp    $0x2f,%al
  jne    L25
L183:
  test   %al,%al
  je     L32
  add    $0x1,%rbx
  mov    %r13,%rax
  mov    %rbx,%rsi
L269:
  mov    %rax,0x8(%rsp)
  mov    %rsi,(%rsp)
  cmpb   $0x2a,(%rax)
  jne    L70
L252:
  cmpb   $0x2a,0x1(%rax)
  jne    L70
  cmpb   $0x2f,0x2(%rax)
  jne    L70
  add    $0x3,%rax
  jmp    L170
  xchg   %ax,%ax
L181:
  cmpb   $0x2a,0x1(%rax)
  jne    L146
  add    $0x3,%rax
  cmpb   $0x2f,-0x1(%rax)
  jne    L146
L170:
  mov    %rax,0x8(%rsp)
  cmpb   $0x2a,(%rax)
  mov    %rax,%r13
  je     L181
L146:
  mov    (%rsp),%rbx
  jmp    L70
  cs nopw 0x0(%rax,%rax,1)
L32:
  mov    $0x1,%eax
L217:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L226:
  mov    (%rsp),%rsi
  movzbl (%rsi),%ecx
  test   %cl,%cl
  je     L120
  cmp    $0x2f,%cl
  je     L120
  lea    0x1(%rsi),%rdx
  jmp    L12
  xchg   %ax,%ax
L241:
  cmp    $0x2f,%cl
  je     L120
L12:
  mov    %rdx,(%rsp)
  movzbl (%rdx),%ecx
  mov    %rdx,%rsi
  add    $0x1,%rdx
  test   %cl,%cl
  jne    L241
L120:
  mov    0x8(%rsp),%rdx
  cmpb   $0x0,(%rdx)
  jne    L6
  test   %cl,%cl
  jne    L167
  jmp    L217
  nopl   0x0(%rax,%rax,1)
L6:
  lea    0x1(%rdx),%rax
  add    $0x1,%rsi
  test   %cl,%cl
  je     L167
  jmp    L269
  nopl   (%rax)
L7:
  mov    %rsp,%rsi
  lea    0x8(%rsp),%rdi
  mov    %r12d,%edx
  xor    %eax,%eax
  call   <fnmatch_helper@plt>
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int fnmatch(p, s, flags) const char *p;
const char *s;
int flags;
{
  const int period = !(flags & 0x04);
  const int pathname = flags & 0x02;
  const char *ptmp = 0;
  const char *stmp = 0;
  if (pathname) {
    while (1) {
      if (p[0] == '*' && p[1] == '*' && p[2] == '/') {
        do {
          p += 3;
        } while (p[0] == '*' && p[1] == '*' && p[2] == '/');
        ptmp = p;
        stmp = s;
      }
      if (fnmatch_helper(&p, &s, flags) == 0) {
        while (*s && *s != '/')
          (++(s));
        if (*p && *s) {
          p++;
          s++;
          continue;
        }
        if (!*p && !*s)
          return 0;
      }
      if (ptmp && stmp && !(period && *stmp == '.')) {
        while (*stmp && *stmp != '/')
          (++(stmp));
        if (*stmp) {
          p = ptmp;
          stmp++;
          s = stmp;
          continue;
        }
      }
      return 1;
    }
  } else
    return fnmatch_helper(&p, &s, flags);
}
```