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

```asm
<cgi_parse_string>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r12
  test   %rdi,%rdi
  je     L34
  mov    $0x1,%ebx
  jmp    L28
L37:
  add    $0x1,%ebx
  lea    0x1(%rax),%rdi
L28:
  mov    $0x26,%esi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L37
  lea    0x1(%rbx,%rbx,1),%edi
  mov    $0x8,%esi
  call   <calloc@plt>
  mov    %rax,(%rsp)
  mov    $0x0,%r14d
  movabs $0x2000004000000001,%r13
  jmp    L72
L41:
  mov    %r12,%rbx
L102:
  mov    $0x1,%edx
  sub    %r12d,%edx
L123:
  lea    (%rdx,%rbx,1),%ebp
  add    $0x1,%rbx
  movzbl (%rbx),%eax
  cmp    $0x3d,%al
  ja     L123
  bt     %rax,%r13
  jae    L123
L146:
  movslq %r14d,%rax
  shl    $0x3,%rax
  mov    %rax,0x8(%rsp)
  mov    (%rsp),%r15
  add    %rax,%r15
  mov    %ebp,%esi
  mov    %r12,%rdi
  call   <hex_to_asc@plt>
  mov    %rax,(%r15)
  cmpb   $0x26,(%rbx)
  je     L92
  movslq %ebp,%rbp
  lea    0x1(%r12,%rbp,1),%rbp
  movzbl 0x0(%rbp),%eax
  cmp    $0x26,%al
  je     L68
  test   %al,%al
  je     L68
  mov    %rbp,%rax
  mov    $0x1,%ecx
  sub    %ebp,%ecx
L106:
  lea    (%rcx,%rax,1),%ebx
  add    $0x1,%rax
  movzbl (%rax),%edx
  cmp    $0x26,%dl
  je     L9
  test   %dl,%dl
  jne    L106
L9:
  mov    (%rsp),%rax
  mov    0x8(%rsp),%rsi
  lea    0x8(%rax,%rsi,1),%r12
  mov    %ebx,%esi
  mov    %rbp,%rdi
  call   <hex_to_asc@plt>
  mov    %rax,(%r12)
  test   %ebx,%ebx
  setg   %al
  movzbl %al,%eax
  add    %rax,%rbp
L11:
  add    $0x2,%r14d
L135:
  mov    $0x26,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L71
L72:
  cmpb   $0x26,(%r12)
  sete   %al
  movzbl %al,%eax
  add    %rax,%r12
  movzbl (%r12),%eax
  cmp    $0x3d,%al
  ja     L41
  mov    %r12,%rbx
  bt     %rax,%r13
  jae    L102
  mov    $0x0,%ebp
  jmp    L146
L92:
  movslq %ebp,%rbp
  add    %r12,%rbp
  add    $0x1,%r14d
  jmp    L135
L34:
  mov    %rdi,(%rsp)
L71:
  mov    (%rsp),%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L68:
  mov    (%rsp),%rax
  mov    0x8(%rsp),%rsi
  lea    0x8(%rax,%rsi,1),%rbx
  mov    $0x0,%esi
  mov    %rbp,%rdi
  call   <hex_to_asc@plt>
  mov    %rax,(%rbx)
  jmp    L11
```

assistant: ```c
char **cgi_parse_string(const char *str) {
  char **kv = NULL;
  const char *p, *end;
  int num = 1, i;
  int len;
  if (!str)
    return (NULL);
  p = str;
  while ((p = strchr(p, '&')) != NULL) {
    num++;
    p++;
  }
  kv = (char **)calloc((num * 2 + 1), sizeof(char **));
  p = str;
  i = 0;
  do {
    len = 0;
    if (*p == '&') {
      p++;
    }
    end = p;
    while ((*end != '=') && (*end != '\0') && (*end != '&')) {
      len++;
      end++;
    }
    kv[i] = hex_to_asc(p, len);
    if (*end == '&') {
      p += len;
      i++;
      continue;
    }
    p += len + 1;
    end = p;
    i++;
    len = 0;
    while ((*end != '&') && (*end != '\0')) {
      len++;
      end++;
    }
    kv[i] = hex_to_asc(p, len);
    if (len > 0)
      p++;
    i++;
  } while ((p = strchr(p, '&')) != NULL);
  return (kv);
}
```