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

```asm
<ECDH_KDF_X9_62>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    0x10(%rbp),%rax
  mov    %rdx,-0x50(%rbp)
  mov    %r8,-0x58(%rbp)
  mov    %r9,-0x60(%rbp)
  mov    %rax,-0x78(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  cmp    $0x40000000,%rsi
  seta   %al
  cmp    $0x40000000,%rcx
  seta   %dl
  or     %dl,%al
  jne    L15
  cmp    $0x40000000,%r9
  jbe    L109
L15:
  xor    %r12d,%r12d
L62:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L19
  lea    -0x28(%rbp),%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax)
L109:
  xor    %eax,%eax
  mov    %rdi,%r13
  mov    %rsi,%r12
  mov    %rcx,%rbx
  call   <EVP_MD_CTX_new@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L15
  mov    -0x78(%rbp),%rdi
  call   <EVP_MD_size@plt>
  lea    -0x3c(%rbp),%rsi
  movl   $0x1,-0x44(%rbp)
  mov    %rax,-0x80(%rbp)
  mov    %rsi,-0x70(%rbp)
  mov    %rbx,-0x68(%rbp)
  mov    %rax,%rbx
  nopl   0x0(%rax,%rax,1)
L124:
  mov    D8(%rip),%rax
  mov    %rsp,%rcx
  mov    %rsp,%r15
  movslq (%rax),%rax
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L178
L22:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L22
L178:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L177
  orq    $0x0,-0x8(%rsp,%rdx,1)
L177:
  mov    -0x78(%rbp),%rsi
  xor    %edx,%edx
  mov    %r14,%rdi
  call   <EVP_DigestInit_ex@plt>
  test   %eax,%eax
  je     L5
  mov    -0x44(%rbp),%eax
  mov    -0x68(%rbp),%rdx
  mov    %r14,%rdi
  mov    -0x50(%rbp),%rsi
  bswap  %eax
  mov    %eax,-0x3c(%rbp)
  call   <EVP_DigestUpdate@plt>
  test   %eax,%eax
  je     L5
  mov    -0x70(%rbp),%rsi
  mov    $0x4,%edx
  mov    %r14,%rdi
  call   <EVP_DigestUpdate@plt>
  test   %eax,%eax
  je     L5
  mov    -0x60(%rbp),%rdx
  mov    -0x58(%rbp),%rsi
  mov    %r14,%rdi
  call   <EVP_DigestUpdate@plt>
  test   %eax,%eax
  je     L5
  xor    %edx,%edx
  cmp    %rbx,%r12
  jb     L142
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <EVP_DigestFinal@plt>
  test   %eax,%eax
  je     L5
  sub    %rbx,%r12
  je     L8
  add    %rbx,%r13
  mov    %r15,%rsp
  addl   $0x1,-0x44(%rbp)
  jmp    L124
  nopl   0x0(%rax,%rax,1)
L5:
  xor    %r12d,%r12d
  mov    %r15,%rsp
L139:
  mov    %r14,%rdi
  call   <EVP_MD_CTX_free@plt>
  jmp    L62
  nopl   0x0(%rax,%rax,1)
L142:
  mov    %rsp,%rsi
  mov    %r14,%rdi
  call   <EVP_DigestFinal@plt>
  test   %eax,%eax
  je     L5
  mov    %rsp,%rsi
  mov    %r13,%rdi
  mov    %r12,%rdx
  call   <memcpy@plt>
  mov    -0x80(%rbp),%rsi
  mov    %rsp,%rdi
  call   <OPENSSL_cleanse@plt>
L8:
  mov    $0x1,%r12d
  mov    %r15,%rsp
  jmp    L139
L19:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, const unsigned char *Z, size_t Zlen, const unsigned char *sinfo, size_t sinfolen, const EVP_MD *md) {
  EVP_MD_CTX *mctx = NULL;
  int rv = 0;
  unsigned int i;
  size_t mdlen;
  unsigned char ctr[4];
  if (sinfolen > (1 << 30) || outlen > (1 << 30) || Zlen > (1 << 30))
    return 0;
  mctx = EVP_MD_CTX_new();
  if (mctx == NULL)
    return 0;
  mdlen = EVP_MD_size(md);
  for (i = 1;; i++) {
    unsigned char mtmp[EVP_MAX_MD_SIZE];
    if (!EVP_DigestInit_ex(mctx, md, NULL))
      goto err;
    ctr[3] = i & 0xFF;
    ctr[2] = (i >> 8) & 0xFF;
    ctr[1] = (i >> 16) & 0xFF;
    ctr[0] = (i >> 24) & 0xFF;
    if (!EVP_DigestUpdate(mctx, Z, Zlen))
      goto err;
    if (!EVP_DigestUpdate(mctx, ctr, sizeof(ctr)))
      goto err;
    if (!EVP_DigestUpdate(mctx, sinfo, sinfolen))
      goto err;
    if (outlen >= mdlen) {
      if (!EVP_DigestFinal(mctx, out, NULL))
        goto err;
      outlen -= mdlen;
      if (outlen == 0)
        break;
      out += mdlen;
    } else {
      if (!EVP_DigestFinal(mctx, mtmp, NULL))
        goto err;
      memcpy(out, mtmp, outlen);
      OPENSSL_cleanse(mtmp, mdlen);
      break;
    }
  }
  rv = 1;
err:
  EVP_MD_CTX_free(mctx);
  return rv;
}
```