user: 请将以下的汇编代码转换成C语言代码：

```asm
<wild_match_per>:
  endbr64
  test   %rsi,%rsi
  je     L247
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %rdi,%rdi
  jne    L404
L267:
  xor    %eax,%eax
L180:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L404:
  movzbl (%rsi),%ecx
  mov    %rsi,%rbx
  test   %cl,%cl
  je     L267
  movl   $0x0,0x8(%rsp)
  xor    %r14d,%r14d
  xor    %r13d,%r13d
  xor    %ebp,%ebp
  xor    %r15d,%r15d
  jmp    L395
  nopw   0x0(%rax,%rax,1)
L23:
  cmp    $0x2a,%al
  jne    L249
  cmpb   $0x0,0x1(%r12)
  lea    0x1(%r12),%rax
  je     L105
  mov    %rax,%r12
  mov    $0x1,%r14d
L270:
  movzbl (%rbx),%ecx
  test   %cl,%cl
  je     L71
L395:
  movzbl (%r12),%eax
  test   %al,%al
  je     L71
L75:
  cmp    $0x3f,%al
  je     L390
  jg     L260
  cmp    $0x25,%al
  jne    L23
  lea    0x1(%r12),%r15
  nopl   (%rax)
L111:
  mov    %r15,%rax
  add    $0x1,%r15
  cmpb   $0x25,-0x1(%r15)
  je     L111
  add    $0x2,%rax
  cmpb   $0x5c,(%r15)
  cmove  %rax,%r15
  cmpb   $0x0,(%rbx)
  jne    L403
  jmp    L370
  nopl   0x0(%rax)
L303:
  movzbl (%rbx),%ecx
  cmp    $0x20,%cl
  je     L110
  add    $0x1,%rbx
  cmpb   $0x0,(%rbx)
  je     L370
L403:
  movsbl (%r15),%edi
  call   <toupper@plt>
  movsbl (%rbx),%edi
  mov    %eax,%ebp
  call   <toupper@plt>
  cmp    %eax,%ebp
  jne    L303
  mov    %r12,%rbp
  mov    %r15,%r12
  mov    $0x1,%r15d
  jmp    L270
  nopl   0x0(%rax)
L260:
  cmp    $0x7e,%al
  jne    L52
  cmp    $0x20,%cl
  je     L11
L183:
  test   %rbp,%rbp
  je     L267
L57:
  mov    0x8(%rsp),%r13d
  lea    -0x1(%rbp),%r12
  jmp    L270
L11:
  add    $0x1,%rbx
  cmpb   $0x20,-0x1(%rbx)
  je     L11
  add    $0x1,%r12
  add    $0x1,%r13d
  jmp    L270
  nopw   0x0(%rax,%rax,1)
L52:
  cmp    $0x5c,%al
  sete   %al
  movzbl %al,%eax
  add    %rax,%r12
L249:
  test   %r14d,%r14d
  jne    L188
  movsbl (%r12),%edi
  call   <toupper@plt>
  movsbl (%rbx),%edi
  mov    %eax,0xc(%rsp)
  call   <toupper@plt>
  cmp    %eax,0xc(%rsp)
  jne    L183
  add    $0x1,%r13d
L397:
  cmpb   $0x1,(%r12)
  mov    %r12,%r15
  sbb    $0xffffffffffffffff,%r15
  cmpb   $0x0,(%rbx)
  jne    L368
  nopl   (%rax)
L370:
  xor    %ecx,%ecx
L269:
  or     (%r15),%cl
  jne    L267
L105:
  mov    0x8(%rsp),%eax
  lea    0x1(%rax,%r13,1),%eax
  jmp    L180
  nopl   0x0(%rax)
L40:
  movsbl (%r12),%edi
  call   <toupper@plt>
  movsbl (%rbx),%edi
  mov    %eax,%ebp
  call   <toupper@plt>
  cmp    %eax,%ebp
  je     L76
  add    $0x1,%rbx
L188:
  cmpb   $0x0,(%rbx)
  jne    L40
L69:
  mov    %r13d,0x8(%rsp)
  mov    %r12,%r15
  xor    %r13d,%r13d
  jmp    L370
  cs nopw 0x0(%rax,%rax,1)
L390:
  add    $0x1,%r12
  add    $0x1,%rbx
  jmp    L270
  nopl   (%rax)
L110:
  mov    %r12,%rbp
  mov    %r15,%r12
  xor    %r15d,%r15d
  movzbl (%r12),%eax
  test   %al,%al
  jne    L75
  cs nopw 0x0(%rax,%rax,1)
L71:
  test   %r15d,%r15d
  je     L267
  mov    %r12,%r15
  jmp    L269
  nopl   0x0(%rax)
L247:
  xor    %eax,%eax
  ret
  nopl   0x0(%rax,%rax,1)
L76:
  cmpb   $0x0,(%rbx)
  je     L69
  movsbl (%r12),%edi
  call   <toupper@plt>
  movsbl (%rbx),%edi
  mov    %eax,%ebp
  call   <toupper@plt>
  mov    %r13d,0x8(%rsp)
  cmp    %eax,%ebp
  je     L20
  mov    %r12,%rbp
  xor    %r15d,%r15d
  jmp    L57
  nopl   (%rax)
L368:
  mov    %r15,%r12
  add    $0x1,%rbx
  xor    %r14d,%r14d
  mov    $0x1,%r15d
  jmp    L270
L20:
  mov    %r14d,%r13d
  mov    %r12,%rbp
  jmp    L397
```

assistant: ```c
int wild_match_per(char *wild, char *matchtext) {
  char *fallback = 0;
  int match = 0, saved = 0, count = 0, wildcard = 0;
  if (!matchtext || !wild)
    return 0;
  while (*matchtext && *wild) {
    switch (*wild) {
    case '%':
      fallback = wild++;
      match = 1;
      while ((*(wild++) == '%'))
        ;
      if (*wild == '\\')
        wild++;
      while (*matchtext && (toupper(*wild) != toupper(*matchtext)))
        if (*matchtext == ' ') {
          match = 0;
          break;
        } else
          matchtext++;
      break;
    case '?':
      wild++;
      matchtext++;
      break;
    case '~':
      wild++;
      if (*matchtext != ' ') {
        count = saved;
        if (!fallback)
          return 0;
        wild = fallback - 1;
        break;
      }
      while ((*(matchtext++) == ' '))
        ;
      count++;
      break;
    case '*':
      if (!*++wild)
        return (count + saved + 1);
      wildcard = 1;
      break;
    default:
      if (*wild == '\\')
        wild++;
      if (wildcard) {
        saved = count;
        match = count = 0;
        fallback = wild;
        while (*matchtext && (toupper(*wild) != toupper(*matchtext)))
          matchtext++;
        if (!*matchtext) {
          match = 1;
          break;
        }
      }
      if (toupper(*wild) != toupper(*matchtext)) {
        if (!fallback)
          return 0;
        count = saved;
        wild = fallback - 1;
        break;
      }
      count++;
      wildcard = 0;
      match = 1;
      if (*wild)
        wild++;
      if (*matchtext)
        matchtext++;
    }
  }
  return (!match || *wild || *matchtext) ? 0 : (count + saved + 1);
}
```