user: 请从给定的汇编指令推导出C源代码:

```asm
<wild_match_per>:
  endbr64
  test   %rsi,%rsi
  je     L224
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %rdi,%rdi
  jne    L277
L325:
  xor    %eax,%eax
L276:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L277:
  movzbl (%rsi),%ecx
  mov    %rsi,%rbx
  test   %cl,%cl
  je     L325
  movl   $0x0,0x8(%rsp)
  xor    %r14d,%r14d
  xor    %r13d,%r13d
  xor    %ebp,%ebp
  xor    %r15d,%r15d
  jmp    L47
  nopw   0x0(%rax,%rax,1)
L97:
  cmp    $0x2a,%al
  jne    L91
  cmpb   $0x0,0x1(%r12)
  lea    0x1(%r12),%rax
  je     L14
  mov    %rax,%r12
  mov    $0x1,%r14d
L283:
  movzbl (%rbx),%ecx
  test   %cl,%cl
  je     L1
L47:
  movzbl (%r12),%eax
  test   %al,%al
  je     L1
L339:
  cmp    $0x3f,%al
  je     L189
  jg     L297
  cmp    $0x25,%al
  jne    L97
  lea    0x1(%r12),%r15
  nopl   (%rax)
L310:
  mov    %r15,%rax
  add    $0x1,%r15
  cmpb   $0x25,-0x1(%r15)
  je     L310
  add    $0x2,%rax
  cmpb   $0x5c,(%r15)
  cmove  %rax,%r15
  cmpb   $0x0,(%rbx)
  jne    L275
  jmp    L229
  nopl   0x0(%rax)
L313:
  movzbl (%rbx),%ecx
  cmp    $0x20,%cl
  je     L140
  add    $0x1,%rbx
  cmpb   $0x0,(%rbx)
  je     L229
L275:
  movsbl (%r15),%edi
  call   <toupper@plt>
  movsbl (%rbx),%edi
  mov    %eax,%ebp
  call   <toupper@plt>
  cmp    %eax,%ebp
  jne    L313
  mov    %r12,%rbp
  mov    %r15,%r12
  mov    $0x1,%r15d
  jmp    L283
  nopl   0x0(%rax)
L297:
  cmp    $0x7e,%al
  jne    L69
  cmp    $0x20,%cl
  je     L269
L5:
  test   %rbp,%rbp
  je     L325
L259:
  mov    0x8(%rsp),%r13d
  lea    -0x1(%rbp),%r12
  jmp    L283
L269:
  add    $0x1,%rbx
  cmpb   $0x20,-0x1(%rbx)
  je     L269
  add    $0x1,%r12
  add    $0x1,%r13d
  jmp    L283
  nopw   0x0(%rax,%rax,1)
L69:
  cmp    $0x5c,%al
  sete   %al
  movzbl %al,%eax
  add    %rax,%r12
L91:
  test   %r14d,%r14d
  jne    L159
  movsbl (%r12),%edi
  call   <toupper@plt>
  movsbl (%rbx),%edi
  mov    %eax,0xc(%rsp)
  call   <toupper@plt>
  cmp    %eax,0xc(%rsp)
  jne    L5
  add    $0x1,%r13d
L138:
  cmpb   $0x1,(%r12)
  mov    %r12,%r15
  sbb    $0xffffffffffffffff,%r15
  cmpb   $0x0,(%rbx)
  jne    L2
  nopl   (%rax)
L229:
  xor    %ecx,%ecx
L261:
  or     (%r15),%cl
  jne    L325
L14:
  mov    0x8(%rsp),%eax
  lea    0x1(%rax,%r13,1),%eax
  jmp    L276
  nopl   0x0(%rax)
L150:
  movsbl (%r12),%edi
  call   <toupper@plt>
  movsbl (%rbx),%edi
  mov    %eax,%ebp
  call   <toupper@plt>
  cmp    %eax,%ebp
  je     L39
  add    $0x1,%rbx
L159:
  cmpb   $0x0,(%rbx)
  jne    L150
L164:
  mov    %r13d,0x8(%rsp)
  mov    %r12,%r15
  xor    %r13d,%r13d
  jmp    L229
  cs nopw 0x0(%rax,%rax,1)
L189:
  add    $0x1,%r12
  add    $0x1,%rbx
  jmp    L283
  nopl   (%rax)
L140:
  mov    %r12,%rbp
  mov    %r15,%r12
  xor    %r15d,%r15d
  movzbl (%r12),%eax
  test   %al,%al
  jne    L339
  cs nopw 0x0(%rax,%rax,1)
L1:
  test   %r15d,%r15d
  je     L325
  mov    %r12,%r15
  jmp    L261
  nopl   0x0(%rax)
L224:
  xor    %eax,%eax
  ret
  nopl   0x0(%rax,%rax,1)
L39:
  cmpb   $0x0,(%rbx)
  je     L164
  movsbl (%r12),%edi
  call   <toupper@plt>
  movsbl (%rbx),%edi
  mov    %eax,%ebp
  call   <toupper@plt>
  mov    %r13d,0x8(%rsp)
  cmp    %eax,%ebp
  je     L290
  mov    %r12,%rbp
  xor    %r15d,%r15d
  jmp    L259
  nopl   (%rax)
L2:
  mov    %r15,%r12
  add    $0x1,%rbx
  xor    %r14d,%r14d
  mov    $0x1,%r15d
  jmp    L283
L290:
  mov    %r14d,%r13d
  mov    %r12,%rbp
  jmp    L138
```

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);
}
```