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

```asm
<c2i_ASN1_INTEGER>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r13
  mov    %rsi,%r15
  mov    %rdx,%r12
  test   %rdi,%rdi
  je     L190
  mov    (%rdi),%rbp
  test   %rbp,%rbp
  je     L190
  mov    (%rsi),%rbx
  lea    (%rbx,%rdx,1),%rax
  mov    %rax,0x8(%rsp)
  lea    0x1(%rdx),%rdi
  call   <malloc@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L148
L207:
  test   %r12,%r12
  jne    L201
  mov    D63(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,0x10(%rbp)
L49:
  mov    0x0(%rbp),%rdi
  call   <free@plt>
  mov    %r14,0x0(%rbp)
  mov    %r12d,0x8(%rbp)
  test   %r13,%r13
  je     L210
  mov    %rbp,0x0(%r13)
L210:
  mov    0x8(%rsp),%rax
  mov    %rax,(%r15)
L3:
  mov    %rbp,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L190:
  mov    $0x0,%eax
  call   <M_ASN1_INTEGER_new@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L3
  mov    D63(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,0x10(%rbp)
  mov    (%r15),%rbx
  lea    (%rbx,%r12,1),%rax
  mov    %rax,0x8(%rsp)
  lea    0x1(%r12),%rdi
  call   <malloc@plt>
  mov    %rax,%r14
  test   %rax,%rax
  jne    L207
  mov    D66(%rip),%rax
  mov    (%rax),%esi
  mov    D58(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
  test   %r13,%r13
  je     L15
  jmp    L252
L201:
  cmpb   $0x0,(%rbx)
  js     L284
  mov    D63(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,0x10(%rbp)
  cmpb   $0x0,(%rbx)
  jne    L61
  cmp    $0x1,%r12
  jne    L151
L61:
  mov    %r12,%rdx
  mov    %rbx,%rsi
  mov    %r14,%rdi
  call   <memcpy@plt>
  jmp    L49
L284:
  mov    D33(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,0x10(%rbp)
  cmpb   $0xff,(%rbx)
  jne    L276
  cmp    $0x1,%r12
  jne    L16
L276:
  mov    %r12d,%edx
  movslq %r12d,%rax
  sub    $0x1,%rax
  add    %rax,%rbx
  add    %r14,%rax
  movzbl (%rbx),%ecx
  test   %r12d,%r12d
  je     L235
  test   %cl,%cl
  jne    L235
L157:
  sub    $0x1,%rax
  movb   $0x0,0x1(%rax)
  sub    $0x1,%rbx
  movzbl (%rbx),%ecx
  sub    $0x1,%edx
  je     L235
  test   %cl,%cl
  je     L157
L235:
  test   %edx,%edx
  jne    L183
  movb   $0x1,(%r14)
  movb   $0x0,(%r14,%r12,1)
  add    $0x1,%r12
  jmp    L49
L16:
  add    $0x1,%rbx
  sub    $0x1,%r12
  jmp    L276
L183:
  neg    %ecx
  mov    %cl,(%rax)
  cmp    $0x1,%edx
  jle    L49
  lea    -0x2(%rdx),%edx
  mov    $0xfffffffffffffffe,%rsi
  sub    %rdx,%rsi
  mov    $0xffffffffffffffff,%rdx
L261:
  movzbl (%rbx,%rdx,1),%ecx
  not    %ecx
  mov    %cl,(%rax,%rdx,1)
  sub    $0x1,%rdx
  cmp    %rdx,%rsi
  jne    L261
  jmp    L49
L151:
  add    $0x1,%rbx
  sub    $0x1,%r12
  jmp    L61
L164:
  mov    $0x0,%ebp
  jmp    L3
L148:
  mov    D66(%rip),%rax
  mov    (%rax),%esi
  mov    D58(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1err@plt>
L252:
  cmp    %rbp,0x0(%r13)
  je     L164
L15:
  mov    %rbp,%rdi
  call   <M_ASN1_INTEGER_free@plt>
  mov    $0x0,%ebp
  jmp    L3
```

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 = M_ASN1_INTEGER_new()) == NULL)
      return (NULL);
    ret->type = V_ASN1_INTEGER;
  } 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:
  ASN1err(ASN1_F_C2I_ASN1_INTEGER, i);
  if ((ret != NULL) && ((a == NULL) || (*a != ret)))
    M_ASN1_INTEGER_free(ret);
  return (NULL);
}
```