user: Translate the below assembly code into C programming language:

```asm
<fnmatch_internal>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %r8d,%ebp
  push   %rbx
  mov    %r8d,%ebx
  sub    $0x58,%rsp
  mov    %rcx,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  mov    D9(%rip),%rax
  and    (%rax),%ebx
  je     L302
  cmpb   $0x2e,(%rdx)
  je     L318
L302:
  lea    0x40(%rsp),%rax
  lea    0x38(%rsp),%r13
  mov    %rax,(%rsp)
L79:
  mov    %ebp,%ecx
  mov    %r13,%rdx
  mov    %r14d,%esi
  mov    %r15,%rdi
  call   <pat_next@plt>
  mov    %eax,%ebx
  cmp    $0xfffffffb,%eax
  je     L310
  cmp    $0xfffffffe,%eax
  je     L385
  mov    (%rsp),%rdx
  mov    0x8(%rsp),%esi
  mov    %r12,%rdi
  call   <str_next@plt>
  test   %eax,%eax
  jle    L271
  mov    0x40(%rsp),%rdx
  cmp    $0xfffffffd,%ebx
  je     L430
  cmp    $0xfffffffc,%ebx
  je     L542
  cmp    %eax,%ebx
  je     L542
  nopl   0x0(%rax)
L385:
  mov    D12(%rip),%rax
  mov    (%rax),%eax
L147:
  mov    0x48(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L244
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L310:
  lea    0x1(%r15),%rbx
  lea    -0x1(%r14),%rsi
  mov    %rbx,%rdi
  mov    %rbx,%r15
  call   <strnlen@plt>
  mov    %rbx,%rdi
  movq   $0x0,0x10(%rsp)
  lea    (%rbx,%rax,1),%r14
  cmp    %r14,%rbx
  jae    L109
L68:
  mov    %r14d,%esi
  mov    %ebp,%ecx
  mov    %r13,%rdx
  mov    %rdi,(%rsp)
  sub    %edi,%esi
  call   <pat_next@plt>
  mov    (%rsp),%rdi
  cmp    $0xfffffffb,%eax
  je     L240
  cmp    $0xfffffffe,%eax
  je     L385
  addq   $0x1,0x10(%rsp)
L116:
  add    0x38(%rsp),%rdi
  cmp    %rdi,%r14
  ja     L68
  mov    0x8(%rsp),%rsi
  mov    %r12,%rdi
  call   <strnlen@plt>
  mov    0x10(%rsp),%rcx
  cmp    %rax,%rcx
  ja     L385
  add    %r12,%rax
  mov    %rax,0x18(%rsp)
  test   %rcx,%rcx
  je     L319
  cmp    %rax,%r12
  jae    L319
  mov    %rax,%r8
  jmp    L4
  nop
L296:
  mov    %rax,%r8
L173:
  subq   $0x1,0x10(%rsp)
  je     L101
  test   %cl,%cl
  je     L324
L4:
  lea    -0x1(%r8),%rax
  cmp    %rax,%r12
  setb   %cl
  cmpb   $0x0,-0x1(%r8)
  jns    L296
  jmp    L75
  nopw   0x0(%rax,%rax,1)
L240:
  movq   $0x0,0x10(%rsp)
  lea    0x1(%rdi),%r15
  jmp    L116
  nopw   0x0(%rax,%rax,1)
L318:
  cmpb   $0x2e,(%rdi)
  je     L302
  jmp    L385
  cs nopw 0x0(%rax,%rax,1)
L430:
  mov    %eax,%esi
  mov    %r15,%rdi
  mov    %rdx,0x10(%rsp)
  call   <match_bracket@plt>
  mov    0x10(%rsp),%rdx
  test   %eax,%eax
  je     L385
L542:
  sub    %rdx,0x8(%rsp)
  add    %rdx,%r12
  add    0x38(%rsp),%r15
  sub    0x38(%rsp),%r14
  jmp    L79
  nopl   0x0(%rax,%rax,1)
L393:
  test   %cl,%cl
  je     L173
  sub    $0x1,%rax
L75:
  movzbl (%rax),%edx
  cmp    %rax,%r12
  mov    %rax,%r8
  setb   %cl
  add    $0xffffff80,%edx
  cmp    $0x3f,%edx
  jbe    L393
  jmp    L173
L271:
  test   %ebx,%ebx
  jne    L385
L439:
  xor    %eax,%eax
  jmp    L147
  nopl   0x0(%rax)
L109:
  mov    0x8(%rsp),%rsi
  mov    %r12,%rdi
  call   <strnlen@plt>
  mov    %rbx,0x20(%rsp)
  lea    (%r12,%rax,1),%r8
  mov    %r8,0x18(%rsp)
  mov    %r8,0x28(%rsp)
L499:
  lea    0x40(%rsp),%rax
  mov    %rax,0x10(%rsp)
  nopw   0x0(%rax,%rax,1)
L352:
  mov    %r14d,%esi
  mov    %ebp,%ecx
  mov    %r15,%rdi
  mov    %r13,%rdx
  sub    %r15d,%esi
  mov    %r8,(%rsp)
  call   <pat_next@plt>
  mov    (%rsp),%r8
  mov    0x18(%rsp),%esi
  mov    0x10(%rsp),%rdx
  add    0x38(%rsp),%r15
  mov    %eax,0x8(%rsp)
  sub    %r8d,%esi
  mov    %r8,%rdi
  call   <str_next@plt>
  mov    (%rsp),%r8
  mov    0x8(%rsp),%ecx
  test   %eax,%eax
  jle    L251
  add    0x40(%rsp),%r8
  cmp    $0xfffffffd,%ecx
  je     L413
  cmp    $0xfffffffc,%ecx
  je     L352
  cmp    %eax,%ecx
  je     L352
  jmp    L385
  nopl   0x0(%rax)
L413:
  mov    %r15,%rdi
  mov    %eax,%esi
  sub    0x38(%rsp),%rdi
  mov    %r8,(%rsp)
  call   <match_bracket@plt>
  mov    (%rsp),%r8
  test   %eax,%eax
  jne    L352
  jmp    L385
L251:
  test   %ecx,%ecx
  jne    L385
L167:
  cmp    %rbx,0x20(%rsp)
  jbe    L439
L381:
  mov    %r12,%r14
  mov    %rbx,%r15
  jmp    L540
  nopl   0x0(%rax,%rax,1)
L181:
  cmp    $0xfffffffc,%ecx
  je     L193
  cmp    %eax,%ecx
  jne    L141
L193:
  add    0x40(%rsp),%r14
L540:
  mov    0x20(%rsp),%esi
  mov    %r15,%rdi
  mov    %ebp,%ecx
  mov    %r13,%rdx
  sub    %r15d,%esi
  call   <pat_next@plt>
  add    0x38(%rsp),%r15
  cmp    $0xfffffffb,%eax
  mov    %eax,(%rsp)
  je     L210
  mov    0x28(%rsp),%esi
  mov    0x10(%rsp),%rdx
  mov    %r14,%rdi
  sub    %r14d,%esi
  call   <str_next@plt>
  mov    (%rsp),%ecx
  test   %eax,%eax
  je     L385
  cmp    $0xfffffffd,%ecx
  jne    L181
  mov    %r15,%rdi
  mov    %eax,%esi
  sub    0x38(%rsp),%rdi
  call   <match_bracket@plt>
  test   %eax,%eax
  jne    L193
L141:
  mov    0x28(%rsp),%esi
  mov    0x10(%rsp),%rdx
  mov    %r12,%rdi
  sub    %r12d,%esi
  call   <str_next@plt>
  test   %eax,%eax
  jle    L227
  add    0x40(%rsp),%r12
  jmp    L167
  nopl   0x0(%rax)
L227:
  mov    0x28(%rsp),%esi
  add    $0x1,%r12
  mov    0x10(%rsp),%rdx
  mov    %r12,%rdi
  sub    %r12d,%esi
  call   <str_next@plt>
  test   %eax,%eax
  js     L227
  jmp    L167
L210:
  cmp    %r15,0x20(%rsp)
  jbe    L439
  mov    %r14,%r12
  mov    %r15,%rbx
  jmp    L381
L319:
  mov    0x18(%rsp),%r8
L324:
  cmpq   $0x0,0x10(%rsp)
  jne    L385
  nopl   0x0(%rax,%rax,1)
L101:
  mov    %r15,0x20(%rsp)
  mov    %r8,0x28(%rsp)
  jmp    L499
L244:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int fnmatch_internal(const char *pat, size_t m, const char *str, size_t n, int flags) {
  const char *p, *ptail, *endpat;
  const char *s, *stail, *endstr;
  size_t pinc, sinc, tailcnt = 0;
  int c, k;
  if (flags & FNM_PERIOD) {
    if (*str == '.' && *pat != '.')
      return FNM_NOMATCH;
  }
  for (;;) {
    switch ((c = pat_next(pat, m, &pinc, flags))) {
    case -2:
      return FNM_NOMATCH;
    case -5:
      pat++;
      m--;
      break;
    default:
      k = str_next(str, n, &sinc);
      if (k <= 0)
        return (c == 0) ? 0 : FNM_NOMATCH;
      str += sinc;
      n -= sinc;
      if (c == -3) {
        if (!match_bracket(pat, k))
          return FNM_NOMATCH;
      } else if (c != -4 && k != c) {
        return FNM_NOMATCH;
      }
      pat += pinc;
      m -= pinc;
      continue;
    }
    break;
  }
  m = strnlen(pat, m);
  endpat = pat + m;
  for (p = ptail = pat; p < endpat; p += pinc) {
    switch (pat_next(p, endpat - p, &pinc, flags)) {
    case -2:
      return FNM_NOMATCH;
    case -5:
      tailcnt = 0;
      ptail = p + 1;
      break;
    default:
      tailcnt++;
      break;
    }
  }
  n = strnlen(str, n);
  endstr = str + n;
  if (n < tailcnt)
    return FNM_NOMATCH;
  for (s = endstr; s > str && tailcnt; tailcnt--) {
    if (s[-1] < 128U)
      s--;
    else
      while ((unsigned char)*--s - 0x80U < 0x40 && s > str)
        ;
  }
  if (tailcnt)
    return FNM_NOMATCH;
  stail = s;
  p = ptail;
  for (;;) {
    c = pat_next(p, endpat - p, &pinc, flags);
    p += pinc;
    if ((k = str_next(s, endstr - s, &sinc)) <= 0) {
      if (c != 0)
        return FNM_NOMATCH;
      break;
    }
    s += sinc;
    if (c == -3) {
      if (!match_bracket(p - pinc, k))
        return FNM_NOMATCH;
    } else if (c != -4 && k != c) {
      return FNM_NOMATCH;
    }
  }
  endstr = stail;
  endpat = ptail;
  while (pat < endpat) {
    p = pat;
    s = str;
    for (;;) {
      c = pat_next(p, endpat - p, &pinc, flags);
      p += pinc;
      if (c == -5) {
        pat = p;
        str = s;
        break;
      }
      k = str_next(s, endstr - s, &sinc);
      if (!k)
        return FNM_NOMATCH;
      if (c == -3) {
        if (!match_bracket(p - pinc, k))
          break;
      } else if (c != -4 && k != c) {
        break;
      }
      s += sinc;
    }
    if (c == -5)
      continue;
    k = str_next(str, endstr - str, &sinc);
    if (k > 0)
      str += sinc;
    else
      for (str++; str_next(str, endstr - str, &sinc) < 0; str++)
        ;
  }
  return 0;
}
```