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

```asm
<strtol>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rsi,(%rsp)
  jmp    L54
  xchg   %ax,%ax
L183:
  add    $0x1,%r15
L54:
  movsbl (%r15),%edi
  call   <isspace@plt>
  mov    %rax,%r14
  test   %rax,%rax
  jne    L183
  movzbl (%r15),%eax
  cmp    $0x2d,%al
  je     L66
  movb   $0x0,0xf(%rsp)
  cmp    $0x2b,%al
  je     L125
L70:
  test   %r12d,%r12d
  jne    L104
L143:
  mov    $0xa,%ebx
  cmp    $0x30,%al
  je     L216
L127:
  movslq %ebx,%rbp
  jmp    L38
  nopl   0x0(%rax)
L118:
  sub    $0x37,%eax
L51:
  cmp    %bl,%al
  jge    L42
  mov    %rbp,%rcx
  movsbq %al,%rax
  imul   %r14,%rcx
  add    %rcx,%rax
  cmp    %rax,%r14
  jg     L48
  mov    %rax,%r14
L38:
  mov    %r15,%r13
  movsbl (%r15),%edi
  add    $0x1,%r15
  call   <toupper@plt>
  cmp    $0x40,%al
  jg     L118
  sub    $0x30,%al
  jns    L51
L42:
  cmpq   $0x0,(%rsp)
  je     L247
  test   %r12d,%r12d
  je     L148
  nopl   (%rax)
L220:
  mov    (%rsp),%rax
  mov    %r13,(%rax)
L247:
  mov    %r14,%rax
  neg    %rax
  cmpb   $0x0,0xf(%rsp)
  cmovne %rax,%r14
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  mov    %r14,%rax
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L148:
  movzbl 0x0(%r13),%eax
  sub    $0x4c,%eax
  cmp    $0x29,%al
  ja     L220
  movabs $0xfffffdfeeffffffe,%rcx
  cs nopw 0x0(%rax,%rax,1)
L30:
  bt     %rax,%rcx
  jb     L220
  movzbl 0x1(%r13),%eax
  add    $0x1,%r13
  sub    $0x4c,%eax
  cmp    $0x29,%al
  ja     L220
  jmp    L30
  nopl   0x0(%rax,%rax,1)
L125:
  movzbl 0x1(%r15),%eax
  add    $0x1,%r15
  test   %r12d,%r12d
  je     L143
L104:
  mov    %r12d,%ebx
  cmp    $0x10,%r12d
  jne    L127
  cmp    $0x30,%al
  jne    L127
  movzbl 0x1(%r15),%eax
  mov    %r15,%rdx
  add    $0x2,%r15
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  cmovne %rdx,%r15
  jmp    L127
  nopl   0x0(%rax)
L66:
  movzbl 0x1(%r15),%eax
  movb   $0x1,0xf(%rsp)
  add    $0x1,%r15
  jmp    L70
  nopl   0x0(%rax,%rax,1)
L48:
  cmpb   $0x0,0xf(%rsp)
  jne    L114
  mov    D25(%rip),%rax
  mov    (%rax),%r14
L69:
  mov    D31(%rip),%rax
  mov    (%rax),%ecx
  mov    D29(%rip),%rax
  mov    %ecx,(%rax)
  jmp    L42
  nopl   0x0(%rax,%rax,1)
L216:
  movzbl 0x1(%r15),%eax
  xor    %ebx,%ebx
  and    $0xffffffdf,%eax
  cmp    $0x58,%al
  sete   %bl
  lea    0x8(,%rbx,8),%ebx
  jmp    L127
  nopl   0x0(%rax,%rax,1)
L114:
  mov    D13(%rip),%rax
  mov    (%rax),%r14
  jmp    L69
```

assistant: ```c
long strtol(const char *__restrict nptr, char **__restrict endptr, int base) {
  long sum, psum;
  char sign;
  int radix = base;
  char *cp = (char *)nptr;
  char digit;
  while (isspace(*cp))
    ++cp;
  sign = 0;
  if (*cp == (char)'-') {
    sign = 1;
    ++cp;
  } else if (*cp == (char)'+')
    ++cp;
  if (base == 0) {
    radix = 10;
    if (*cp == (char)'0') {
      if (cp[1] == (char)'x' || cp[1] == (char)'X') {
        radix = 16;
      } else {
        radix = 8;
      }
    }
  }
  if (base == 16 && *cp == (char)'0' && (cp[1] == (char)'x' || cp[1] == (char)'X'))
    cp += 2;
  sum = 0;
  for (;;) {
    digit = toupper(*(cp++));
    if (digit >= (char)'A')
      digit = (digit - (char)'A') + (char)10;
    else
      digit -= (char)'0';
    if (digit < (char)0 || digit >= (char)radix)
      break;
    psum = sum;
    sum *= radix;
    sum += digit;
    if (sum < psum) {
      sum = sign ? LONG_MIN : LONG_MAX;
      errno = ERANGE;
      break;
    }
  }
  if (endptr) {
    --cp;
    if (base == 0) {
      while (*cp == (char)'h' || *cp == (char)'u' || *cp == (char)'l' || *cp == (char)'L')
        ++cp;
    }
    *endptr = (char *)cp;
  }
  return (sign ? -sum : sum);
}
```