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    D2(%rip),%rax
  and    (%rax),%ebx
  je     L240
  cmpb   $0x2e,(%rdx)
  je     L112
L240:
  lea    0x40(%rsp),%rax
  lea    0x38(%rsp),%r13
  mov    %rax,(%rsp)
L113:
  mov    %ebp,%ecx
  mov    %r13,%rdx
  mov    %r14d,%esi
  mov    %r15,%rdi
  call   <pat_next@plt>
  mov    %eax,%ebx
  cmp    $0xfffffffb,%eax
  je     L29
  cmp    $0xfffffffe,%eax
  je     L396
  mov    (%rsp),%rdx
  mov    0x8(%rsp),%esi
  mov    %r12,%rdi
  call   <str_next@plt>
  test   %eax,%eax
  jle    L211
  mov    0x40(%rsp),%rdx
  cmp    $0xfffffffd,%ebx
  je     L357
  cmp    $0xfffffffc,%ebx
  je     L89
  cmp    %eax,%ebx
  je     L89
  nopl   0x0(%rax)
L396:
  mov    D10(%rip),%rax
  mov    (%rax),%eax
L480:
  mov    0x48(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L161
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L29:
  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    L177
L413:
  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     L374
  cmp    $0xfffffffe,%eax
  je     L396
  addq   $0x1,0x10(%rsp)
L380:
  add    0x38(%rsp),%rdi
  cmp    %rdi,%r14
  ja     L413
  mov    0x8(%rsp),%rsi
  mov    %r12,%rdi
  call   <strnlen@plt>
  mov    0x10(%rsp),%rcx
  cmp    %rax,%rcx
  ja     L396
  add    %r12,%rax
  mov    %rax,0x18(%rsp)
  mov    0x18(%rsp),%r8
  test   %rcx,%rcx
  je     L509
  cmp    %rax,%r12
  jb     L55
  jmp    L509
L11:
  subq   $0x1,0x10(%rsp)
  je     L434
  test   %sil,%sil
  je     L509
L55:
  lea    -0x1(%r8),%rdx
  movzbl -0x1(%r8),%eax
  cmp    %rdx,%r12
  mov    %rdx,%r8
  setb   %sil
  test   %al,%al
  jns    L11
  jmp    L280
  xchg   %ax,%ax
L374:
  movq   $0x0,0x10(%rsp)
  lea    0x1(%rdi),%r15
  jmp    L380
  nopw   0x0(%rax,%rax,1)
L112:
  cmpb   $0x2e,(%rdi)
  je     L240
  jmp    L396
  cs nopw 0x0(%rax,%rax,1)
L357:
  mov    %eax,%esi
  mov    %r15,%rdi
  mov    %rdx,0x10(%rsp)
  call   <match_bracket@plt>
  mov    0x10(%rsp),%rdx
  test   %eax,%eax
  je     L396
L89:
  sub    %rdx,0x8(%rsp)
  add    %rdx,%r12
  add    0x38(%rsp),%r15
  sub    0x38(%rsp),%r14
  jmp    L113
  nopl   0x0(%rax,%rax,1)
L496:
  test   %cl,%cl
  je     L11
  movzbl -0x1(%rdx),%eax
  sub    $0x1,%rdx
L280:
  cmp    %rdx,%r12
  mov    %rdx,%r8
  setb   %cl
  add    $0xffffff80,%eax
  mov    %ecx,%esi
  cmp    $0x3f,%eax
  jbe    L496
  jmp    L11
L211:
  test   %ebx,%ebx
  jne    L396
L22:
  xor    %eax,%eax
  jmp    L480
  nop
L177:
  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)
L21:
  lea    0x40(%rsp),%rax
  mov    %rax,0x10(%rsp)
  nopw   0x0(%rax,%rax,1)
L103:
  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    L247
  add    0x40(%rsp),%r8
  cmp    $0xfffffffd,%ecx
  je     L450
  cmp    $0xfffffffc,%ecx
  je     L103
  cmp    %eax,%ecx
  je     L103
  jmp    L396
  nopl   0x0(%rax)
L450:
  mov    %r15,%rdi
  mov    %eax,%esi
  sub    0x38(%rsp),%rdi
  mov    %r8,(%rsp)
  call   <match_bracket@plt>
  mov    (%rsp),%r8
  test   %eax,%eax
  jne    L103
  jmp    L396
L247:
  test   %ecx,%ecx
  jne    L396
L143:
  cmp    %rbx,0x20(%rsp)
  jbe    L22
L452:
  mov    %r12,%r14
  mov    %rbx,%r15
  jmp    L495
  nopl   0x0(%rax,%rax,1)
L482:
  cmp    $0xfffffffc,%ecx
  je     L520
  cmp    %eax,%ecx
  jne    L50
L520:
  add    0x40(%rsp),%r14
L495:
  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     L463
  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     L396
  cmp    $0xfffffffd,%ecx
  jne    L482
  mov    %r15,%rdi
  mov    %eax,%esi
  sub    0x38(%rsp),%rdi
  call   <match_bracket@plt>
  test   %eax,%eax
  jne    L520
L50:
  mov    0x28(%rsp),%esi
  mov    0x10(%rsp),%rdx
  mov    %r12,%rdi
  sub    %r12d,%esi
  call   <str_next@plt>
  test   %eax,%eax
  jle    L328
  add    0x40(%rsp),%r12
  jmp    L143
  nopl   0x0(%rax)
L328:
  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     L328
  jmp    L143
L463:
  cmp    %r15,0x20(%rsp)
  jbe    L22
  mov    %r14,%r12
  mov    %r15,%rbx
  jmp    L452
L509:
  cmpq   $0x0,0x10(%rsp)
  jne    L396
  nopl   0x0(%rax,%rax,1)
L434:
  mov    %r15,0x20(%rsp)
  mov    %r8,0x28(%rsp)
  jmp    L21
L161:
  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;
}
```