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

```asm
<fnmatch_internal>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%r13
  mov    %rdx,%r12
  mov    %rcx,(%rsp)
  mov    %r8d,%ebp
  mov    %fs:0x28,%rax
  mov    %rax,0x48(%rsp)
  xor    %eax,%eax
  mov    D37(%rip),%rax
  mov    %r8d,%ecx
  and    (%rax),%ecx
  je     L122
  cmpb   $0x2e,(%rdx)
  je     L405
L122:
  lea    0x38(%rsp),%r14
L301:
  mov    %ebp,%ecx
  mov    %r14,%rdx
  mov    %r13d,%esi
  mov    %rbx,%rdi
  call   <pat_next@plt>
  mov    %eax,%r15d
  cmp    $0xfffffffb,%eax
  je     L487
  cmp    $0xfffffffe,%eax
  jne    L126
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
L482:
  mov    0x48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L432
  mov    %r15d,%eax
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L405:
  cmpb   $0x2e,(%rdi)
  je     L122
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L487:
  add    $0x1,%rbx
  lea    -0x1(%r13),%rsi
  mov    %rbx,%rdi
  call   <strnlen@plt>
  lea    (%rbx,%rax,1),%r14
  mov    %rbx,0x10(%rsp)
  mov    %rbx,%r13
  mov    $0x0,%r15d
  lea    0x38(%rsp),%rax
  mov    %rax,0x8(%rsp)
  cmp    %r14,%rbx
  jb     L244
  mov    (%rsp),%rsi
  mov    %r12,%rdi
  call   <strnlen@plt>
  lea    (%r12,%rax,1),%r13
  mov    %rbx,0x10(%rsp)
  mov    %r13,0x18(%rsp)
  mov    $0x0,%r15d
L458:
  mov    %r13,0x8(%rsp)
  mov    0x10(%rsp),%rax
  mov    %rax,(%rsp)
  lea    0x38(%rsp),%rax
  mov    %rax,0x28(%rsp)
  test   %r15,%r15
  je     L369
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L126:
  lea    0x40(%rsp),%rdx
  mov    (%rsp),%esi
  mov    %r12,%rdi
  call   <str_next@plt>
  test   %eax,%eax
  jle    L227
  mov    0x40(%rsp),%rdx
  mov    %rdx,0x8(%rsp)
  cmp    $0xfffffffd,%r15d
  je     L393
  cmp    $0xfffffffc,%r15d
  je     L446
  cmp    %eax,%r15d
  je     L446
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L227:
  test   %r15d,%r15d
  je     L482
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L393:
  mov    %eax,%esi
  mov    %rbx,%rdi
  call   <match_bracket@plt>
  test   %eax,%eax
  jne    L446
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L446:
  mov    0x8(%rsp),%rdx
  add    %rdx,%r12
  sub    %rdx,(%rsp)
  add    0x38(%rsp),%rbx
  sub    0x38(%rsp),%r13
  jmp    L301
L516:
  lea    0x1(%r13),%rax
  mov    %rax,0x10(%rsp)
  mov    $0x0,%r15d
L333:
  mov    %r13,%rax
  add    0x38(%rsp),%rax
  mov    %rax,%r13
  cmp    %rax,%r14
  jbe    L401
L244:
  mov    %ebp,%ecx
  mov    0x8(%rsp),%rdx
  mov    %r14d,%esi
  sub    %r13d,%esi
  mov    %r13,%rdi
  call   <pat_next@plt>
  cmp    $0xfffffffb,%eax
  je     L516
  cmp    $0xfffffffe,%eax
  jne    L344
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L344:
  add    $0x1,%r15
  jmp    L333
L401:
  mov    (%rsp),%rsi
  mov    %r12,%rdi
  call   <strnlen@plt>
  cmp    %rax,%r15
  jbe    L116
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L116:
  add    %r12,%rax
  mov    %rax,0x18(%rsp)
  cmp    %rax,%r12
  jae    L261
  test   %r15,%r15
  je     L261
  mov    0x18(%rsp),%r13
  jmp    L583
L261:
  mov    0x18(%rsp),%r13
  jmp    L458
L28:
  sub    $0x1,%r13
  movzbl 0x0(%r13),%eax
  add    $0xffffff80,%eax
  cmp    $0x3f,%eax
  ja     L341
  cmp    %r13,%r12
  jb     L28
L341:
  sub    $0x1,%r15
  cmp    %r13,%r12
  jae    L458
  test   %r15,%r15
  je     L458
L583:
  cmpb   $0x0,-0x1(%r13)
  js     L28
  sub    $0x1,%r13
  jmp    L341
L366:
  test   %r15d,%r15d
  jne    L396
  lea    0x38(%rsp),%rax
  mov    %rax,0x20(%rsp)
  cmp    0x10(%rsp),%rbx
  jb     L296
  jmp    L482
L396:
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L60:
  mov    0x20(%rsp),%rdi
  sub    0x38(%rsp),%rdi
  mov    %eax,%esi
  call   <match_bracket@plt>
  test   %eax,%eax
  je     L339
L369:
  mov    %ebp,%ecx
  mov    0x28(%rsp),%rdx
  mov    %r14d,%esi
  mov    (%rsp),%rax
  sub    %eax,%esi
  mov    %rax,%rdi
  call   <pat_next@plt>
  mov    %eax,%r15d
  mov    (%rsp),%rax
  add    0x38(%rsp),%rax
  mov    %rax,0x20(%rsp)
  mov    %rax,(%rsp)
  lea    0x40(%rsp),%rdx
  mov    0x18(%rsp),%esi
  mov    0x8(%rsp),%rdi
  sub    %edi,%esi
  call   <str_next@plt>
  test   %eax,%eax
  jle    L366
  mov    0x40(%rsp),%rcx
  add    %rcx,0x8(%rsp)
  cmp    $0xfffffffd,%r15d
  je     L60
  cmp    $0xfffffffc,%r15d
  je     L369
  cmp    %eax,%r15d
  je     L369
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L339:
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L605:
  mov    D116(%rip),%rax
  mov    (%rax),%r15d
  jmp    L482
L105:
  mov    0x18(%rsp),%rdi
  sub    0x38(%rsp),%rdi
  mov    %eax,%esi
  call   <match_bracket@plt>
  test   %eax,%eax
  je     L283
L37:
  mov    0x40(%rsp),%rcx
  add    %rcx,0x8(%rsp)
L510:
  mov    %ebp,%ecx
  mov    0x20(%rsp),%rdx
  mov    0x10(%rsp),%esi
  mov    (%rsp),%rax
  sub    %eax,%esi
  mov    %rax,%rdi
  call   <pat_next@plt>
  mov    %eax,%r14d
  mov    (%rsp),%rax
  add    0x38(%rsp),%rax
  mov    %rax,0x18(%rsp)
  mov    %rax,(%rsp)
  cmp    $0xfffffffb,%r14d
  je     L233
  lea    0x40(%rsp),%rdx
  mov    %r13d,%esi
  mov    0x8(%rsp),%rdi
  sub    %edi,%esi
  call   <str_next@plt>
  test   %eax,%eax
  je     L605
  cmp    $0xfffffffd,%r14d
  je     L105
  cmp    $0xfffffffc,%r14d
  je     L37
  cmp    %eax,%r14d
  je     L37
L283:
  lea    0x40(%rsp),%rdx
  mov    %r13d,%esi
  sub    %r12d,%esi
  mov    %r12,%rdi
  call   <str_next@plt>
  test   %eax,%eax
  jle    L388
  add    0x40(%rsp),%r12
L350:
  cmp    0x10(%rsp),%rbx
  jae    L482
L296:
  mov    %r12,0x8(%rsp)
  mov    %rbx,(%rsp)
  jmp    L510
L388:
  add    $0x1,%r12
  lea    0x40(%rsp),%r14
  jmp    L260
L515:
  add    $0x1,%r12
L260:
  mov    %r14,%rdx
  mov    %r13d,%esi
  sub    %r12d,%esi
  mov    %r12,%rdi
  call   <str_next@plt>
  test   %eax,%eax
  js     L515
  jmp    L350
L233:
  mov    (%rsp),%rbx
  mov    0x8(%rsp),%r12
  jmp    L350
L432:
  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;
}
```