#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ EC_POINT;
typedef int /*<<< orphan*/ EC_KEY;
typedef int /*<<< orphan*/ EC_GROUP;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ *BN_bin2bn(unsigned char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_KEY_check_key(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_KEY_new();
int /*<<< orphan*/ EC_KEY_set_group(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_KEY_set_private_key(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_KEY_set_public_key(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_POINT_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_POINT_is_on_curve(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_POINT_new(int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_POINT_set_affine_coordinates_GFp(int /*<<< orphan*/ *,
                                                       int /*<<< orphan*/ *,
                                                       int /*<<< orphan*/ *,
                                                       int /*<<< orphan*/ *,
                                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ *sm2_ec_group();
int /*<<< orphan*/ *sm2_ec_group2();
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;
}


x86 assembly (clang, -O0):
<GetECKeyPrivate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    120b <GetECKeyPrivate+0x3b>
mov    $0x0,%al
call   10c0 <EC_KEY_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x10(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1268 <GetECKeyPrivate+0x98>
cmpq   $0x0,-0x48(%rbp)
je     1268 <GetECKeyPrivate+0x98>
cmpq   $0x0,-0x50(%rbp)
jne    12b0 <GetECKeyPrivate+0xe0>
cmpq   $0x0,-0x40(%rbp)
je     127c <GetECKeyPrivate+0xac>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1290 <GetECKeyPrivate+0xc0>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     12a4 <GetECKeyPrivate+0xd4>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
mov    -0x10(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1080 <EC_KEY_set_private_key@plt>
cmp    $0x0,%eax
jne    130e <GetECKeyPrivate+0x13e>
cmpq   $0x0,-0x40(%rbp)
je     12da <GetECKeyPrivate+0x10a>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     12ee <GetECKeyPrivate+0x11e>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     1302 <GetECKeyPrivate+0x132>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
movq   $0x0,-0x58(%rbp)
cmpl   $0x0,0x18(%rbp)
jne    1330 <GetECKeyPrivate+0x160>
mov    $0x0,%al
call   1050 <sm2_ec_group@plt>
mov    %rax,-0x58(%rbp)
jmp    1397 <GetECKeyPrivate+0x1c7>
cmpl   $0x1,0x18(%rbp)
jne    134a <GetECKeyPrivate+0x17a>
mov    $0x0,%al
call   10a0 <sm2_ec_group2@plt>
mov    %rax,-0x58(%rbp)
jmp    1392 <GetECKeyPrivate+0x1c2>
cmpq   $0x0,-0x40(%rbp)
je     135e <GetECKeyPrivate+0x18e>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1372 <GetECKeyPrivate+0x1a2>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     1386 <GetECKeyPrivate+0x1b6>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xfffffff6,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
jmp    1397 <GetECKeyPrivate+0x1c7>
cmpq   $0x0,-0x58(%rbp)
jne    13ea <GetECKeyPrivate+0x21a>
cmpq   $0x0,-0x40(%rbp)
je     13b6 <GetECKeyPrivate+0x1e6>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     13ca <GetECKeyPrivate+0x1fa>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     13de <GetECKeyPrivate+0x20e>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
mov    -0x10(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   10d0 <EC_KEY_set_group@plt>
cmp    $0x0,%eax
jne    1448 <GetECKeyPrivate+0x278>
cmpq   $0x0,-0x40(%rbp)
je     1414 <GetECKeyPrivate+0x244>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1428 <GetECKeyPrivate+0x258>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     143c <GetECKeyPrivate+0x26c>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
mov    -0x58(%rbp),%rdi
call   10f0 <EC_POINT_new@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    14a8 <GetECKeyPrivate+0x2d8>
cmpq   $0x0,-0x40(%rbp)
je     1474 <GetECKeyPrivate+0x2a4>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1488 <GetECKeyPrivate+0x2b8>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     149c <GetECKeyPrivate+0x2cc>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xfffffffb,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1090 <EC_POINT_set_affine_coordinates_GFp@plt>
cmp    $0x0,%eax
jne    1527 <GetECKeyPrivate+0x357>
cmpq   $0x0,-0x40(%rbp)
je     14df <GetECKeyPrivate+0x30f>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     14f3 <GetECKeyPrivate+0x323>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     1507 <GetECKeyPrivate+0x337>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x60(%rbp)
je     151b <GetECKeyPrivate+0x34b>
mov    -0x60(%rbp),%rdi
call   10e0 <EC_POINT_free@plt>
movl   $0xfffffffa,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10b0 <EC_POINT_is_on_curve@plt>
cmp    $0x0,%eax
jne    159d <GetECKeyPrivate+0x3cd>
cmpq   $0x0,-0x40(%rbp)
je     1555 <GetECKeyPrivate+0x385>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1569 <GetECKeyPrivate+0x399>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     157d <GetECKeyPrivate+0x3ad>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x60(%rbp)
je     1591 <GetECKeyPrivate+0x3c1>
mov    -0x60(%rbp),%rdi
call   10e0 <EC_POINT_free@plt>
movl   $0xfffffff9,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
mov    -0x10(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1030 <EC_KEY_set_public_key@plt>
cmp    $0x0,%eax
jne    160f <GetECKeyPrivate+0x43f>
cmpq   $0x0,-0x40(%rbp)
je     15c7 <GetECKeyPrivate+0x3f7>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     15db <GetECKeyPrivate+0x40b>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     15ef <GetECKeyPrivate+0x41f>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x60(%rbp)
je     1603 <GetECKeyPrivate+0x433>
mov    -0x60(%rbp),%rdi
call   10e0 <EC_POINT_free@plt>
movl   $0xfffffff8,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
mov    -0x10(%rbp),%rdi
call   1040 <EC_KEY_check_key@plt>
cmp    $0x0,%eax
jne    167d <GetECKeyPrivate+0x4ad>
cmpq   $0x0,-0x40(%rbp)
je     1635 <GetECKeyPrivate+0x465>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     1649 <GetECKeyPrivate+0x479>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     165d <GetECKeyPrivate+0x48d>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x60(%rbp)
je     1671 <GetECKeyPrivate+0x4a1>
mov    -0x60(%rbp),%rdi
call   10e0 <EC_POINT_free@plt>
movl   $0xfffffff7,-0x4(%rbp)
jmp    16d4 <GetECKeyPrivate+0x504>
cmpq   $0x0,-0x40(%rbp)
je     1691 <GetECKeyPrivate+0x4c1>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x48(%rbp)
je     16a5 <GetECKeyPrivate+0x4d5>
mov    -0x48(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     16b9 <GetECKeyPrivate+0x4e9>
mov    -0x50(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x60(%rbp)
je     16cd <GetECKeyPrivate+0x4fd>
mov    -0x60(%rbp),%rdi
call   10e0 <EC_POINT_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetECKeyPrivate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,%r13
mov    %r8d,%ebx
mov    %rcx,%rbp
mov    %edx,%r14d
mov    %rsi,%r12
mov    %rdi,%r15
test   %rdi,%rdi
jne    11fc <GetECKeyPrivate+0x2c>
xor    %eax,%eax
call   10c0 <EC_KEY_new@plt>
mov    %rax,%r15
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    0x40(%rsp),%esi
xor    %edx,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,%r13
mov    %r12,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     1264 <GetECKeyPrivate+0x94>
test   %r13,%r13
je     1264 <GetECKeyPrivate+0x94>
test   %r14,%r14
je     1264 <GetECKeyPrivate+0x94>
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <EC_KEY_set_private_key@plt>
test   %eax,%eax
je     1299 <GetECKeyPrivate+0xc9>
mov    0x48(%rsp),%eax
cmp    $0x1,%eax
je     12bb <GetECKeyPrivate+0xeb>
test   %eax,%eax
jne    1372 <GetECKeyPrivate+0x1a2>
xor    %eax,%eax
call   1050 <sm2_ec_group@plt>
jmp    12c2 <GetECKeyPrivate+0xf2>
test   %rbx,%rbx
je     1271 <GetECKeyPrivate+0xa1>
mov    %rbx,%rdi
call   1070 <BN_free@plt>
test   %r13,%r13
je     127e <GetECKeyPrivate+0xae>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    $0xffffffff,%ebx
test   %r14,%r14
je     146a <GetECKeyPrivate+0x29a>
mov    %r14,%rdi
call   1070 <BN_free@plt>
jmp    146a <GetECKeyPrivate+0x29a>
mov    %rbx,%rdi
call   1070 <BN_free@plt>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    $0xfffffffe,%ebx
jmp    146a <GetECKeyPrivate+0x29a>
xor    %eax,%eax
call   10a0 <sm2_ec_group2@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1394 <GetECKeyPrivate+0x1c4>
mov    %r15,%rdi
mov    %rbp,%rsi
call   10d0 <EC_KEY_set_group@plt>
test   %eax,%eax
je     13b6 <GetECKeyPrivate+0x1e6>
mov    %rbp,%rdi
call   10f0 <EC_POINT_new@plt>
test   %rax,%rax
je     13d8 <GetECKeyPrivate+0x208>
mov    %rax,%r12
mov    %rbp,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %r8d,%r8d
call   1090 <EC_POINT_set_affine_coordinates_GFp@plt>
test   %eax,%eax
je     13f7 <GetECKeyPrivate+0x227>
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   10b0 <EC_POINT_is_on_curve@plt>
test   %eax,%eax
je     141e <GetECKeyPrivate+0x24e>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <EC_KEY_set_public_key@plt>
test   %eax,%eax
je     1445 <GetECKeyPrivate+0x275>
mov    %r15,%rdi
call   1040 <EC_KEY_check_key@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %rbx,%rdi
call   1070 <BN_free@plt>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    %r12,%rdi
call   10e0 <EC_POINT_free@plt>
lea    -0x9(%rbp,%rbp,8),%ebx
jmp    146a <GetECKeyPrivate+0x29a>
mov    %rbx,%rdi
call   1070 <BN_free@plt>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    $0xfffffff6,%ebx
jmp    146a <GetECKeyPrivate+0x29a>
mov    %rbx,%rdi
call   1070 <BN_free@plt>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    $0xfffffffd,%ebx
jmp    146a <GetECKeyPrivate+0x29a>
mov    %rbx,%rdi
call   1070 <BN_free@plt>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    $0xfffffffc,%ebx
jmp    146a <GetECKeyPrivate+0x29a>
mov    %rbx,%rdi
call   1070 <BN_free@plt>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    $0xfffffffb,%ebx
jmp    146a <GetECKeyPrivate+0x29a>
mov    %rbx,%rdi
call   1070 <BN_free@plt>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    %r12,%rdi
call   10e0 <EC_POINT_free@plt>
mov    $0xfffffffa,%ebx
jmp    146a <GetECKeyPrivate+0x29a>
mov    %rbx,%rdi
call   1070 <BN_free@plt>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    %r12,%rdi
call   10e0 <EC_POINT_free@plt>
mov    $0xfffffff9,%ebx
jmp    146a <GetECKeyPrivate+0x29a>
mov    %rbx,%rdi
call   1070 <BN_free@plt>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    %r12,%rdi
call   10e0 <EC_POINT_free@plt>
mov    $0xfffffff8,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @GetECKeyPrivate(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4, i8* %5, i32 %6, i32 %7) {
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32*
store i32* %0, i32** %10
store i8* %1, i8** %11
store i32 %2, i32* %12
store i8* %3, i8** %13
store i32 %4, i32* %14
store i8* %5, i8** %15
store i32 %6, i32* %16
store i32 %7, i32* %17
%23 = load i32*, i32** %10
%24 = icmp ne i32* %23, null
br i1 %24, label %27, label %25
25: ; preds = %8
%26 = call i32* (...) @EC_KEY_new()
store i32* %26, i32** %10
br label %27
27: ; preds = %25, %8
%28 = load i8*, i8** %13
%29 = load i32, i32* %14
%30 = call i32* @BN_bin2bn(i8* %28, i32 %29, i32* null)
store i32* %30, i32** %18
%31 = load i8*, i8** %15
%32 = load i32, i32* %16
%33 = call i32* @BN_bin2bn(i8* %31, i32 %32, i32* null)
store i32* %33, i32** %19
%34 = load i8*, i8** %11
%35 = load i32, i32* %12
%36 = call i32* @BN_bin2bn(i8* %34, i32 %35, i32* null)
store i32* %36, i32** %20
%37 = load i32*, i32** %18
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %45
39: ; preds = %27
%40 = load i32*, i32** %19
%41 = icmp ne i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32*, i32** %20
%44 = icmp ne i32* %43, null
br i1 %44, label %64, label %45
45: ; preds = %42, %39, %27
%46 = load i32*, i32** %18
%47 = icmp ne i32* %46, null
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i32*, i32** %18
%50 = call i32 @BN_free(i32* %49)
br label %51
51: ; preds = %48, %45
%52 = load i32*, i32** %19
%53 = icmp ne i32* %52, null
br i1 %53, label %54, label %57
54: ; preds = %51
%55 = load i32*, i32** %19
%56 = call i32 @BN_free(i32* %55)
br label %57
57: ; preds = %54, %51
%58 = load i32*, i32** %20
%59 = icmp ne i32* %58, null
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load i32*, i32** %20
%62 = call i32 @BN_free(i32* %61)
br label %63
63: ; preds = %60, %57
store i32 -1, i32* %9
br label %334
64: ; preds = %42
%65 = load i32*, i32** %10
%66 = load i32*, i32** %20
%67 = call i32 @EC_KEY_set_private_key(i32* %65, i32* %66)
%68 = icmp ne i32 %67, 0
br i1 %68, label %88, label %69
69: ; preds = %64
%70 = load i32*, i32** %18
%71 = icmp ne i32* %70, null
br i1 %71, label %72, label %75
72: ; preds = %69
%73 = load i32*, i32** %18
%74 = call i32 @BN_free(i32* %73)
br label %75
75: ; preds = %72, %69
%76 = load i32*, i32** %19
%77 = icmp ne i32* %76, null
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = load i32*, i32** %19
%80 = call i32 @BN_free(i32* %79)
br label %81
81: ; preds = %78, %75
%82 = load i32*, i32** %20
%83 = icmp ne i32* %82, null
br i1 %83, label %84, label %87
84: ; preds = %81
%85 = load i32*, i32** %20
%86 = call i32 @BN_free(i32* %85)
br label %87
87: ; preds = %84, %81
store i32 -2, i32* %9
br label %334
88: ; preds = %64
store i32* null, i32** %21
%89 = load i32, i32* %17
%90 = icmp eq i32 %89, 0
br i1 %90, label %91, label %93
91: ; preds = %88
%92 = call i32* (...) @sm2_ec_group()
store i32* %92, i32** %21
br label %118
93: ; preds = %88
%94 = load i32, i32* %17
%95 = icmp eq i32 %94, 1
br i1 %95, label %96, label %98
96: ; preds = %93
%97 = call i32* (...) @sm2_ec_group2()
store i32* %97, i32** %21
br label %117
98: ; preds = %93
%99 = load i32*, i32** %18
%100 = icmp ne i32* %99, null
br i1 %100, label %101, label %104
101: ; preds = %98
%102 = load i32*, i32** %18
%103 = call i32 @BN_free(i32* %102)
br label %104
104: ; preds = %101, %98
%105 = load i32*, i32** %19
%106 = icmp ne i32* %105, null
br i1 %106, label %107, label %110
107: ; preds = %104
%108 = load i32*, i32** %19
%109 = call i32 @BN_free(i32* %108)
br label %110
110: ; preds = %107, %104
%111 = load i32*, i32** %20
%112 = icmp ne i32* %111, null
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = load i32*, i32** %20
%115 = call i32 @BN_free(i32* %114)
br label %116
116: ; preds = %113, %110
store i32 -10, i32* %9
br label %334
117: ; preds = %96
br label %118
118: ; preds = %117, %91
%119 = load i32*, i32** %21
%120 = icmp ne i32* %119, null
br i1 %120, label %140, label %121
121: ; preds = %118
%122 = load i32*, i32** %18
%123 = icmp ne i32* %122, null
br i1 %123, label %124, label %127
124: ; preds = %121
%125 = load i32*, i32** %18
%126 = call i32 @BN_free(i32* %125)
br label %127
127: ; preds = %124, %121
%128 = load i32*, i32** %19
%129 = icmp ne i32* %128, null
br i1 %129, label %130, label %133
130: ; preds = %127
%131 = load i32*, i32** %19
%132 = call i32 @BN_free(i32* %131)
br label %133
133: ; preds = %130, %127
%134 = load i32*, i32** %20
%135 = icmp ne i32* %134, null
br i1 %135, label %136, label %139
136: ; preds = %133
%137 = load i32*, i32** %20
%138 = call i32 @BN_free(i32* %137)
br label %139
139: ; preds = %136, %133
store i32 -3, i32* %9
br label %334
140: ; preds = %118
%141 = load i32*, i32** %10
%142 = load i32*, i32** %21
%143 = call i32 @EC_KEY_set_group(i32* %141, i32* %142)
%144 = icmp ne i32 %143, 0
br i1 %144, label %164, label %145
145: ; preds = %140
%146 = load i32*, i32** %18
%147 = icmp ne i32* %146, null
br i1 %147, label %148, label %151
148: ; preds = %145
%149 = load i32*, i32** %18
%150 = call i32 @BN_free(i32* %149)
br label %151
151: ; preds = %148, %145
%152 = load i32*, i32** %19
%153 = icmp ne i32* %152, null
br i1 %153, label %154, label %157
154: ; preds = %151
%155 = load i32*, i32** %19
%156 = call i32 @BN_free(i32* %155)
br label %157
157: ; preds = %154, %151
%158 = load i32*, i32** %20
%159 = icmp ne i32* %158, null
br i1 %159, label %160, label %163
160: ; preds = %157
%161 = load i32*, i32** %20
%162 = call i32 @BN_free(i32* %161)
br label %163
163: ; preds = %160, %157
store i32 -4, i32* %9
br label %334
164: ; preds = %140
%165 = load i32*, i32** %21
%166 = call i32* @EC_POINT_new(i32* %165)
store i32* %166, i32** %22
%167 = load i32*, i32** %22
%168 = icmp ne i32* %167, null
br i1 %168, label %188, label %169
169: ; preds = %164
%170 = load i32*, i32** %18
%171 = icmp ne i32* %170, null
br i1 %171, label %172, label %175
172: ; preds = %169
%173 = load i32*, i32** %18
%174 = call i32 @BN_free(i32* %173)
br label %175
175: ; preds = %172, %169
%176 = load i32*, i32** %19
%177 = icmp ne i32* %176, null
br i1 %177, label %178, label %181
178: ; preds = %175
%179 = load i32*, i32** %19
%180 = call i32 @BN_free(i32* %179)
br label %181
181: ; preds = %178, %175
%182 = load i32*, i32** %20
%183 = icmp ne i32* %182, null
br i1 %183, label %184, label %187
184: ; preds = %181
%185 = load i32*, i32** %20
%186 = call i32 @BN_free(i32* %185)
br label %187
187: ; preds = %184, %181
store i32 -5, i32* %9
br label %334
188: ; preds = %164
%189 = load i32*, i32** %21
%190 = load i32*, i32** %22
%191 = load i32*, i32** %18
%192 = load i32*, i32** %19
%193 = call i32 @EC_POINT_set_affine_coordinates_GFp(i32* %189, i32* %190, i32* %191, i32* %192, i32* null)
%194 = icmp ne i32 %193, 0
br i1 %194, label %220, label %195
195: ; preds = %188
%196 = load i32*, i32** %18
%197 = icmp ne i32* %196, null
br i1 %197, label %198, label %201
198: ; preds = %195
%199 = load i32*, i32** %18
%200 = call i32 @BN_free(i32* %199)
br label %201
201: ; preds = %198, %195
%202 = load i32*, i32** %19
%203 = icmp ne i32* %202, null
br i1 %203, label %204, label %207
204: ; preds = %201
%205 = load i32*, i32** %19
%206 = call i32 @BN_free(i32* %205)
br label %207
207: ; preds = %204, %201
%208 = load i32*, i32** %20
%209 = icmp ne i32* %208, null
br i1 %209, label %210, label %213
210: ; preds = %207
%211 = load i32*, i32** %20
%212 = call i32 @BN_free(i32* %211)
br label %213
213: ; preds = %210, %207
%214 = load i32*, i32** %22
%215 = icmp ne i32* %214, null
br i1 %215, label %216, label %219
216: ; preds = %213
%217 = load i32*, i32** %22
%218 = call i32 @EC_POINT_free(i32* %217)
br label %219
219: ; preds = %216, %213
store i32 -6, i32* %9
br label %334
220: ; preds = %188
%221 = load i32*, i32** %21
%222 = load i32*, i32** %22
%223 = call i32 @EC_POINT_is_on_curve(i32* %221, i32* %222, i32* null)
%224 = icmp ne i32 %223, 0
br i1 %224, label %250, label %225
225: ; preds = %220
%226 = load i32*, i32** %18
%227 = icmp ne i32* %226, null
br i1 %227, label %228, label %231
228: ; preds = %225
%229 = load i32*, i32** %18
%230 = call i32 @BN_free(i32* %229)
br label %231
231: ; preds = %228, %225
%232 = load i32*, i32** %19
%233 = icmp ne i32* %232, null
br i1 %233, label %234, label %237
234: ; preds = %231
%235 = load i32*, i32** %19
%236 = call i32 @BN_free(i32* %235)
br label %237
237: ; preds = %234, %231
%238 = load i32*, i32** %20
%239 = icmp ne i32* %238, null
br i1 %239, label %240, label %243
240: ; preds = %237
%241 = load i32*, i32** %20
%242 = call i32 @BN_free(i32* %241)
br label %243
243: ; preds = %240, %237
%244 = load i32*, i32** %22
%245 = icmp ne i32* %244, null
br i1 %245, label %246, label %249
246: ; preds = %243
%247 = load i32*, i32** %22
%248 = call i32 @EC_POINT_free(i32* %247)
br label %249
249: ; preds = %246, %243
store i32 -7, i32* %9
br label %334
250: ; preds = %220
%251 = load i32*, i32** %10
%252 = load i32*, i32** %22
%253 = call i32 @EC_KEY_set_public_key(i32* %251, i32* %252)
%254 = icmp ne i32 %253, 0
br i1 %254, label %280, label %255
255: ; preds = %250
%256 = load i32*, i32** %18
%257 = icmp ne i32* %256, null
br i1 %257, label %258, label %261
258: ; preds = %255
%259 = load i32*, i32** %18
%260 = call i32 @BN_free(i32* %259)
br label %261
261: ; preds = %258, %255
%262 = load i32*, i32** %19
%263 = icmp ne i32* %262, null
br i1 %263, label %264, label %267
264: ; preds = %261
%265 = load i32*, i32** %19
%266 = call i32 @BN_free(i32* %265)
br label %267
267: ; preds = %264, %261
%268 = load i32*, i32** %20
%269 = icmp ne i32* %268, null
br i1 %269, label %270, label %273
270: ; preds = %267
%271 = load i32*, i32** %20
%272 = call i32 @BN_free(i32* %271)
br label %273
273: ; preds = %270, %267
%274 = load i32*, i32** %22
%275 = icmp ne i32* %274, null
br i1 %275, label %276, label %279
276: ; preds = %273
%277 = load i32*, i32** %22
%278 = call i32 @EC_POINT_free(i32* %277)
br label %279
279: ; preds = %276, %273
store i32 -8, i32* %9
br label %334
280: ; preds = %250
%281 = load i32*, i32** %10
%282 = call i32 @EC_KEY_check_key(i32* %281)
%283 = icmp ne i32 %282, 0
br i1 %283, label %309, label %284
284: ; preds = %280
%285 = load i32*, i32** %18
%286 = icmp ne i32* %285, null
br i1 %286, label %287, label %290
287: ; preds = %284
%288 = load i32*, i32** %18
%289 = call i32 @BN_free(i32* %288)
br label %290
290: ; preds = %287, %284
%291 = load i32*, i32** %19
%292 = icmp ne i32* %291, null
br i1 %292, label %293, label %296
293: ; preds = %290
%294 = load i32*, i32** %19
%295 = call i32 @BN_free(i32* %294)
br label %296
296: ; preds = %293, %290
%297 = load i32*, i32** %20
%298 = icmp ne i32* %297, null
br i1 %298, label %299, label %302
299: ; preds = %296
%300 = load i32*, i32** %20
%301 = call i32 @BN_free(i32* %300)
br label %302
302: ; preds = %299, %296
%303 = load i32*, i32** %22
%304 = icmp ne i32* %303, null
br i1 %304, label %305, label %308
305: ; preds = %302
%306 = load i32*, i32** %22
%307 = call i32 @EC_POINT_free(i32* %306)
br label %308
308: ; preds = %305, %302
store i32 -9, i32* %9
br label %334
309: ; preds = %280
%310 = load i32*, i32** %18
%311 = icmp ne i32* %310, null
br i1 %311, label %312, label %315
312: ; preds = %309
%313 = load i32*, i32** %18
%314 = call i32 @BN_free(i32* %313)
br label %315
315: ; preds = %312, %309
%316 = load i32*, i32** %19
%317 = icmp ne i32* %316, null
br i1 %317, label %318, label %321
318: ; preds = %315
%319 = load i32*, i32** %19
%320 = call i32 @BN_free(i32* %319)
br label %321
321: ; preds = %318, %315
%322 = load i32*, i32** %20
%323 = icmp ne i32* %322, null
br i1 %323, label %324, label %327
324: ; preds = %321
%325 = load i32*, i32** %20
%326 = call i32 @BN_free(i32* %325)
br label %327
327: ; preds = %324, %321
%328 = load i32*, i32** %22
%329 = icmp ne i32* %328, null
br i1 %329, label %330, label %333
330: ; preds = %327
%331 = load i32*, i32** %22
%332 = call i32 @EC_POINT_free(i32* %331)
br label %333
333: ; preds = %330, %327
store i32 0, i32* %9
br label %334
334: ; preds = %333, %308, %279, %249, %219, %187, %163, %139, %116, %87, %63
%335 = load i32, i32* %9
ret i32 %335
}

LLVM IR (-O2):
define i32 @GetECKeyPrivate(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4, i8* %5, i32 %6, i32 %7) {
%9 = icmp eq i32* %0, null
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32* (...) @EC_KEY_new()
br label %12
12: ; preds = %10, %8
%13 = phi i32* [ %0, %8 ], [ %11, %10 ]
%14 = tail call i32* @BN_bin2bn(i8* %3, i32 %4, i32* null)
%15 = tail call i32* @BN_bin2bn(i8* %5, i32 %6, i32* null)
%16 = tail call i32* @BN_bin2bn(i8* %1, i32 %2, i32* null)
%17 = icmp ne i32* %14, null
%18 = icmp ne i32* %15, null
%19 = select i1 %17, i1 %18, i1 false
%20 = icmp ne i32* %16, null
%21 = select i1 %19, i1 %20, i1 false
br i1 %21, label %31, label %22
22: ; preds = %12
br i1 %17, label %23, label %25
23: ; preds = %22
%24 = tail call i32 @BN_free(i32* %14)
br label %25
25: ; preds = %23, %22
br i1 %18, label %26, label %28
26: ; preds = %25
%27 = tail call i32 @BN_free(i32* %15)
br label %28
28: ; preds = %26, %25
br i1 %20, label %29, label %100
29: ; preds = %28
%30 = tail call i32 @BN_free(i32* %16)
br label %100
31: ; preds = %12
%32 = tail call i32 @EC_KEY_set_private_key(i32* %13, i32* %16)
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = tail call i32 @BN_free(i32* %14)
%36 = tail call i32 @BN_free(i32* %15)
%37 = tail call i32 @BN_free(i32* %16)
br label %100
38: ; preds = %31
switch i32 %7, label %43 [
i32 0, label %39
i32 1, label %41
]
39: ; preds = %38
%40 = tail call i32* (...) @sm2_ec_group()
br label %47
41: ; preds = %38
%42 = tail call i32* (...) @sm2_ec_group2()
br label %47
43: ; preds = %38
%44 = tail call i32 @BN_free(i32* %14)
%45 = tail call i32 @BN_free(i32* %15)
%46 = tail call i32 @BN_free(i32* %16)
br label %100
47: ; preds = %41, %39
%48 = phi i32* [ %40, %39 ], [ %42, %41 ]
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %54
50: ; preds = %47
%51 = tail call i32 @BN_free(i32* %14)
%52 = tail call i32 @BN_free(i32* %15)
%53 = tail call i32 @BN_free(i32* %16)
br label %100
54: ; preds = %47
%55 = tail call i32 @EC_KEY_set_group(i32* %13, i32* %48)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %54
%58 = tail call i32 @BN_free(i32* %14)
%59 = tail call i32 @BN_free(i32* %15)
%60 = tail call i32 @BN_free(i32* %16)
br label %100
61: ; preds = %54
%62 = tail call i32* @EC_POINT_new(i32* %48)
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %68
64: ; preds = %61
%65 = tail call i32 @BN_free(i32* %14)
%66 = tail call i32 @BN_free(i32* %15)
%67 = tail call i32 @BN_free(i32* %16)
br label %100
68: ; preds = %61
%69 = tail call i32 @EC_POINT_set_affine_coordinates_GFp(i32* %48, i32* %62, i32* %14, i32* %15, i32* null)
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %76
71: ; preds = %68
%72 = tail call i32 @BN_free(i32* %14)
%73 = tail call i32 @BN_free(i32* %15)
%74 = tail call i32 @BN_free(i32* %16)
%75 = tail call i32 @EC_POINT_free(i32* %62)
br label %100
76: ; preds = %68
%77 = tail call i32 @EC_POINT_is_on_curve(i32* %48, i32* %62, i32* null)
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %84
79: ; preds = %76
%80 = tail call i32 @BN_free(i32* %14)
%81 = tail call i32 @BN_free(i32* %15)
%82 = tail call i32 @BN_free(i32* %16)
%83 = tail call i32 @EC_POINT_free(i32* %62)
br label %100
84: ; preds = %76
%85 = tail call i32 @EC_KEY_set_public_key(i32* %13, i32* %62)
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %92
87: ; preds = %84
%88 = tail call i32 @BN_free(i32* %14)
%89 = tail call i32 @BN_free(i32* %15)
%90 = tail call i32 @BN_free(i32* %16)
%91 = tail call i32 @EC_POINT_free(i32* %62)
br label %100
92: ; preds = %84
%93 = tail call i32 @EC_KEY_check_key(i32* %13)
%94 = icmp eq i32 %93, 0
%95 = tail call i32 @BN_free(i32* %14)
%96 = tail call i32 @BN_free(i32* %15)
%97 = tail call i32 @BN_free(i32* %16)
%98 = tail call i32 @EC_POINT_free(i32* %62)
%99 = select i1 %94, i32 -9, i32 0
br label %100
100: ; preds = %92, %43, %50, %57, %87, %79, %71, %64, %28, %29, %34
%101 = phi i32 [ -2, %34 ], [ -1, %29 ], [ -1, %28 ], [ -4, %57 ], [ -3, %50 ], [ -10, %43 ], [ -8, %87 ], [ -7, %79 ], [ -6, %71 ], [ -5, %64 ], [ %99, %92 ]
ret i32 %101
}