user: Converte this assembly snippet into its equivalent C code:

```asm
<c2i_ASN1_INTEGER>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  movq   $0x0,-0x28(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  je     L38
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L22
L38:
  mov    $0x0,%eax
  call   <ASN1_INTEGER_new@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L115
  mov    $0x0,%eax
  jmp    L85
L22:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x28(%rbp)
L115:
  mov    -0x40(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x48(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x48(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L175
  mov    D1(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x2c(%rbp)
  nop
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <ASN1error@plt>
  cmpq   $0x0,-0x38(%rbp)
  je     L95
  jmp    L28
L175:
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x48(%rbp)
  jne    L8
  mov    D29(%rip),%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,0x10(%rax)
  jmp    L167
L8:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jns    L34
  mov    D12(%rip),%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,0x10(%rax)
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0xff,%al
  jne    L235
  cmpq   $0x1,-0x48(%rbp)
  je     L235
  addq   $0x1,-0x20(%rbp)
  subq   $0x1,-0x48(%rbp)
L235:
  mov    -0x48(%rbp),%rax
  mov    %eax,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  sub    $0x1,%rax
  add    %rax,-0x20(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  sub    $0x1,%rax
  add    %rax,-0x18(%rbp)
  jmp    L249
L177:
  mov    -0x18(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movb   $0x0,(%rax)
  subl   $0x1,-0x2c(%rbp)
  subq   $0x1,-0x20(%rbp)
L249:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L66
  cmpl   $0x0,-0x2c(%rbp)
  jne    L177
L66:
  cmpl   $0x0,-0x2c(%rbp)
  jne    L214
  mov    -0x8(%rbp),%rax
  movb   $0x1,(%rax)
  mov    -0x48(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  addq   $0x1,-0x48(%rbp)
  jmp    L167
L214:
  mov    -0x20(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movzbl (%rax),%ecx
  mov    -0x18(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  neg    %ecx
  mov    %ecx,%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x2c(%rbp)
  jmp    L185
L81:
  mov    -0x20(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movzbl (%rax),%ecx
  mov    -0x18(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  not    %ecx
  mov    %ecx,%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x2c(%rbp)
L185:
  cmpl   $0x0,-0x2c(%rbp)
  jg     L81
  jmp    L167
L34:
  mov    D29(%rip),%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,0x10(%rax)
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L23
  cmpq   $0x1,-0x48(%rbp)
  je     L23
  addq   $0x1,-0x20(%rbp)
  subq   $0x1,-0x48(%rbp)
L23:
  mov    -0x48(%rbp),%rdx
  mov    -0x20(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
L167:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x28(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x48(%rbp),%rax
  mov    %eax,%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,0x8(%rax)
  cmpq   $0x0,-0x38(%rbp)
  je     L113
  mov    -0x38(%rbp),%rax
  mov    -0x28(%rbp),%rdx
  mov    %rdx,(%rax)
L113:
  mov    -0x40(%rbp),%rax
  mov    -0x10(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x28(%rbp),%rax
  jmp    L85
L28:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x28(%rbp)
  je     L193
L95:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <ASN1_INTEGER_free@plt>
L193:
  mov    $0x0,%eax
L85:
  leave
  ret
```

assistant: ```c
ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a, const unsigned char **pp, long len) {
  ASN1_INTEGER *ret = NULL;
  const unsigned char *p, *pend;
  unsigned char *to, *s;
  int i;
  if ((a == NULL) || ((*a) == NULL)) {
    if ((ret = ASN1_INTEGER_new()) == NULL)
      return (NULL);
  } else
    ret = (*a);
  p = *pp;
  pend = p + len;
  s = malloc(len + 1);
  if (s == NULL) {
    i = ERR_R_MALLOC_FAILURE;
    goto err;
  }
  to = s;
  if (!len) {
    ret->type = V_ASN1_INTEGER;
  } else if (*p & 0x80) {
    ret->type = V_ASN1_NEG_INTEGER;
    if ((*p == 0xff) && (len != 1)) {
      p++;
      len--;
    }
    i = len;
    p += i - 1;
    to += i - 1;
    while ((!*p) && i) {
      *(to--) = 0;
      i--;
      p--;
    }
    if (!i) {
      *s = 1;
      s[len] = 0;
      len++;
    } else {
      *(to--) = (*(p--) ^ 0xff) + 1;
      i--;
      for (; i > 0; i--)
        *(to--) = *(p--) ^ 0xff;
    }
  } else {
    ret->type = V_ASN1_INTEGER;
    if ((*p == 0) && (len != 1)) {
      p++;
      len--;
    }
    memcpy(s, p, len);
  }
  free(ret->data);
  ret->data = s;
  ret->length = (int)len;
  if (a != NULL)
    (*a) = ret;
  *pp = pend;
  return (ret);
err:
  ASN1error(i);
  if (a == NULL || *a != ret)
    ASN1_INTEGER_free(ret);
  return (NULL);
}
```