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

```asm
<pq_nkrange>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L56
  mov    $0x0,%eax
  jmp    L3
L56:
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  add    $0x1,%eax
  mov    $0x1,%esi
  mov    %eax,%edi
  call   <calloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x24(%rbp),%eax
  add    $0x1,%eax
  mov    $0x1,%esi
  mov    %eax,%edi
  call   <calloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  movl   $0x0,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x30(%rbp)
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x34(%rbp)
  jmp    L32
L23:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2c,%al
  jne    L92
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x30(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %eax,-0x28(%rbp)
  mov    -0x1c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L18
  mov    $0x1,%eax
  jmp    L48
L18:
  mov    $0xffffffff,%eax
L48:
  mov    %eax,-0x20(%rbp)
  jmp    L99
L117:
  addl   $0x1,-0x34(%rbp)
  mov    -0x20(%rbp),%eax
  add    %eax,-0x28(%rbp)
L99:
  mov    -0x28(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jne    L117
  movl   $0x0,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x30(%rbp)
  addl   $0x1,-0x34(%rbp)
  addq   $0x1,-0x18(%rbp)
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x10(%rbp),%rax
  mov    %dl,(%rax)
  jmp    L32
L92:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2d,%al
  jne    L89
  mov    -0x10(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  movl   $0x0,-0x30(%rbp)
  addl   $0x1,-0x2c(%rbp)
  addq   $0x1,-0x18(%rbp)
  jmp    L32
L89:
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x18(%rbp),%rdx
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
  mov    -0x30(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x30(%rbp)
  addl   $0x1,-0x2c(%rbp)
  addq   $0x1,-0x18(%rbp)
L32:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L23
  mov    -0x2c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x30(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %eax,-0x28(%rbp)
  mov    -0x1c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jl     L126
  mov    $0x1,%eax
  jmp    L158
L126:
  mov    $0xffffffff,%eax
L158:
  mov    %eax,-0x20(%rbp)
  jmp    L136
L36:
  addl   $0x1,-0x34(%rbp)
  mov    -0x20(%rbp),%eax
  add    %eax,-0x28(%rbp)
L136:
  mov    -0x28(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jne    L36
  addl   $0x1,-0x34(%rbp)
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x34(%rbp),%eax
L3:
  leave
  ret
```

assistant: ```c
int pq_nkrange(char *text) {
  int a, i, j, c;
  int strsize;
  int cval, pval;
  char *tmp, *curr, *prev;
  if (*text == '\0') {
    return 0;
  }
  strsize = strlen(text);
  curr = calloc(strsize + 1, sizeof *curr);
  prev = calloc(strsize + 1, sizeof *prev);
  tmp = text;
  prev[0] = '\0';
  a = c = i = j = 0;
  while (*tmp) {
    if (*tmp == ',') {
      curr[i] = prev[j] = '\0';
      cval = atoi(curr);
      pval = atoi(prev);
      c = cval >= pval ? 1 : -1;
      while (pval != cval) {
        a++;
        pval = pval + c;
      }
      i = j = 0;
      a++;
      tmp++;
      curr[0] = prev[0] = '\0';
    } else if (*tmp == '-') {
      prev[j] = curr[0] = '\0';
      i = 0;
      j++;
      tmp++;
    } else {
      curr[i] = prev[j] = *tmp;
      i++;
      j++;
      tmp++;
    }
  }
  curr[i] = prev[j] = '\0';
  cval = atoi(curr);
  pval = atoi(prev);
  c = cval >= pval ? 1 : -1;
  while (pval != cval) {
    a++;
    pval = pval + c;
  }
  a++;
  free(curr);
  free(prev);
  return a;
}
```