user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<EVP_BytesToKey>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    0x10(%rbp),%rax
  mov    %rdx,-0x50(%rbp)
  mov    %rcx,-0x58(%rbp)
  mov    %rsp,%rcx
  mov    %rax,-0x78(%rbp)
  mov    0x18(%rbp),%rax
  mov    %rdi,-0x70(%rbp)
  mov    %r8d,-0x5c(%rbp)
  mov    %r9d,-0x44(%rbp)
  mov    %rax,-0x80(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    D32(%rip),%rax
  movslq (%rax),%rax
  mov    %eax,-0x60(%rbp)
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L327
L200:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L200
L327:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L180
L246:
  mov    -0x70(%rbp),%r15
  movl   $0x0,-0x3c(%rbp)
  mov    %rsp,%r12
  mov    %r15,%rdi
  call   <EVP_CIPHER_key_length@plt>
  mov    %r15,%rdi
  mov    %eax,%ebx
  mov    %eax,-0x48(%rbp)
  call   <EVP_CIPHER_iv_length@plt>
  xor    %edi,%edi
  mov    %eax,-0x68(%rbp)
  mov    %eax,%r15d
  mov    D31(%rip),%rax
  cmp    %ebx,(%rax)
  setge  %dil
  call   <OPENSSL_assert@plt>
  mov    D8(%rip),%rax
  xor    %edi,%edi
  cmp    %r15d,(%rax)
  setge  %dil
  call   <OPENSSL_assert@plt>
  cmpq   $0x0,-0x58(%rbp)
  je     L138
  xor    %eax,%eax
  lea    -0x3c(%rbp),%r15
  call   <EVP_MD_CTX_new@plt>
  movl   $0x0,-0x64(%rbp)
  mov    %rax,%r14
  test   %rax,%rax
  je     L206
L1:
  xor    %edx,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <EVP_DigestInit_ex@plt>
  test   %eax,%eax
  je     L206
  mov    -0x64(%rbp),%edi
  test   %edi,%edi
  je     L330
  mov    -0x3c(%rbp),%edx
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <EVP_DigestUpdate@plt>
  test   %eax,%eax
  je     L206
L330:
  mov    -0x5c(%rbp),%edx
  mov    -0x58(%rbp),%rsi
  mov    %r14,%rdi
  call   <EVP_DigestUpdate@plt>
  test   %eax,%eax
  je     L206
  cmpq   $0x0,-0x50(%rbp)
  je     L62
  mov    D38(%rip),%rax
  mov    -0x50(%rbp),%rsi
  mov    %r14,%rdi
  mov    (%rax),%edx
  call   <EVP_DigestUpdate@plt>
  test   %eax,%eax
  je     L206
L62:
  mov    %r15,%rdx
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <EVP_DigestFinal_ex@plt>
  test   %eax,%eax
  je     L206
  cmpl   $0x1,-0x44(%rbp)
  mov    $0x1,%ebx
  ja     L356
  jmp    L339
  nop
L16:
  mov    -0x3c(%rbp),%edx
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <EVP_DigestUpdate@plt>
  test   %eax,%eax
  je     L206
  mov    %r15,%rdx
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   <EVP_DigestFinal_ex@plt>
  test   %eax,%eax
  je     L206
  add    $0x1,%ebx
  cmp    -0x44(%rbp),%ebx
  je     L339
L356:
  xor    %edx,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <EVP_DigestInit_ex@plt>
  test   %eax,%eax
  jne    L16
L206:
  movl   $0x0,-0x48(%rbp)
L97:
  mov    %r14,%rdi
  call   <EVP_MD_CTX_free@plt>
  mov    -0x60(%rbp),%esi
  mov    %r12,%rdi
  call   <OPENSSL_cleanse@plt>
L138:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L42
  mov    -0x48(%rbp),%eax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax)
L180:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L246
  nopl   0x0(%rax,%rax,1)
L339:
  mov    -0x48(%rbp),%esi
  xor    %edx,%edx
  test   %esi,%esi
  jne    L3
L92:
  mov    -0x68(%rbp),%eax
  test   %eax,%eax
  je     L373
  movl   $0x0,-0x48(%rbp)
L288:
  mov    -0x3c(%rbp),%eax
  cmp    %edx,%eax
  jne    L28
L326:
  addl   $0x1,-0x64(%rbp)
  jmp    L1
