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

```asm
<str_of_bn>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsi)
  movq   $0x0,0x8(%rsp)
  movq   $0x0,0x10(%rsp)
  call   <BN_is_zero@plt>
  test   %rax,%rax
  je     L69
  mov    $0x4,%edi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  test   %rax,%rax
  je     L11
  lea    0x8(%rsp),%rdi
  xor    %esi,%esi
  mov    %rax,0x8(%rsp)
  call   <write_u32@plt>
  movq   $0x4,(%r12)
  mov    $0x1,%eax
  jmp    L135
  xchg   %ax,%ax
L69:
  mov    %rbp,%rdi
  call   <BN_is_negative@plt>
  test   %rax,%rax
  je     L67
L11:
  xor    %eax,%eax
L135:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L101
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L67:
  mov    %rbp,%rdi
  call   <BN_num_bytes@plt>
  lea    0x5(%rax),%r13d
  movslq %r13d,%r13
  cmp    $0x5,%r13
  jbe    L11
  mov    %r13,%rdi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  test   %rax,%rax
  je     L11
  lea    -0x4(%r13),%rsi
  lea    0x8(%rsp),%rdi
  mov    %rax,0x8(%rsp)
  call   <write_u32@plt>
  mov    0x8(%rsp),%rax
  mov    %rbp,%rdi
  movb   $0x0,(%rax)
  mov    0x8(%rsp),%rax
  lea    0x1(%rax),%rsi
  call   <BN_bn2bin@plt>
  test   %eax,%eax
  jle    L25
  lea    -0x5(%r13),%rdx
  movslq %eax,%r14
  cmp    %rdx,%r14
  jne    L25
  mov    0x8(%rsp),%rax
  cmpb   $0x0,0x1(%rax)
  js     L97
  lea    -0x1(%r13),%rbp
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  test   %rax,%rax
  je     L108
  lea    0x10(%rsp),%rdi
  mov    %r14,%rsi
  mov    %rax,0x10(%rsp)
  call   <write_u32@plt>
  mov    (%rbx),%rax
  mov    0x10(%rsp),%rdi
  mov    %r14,%rdx
  lea    0x5(%rax),%rsi
  call   <memcpy@plt>
  mov    (%rbx),%rdi
  mov    %r13,%rsi
  call   <_explicit_bzero@plt>
  mov    (%rbx),%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rax
  mov    %rax,(%rbx)
  mov    $0x1,%eax
  mov    %rbp,(%r12)
  jmp    L135
  nopl   0x0(%rax)
L25:
  mov    (%rbx),%rdi
  call   <free@plt>
  movq   $0x0,(%rbx)
  jmp    L11
  nopl   0x0(%rax)
L97:
  mov    %r13,(%r12)
  mov    $0x1,%eax
  jmp    L135
L108:
  mov    (%rbx),%rdi
  mov    %r13,%rsi
  call   <_explicit_bzero@plt>
  mov    (%rbx),%rdi
  call   <free@plt>
  movq   $0x0,(%rbx)
  xor    %eax,%eax
  jmp    L135
L101:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int str_of_bn(const BIGNUM *bn, char **dst, size_t *dst_len) {
  int wtn = 0;
  char *ptr = NULL, *ptr2 = NULL;
  size_t len = 0;
  *dst = NULL;
  if (BN_is_zero(bn)) {
    ;
    *dst = (char *)malloc(4);
    if (!*dst)
      return 0;
    ptr = *dst;
    write_u32(&ptr, 0u);
    *dst_len = 4;
    return 1;
  };
  if (BN_is_negative(bn)) {
    ;
    return 0;
  }
  len = 4 + BN_num_bytes(bn) + 1;
  ;
  if (len < 6)
    return 0;
  *dst = (char *)malloc(len);
  if (!*dst) {
    ;
    return 0;
  }
  ptr = *dst;
  write_u32(&ptr, len - 4);
  ptr[0] = 0;
  wtn = BN_bn2bin(bn, (unsigned char *)ptr + 1);
  ;
  if (wtn <= 0 || (size_t)wtn != len - 5) {
    ;
    free(*dst);
    *dst = NULL;
    return 0;
  }
  if ((unsigned char)(ptr[1]) & 0x80) {
    ;
    *dst_len = len;
    return 1;
  };
  ptr = (char *)malloc(len - 1);
  if (!ptr) {
    ;
    _explicit_bzero(*dst, len);
    free(*dst);
    *dst = NULL;
    return 0;
  }
  ptr2 = ptr;
  write_u32(&ptr2, len - 5);
  memcpy(ptr2, *dst + 5, len - 5);
  ;
  _explicit_bzero(*dst, len);
  free(*dst);
  *dst = ptr;
  *dst_len = len - 1;
  return 1;
}
```