user: Converte this assembly snippet into its equivalent C code:

```asm
<strtoimax>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x28,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,0x8(%rsp)
  nopl   0x0(%rax)
L71:
  mov    %r15,%rbp
  movzbl (%r15),%r13d
  add    $0x1,%r15
  mov    %r13d,%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L71
  cmp    $0x2d,%r13d
  je     L44
  cmp    $0x2b,%r13d
  je     L127
  mov    %ebx,%eax
  and    $0xffffffef,%eax
  jne    L87
L302:
  cmp    $0x30,%r13d
  je     L222
L66:
  test   %ebx,%ebx
  mov    $0xa,%edx
  cmove  %edx,%ebx
L300:
  test   %eax,%eax
  je     L87
L105:
  mov    D39(%rip),%rax
  mov    (%rax),%eax
  cltd
  idiv   %ebx
  mov    %eax,%r14d
  test   %edx,%edx
  jle    L290
  sub    %ebx,%edx
  add    $0x1,%r14d
L290:
  neg    %edx
  xor    %ebp,%ebp
  xor    %r12d,%r12d
  mov    %edx,0x1c(%rsp)
  jmp    L151
  nopl   0x0(%rax)
L28:
  cmp    %ebx,%ecx
  jge    L330
L345:
  cmp    $0xffffffff,%ebp
  je     L50
  cmp    %r14d,%r12d
  jl     L0
  jne    L197
  cmp    0x1c(%rsp),%ecx
  jle    L197
L0:
  mov    D39(%rip),%rax
  mov    $0xffffffff,%ebp
  mov    (%rax),%r12d
  mov    D76(%rip),%rax
  mov    (%rax),%edx
  mov    D55(%rip),%rax
  mov    %edx,(%rax)
L50:
  movzbl (%r15),%r13d
  add    $0x1,%r15
L151:
  mov    %r13d,%edi
  call   <isdigit@plt>
  lea    -0x30(%r13),%ecx
  test   %rax,%rax
  jne    L28
  mov    %r13d,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L330
  mov    %r13d,%edi
  call   <isupper@plt>
  mov    %r13d,%ecx
  cmp    $0x1,%rax
  sbb    %eax,%eax
  and    $0x20,%eax
  add    $0x37,%eax
  sub    %eax,%ecx
  cmp    %ebx,%ecx
  jl     L345
  xchg   %ax,%ax
L330:
  mov    0x8(%rsp),%rax
  test   %rax,%rax
  je     L148
  lea    -0x1(%r15),%rsi
  test   %ebp,%ebp
  cmove  0x10(%rsp),%rsi
  mov    %rsi,(%rax)
L148:
  add    $0x28,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L87:
  mov    D9(%rip),%rax
  xor    %ebp,%ebp
  xor    %r12d,%r12d
  mov    (%rax),%eax
  cltd
  idiv   %ebx
  mov    %edx,0x1c(%rsp)
  mov    %eax,%r14d
  jmp    L51
  nopw   0x0(%rax,%rax,1)
L96:
  cmp    %ebx,%eax
  jge    L330
  cmp    $0xffffffff,%ebp
  je     L245
  cmp    %r12d,%r14d
  jl     L94
  cmp    0x1c(%rsp),%eax
  jle    L268
  cmp    %r12d,%r14d
  jne    L268
L94:
  mov    D9(%rip),%rax
  mov    $0xffffffff,%ebp
  mov    (%rax),%r12d
  mov    D76(%rip),%rax
  mov    (%rax),%edx
  mov    D55(%rip),%rax
  mov    %edx,(%rax)
L245:
  movzbl (%r15),%r13d
  add    $0x1,%r15
L51:
  mov    %r13d,%edi
  call   <isdigit@plt>
  mov    %rax,%r8
  lea    -0x30(%r13),%eax
  test   %r8,%r8
  jne    L96
  mov    %r13d,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  je     L330
  mov    %r13d,%edi
  call   <isupper@plt>
  cmp    $0x1,%rax
  mov    %r13d,%eax
  sbb    %edx,%edx
  and    $0x20,%edx
  add    $0x37,%edx
  sub    %edx,%eax
  jmp    L96
  nopl   (%rax)
L268:
  imul   %ebx,%r12d
  mov    $0x1,%ebp
  add    %eax,%r12d
  jmp    L245
  cs nopw 0x0(%rax,%rax,1)
L127:
  mov    %ebx,%eax
  movsbl (%r15),%r13d
  lea    0x2(%rbp),%r15
  and    $0xffffffef,%eax
  je     L302
  jmp    L87
  nopl   0x0(%rax,%rax,1)
L197:
  imul   %ebx,%r12d
  mov    $0x1,%ebp
  sub    %ecx,%r12d
  jmp    L50
  nopl   0x0(%rax)
L44:
  add    $0x2,%rbp
  movsbl (%r15),%r13d
  mov    %rbp,%r15
  test   $0xffffffef,%ebx
  jne    L105
  mov    $0x1,%eax
  cmp    $0x30,%r13d
  jne    L66
L222:
  movzbl (%r15),%edx
  and    $0xffffffdf,%edx
  cmp    $0x58,%dl
  jne    L288
  movsbl 0x1(%r15),%r13d
  mov    $0x10,%ebx
  add    $0x2,%r15
  jmp    L300
L288:
  test   %ebx,%ebx
  mov    $0x8,%edx
  cmove  %edx,%ebx
  jmp    L300
```

assistant: ```c
intmax_t strtoimax(const char *nptr, char **endptr, int base) {
  const char *s;
  intmax_t acc, cutoff;
  int c;
  int neg, any, cutlim;
  s = nptr;
  do {
    c = (unsigned char)*s++;
  } while (isspace(c));
  if (c == '-') {
    neg = 1;
    c = *s++;
  } else {
    neg = 0;
    if (c == '+')
      c = *s++;
  }
  if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) {
    c = s[1];
    s += 2;
    base = 16;
  }
  if (base == 0)
    base = c == '0' ? 8 : 10;
  cutoff = neg ? INTMAX_MIN : INTMAX_MAX;
  cutlim = cutoff % base;
  cutoff /= base;
  if (neg) {
    if (cutlim > 0) {
      cutlim -= base;
      cutoff += 1;
    }
    cutlim = -cutlim;
  }
  for (acc = 0, any = 0;; c = (unsigned char)*s++) {
    if (isdigit(c))
      c -= '0';
    else if (isalpha(c))
      c -= isupper(c) ? 'A' - 10 : 'a' - 10;
    else
      break;
    if (c >= base)
      break;
    if (any < 0)
      continue;
    if (neg) {
      if (acc < cutoff || (acc == cutoff && c > cutlim)) {
        any = -1;
        acc = INTMAX_MIN;
        errno = ERANGE;
      } else {
        any = 1;
        acc *= base;
        acc -= c;
      }
    } else {
      if (acc > cutoff || (acc == cutoff && c > cutlim)) {
        any = -1;
        acc = INTMAX_MAX;
        errno = ERANGE;
      } else {
        any = 1;
        acc *= base;
        acc += c;
      }
    }
  }
  if (endptr != 0)
    *endptr = (char *)(any ? s - 1 : nptr);
  return (acc);
}
```