user: Please show me the C implementation that matches the assembly code listed below:

```asm
<strtoimax>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0x8,%rsp
  nopl   (%rax)
L320:
  mov    %r13,%r15
  movzbl 0x0(%r13),%edi
  add    $0x1,%r13
  mov    %edi,%r14d
  call   <isspace@plt>
  test   %rax,%rax
  jne    L320
  cmp    $0x2d,%r14b
  je     L371
  xor    %r8d,%r8d
  cmp    $0x2b,%r14b
  je     L65
L263:
  test   $0xffffffef,%ebx
  je     L314
L22:
  lea    -0x2(%rbx),%edx
  xor    %eax,%eax
  cmp    $0x22,%edx
  jbe    L202
L9:
  mov    D32(%rip),%rdx
  mov    (%rdx),%ecx
  mov    D75(%rip),%rdx
  mov    %ecx,(%rdx)
  test   %r12,%r12
  je     L63
L328:
  mov    %rbp,(%r12)
L63:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L314:
  cmp    $0x30,%r14b
  je     L154
  test   %ebx,%ebx
  jne    L22
  mov    $0xa,%ebx
L202:
  test   %r8d,%r8d
  jne    L116
  mov    D52(%rip),%rax
  mov    (%rax),%eax
L23:
  cltd
  xor    %esi,%esi
  idiv   %ebx
  mov    %eax,%edi
  xor    %eax,%eax
  jmp    L200
L380:
  lea    -0x37(%r14),%ecx
L211:
  movsbl %cl,%ecx
  cmp    %ebx,%ecx
  jge    L394
L291:
  test   %esi,%esi
  js     L61
  cmp    %edi,%eax
  jg     L61
  cmp    %edx,%ecx
  jle    L110
  mov    $0xffffffff,%esi
  cmp    %edi,%eax
  je     L129
L110:
  imul   %ebx,%eax
  mov    $0x1,%esi
  add    %ecx,%eax
L129:
  movzbl 0x0(%r13),%r14d
  add    $0x1,%r13
L200:
  lea    -0x30(%r14),%ecx
  cmp    $0x9,%cl
  jbe    L211
  lea    -0x41(%r14),%ecx
  cmp    $0x19,%cl
  jbe    L380
  lea    -0x61(%r14),%ecx
  cmp    $0x19,%cl
  ja     L394
  lea    -0x57(%r14),%ecx
  movsbl %cl,%ecx
  cmp    %ebx,%ecx
  jl     L291
  nopl   0x0(%rax)
L394:
  cmp    $0xffffffff,%esi
  je     L183
  test   %esi,%esi
  je     L9
  test   %r8d,%r8d
  je     L308
  neg    %eax
  test   %r12,%r12
  jne    L330
  jmp    L63
  nopw   0x0(%rax,%rax,1)
L116:
  mov    D53(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L23
L65:
  movzbl 0x0(%r13),%r14d
  lea    0x2(%r15),%r13
  jmp    L263
  xchg   %ax,%ax
L61:
  mov    $0xffffffff,%esi
  jmp    L129
  nopw   0x0(%rax,%rax,1)
L371:
  movzbl 0x0(%r13),%r14d
  mov    $0x1,%r8d
  lea    0x2(%r15),%r13
  jmp    L263
  nopl   0x0(%rax)
L183:
  test   %r8d,%r8d
  jne    L102
  mov    D52(%rip),%rax
  mov    (%rax),%eax
L391:
  mov    D18(%rip),%rdx
  mov    (%rdx),%ecx
  mov    D75(%rip),%rdx
  mov    %ecx,(%rdx)
  test   %r12,%r12
  je     L63
L330:
  lea    -0x1(%r13),%rbp
  jmp    L328
  nopw   0x0(%rax,%rax,1)
L154:
  movzbl 0x0(%r13),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L360
  movzbl 0x1(%r13),%edx
  mov    %edx,%eax
  and    $0xffffffdf,%eax
  sub    $0x41,%eax
  cmp    $0x5,%al
  jbe    L133
  lea    -0x30(%rdx),%eax
  cmp    $0x9,%al
  jbe    L133
L360:
  test   %ebx,%ebx
  jne    L22
  mov    $0x8,%ebx
  jmp    L202
  cs nopw 0x0(%rax,%rax,1)
L102:
  mov    D53(%rip),%rax
  mov    (%rax),%eax
  jmp    L391
  nopl   0x0(%rax,%rax,1)
L308:
  test   %r12,%r12
  jne    L330
  jmp    L63
L133:
  add    $0x2,%r13
  mov    %edx,%r14d
  mov    $0x10,%ebx
  jmp    L202
```

assistant: ```c
intmax_t strtoimax(const char *__restrict nptr, char **__restrict endptr, int base) {
  const char *s;
  uintmax_t acc;
  char c;
  uintmax_t cutoff;
  int neg, any, cutlim;
  s = nptr;
  do {
    c = *s++;
  } while (isspace((unsigned char)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') && ((s[1] >= '0' && s[1] <= '9') || (s[1] >= 'A' && s[1] <= 'F') || (s[1] >= 'a' && s[1] <= 'f'))) {
    c = s[1];
    s += 2;
    base = 16;
  }
  if (base == 0)
    base = c == '0' ? 8 : 10;
  acc = any = 0;
  if (base < 2 || base > 36)
    goto noconv;
  cutoff = neg ? (uintmax_t) - (INTMAX_MIN + INTMAX_MAX) + INTMAX_MAX : INTMAX_MAX;
  cutlim = cutoff % base;
  cutoff /= base;
  for (;; c = *s++) {
    if (c >= '0' && c <= '9')
      c -= '0';
    else if (c >= 'A' && c <= 'Z')
      c -= 'A' - 10;
    else if (c >= 'a' && c <= 'z')
      c -= 'a' - 10;
    else
      break;
    if (c >= base)
      break;
    if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
      any = -1;
    else {
      any = 1;
      acc *= base;
      acc += c;
    }
  }
  if (any < 0) {
    acc = neg ? INTMAX_MIN : INTMAX_MAX;
    errno = ERANGE;
  } else if (!any) {
  noconv:
    errno = EINVAL;
  } else if (neg)
    acc = -acc;
  if (endptr != NULL)
    *endptr = (char *)(any ? s - 1 : nptr);
  return (acc);
}
```