user: Translate the below assembly code into C programming language:

```asm
<GetECKeyPrivate>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  mov    %edx,%r12d
  mov    %rcx,%r14
  mov    %r8d,%r15d
  mov    %r9,%r13
  test   %rdi,%rdi
  je     L249
L78:
  mov    $0x0,%edx
  mov    %r15d,%esi
  mov    %r14,%rdi
  call   <BN_bin2bn@plt>
  mov    %rax,%r14
  mov    $0x0,%edx
  mov    0x40(%rsp),%esi
  mov    %r13,%rdi
  call   <BN_bin2bn@plt>
  mov    %rax,%r13
  mov    $0x0,%edx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <BN_bin2bn@plt>
  mov    %rax,%r12
  test   %r14,%r14
  sete   %al
  test   %r13,%r13
  sete   %dl
  or     %dl,%al
  jne    L242
  test   %r12,%r12
  je     L242
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <EC_KEY_set_private_key@plt>
  test   %eax,%eax
  je     L150
  cmpl   $0x0,0x48(%rsp)
  je     L195
  cmpl   $0x1,0x48(%rsp)
  jne    L222
  mov    $0x0,%eax
  call   <sm2_ec_group2@plt>
  mov    %rax,%rbp
L241:
  test   %rbp,%rbp
  je     L126
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <EC_KEY_set_group@plt>
  test   %eax,%eax
  je     L32
  mov    %rbp,%rdi
  call   <EC_POINT_new@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L90
  mov    $0x0,%r8d
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    %rax,%rsi
  mov    %rbp,%rdi
  call   <EC_POINT_set_affine_coordinates_GFp@plt>
  test   %eax,%eax
  je     L110
  mov    $0x0,%edx
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <EC_POINT_is_on_curve@plt>
  test   %eax,%eax
  je     L120
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <EC_KEY_set_public_key@plt>
  test   %eax,%eax
  je     L54
  mov    %rbx,%rdi
  call   <EC_KEY_check_key@plt>
  test   %eax,%eax
  je     L45
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    %r15,%rdi
  call   <EC_POINT_free@plt>
  mov    $0x0,%eax
L44:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L249:
  mov    $0x0,%eax
  call   <EC_KEY_new@plt>
  mov    %rax,%rbx
  jmp    L78
L242:
  test   %r14,%r14
  je     L76
  mov    %r14,%rdi
  call   <BN_free@plt>
L76:
  test   %r13,%r13
  je     L6
  mov    %r13,%rdi
  call   <BN_free@plt>
L6:
  mov    $0xffffffff,%eax
  test   %r12,%r12
  je     L44
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    $0xffffffff,%eax
  jmp    L44
L150:
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    $0xfffffffe,%eax
  jmp    L44
L195:
  mov    $0x0,%eax
  call   <sm2_ec_group@plt>
  mov    %rax,%rbp
  jmp    L241
L222:
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    $0xfffffff6,%eax
  jmp    L44
L126:
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    $0xfffffffd,%eax
  jmp    L44
L32:
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    $0xfffffffc,%eax
  jmp    L44
L90:
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    $0xfffffffb,%eax
  jmp    L44
L110:
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    %r15,%rdi
  call   <EC_POINT_free@plt>
  mov    $0xfffffffa,%eax
  jmp    L44
L120:
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    %r15,%rdi
  call   <EC_POINT_free@plt>
  mov    $0xfffffff9,%eax
  jmp    L44
L54:
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    %r15,%rdi
  call   <EC_POINT_free@plt>
  mov    $0xfffffff8,%eax
  jmp    L44
L45:
  mov    %r14,%rdi
  call   <BN_free@plt>
  mov    %r13,%rdi
  call   <BN_free@plt>
  mov    %r12,%rdi
  call   <BN_free@plt>
  mov    %r15,%rdi
  call   <EC_POINT_free@plt>
  mov    $0xfffffff7,%eax
  jmp    L44
```

assistant: ```c
int GetECKeyPrivate(EC_KEY *ec_key, unsigned char *privD, int privDlen, unsigned char *pubX, int pubXlen, unsigned char *pubY, int pubYlen, int ctype) {
  if (!ec_key)
    ec_key = EC_KEY_new();
  BIGNUM *pub_key_x = BN_bin2bn(pubX, pubXlen, NULL);
  BIGNUM *pub_key_y = BN_bin2bn(pubY, pubYlen, NULL);
  BIGNUM *priv_key = BN_bin2bn(privD, privDlen, NULL);
  if (!pub_key_x || !pub_key_y || !priv_key) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    return -1;
  }
  if (!EC_KEY_set_private_key(ec_key, priv_key)) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    return -2;
  }
  EC_GROUP *ec_group = NULL;
  if (ctype == 0) {
    ec_group = sm2_ec_group();
  } else if (ctype == 1) {
    ec_group = sm2_ec_group2();
  } else {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    return -10;
  }
  if (!ec_group) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    return -3;
  }
  if (!EC_KEY_set_group(ec_key, ec_group)) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    return -4;
  }
  EC_POINT *pub_key = EC_POINT_new(ec_group);
  if (!pub_key) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    return -5;
  }
  if (!EC_POINT_set_affine_coordinates_GFp(ec_group, pub_key, pub_key_x, pub_key_y, NULL)) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    if (pub_key)
      EC_POINT_free(pub_key);
    return -6;
  }
  if (!EC_POINT_is_on_curve(ec_group, pub_key, NULL)) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    if (pub_key)
      EC_POINT_free(pub_key);
    return -7;
  }
  if (!EC_KEY_set_public_key(ec_key, pub_key)) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    if (pub_key)
      EC_POINT_free(pub_key);
    return -8;
  }
  if (!EC_KEY_check_key(ec_key)) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    if (priv_key)
      BN_free(priv_key);
    if (pub_key)
      EC_POINT_free(pub_key);
    return -9;
  }
  if (pub_key_x)
    BN_free(pub_key_x);
  if (pub_key_y)
    BN_free(pub_key_y);
  if (priv_key)
    BN_free(priv_key);
  if (pub_key)
    EC_POINT_free(pub_key);
  return 0;
}
```