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

```asm
<eckey_type2param>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %edi,-0x44(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x28(%rbp)
  mov    D22(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x44(%rbp)
  jne    L33
  mov    -0x50(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  movq   $0x0,-0x30(%rbp)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x10(%rbp),%rax
  mov    0x8(%rax),%eax
  mov    %eax,-0x34(%rbp)
  mov    -0x34(%rbp),%edx
  lea    -0x30(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x0,%edi
  call   <d2i_ECParameters@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L16
  mov    D49(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <ECerror@plt>
  jmp    L138
L33:
  mov    D20(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x44(%rbp)
  jne    L0
  mov    -0x50(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  mov    $0x0,%eax
  call   <EC_KEY_new@plt>
  mov    %rax,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L96
  mov    D52(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <ECerror@plt>
  jmp    L138
L96:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <OBJ_obj2nid@plt>
  mov    %eax,%edi
  call   <EC_GROUP_new_by_curve_name@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L32
  mov    D43(%rip),%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <EC_GROUP_set_asn1_flag@plt>
  mov    -0x18(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <EC_KEY_set_group@plt>
  test   %rax,%rax
  je     L9
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <EC_GROUP_free@plt>
  jmp    L16
L0:
  mov    D49(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <ECerror@plt>
  jmp    L138
L16:
  mov    -0x28(%rbp),%rax
  jmp    L20
L32:
  nop
  jmp    L138
L9:
  nop
L138:
  cmpq   $0x0,-0x28(%rbp)
  je     L134
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <EC_KEY_free@plt>
L134:
  mov    $0x0,%eax
L20:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L12
  call   <__stack_chk_fail@plt>
L12:
  leave
  ret
```

assistant: ```c
EC_KEY *eckey_type2param(int ptype, void *pval) {
  EC_KEY *eckey = NULL;
  if (ptype == V_ASN1_SEQUENCE) {
    ASN1_STRING *pstr = pval;
    const unsigned char *pm = NULL;
    int pmlen;
    pm = pstr->data;
    pmlen = pstr->length;
    if (!(eckey = d2i_ECParameters(NULL, &pm, pmlen))) {
      ECerror(EC_R_DECODE_ERROR);
      goto ecerr;
    }
  } else if (ptype == V_ASN1_OBJECT) {
    ASN1_OBJECT *poid = pval;
    EC_GROUP *group;
    if ((eckey = EC_KEY_new()) == NULL) {
      ECerror(ERR_R_MALLOC_FAILURE);
      goto ecerr;
    }
    group = EC_GROUP_new_by_curve_name(OBJ_obj2nid(poid));
    if (group == NULL)
      goto ecerr;
    EC_GROUP_set_asn1_flag(group, OPENSSL_EC_NAMED_CURVE);
    if (EC_KEY_set_group(eckey, group) == 0)
      goto ecerr;
    EC_GROUP_free(group);
  } else {
    ECerror(EC_R_DECODE_ERROR);
    goto ecerr;
  }
  return eckey;
ecerr:
  if (eckey)
    EC_KEY_free(eckey);
  return NULL;
}
```