user: Converte this assembly snippet into its equivalent C code:

```asm
<is_immediate_ca>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  sub    $0x10,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rdx,(%rsp)
  test   %rdi,%rdi
  je     L39
  test   %rdx,%rdx
  je     L39
  xor    %eax,%eax
  mov    %esi,%r13d
  mov    %ecx,%r12d
  call   <EVP_md5@plt>
  mov    %eax,%edi
  call   <EVP_add_digest@plt>
  test   %rax,%rax
  je     L39
  xor    %eax,%eax
  call   <EVP_sha1@plt>
  mov    %eax,%edi
  call   <EVP_add_digest@plt>
  test   %rax,%rax
  jne    L61
L39:
  xor    %r12d,%r12d
L126:
  add    $0x10,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L61:
  xor    %eax,%eax
  call   <EVP_sha256@plt>
  mov    %eax,%edi
  call   <EVP_add_digest@plt>
  test   %rax,%rax
  je     L39
  mov    %r13d,%edx
  lea    0x8(%rsp),%rsi
  xor    %edi,%edi
  call   <d2i_X509@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L39
  mov    %rsp,%rsi
  mov    %r12d,%edx
  xor    %edi,%edi
  call   <d2i_X509@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L113
  xor    %eax,%eax
  call   <X509_STORE_new@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L130
  mov    %rbp,%rsi
  mov    %rax,%rdi
  call   <X509_STORE_add_cert@plt>
  test   %rax,%rax
  je     L106
  mov    D12(%rip),%rax
  mov    %r14,%rdi
  mov    (%rax),%esi
  mov    D11(%rip),%rax
  or     (%rax),%esi
  call   <X509_STORE_set_flags@plt>
  xor    %eax,%eax
  call   <X509_STORE_CTX_new@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L106
  xor    %ecx,%ecx
  mov    %r13,%rdx
  mov    %r14,%rsi
  mov    %rax,%rdi
  call   <X509_STORE_CTX_init@plt>
  xor    %r12d,%r12d
  test   %rax,%rax
  je     L149
  mov    %r15,%rdi
  call   <X509_verify_cert@plt>
  xor    %edx,%edx
  mov    %r15,%rdi
  test   %eax,%eax
  cmovns %eax,%edx
  mov    %edx,%r12d
  call   <X509_STORE_CTX_cleanup@plt>
  nopl   (%rax)
L149:
  mov    %r13,%rdi
  call   <X509_free@plt>
  mov    %rbp,%rdi
  call   <X509_free@plt>
  mov    %r14,%rdi
  call   <X509_STORE_free@plt>
  mov    %r15,%rdi
  call   <X509_STORE_CTX_free@plt>
  jmp    L126
  nopl   (%rax)
L106:
  xor    %r12d,%r12d
  xor    %r15d,%r15d
  jmp    L149
L113:
  mov    %r13,%rdi
  call   <X509_free@plt>
  jmp    L39
L130:
  mov    %r13,%rdi
  xor    %r12d,%r12d
  call   <X509_free@plt>
  mov    %rbp,%rdi
  call   <X509_free@plt>
  jmp    L126
```

assistant: ```c
int is_immediate_ca(const uint8_t *cert, const uint32_t cert_size, const uint8_t *ca_cert, const uint32_t ca_cert_size) {
  X509 *X509cert = NULL;
  X509 *X509ca = NULL;
  X509_STORE *cert_store = NULL;
  X509_STORE_CTX *cert_ctx = NULL;
  int ret = 0;
  if (cert == NULL || ca_cert == NULL)
    return 0;
  if (EVP_add_digest(EVP_md5()) == 0)
    return 0;
  if (EVP_add_digest(EVP_sha1()) == 0)
    return 0;
  if (EVP_add_digest(EVP_sha256()) == 0)
    return 0;
  X509cert = d2i_X509(NULL, &cert, cert_size);
  if (X509cert == NULL)
    return 0;
  X509ca = d2i_X509(NULL, &ca_cert, ca_cert_size);
  if (X509ca == NULL)
    goto err;
  cert_store = X509_STORE_new();
  if (cert_store == NULL)
    goto err;
  if (X509_STORE_add_cert(cert_store, X509ca) == 0)
    goto err;
  X509_STORE_set_flags(cert_store, X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_NO_CHECK_TIME);
  cert_ctx = X509_STORE_CTX_new();
  if (cert_ctx == NULL)
    goto err;
  if (X509_STORE_CTX_init(cert_ctx, cert_store, X509cert, NULL) == 0)
    goto err;
  ret = X509_verify_cert(cert_ctx);
  if (ret < 0)
    ret = 0;
  X509_STORE_CTX_cleanup(cert_ctx);
err:
  if (X509cert)
    X509_free(X509cert);
  if (X509ca)
    X509_free(X509ca);
  if (cert_store)
    X509_STORE_free(cert_store);
  if (cert_store)
    X509_STORE_CTX_free(cert_ctx);
  return ret;
}
```