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

```asm
<strtol>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  xor    %edi,%edi
  push   %rbx
  mov    %edx,%ebx
  sub    $0x18,%rsp
  test   %rbp,%rbp
  setne  %dil
  mov    %rsi,0x8(%rsp)
  call   <assert@plt>
  mov    %rbp,%rsi
  nopl   (%rax)
L145:
  mov    %rsi,%rdx
  movzbl (%rsi),%ecx
  add    $0x1,%rsi
  mov    %ecx,%eax
  sub    $0x9,%eax
  cmp    $0x1,%al
  jbe    L145
  cmp    $0x20,%ecx
  je     L145
  mov    %ebx,%eax
  and    $0xffffffef,%eax
  cmp    $0x2d,%ecx
  je     L255
  cmp    $0x2b,%ecx
  je     L232
  movslq %ebx,%r14
  test   %eax,%eax
  je     L244
L163:
  mov    D58(%rip),%rax
  xor    %r11d,%r11d
  mov    (%rax),%r12
  mov    %r12,%rax
  cqto
  idiv   %r14
  mov    %rax,%r10
  mov    D14(%rip),%rax
  mov    (%rax),%r13
L91:
  mov    D1(%rip),%rax
  xor    %r8d,%r8d
  mov    %ecx,%r9d
  mov    (%rax),%r15d
  xor    %eax,%eax
  jmp    L303
L147:
  cmp    %r10,%rax
  jl     L187
  jne    L289
  cmp    %edx,%ecx
  jle    L289
L187:
  mov    D63(%rip),%rax
  mov    $0xffffffff,%r8d
  mov    %r15d,(%rax)
  mov    %r13,%rax
L95:
  movzbl (%rsi),%r9d
  add    $0x1,%rsi
L303:
  lea    -0x30(%r9),%ecx
  cmp    $0x9,%ecx
  jbe    L122
  mov    %r9d,%ecx
  lea    -0x41(%r9),%edi
  and    $0xffffffdf,%ecx
  sub    $0x41,%ecx
  cmp    $0x19,%ecx
  ja     L47
  cmp    $0x1a,%edi
  mov    %r9d,%ecx
  sbb    %edi,%edi
  and    $0xffffffe0,%edi
  add    $0x57,%edi
  sub    %edi,%ecx
L122:
  cmp    %ecx,%ebx
  jle    L47
  cmp    $0xffffffff,%r8d
  je     L95
  test   %r11d,%r11d
  jne    L147
  cmp    %r10,%rax
  jg     L0
  jne    L73
  cmp    %edx,%ecx
  jle    L73
L0:
  mov    D63(%rip),%rax
  mov    $0xffffffff,%r8d
  mov    %r15d,(%rax)
  mov    %r12,%rax
  jmp    L95
  nopl   0x0(%rax,%rax,1)
L255:
  movsbl 0x1(%rdx),%ecx
  lea    0x2(%rdx),%rsi
  movslq %ebx,%r14
  test   %eax,%eax
  jne    L212
  mov    $0x1,%eax
L244:
  cmp    $0x30,%ecx
  je     L327
  test   %ebx,%ebx
  jne    L321
  mov    $0xa,%r14d
  mov    $0xa,%ebx
L182:
  test   %eax,%eax
  je     L163
L212:
  mov    D14(%rip),%rax
  mov    (%rax),%r13
  mov    %r13,%rax
  cqto
  idiv   %r14
  mov    %edx,%edi
  mov    %rax,%r10
  test   %rdx,%rdx
  jle    L146
  sub    %ebx,%edi
  add    $0x1,%r10
L146:
  mov    D58(%rip),%rax
  mov    %edi,%edx
  mov    $0x1,%r11d
  neg    %edx
  mov    (%rax),%r12
  jmp    L91
  nopl   0x0(%rax,%rax,1)
L73:
  imul   %r14,%rax
  movslq %ecx,%rcx
  mov    $0x1,%r8d
  add    %rcx,%rax
  jmp    L95
  nopl   (%rax)
L289:
  imul   %r14,%rax
  movslq %ecx,%rcx
  mov    %r11d,%r8d
  sub    %rcx,%rax
  jmp    L95
  nopw   0x0(%rax,%rax,1)
L47:
  mov    0x8(%rsp),%rbx
  test   %rbx,%rbx
  je     L228
  sub    $0x1,%rsi
  test   %r8d,%r8d
  cmovne %rsi,%rbp
  mov    %rbp,(%rbx)
L228:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L232:
  movsbl 0x1(%rdx),%ecx
  lea    0x2(%rdx),%rsi
  movslq %ebx,%r14
  test   %eax,%eax
  jne    L163
  jmp    L244
L327:
  movzbl (%rsi),%edx
  and    $0xffffffdf,%edx
  cmp    $0x58,%dl
  jne    L25
  movsbl 0x1(%rsi),%ecx
  mov    $0x10,%r14d
  add    $0x2,%rsi
  mov    $0x10,%ebx
  jmp    L182
L25:
  test   %ebx,%ebx
  jne    L321
  mov    $0x8,%r14d
  mov    $0x8,%ebx
  jmp    L182
L321:
  movslq %ebx,%r14
  jmp    L182
```

assistant: ```c
long int strtol(const char *nptr, char **endptr, int base) {
  const char *s;
  long acc, cutoff;
  int c;
  int neg, any, cutlim;
  assert(nptr != NULL);
  s = nptr;
  do {
    c = (unsigned char)*s++;
  } while (((c == ' ') || (c == '\n') || (c == '\t')));
  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 ? LONG_MIN : LONG_MAX;
  cutlim = (int)(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 ((c >= '0' && c <= '9'))
      c -= '0';
    else if ((((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))))
      c -= ((c >= 'A') && (c <= 'Z')) ? '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 = LONG_MIN;
        errno = ERANGE;
      } else {
        any = 1;
        acc *= base;
        acc -= c;
      }
    } else {
      if (acc > cutoff || (acc == cutoff && c > cutlim)) {
        any = -1;
        acc = LONG_MAX;
        errno = ERANGE;
      } else {
        any = 1;
        acc *= base;
        acc += c;
      }
    }
  }
  if (endptr != 0)
    *endptr = (char *)(any ? s - 1 : nptr);
  return (acc);
}
```