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

```asm
<strtoumax>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %rsi,%r12
  mov    %edx,%ebp
  lea    -0x2(%rdx),%eax
  cmp    $0x22,%eax
  jbe    L150
  test   %edx,%edx
  je     L150
  test   %rsi,%rsi
  je     L234
  mov    %rdi,(%r12)
L234:
  mov    D15(%rip),%rax
  mov    (%rax),%edx
  mov    D17(%rip),%rax
  mov    %edx,(%rax)
  mov    $0x0,%esi
L209:
  mov    %esi,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L240:
  add    $0x1,%rbx
L150:
  movsbl (%rbx),%edi
  call   <isspace@plt>
  test   %rax,%rax
  jne    L240
  test   %ebp,%ebp
  jne    L89
  mov    $0xa,%ebp
  cmpb   $0x30,(%rbx)
  je     L42
L89:
  mov    %ebp,%r8d
  movzbl (%rbx),%edx
  test   %dl,%dl
  je     L20
  mov    D49(%rip),%rax
  movsbl (%rax),%r10d
  mov    $0x0,%esi
  movsbl %bpl,%edi
  jmp    L54
L42:
  cmpb   $0x78,0x1(%rbx)
  je     L12
  add    $0x1,%rbx
  mov    $0x8,%ebp
  jmp    L89
L12:
  add    $0x2,%rbx
  mov    $0x10,%ebp
  jmp    L89
L16:
  cmp    $0x9,%cl
  ja     L77
L195:
  cmp    %r8b,%cl
  jge    L147
  movsbl %sil,%r11d
  movsbl %cl,%edx
  mov    %r10d,%eax
  sub    %edx,%eax
  cltd
  idiv   %edi
  cmp    %eax,%r11d
  jg     L163
  mov    %esi,%eax
  imul   %ebp,%eax
  mov    %eax,%esi
  add    %ecx,%esi
  movzbl (%rbx),%edx
  test   %dl,%dl
  je     L22
L54:
  mov    %rbx,%r9
  add    $0x1,%rbx
  mov    %edx,%eax
  lea    -0x30(%rdx),%ecx
  sub    $0x61,%edx
  cmp    $0x9,%cl
  jbe    L16
  cmp    $0x19,%dl
  jbe    L16
  lea    -0x41(%rax),%edx
  cmp    $0x19,%dl
  ja     L147
L248:
  lea    -0x37(%rax),%ecx
  jmp    L195
L77:
  cmp    $0x19,%dl
  ja     L248
  lea    -0x57(%rax),%ecx
  jmp    L195
L163:
  mov    D13(%rip),%rax
  mov    (%rax),%edx
  mov    D17(%rip),%rax
  mov    %edx,(%rax)
  test   %r12,%r12
  je     L57
  mov    %r9,(%r12)
L57:
  mov    D26(%rip),%rax
  movzbl (%rax),%esi
  jmp    L209
L22:
  mov    %rbx,%r9
L147:
  test   %r12,%r12
  je     L209
  mov    %r9,(%r12)
  jmp    L209
L20:
  mov    %edx,%esi
  mov    %rbx,%r9
  jmp    L147
```

assistant: ```c
uintmax_t strtoumax(const char *str, char **str_end, int base) {
  if (((base < 2) || (base > 36)) && (base != 0)) {
    if (str_end != NULL)
      *str_end = (char *)str;
    errno = EINVAL;
    return 0;
  };
  while (isspace(*str))
    str++;
  uintmax_t out = 0;
  if (base == 0) {
    if (*str == '0') {
      str++;
      base = 8;
      if (*str == 'x') {
        str++;
        base = 16;
      };
    } else {
      base = 10;
    };
  };
  uintmax_t llbase = (uintmax_t)base;
  while (*str != 0) {
    char c = *str++;
    if (((c < '0') || (c > '9')) && ((c < 'a') || (c > 'z')) && ((c < 'A') || (c > 'Z'))) {
      str--;
      goto finished;
    };
    uintmax_t digit = 0;
    if ((c >= '0') && (c <= '9')) {
      digit = c - '0';
    } else if ((c >= 'a') && (c <= 'z')) {
      digit = 10 + c - 'a';
    } else {
      digit = 10 + c - 'A';
    };
    if (digit >= llbase) {
      str--;
      goto finished;
    };
    if (out > ((UINTMAX_MAX - digit) / llbase)) {
      str--;
      errno = ERANGE;
      if (str_end != NULL)
        *str_end = (char *)str;
      return ULONG_MAX;
    };
    out = out * llbase + digit;
  };
finished:
  if (str_end != NULL)
    *str_end = (char *)str;
  return out;
}
```