user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<wcstoimax>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x18,%rsp
  mov    %rsi,(%rsp)
  jmp    L188
  nopl   (%rax)
L182:
  add    $0x1,%r15
L188:
  movsbl (%r15),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L182
  movzbl (%r15),%eax
  cmp    $0x2d,%al
  je     L86
  movl   $0x0,0xc(%rsp)
  cmp    $0x2b,%al
  je     L34
L200:
  test   %ebx,%ebx
  jne    L82
  mov    $0xa,%ebx
  cmp    $0x30,%al
  je     L231
L47:
  mov    D13(%rip),%rax
  xor    %ebp,%ebp
  xor    %r13d,%r13d
  mov    $0x1,%r14d
  mov    (%rax),%eax
  cltd
  idiv   %ebx
  mov    %edx,0x8(%rsp)
  mov    %eax,%r12d
  jmp    L105
  nopl   0x0(%rax,%rax,1)
L130:
  jne    L98
  cmp    %eax,0x8(%rsp)
  cmovl  %r14d,%ebp
L98:
  mov    %r13d,%r8d
  add    $0x1,%r15
  imul   %ebx,%r8d
  lea    (%r8,%rax,1),%r13d
L105:
  movsbl (%r15),%edi
  call   <CharToInt@plt>
  cmp    %eax,%ebx
  jle    L102
  cmp    %r12d,%r13d
  jle    L130
  mov    $0x1,%ebp
  jmp    L98
  nopw   0x0(%rax,%rax,1)
L102:
  mov    (%rsp),%rax
  test   %rax,%rax
  je     L225
  mov    %r15,(%rax)
L225:
  test   %ebp,%ebp
  jne    L19
  mov    0xc(%rsp),%edx
  mov    %r13d,%eax
  neg    %eax
  test   %edx,%edx
  cmovne %eax,%r13d
L155:
  add    $0x18,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L82:
  cmp    $0x10,%ebx
  jne    L47
  cmp    $0x30,%al
  jne    L47
  movzbl 0x1(%r15),%eax
  lea    0x2(%r15),%rdx
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  cmove  %rdx,%r15
  jmp    L47
L34:
  movzbl 0x1(%r15),%eax
  add    $0x1,%r15
  jmp    L200
  xchg   %ax,%ax
L86:
  movzbl 0x1(%r15),%eax
  movl   $0x1,0xc(%rsp)
  add    $0x1,%r15
  jmp    L200
  cs nopw 0x0(%rax,%rax,1)
L19:
  mov    D27(%rip),%rax
  mov    0xc(%rsp),%ecx
  mov    (%rax),%edx
  mov    D30(%rip),%rax
  mov    %edx,(%rax)
  test   %ecx,%ecx
  je     L15
  mov    D10(%rip),%rax
  mov    (%rax),%r13d
  jmp    L155
  nopl   0x0(%rax)
L15:
  mov    D13(%rip),%rax
  mov    (%rax),%r13d
  jmp    L155
  nop
L231:
  movzbl 0x1(%r15),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L25
  add    $0x2,%r15
  mov    $0x10,%ebx
  jmp    L47
L25:
  add    $0x1,%r15
  mov    $0x8,%ebx
  jmp    L47
```

assistant: ```c
intmax_t wcstoimax(wchar_t const *restrict nptr, wchar_t **restrict endptr, int base) {
  while (isspace(*nptr))
    ++nptr;
  bool sign;
  if (*nptr == '-')
    sign = true, ++nptr;
  else if (*nptr == '+')
    sign = false, ++nptr;
  else
    sign = false;
  if (!base) {
    if (*nptr == '0') {
      if (*++nptr == 'X' || *nptr == 'x')
        base = 16, ++nptr;
      else
        base = 8;
    } else
      base = 10;
  } else if (base == 16) {
    if (nptr[0] == '0' && (nptr[1] == 'X' || nptr[1] == 'x'))
      nptr += 2;
  };
  intmax_t val = 0, mul = base, max = INTMAX_MAX / mul;
  int gap = INTMAX_MAX % mul;
  bool ovr = 0;
  for (int dig; (dig = CharToInt(*nptr)) < base; ++nptr) {
    if (val > max || (val == max && dig > gap))
      ovr = 1;
    val = val * mul + dig;
  };
  if (endptr)
    *endptr = (wchar_t *)nptr;
  if (ovr) {
    errno = ERANGE;
    return sign ? INTMAX_MIN : INTMAX_MAX;
  }
  return sign ? -val : val;
  ;
}
```