user: 请将以下的汇编代码转换成C语言代码:

```asm
<dh_get_secret>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,%eax
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8,-0x48(%rbp)
  mov    %r9,-0x50(%rbp)
  mov    %ax,-0x2c(%rbp)
  movq   $0x0,-0x8(%rbp)
  movq   $0x0,-0x18(%rbp)
  movq   $0x0,-0x10(%rbp)
  mov    -0x48(%rbp),%rax
  movq   $0x0,(%rax)
  movswl -0x2c(%rbp),%ecx
  mov    -0x28(%rbp),%rax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <BN_bin2bn@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L102
  movl   $0x5,-0x20(%rbp)
  jmp    L14
L102:
  mov    $0x0,%eax
  call   <BN_new@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L87
  movl   $0x5,-0x20(%rbp)
  jmp    L14
L87:
  mov    $0x0,%eax
  call   <BN_CTX_new@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L42
  movl   $0x5,-0x20(%rbp)
  jmp    L14
L42:
  mov    -0x10(%rbp),%rdi
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  mov    -0x8(%rbp),%rsi
  mov    -0x18(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <BN_mod_exp@plt>
  test   %eax,%eax
  jne    L15
  movl   $0x5,-0x20(%rbp)
  jmp    L14
L15:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_num_bytes@plt>
  mov    -0x50(%rbp),%rdx
  mov    %eax,(%rdx)
  mov    -0x50(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L97
  movl   $0x5,-0x20(%rbp)
  jmp    L14
L97:
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <BN_bn2bin@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x50(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x1c(%rbp)
  je     L69
  movl   $0x5,-0x20(%rbp)
  jmp    L14
L69:
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_free@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_free@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_CTX_free@plt>
  mov    $0x0,%eax
  jmp    L112
L14:
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L147
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <free@plt>
L147:
  cmpq   $0x0,-0x8(%rbp)
  je     L98
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_free@plt>
L98:
  cmpq   $0x0,-0x18(%rbp)
  je     L139
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_free@plt>
L139:
  cmpq   $0x0,-0x10(%rbp)
  je     L168
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_CTX_free@plt>
L168:
  mov    -0x48(%rbp),%rax
  movq   $0x0,(%rax)
  mov    -0x20(%rbp),%eax
L112:
  leave
  ret
```

assistant: ```c
int dh_get_secret(const unsigned char *public, short public_len, BIGNUM *bn_private, BIGNUM *bn_prime, unsigned char **psecret_key, int *psecret_key_len) {
  int err, len;
  BIGNUM *bn_public = NULL;
  BIGNUM *bn_secret = NULL;
  BN_CTX *ctx = NULL;
  *psecret_key = NULL;
  bn_public = BN_bin2bn(public, public_len, NULL);
  if (!bn_public) {
    err = 5;
    goto ret_err;
  }
  bn_secret = BN_new();
  if (!bn_secret) {
    err = 5;
    goto ret_err;
  }
  ctx = BN_CTX_new();
  if (!ctx) {
    err = 5;
    goto ret_err;
  }
  if (!BN_mod_exp(bn_secret, bn_public, bn_private, bn_prime, ctx)) {
    err = 5;
    goto ret_err;
  }
  *psecret_key_len = BN_num_bytes(bn_secret);
  *psecret_key = (unsigned char *)malloc(*psecret_key_len);
  if (!*psecret_key) {
    err = 5;
    goto ret_err;
  }
  len = BN_bn2bin(bn_secret, *psecret_key);
  if (len != *psecret_key_len) {
    err = 5;
    goto ret_err;
  }
  BN_free(bn_public);
  BN_free(bn_secret);
  BN_CTX_free(ctx);
  return 0;
ret_err:;
  if (*psecret_key)
    free(*psecret_key);
  if (bn_public)
    BN_free(bn_public);
  if (bn_secret)
    BN_free(bn_secret);
  if (ctx)
    BN_CTX_free(ctx);
  *psecret_key = NULL;
  return err;
}
```