L3:
  mov    -0x48(%rbp),%r8d
  mov    -0x3c(%rbp),%edi
  xor    %eax,%eax
  mov    -0x78(%rbp),%rcx
  mov    %r8,%rsi
  nopl   0x0(%rax,%rax,1)
L256:
  mov    %esi,%r9d
  mov    %eax,%edx
  sub    %eax,%r9d
  cmp    %rdi,%rax
  je     L120
  test   %rcx,%rcx
  je     L316
  movzbl (%r12,%rax,1),%r9d
  add    $0x1,%rcx
  mov    %r9b,-0x1(%rcx)
L316:
  add    $0x1,%rax
  add    $0x1,%edx
  cmp    %r8,%rax
  jne    L256
  mov    %rcx,-0x78(%rbp)
  jmp    L92
L28:
  mov    -0x68(%rbp),%esi
  mov    -0x80(%rbp),%rcx
  jmp    L218
  nopw   0x0(%rax,%rax,1)
L245:
  cmp    %edx,%eax
  je     L33
L218:
  test   %rcx,%rcx
  je     L287
  mov    %edx,%edi
  add    $0x1,%rcx
  movzbl (%r12,%rdi,1),%edi
  mov    %dil,-0x1(%rcx)
L287:
  add    $0x1,%edx
  sub    $0x1,%esi
  jne    L245
  mov    %rcx,-0x80(%rbp)
L57:
  mov    -0x48(%rbp),%edx
  test   %edx,%edx
  je     L373
  movl   $0x0,-0x68(%rbp)
  jmp    L326
L120:
  mov    %rcx,-0x78(%rbp)
  mov    -0x68(%rbp),%ecx
  mov    %r9d,-0x48(%rbp)
  test   %ecx,%ecx
  je     L57
  jmp    L288
  nopl   0x0(%rax,%rax,1)
L33:
  mov    %esi,-0x68(%rbp)
  mov    %rcx,-0x80(%rbp)
  jmp    L326
L373:
  mov    -0x70(%rbp),%rdi
  call   <EVP_CIPHER_key_length@plt>
  mov    %eax,-0x48(%rbp)
  jmp    L97
L42:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, const unsigned char *salt, const unsigned char *data, int datal, int count, unsigned char *key, unsigned char *iv) {
  EVP_MD_CTX *c;
  unsigned char md_buf[EVP_MAX_MD_SIZE];
  int niv, nkey, addmd = 0;
  unsigned int mds = 0, i;
  int rv = 0;
  nkey = EVP_CIPHER_key_length(type);
  niv = EVP_CIPHER_iv_length(type);
  OPENSSL_assert(nkey <= EVP_MAX_KEY_LENGTH);
  OPENSSL_assert(niv <= EVP_MAX_IV_LENGTH);
  if (data == NULL)
    return nkey;
  c = EVP_MD_CTX_new();
  if (c == NULL)
    goto err;
  for (;;) {
    if (!EVP_DigestInit_ex(c, md, NULL))
      goto err;
    if (addmd++)
      if (!EVP_DigestUpdate(c, &(md_buf[0]), mds))
        goto err;
    if (!EVP_DigestUpdate(c, data, datal))
      goto err;
    if (salt != NULL)
      if (!EVP_DigestUpdate(c, salt, PKCS5_SALT_LEN))
        goto err;
    if (!EVP_DigestFinal_ex(c, &(md_buf[0]), &mds))
      goto err;
    for (i = 1; i < (unsigned int)count; i++) {
      if (!EVP_DigestInit_ex(c, md, NULL))
        goto err;
      if (!EVP_DigestUpdate(c, &(md_buf[0]), mds))
        goto err;
      if (!EVP_DigestFinal_ex(c, &(md_buf[0]), &mds))
        goto err;
    }
    i = 0;
    if (nkey) {
      for (;;) {
        if (nkey == 0)
          break;
        if (i == mds)
          break;
        if (key != NULL)
          *(key++) = md_buf[i];
        nkey--;
        i++;
      }
    }
    if (niv && (i != mds)) {
      for (;;) {
        if (niv == 0)
          break;
        if (i == mds)
          break;
        if (iv != NULL)
          *(iv++) = md_buf[i];
        niv--;
        i++;
      }
    }
    if ((nkey == 0) && (niv == 0))
      break;
  }
  rv = EVP_CIPHER_key_length(type);
err:
  EVP_MD_CTX_free(c);
  OPENSSL_cleanse(md_buf, sizeof(md_buf));
  return rv;
}
```