user: Please show me the C implementation that matches the assembly code listed below:

```asm
<handle_ccn_signature>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x70,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %rdx,-0x68(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x44(%rbp)
  movq   $0x0,-0x30(%rbp)
  movq   $0x0,-0x28(%rbp)
  jmp    L44
L173:
  mov    -0x50(%rbp),%eax
  test   %eax,%eax
  jne    L20
  mov    -0x4c(%rbp),%eax
  test   %eax,%eax
  je     L147
L20:
  mov    -0x4c(%rbp),%eax
  cmp    $0x2,%eax
  jne    L182
  mov    -0x50(%rbp),%eax
  cmp    $0xe,%eax
  jne    L182
  mov    -0x50(%rbp),%esi
  mov    -0x4c(%rbp),%eax
  lea    -0x48(%rbp),%r8
  lea    -0x38(%rbp),%rdi
  mov    -0x60(%rbp),%rcx
  mov    -0x58(%rbp),%rdx
  mov    %r8,%r9
  mov    %rdi,%r8
  mov    %eax,%edi
  call   <ccnl_ccnb_consume@plt>
  test   %rax,%rax
  js     L80
  mov    -0x48(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L225
  mov    -0x48(%rbp),%edx
  mov    -0x38(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x48(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  jmp    L44
L182:
  mov    -0x60(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x40(%rbp)
  mov    -0x4c(%rbp),%eax
  cmp    $0x2,%eax
  jne    L239
  mov    -0x50(%rbp),%eax
  cmp    $0x36,%eax
  jne    L239
  mov    -0x50(%rbp),%esi
  mov    -0x4c(%rbp),%eax
  lea    -0x48(%rbp),%r8
  lea    -0x38(%rbp),%rdi
  mov    -0x60(%rbp),%rcx
  mov    -0x58(%rbp),%rdx
  mov    %r8,%r9
  mov    %rdi,%r8
  mov    %eax,%edi
  call   <ccnl_ccnb_consume@plt>
  test   %rax,%rax
  js     L228
  mov    -0x48(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L40
  mov    -0x48(%rbp),%edx
  mov    -0x38(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x48(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x28(%rbp)
  jmp    L44
L239:
  mov    -0x50(%rbp),%esi
  mov    -0x4c(%rbp),%eax
  mov    -0x60(%rbp),%rcx
  mov    -0x58(%rbp),%rdx
  mov    $0x0,%r9d
  mov    $0x0,%r8d
  mov    %eax,%edi
  call   <ccnl_ccnb_consume@plt>
  test   %rax,%rax
  js     L217
L44:
  lea    -0x4c(%rbp),%rcx
  lea    -0x50(%rbp),%rdx
  mov    -0x60(%rbp),%rsi
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <ccnl_ccnb_dehead@plt>
  test   %rax,%rax
  je     L173
  jmp    L208
L147:
  nop
L208:
  mov    -0x60(%rbp),%rax
  mov    (%rax),%eax
  add    $0x4,%eax
  sub    %eax,-0x40(%rbp)
  mov    -0x58(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x60(%rbp),%rax
  mov    (%rax),%eax
  sub    $0x1,%eax
  mov    %eax,-0x3c(%rbp)
  cmpq   $0x0,-0x68(%rbp)
  je     L235
  mov    -0x40(%rbp),%edi
  mov    -0x28(%rbp),%rcx
  mov    -0x3c(%rbp),%edx
  mov    -0x10(%rbp),%rsi
  mov    -0x68(%rbp),%rax
  mov    %edi,%r8d
  mov    %rax,%rdi
  call   <verify@plt>
  mov    %eax,-0x44(%rbp)
  jmp    L145
L80:
  nop
  jmp    L145
L225:
  nop
  jmp    L145
L228:
  nop
  jmp    L145
L40:
  nop
  jmp    L145
L217:
  nop
  jmp    L145
L235:
  nop
L145:
  mov    -0x44(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L79
  call   <__stack_chk_fail@plt>
L79:
  leave
  ret
```

assistant: ```c
int handle_ccn_signature(unsigned char **buf, int *buflen, char *relay_public_key) {
  int num, typ, verified = 0, siglen;
  unsigned char *sigtype = 0, *sig = 0;
  while (ccnl_ccnb_dehead(buf, buflen, &num, &typ) == 0) {
    if (num == 0 && typ == 0)
      break;
    if (typ == 2 && num == 14) {
      char *s;
      unsigned char *valptr;
      int vallen;
      if (ccnl_ccnb_consume(typ, num, buf, buflen, &valptr, &vallen) < 0)
        goto Bail;
      s = malloc(vallen + 1);
      if (!s)
        goto Bail;
      memcpy(s, valptr, vallen);
      s[vallen] = '\0';
      free(sigtype);
      sigtype = (unsigned char *)s;
      continue;
    }
    do {
    } while (0);
    siglen = *buflen;
    if (typ == 2 && num == 54) {
      char *s;
      unsigned char *valptr;
      int vallen;
      if (ccnl_ccnb_consume(typ, num, buf, buflen, &valptr, &vallen) < 0)
        goto Bail;
      s = malloc(vallen + 1);
      if (!s)
        goto Bail;
      memcpy(s, valptr, vallen);
      s[vallen] = '\0';
      free(sig);
      sig = (unsigned char *)s;
      continue;
    }
    do {
    } while (0);
    if (ccnl_ccnb_consume(typ, num, buf, buflen, 0, 0) < 0)
      goto Bail;
  }
  siglen = siglen - ((*buflen) + 4);
  unsigned char *buf2 = *buf;
  int buflen2 = *buflen - 1;
  if (relay_public_key) {
    verified = verify(relay_public_key, buf2, buflen2, (unsigned char *)sig, siglen);
  }
Bail:
  return verified;
}
```