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

```asm
<duda_utils_strtol>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  movl   $0x0,-0x28(%rbp)
  movl   $0xa,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x2c(%rbp)
  cmpl   $0x2d,-0x2c(%rbp)
  jne    L27
  movl   $0x1,-0x28(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x2c(%rbp)
  jmp    L83
L27:
  cmpl   $0x2b,-0x2c(%rbp)
  jne    L83
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x2c(%rbp)
L83:
  cmpl   $0x0,-0x28(%rbp)
  je     L92
  mov    D18(%rip),%rax
  mov    (%rax),%rax
  neg    %rax
  jmp    L126
L92:
  mov    D4(%rip),%rax
  mov    (%rax),%rax
L126:
  mov    %rax,-0x8(%rbp)
  mov    -0x20(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%edx
  div    %rcx
  mov    %rdx,%rax
  mov    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  movslq %eax,%rsi
  mov    -0x8(%rbp),%rax
  mov    $0x0,%edx
  div    %rsi
  mov    %rax,-0x8(%rbp)
  movq   $0x0,-0x10(%rbp)
  movl   $0x0,-0x24(%rbp)
  jmp    L107
L151:
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L54
  subl   $0x30,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jl     L18
  jmp    L133
L54:
  movl   $0xffffffff,-0x24(%rbp)
  jmp    L106
L133:
  movl   $0xffffffff,-0x24(%rbp)
  jmp    L106
L18:
  cmpl   $0x0,-0x24(%rbp)
  js     L187
  mov    -0x10(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  ja     L187
  mov    -0x10(%rbp),%rax
  cmp    -0x8(%rbp),%rax
  jne    L135
  mov    -0x2c(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jle    L135
L187:
  movl   $0xffffffff,-0x24(%rbp)
  jmp    L121
L135:
  movl   $0x1,-0x24(%rbp)
  mov    -0x20(%rbp),%eax
  cltq
  mov    -0x10(%rbp),%rdx
  imul   %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  add    %rax,-0x10(%rbp)
L121:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,-0x2c(%rbp)
L107:
  mov    -0x18(%rbp),%rax
  sub    -0x38(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x3c(%rbp),%eax
  cltq
  cmp    %rax,%rdx
  jle    L151
L106:
  cmpl   $0x0,-0x24(%rbp)
  jns    L72
  mov    -0x48(%rbp),%rax
  movq   $0x0,(%rax)
  mov    $0xffffffff,%eax
  jmp    L164
L72:
  cmpl   $0x0,-0x28(%rbp)
  je     L192
  negq   -0x10(%rbp)
L192:
  mov    -0x10(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,(%rax)
  mov    $0x0,%eax
L164:
  leave
  ret
```

assistant: ```c
int duda_utils_strtol(const char *nptr, int len, long *result) {
  const char *s = nptr;
  unsigned long acc;
  int c;
  unsigned long cutoff;
  int neg = 0, any, cutlim;
  int base = 10;
  c = *s++;
  if (c == '-') {
    neg = 1;
    c = *s++;
  } else if (c == '+') {
    c = *s++;
  }
  cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
  cutlim = cutoff % (unsigned long)base;
  cutoff /= (unsigned long)base;
  for (acc = 0, any = 0; (s - ((const char *)nptr) <= len); c = *s++) {
    if (isdigit(c)) {
      c -= '0';
    } else {
      any = -1;
      break;
    }
    if (c >= base) {
      any = -1;
      break;
    }
    if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) {
      any = -1;
    } else {
      any = 1;
      acc *= base;
      acc += c;
    }
  }
  if (any < 0) {
    *result = 0;
    return -1;
  } else if (neg) {
    acc = -acc;
  }
  *result = acc;
  return 0;
}
```