user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<strtol>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbp
  mov    %rsi,0x8(%rsp)
  mov    %edx,%ebx
  test   %rdi,%rdi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    %rbp,%rsi
L158:
  mov    %rsi,%rdx
  add    $0x1,%rsi
  movzbl -0x1(%rsi),%eax
  movzbl %al,%ecx
  sub    $0x9,%eax
  cmp    $0x1,%al
  jbe    L158
  cmp    $0x20,%ecx
  je     L158
  cmp    $0x2d,%ecx
  je     L70
  mov    $0x0,%r10d
  cmp    $0x2b,%ecx
  je     L39
L261:
  test   $0xffffffef,%ebx
  jne    L152
  cmp    $0x30,%ecx
  je     L315
L152:
  test   %ebx,%ebx
  jne    L112
  cmp    $0x30,%ecx
  setne  %bl
  movzbl %bl,%ebx
  lea    0x8(%rbx,%rbx,1),%ebx
L112:
  test   %r10d,%r10d
  je     L173
  mov    D15(%rip),%rax
  mov    (%rax),%rax
  movslq %ebx,%r13
  cqto
  idiv   %r13
  mov    %edx,%edi
  mov    %rax,%r8
  test   %edx,%edx
  jle    L239
  sub    %ebx,%edi
  lea    0x1(%rax),%r8
L239:
  neg    %edi
  mov    %edi,(%rsp)
  jmp    L259
L70:
  movsbl (%rsi),%ecx
  lea    0x2(%rdx),%rsi
  mov    $0x1,%r10d
  jmp    L261
L39:
  movsbl (%rsi),%ecx
  lea    0x2(%rdx),%rsi
  jmp    L261
L315:
  movzbl (%rsi),%eax
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  jne    L13
  movsbl 0x1(%rsi),%ecx
  add    $0x2,%rsi
  mov    $0x10,%ebx
  jmp    L112
L13:
  mov    $0x30,%ecx
  jmp    L152
L173:
  mov    D45(%rip),%rax
  mov    (%rax),%rax
  movslq %ebx,%r13
  cqto
  idiv   %r13
  mov    %edx,(%rsp)
  mov    %rax,%r8
L259:
  mov    D45(%rip),%rax
  mov    (%rax),%r15
  mov    D43(%rip),%rax
  mov    (%rax),%r12d
  mov    D15(%rip),%rax
  mov    (%rax),%r14
  mov    $0x0,%edi
  mov    $0x0,%eax
  mov    $0xffffffff,%r11d
  mov    %r10d,0x4(%rsp)
  jmp    L105
L252:
  lea    -0x41(%rcx),%r9d
  mov    %ecx,%edx
  and    $0xffffffdf,%edx
  sub    $0x41,%edx
  cmp    $0x19,%edx
  ja     L297
  cmp    $0x1a,%r9d
  sbb    %edx,%edx
  and    $0xffffffe0,%edx
  add    $0x57,%edx
  sub    %edx,%ecx
  jmp    L160
L1:
  mov    D25(%rip),%rax
  mov    %r12d,(%rax)
  mov    %r14,%rax
  mov    %r11d,%edi
L137:
  add    $0x1,%rsi
  movzbl -0x1(%rsi),%ecx
L105:
  lea    -0x30(%rcx),%edx
  cmp    $0x9,%edx
  ja     L252
  mov    %edx,%ecx
L160:
  cmp    %ecx,%ebx
  jle    L297
  test   %edi,%edi
  js     L137
  test   %r10d,%r10d
  je     L233
  cmp    %r8,%rax
  jl     L1
  jne    L129
  cmp    (%rsp),%ecx
  jg     L1
L129:
  imul   %r13,%rax
  movslq %ecx,%rcx
  sub    %rcx,%rax
  mov    0x4(%rsp),%edi
  jmp    L137
L233:
  cmp    %r8,%rax
  jg     L313
  jne    L229
  cmp    (%rsp),%ecx
  jle    L229
L313:
  mov    D25(%rip),%rax
  mov    %r12d,(%rax)
  mov    %r15,%rax
  mov    %r11d,%edi
  jmp    L137
L229:
  imul   %r13,%rax
  movslq %ecx,%rcx
  add    %rcx,%rax
  mov    $0x1,%edi
  jmp    L137
L297:
  mov    0x8(%rsp),%rbx
  test   %rbx,%rbx
  je     L287
  sub    $0x1,%rsi
  test   %edi,%edi
  cmovne %rsi,%rbp
  mov    %rbp,(%rbx)
L287:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

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);
}
```