#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_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 GetECKeyPublic(EC_KEY *ec_key, 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);
  if (!pub_key_x || !pub_key_y) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    return -1;
  }
  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);
    return -10;
  }
  if (!ec_group) {
    if (pub_key_x)
      BN_free(pub_key_x);
    if (pub_key_y)
      BN_free(pub_key_y);
    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);
    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);
    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 (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 (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 (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 (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 (pub_key)
    EC_POINT_free(pub_key);
  return 0;
}


x86 assembly (clang, -O0):
<GetECKeyPublic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9d,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11f5 <GetECKeyPublic+0x35>
mov    $0x0,%al
call   10b0 <EC_KEY_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1233 <GetECKeyPublic+0x73>
cmpq   $0x0,-0x40(%rbp)
jne    1267 <GetECKeyPublic+0xa7>
cmpq   $0x0,-0x38(%rbp)
je     1247 <GetECKeyPublic+0x87>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     125b <GetECKeyPublic+0x9b>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1579 <GetECKeyPublic+0x3b9>
movq   $0x0,-0x48(%rbp)
cmpl   $0x0,-0x30(%rbp)
jne    1289 <GetECKeyPublic+0xc9>
mov    $0x0,%al
call   1050 <sm2_ec_group@plt>
mov    %rax,-0x48(%rbp)
jmp    12dc <GetECKeyPublic+0x11c>
cmpl   $0x1,-0x30(%rbp)
jne    12a3 <GetECKeyPublic+0xe3>
mov    $0x0,%al
call   1090 <sm2_ec_group2@plt>
mov    %rax,-0x48(%rbp)
jmp    12d7 <GetECKeyPublic+0x117>
cmpq   $0x0,-0x38(%rbp)
je     12b7 <GetECKeyPublic+0xf7>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     12cb <GetECKeyPublic+0x10b>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xfffffff6,-0x4(%rbp)
jmp    1579 <GetECKeyPublic+0x3b9>
jmp    12dc <GetECKeyPublic+0x11c>
cmpq   $0x0,-0x48(%rbp)
jne    131b <GetECKeyPublic+0x15b>
cmpq   $0x0,-0x38(%rbp)
je     12fb <GetECKeyPublic+0x13b>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     130f <GetECKeyPublic+0x14f>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    1579 <GetECKeyPublic+0x3b9>
mov    -0x10(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   10c0 <EC_KEY_set_group@plt>
cmp    $0x0,%eax
jne    1365 <GetECKeyPublic+0x1a5>
cmpq   $0x0,-0x38(%rbp)
je     1345 <GetECKeyPublic+0x185>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     1359 <GetECKeyPublic+0x199>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xfffffffc,-0x4(%rbp)
jmp    1579 <GetECKeyPublic+0x3b9>
mov    -0x48(%rbp),%rdi
call   10e0 <EC_POINT_new@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13b1 <GetECKeyPublic+0x1f1>
cmpq   $0x0,-0x38(%rbp)
je     1391 <GetECKeyPublic+0x1d1>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     13a5 <GetECKeyPublic+0x1e5>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
movl   $0xfffffffb,-0x4(%rbp)
jmp    1579 <GetECKeyPublic+0x3b9>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1080 <EC_POINT_set_affine_coordinates_GFp@plt>
cmp    $0x0,%eax
jne    141c <GetECKeyPublic+0x25c>
cmpq   $0x0,-0x38(%rbp)
je     13e8 <GetECKeyPublic+0x228>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     13fc <GetECKeyPublic+0x23c>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     1410 <GetECKeyPublic+0x250>
mov    -0x50(%rbp),%rdi
call   10d0 <EC_POINT_free@plt>
movl   $0xfffffffa,-0x4(%rbp)
jmp    1579 <GetECKeyPublic+0x3b9>
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   10a0 <EC_POINT_is_on_curve@plt>
cmp    $0x0,%eax
jne    147e <GetECKeyPublic+0x2be>
cmpq   $0x0,-0x38(%rbp)
je     144a <GetECKeyPublic+0x28a>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     145e <GetECKeyPublic+0x29e>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     1472 <GetECKeyPublic+0x2b2>
mov    -0x50(%rbp),%rdi
call   10d0 <EC_POINT_free@plt>
movl   $0xfffffff9,-0x4(%rbp)
jmp    1579 <GetECKeyPublic+0x3b9>
mov    -0x10(%rbp),%rdi
mov    -0x50(%rbp),%rsi
call   1030 <EC_KEY_set_public_key@plt>
cmp    $0x0,%eax
jne    14dc <GetECKeyPublic+0x31c>
cmpq   $0x0,-0x38(%rbp)
je     14a8 <GetECKeyPublic+0x2e8>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     14bc <GetECKeyPublic+0x2fc>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     14d0 <GetECKeyPublic+0x310>
mov    -0x50(%rbp),%rdi
call   10d0 <EC_POINT_free@plt>
movl   $0xfffffff8,-0x4(%rbp)
jmp    1579 <GetECKeyPublic+0x3b9>
mov    -0x10(%rbp),%rdi
call   1040 <EC_KEY_check_key@plt>
cmp    $0x0,%eax
jne    1536 <GetECKeyPublic+0x376>
cmpq   $0x0,-0x38(%rbp)
je     1502 <GetECKeyPublic+0x342>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     1516 <GetECKeyPublic+0x356>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     152a <GetECKeyPublic+0x36a>
mov    -0x50(%rbp),%rdi
call   10d0 <EC_POINT_free@plt>
movl   $0xfffffff7,-0x4(%rbp)
jmp    1579 <GetECKeyPublic+0x3b9>
cmpq   $0x0,-0x38(%rbp)
je     154a <GetECKeyPublic+0x38a>
mov    -0x38(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x40(%rbp)
je     155e <GetECKeyPublic+0x39e>
mov    -0x40(%rbp),%rdi
call   1070 <BN_free@plt>
cmpq   $0x0,-0x50(%rbp)
je     1572 <GetECKeyPublic+0x3b2>
mov    -0x50(%rbp),%rdi
call   10d0 <EC_POINT_free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetECKeyPublic>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r12d
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %edx,%ebx
mov    %rsi,%rbp
test   %rdi,%rdi
jne    11e8 <GetECKeyPublic+0x28>
xor    %eax,%eax
call   10b0 <EC_KEY_new@plt>
mov    %rax,%rdi
mov    %rdi,(%rsp)
mov    %rbp,%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,%r13
mov    %r15,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   1060 <BN_bin2bn@plt>
mov    %rax,%r14
test   %r13,%r13
je     122d <GetECKeyPublic+0x6d>
test   %r14,%r14
je     122d <GetECKeyPublic+0x6d>
cmp    $0x1,%r12d
je     1255 <GetECKeyPublic+0x95>
test   %r12d,%r12d
jne    130a <GetECKeyPublic+0x14a>
xor    %eax,%eax
call   1050 <sm2_ec_group@plt>
jmp    125c <GetECKeyPublic+0x9c>
test   %r13,%r13
je     123a <GetECKeyPublic+0x7a>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    $0xffffffff,%ebx
test   %r14,%r14
je     13c7 <GetECKeyPublic+0x207>
mov    %r14,%rdi
call   1070 <BN_free@plt>
jmp    13c7 <GetECKeyPublic+0x207>
xor    %eax,%eax
call   1090 <sm2_ec_group2@plt>
mov    %rax,%rbp
test   %rax,%rax
je     1324 <GetECKeyPublic+0x164>
mov    (%rsp),%rdi
mov    %rbp,%rsi
call   10c0 <EC_KEY_set_group@plt>
test   %eax,%eax
je     133e <GetECKeyPublic+0x17e>
mov    %rbp,%rdi
call   10e0 <EC_POINT_new@plt>
test   %rax,%rax
je     1355 <GetECKeyPublic+0x195>
mov    %rax,%r12
mov    %rbp,%rdi
mov    %rax,%rsi
mov    %r13,%rdx
mov    %r14,%rcx
xor    %r8d,%r8d
call   1080 <EC_POINT_set_affine_coordinates_GFp@plt>
test   %eax,%eax
je     136c <GetECKeyPublic+0x1ac>
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %edx,%edx
call   10a0 <EC_POINT_is_on_curve@plt>
test   %eax,%eax
je     138b <GetECKeyPublic+0x1cb>
mov    (%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rsi
call   1030 <EC_KEY_set_public_key@plt>
test   %eax,%eax
je     13aa <GetECKeyPublic+0x1ea>
mov    %rbx,%rdi
call   1040 <EC_KEY_check_key@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    %r12,%rdi
call   10d0 <EC_POINT_free@plt>
lea    (%rbx,%rbx,8),%ebx
add    $0xfffffff7,%ebx
jmp    13c7 <GetECKeyPublic+0x207>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    $0xfffffff6,%ebx
jmp    13c7 <GetECKeyPublic+0x207>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    $0xfffffffd,%ebx
jmp    13c7 <GetECKeyPublic+0x207>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    $0xfffffffc,%ebx
jmp    13c7 <GetECKeyPublic+0x207>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    $0xfffffffb,%ebx
jmp    13c7 <GetECKeyPublic+0x207>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    %r12,%rdi
call   10d0 <EC_POINT_free@plt>
mov    $0xfffffffa,%ebx
jmp    13c7 <GetECKeyPublic+0x207>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    %r12,%rdi
call   10d0 <EC_POINT_free@plt>
mov    $0xfffffff9,%ebx
jmp    13c7 <GetECKeyPublic+0x207>
mov    %r13,%rdi
call   1070 <BN_free@plt>
mov    %r14,%rdi
call   1070 <BN_free@plt>
mov    %r12,%rdi
call   10d0 <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 @GetECKeyPublic(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
store i32* %0, i32** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i8* %3, i8** %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%18 = load i32*, i32** %8
%19 = icmp ne i32* %18, null
br i1 %19, label %22, label %20
20: ; preds = %6
%21 = call i32* (...) @EC_KEY_new()
store i32* %21, i32** %8
br label %22
22: ; preds = %20, %6
%23 = load i8*, i8** %9
%24 = load i32, i32* %10
%25 = call i32* @BN_bin2bn(i8* %23, i32 %24, i32* null)
store i32* %25, i32** %14
%26 = load i8*, i8** %11
%27 = load i32, i32* %12
%28 = call i32* @BN_bin2bn(i8* %26, i32 %27, i32* null)
store i32* %28, i32** %15
%29 = load i32*, i32** %14
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %34
31: ; preds = %22
%32 = load i32*, i32** %15
%33 = icmp ne i32* %32, null
br i1 %33, label %47, label %34
34: ; preds = %31, %22
%35 = load i32*, i32** %14
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32*, i32** %14
%39 = call i32 @BN_free(i32* %38)
br label %40
40: ; preds = %37, %34
%41 = load i32*, i32** %15
%42 = icmp ne i32* %41, null
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = load i32*, i32** %15
%45 = call i32 @BN_free(i32* %44)
br label %46
46: ; preds = %43, %40
store i32 -1, i32* %7
br label %239
47: ; preds = %31
store i32* null, i32** %16
%48 = load i32, i32* %13
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32* (...) @sm2_ec_group()
store i32* %51, i32** %16
br label %71
52: ; preds = %47
%53 = load i32, i32* %13
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32* (...) @sm2_ec_group2()
store i32* %56, i32** %16
br label %70
57: ; preds = %52
%58 = load i32*, i32** %14
%59 = icmp ne i32* %58, null
br i1 %59, label %60, label %63
60: ; preds = %57
%61 = load i32*, i32** %14
%62 = call i32 @BN_free(i32* %61)
br label %63
63: ; preds = %60, %57
%64 = load i32*, i32** %15
%65 = icmp ne i32* %64, null
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i32*, i32** %15
%68 = call i32 @BN_free(i32* %67)
br label %69
69: ; preds = %66, %63
store i32 -10, i32* %7
br label %239
70: ; preds = %55
br label %71
71: ; preds = %70, %50
%72 = load i32*, i32** %16
%73 = icmp ne i32* %72, null
br i1 %73, label %87, label %74
74: ; preds = %71
%75 = load i32*, i32** %14
%76 = icmp ne i32* %75, null
br i1 %76, label %77, label %80
77: ; preds = %74
%78 = load i32*, i32** %14
%79 = call i32 @BN_free(i32* %78)
br label %80
80: ; preds = %77, %74
%81 = load i32*, i32** %15
%82 = icmp ne i32* %81, null
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = load i32*, i32** %15
%85 = call i32 @BN_free(i32* %84)
br label %86
86: ; preds = %83, %80
store i32 -3, i32* %7
br label %239
87: ; preds = %71
%88 = load i32*, i32** %8
%89 = load i32*, i32** %16
%90 = call i32 @EC_KEY_set_group(i32* %88, i32* %89)
%91 = icmp ne i32 %90, 0
br i1 %91, label %105, label %92
92: ; preds = %87
%93 = load i32*, i32** %14
%94 = icmp ne i32* %93, null
br i1 %94, label %95, label %98
95: ; preds = %92
%96 = load i32*, i32** %14
%97 = call i32 @BN_free(i32* %96)
br label %98
98: ; preds = %95, %92
%99 = load i32*, i32** %15
%100 = icmp ne i32* %99, null
br i1 %100, label %101, label %104
101: ; preds = %98
%102 = load i32*, i32** %15
%103 = call i32 @BN_free(i32* %102)
br label %104
104: ; preds = %101, %98
store i32 -4, i32* %7
br label %239
105: ; preds = %87
%106 = load i32*, i32** %16
%107 = call i32* @EC_POINT_new(i32* %106)
store i32* %107, i32** %17
%108 = load i32*, i32** %17
%109 = icmp ne i32* %108, null
br i1 %109, label %123, label %110
110: ; preds = %105
%111 = load i32*, i32** %14
%112 = icmp ne i32* %111, null
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = load i32*, i32** %14
%115 = call i32 @BN_free(i32* %114)
br label %116
116: ; preds = %113, %110
%117 = load i32*, i32** %15
%118 = icmp ne i32* %117, null
br i1 %118, label %119, label %122
119: ; preds = %116
%120 = load i32*, i32** %15
%121 = call i32 @BN_free(i32* %120)
br label %122
122: ; preds = %119, %116
store i32 -5, i32* %7
br label %239
123: ; preds = %105
%124 = load i32*, i32** %16
%125 = load i32*, i32** %17
%126 = load i32*, i32** %14
%127 = load i32*, i32** %15
%128 = call i32 @EC_POINT_set_affine_coordinates_GFp(i32* %124, i32* %125, i32* %126, i32* %127, i32* null)
%129 = icmp ne i32 %128, 0
br i1 %129, label %149, label %130
130: ; preds = %123
%131 = load i32*, i32** %14
%132 = icmp ne i32* %131, null
br i1 %132, label %133, label %136
133: ; preds = %130
%134 = load i32*, i32** %14
%135 = call i32 @BN_free(i32* %134)
br label %136
136: ; preds = %133, %130
%137 = load i32*, i32** %15
%138 = icmp ne i32* %137, null
br i1 %138, label %139, label %142
139: ; preds = %136
%140 = load i32*, i32** %15
%141 = call i32 @BN_free(i32* %140)
br label %142
142: ; preds = %139, %136
%143 = load i32*, i32** %17
%144 = icmp ne i32* %143, null
br i1 %144, label %145, label %148
145: ; preds = %142
%146 = load i32*, i32** %17
%147 = call i32 @EC_POINT_free(i32* %146)
br label %148
148: ; preds = %145, %142
store i32 -6, i32* %7
br label %239
149: ; preds = %123
%150 = load i32*, i32** %16
%151 = load i32*, i32** %17
%152 = call i32 @EC_POINT_is_on_curve(i32* %150, i32* %151, i32* null)
%153 = icmp ne i32 %152, 0
br i1 %153, label %173, label %154
154: ; preds = %149
%155 = load i32*, i32** %14
%156 = icmp ne i32* %155, null
br i1 %156, label %157, label %160
157: ; preds = %154
%158 = load i32*, i32** %14
%159 = call i32 @BN_free(i32* %158)
br label %160
160: ; preds = %157, %154
%161 = load i32*, i32** %15
%162 = icmp ne i32* %161, null
br i1 %162, label %163, label %166
163: ; preds = %160
%164 = load i32*, i32** %15
%165 = call i32 @BN_free(i32* %164)
br label %166
166: ; preds = %163, %160
%167 = load i32*, i32** %17
%168 = icmp ne i32* %167, null
br i1 %168, label %169, label %172
169: ; preds = %166
%170 = load i32*, i32** %17
%171 = call i32 @EC_POINT_free(i32* %170)
br label %172
172: ; preds = %169, %166
store i32 -7, i32* %7
br label %239
173: ; preds = %149
%174 = load i32*, i32** %8
%175 = load i32*, i32** %17
%176 = call i32 @EC_KEY_set_public_key(i32* %174, i32* %175)
%177 = icmp ne i32 %176, 0
br i1 %177, label %197, label %178
178: ; preds = %173
%179 = load i32*, i32** %14
%180 = icmp ne i32* %179, null
br i1 %180, label %181, label %184
181: ; preds = %178
%182 = load i32*, i32** %14
%183 = call i32 @BN_free(i32* %182)
br label %184
184: ; preds = %181, %178
%185 = load i32*, i32** %15
%186 = icmp ne i32* %185, null
br i1 %186, label %187, label %190
187: ; preds = %184
%188 = load i32*, i32** %15
%189 = call i32 @BN_free(i32* %188)
br label %190
190: ; preds = %187, %184
%191 = load i32*, i32** %17
%192 = icmp ne i32* %191, null
br i1 %192, label %193, label %196
193: ; preds = %190
%194 = load i32*, i32** %17
%195 = call i32 @EC_POINT_free(i32* %194)
br label %196
196: ; preds = %193, %190
store i32 -8, i32* %7
br label %239
197: ; preds = %173
%198 = load i32*, i32** %8
%199 = call i32 @EC_KEY_check_key(i32* %198)
%200 = icmp ne i32 %199, 0
br i1 %200, label %220, label %201
201: ; preds = %197
%202 = load i32*, i32** %14
%203 = icmp ne i32* %202, null
br i1 %203, label %204, label %207
204: ; preds = %201
%205 = load i32*, i32** %14
%206 = call i32 @BN_free(i32* %205)
br label %207
207: ; preds = %204, %201
%208 = load i32*, i32** %15
%209 = icmp ne i32* %208, null
br i1 %209, label %210, label %213
210: ; preds = %207
%211 = load i32*, i32** %15
%212 = call i32 @BN_free(i32* %211)
br label %213
213: ; preds = %210, %207
%214 = load i32*, i32** %17
%215 = icmp ne i32* %214, null
br i1 %215, label %216, label %219
216: ; preds = %213
%217 = load i32*, i32** %17
%218 = call i32 @EC_POINT_free(i32* %217)
br label %219
219: ; preds = %216, %213
store i32 -9, i32* %7
br label %239
220: ; preds = %197
%221 = load i32*, i32** %14
%222 = icmp ne i32* %221, null
br i1 %222, label %223, label %226
223: ; preds = %220
%224 = load i32*, i32** %14
%225 = call i32 @BN_free(i32* %224)
br label %226
226: ; preds = %223, %220
%227 = load i32*, i32** %15
%228 = icmp ne i32* %227, null
br i1 %228, label %229, label %232
229: ; preds = %226
%230 = load i32*, i32** %15
%231 = call i32 @BN_free(i32* %230)
br label %232
232: ; preds = %229, %226
%233 = load i32*, i32** %17
%234 = icmp ne i32* %233, null
br i1 %234, label %235, label %238
235: ; preds = %232
%236 = load i32*, i32** %17
%237 = call i32 @EC_POINT_free(i32* %236)
br label %238
238: ; preds = %235, %232
store i32 0, i32* %7
br label %239
239: ; preds = %238, %219, %196, %172, %148, %122, %104, %86, %69, %46
%240 = load i32, i32* %7
ret i32 %240
}

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