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

```asm
<strtol>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  nopl   (%rax)
L255:
  mov    %rbx,%r14
  movzbl (%rbx),%edi
  add    $0x1,%rbx
  mov    %edi,%r15d
  call   <isspace@plt>
  test   %rax,%rax
  jne    L255
  cmp    $0x2d,%r15b
  je     L16
  xor    %r8d,%r8d
  cmp    $0x2b,%r15b
  je     L147
L205:
  test   $0xffffffef,%ebp
  je     L289
L380:
  lea    -0x2(%rbp),%edx
  movslq %ebp,%r10
  cmp    $0x22,%edx
  jbe    L393
  test   %r13,%r13
  je     L214
L408:
  mov    %r12,0x0(%r13)
L214:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L289:
  cmp    $0x30,%r15b
  je     L332
  test   %ebp,%ebp
  jne    L380
  mov    $0xa,%r10d
  mov    $0xa,%ebp
L393:
  test   %r8d,%r8d
  jne    L78
  mov    D21(%rip),%rax
  mov    (%rax),%rax
L305:
  xor    %edx,%edx
  xor    %r11d,%r11d
  xor    %ecx,%ecx
  div    %r10
  mov    %rax,%r9
  jmp    L262
  nopl   0x0(%rax,%rax,1)
L242:
  cmp    %edx,%edi
  jle    L298
  mov    $0xffffffff,%r11d
  cmp    %r9,%rcx
  je     L259
L298:
  mov    %rcx,%rax
  movsbq %sil,%rsi
  mov    $0x1,%r11d
  imul   %r10,%rax
  lea    (%rsi,%rax,1),%rcx
L259:
  movzbl (%rbx),%r15d
  add    $0x1,%rbx
L262:
  lea    -0x30(%r15),%esi
  cmp    $0x9,%sil
  jbe    L74
  lea    -0x41(%r15),%eax
  lea    -0x37(%r15),%esi
  cmp    $0x19,%al
  jbe    L74
  lea    -0x61(%r15),%eax
  cmp    $0x19,%al
  ja     L216
  lea    -0x57(%r15),%esi
L74:
  movsbl %sil,%edi
  cmp    %ebp,%edi
  jge    L216
  test   %r11d,%r11d
  js     L191
  cmp    %r9,%rcx
  jbe    L242
L191:
  mov    $0xffffffff,%r11d
  jmp    L259
  nopl   0x0(%rax,%rax,1)
L78:
  mov    D37(%rip),%rax
  mov    (%rax),%rax
  neg    %rax
  jmp    L305
  nopw   0x0(%rax,%rax,1)
L147:
  movzbl (%rbx),%r15d
  lea    0x2(%r14),%rbx
  jmp    L205
  nopl   (%rax)
L216:
  cmp    $0xffffffff,%r11d
  je     L72
  test   %r11d,%r11d
  je     L368
  test   %r8d,%r8d
  je     L26
  neg    %rcx
  test   %r13,%r13
  jne    L91
L248:
  add    $0x8,%rsp
  mov    %rcx,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L16:
  movzbl (%rbx),%r15d
  mov    $0x1,%r8d
  lea    0x2(%r14),%rbx
  jmp    L205
  nopl   0x0(%rax,%rax,1)
L72:
  test   %r8d,%r8d
  jne    L47
  mov    D21(%rip),%rax
  mov    (%rax),%rcx
  test   %r13,%r13
  je     L248
L91:
  lea    -0x1(%rbx),%r12
  mov    %rcx,%rax
  jmp    L408
  nopl   0x0(%rax,%rax,1)
L368:
  mov    %rcx,%rax
  test   %r13,%r13
  jne    L408
  jmp    L214
  nopl   0x0(%rax)
L332:
  movzbl (%rbx),%edx
  and    $0xffffffdf,%edx
  cmp    $0x58,%dl
  jne    L109
  movzbl 0x1(%rbx),%ecx
  mov    %ecx,%edx
  and    $0xffffffdf,%edx
  sub    $0x41,%edx
  cmp    $0x5,%dl
  jbe    L286
  lea    -0x30(%rcx),%edx
  cmp    $0x9,%dl
  jbe    L286
L109:
  test   %ebp,%ebp
  jne    L380
  mov    $0x8,%r10d
  mov    $0x8,%ebp
  jmp    L393
  nopl   0x0(%rax)
L47:
  mov    D37(%rip),%rax
  mov    (%rax),%rcx
  test   %r13,%r13
  jne    L91
  jmp    L248
  nopl   0x0(%rax)
L26:
  test   %r13,%r13
  jne    L91
  jmp    L248
L286:
  add    $0x2,%rbx
  mov    %ecx,%r15d
  mov    $0x10,%r10d
  mov    $0x10,%ebp
  jmp    L393
```

assistant: ```c
long strtol(const char *__restrict nptr, char **__restrict endptr, int base) {
  const char *s;
  unsigned long acc;
  char c;
  unsigned long 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 ? (unsigned long)-(LONG_MIN + LONG_MAX) + LONG_MAX : LONG_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 ? LONG_MIN : LONG_MAX;
  } else if (!any) {
  } else if (neg)
    acc = -acc;
noconv:
  if (endptr != NULL)
    *endptr = (char *)(any ? s - 1 : nptr);
  return (acc);
}
```