#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*/ uint8_t;
typedef int /*<<< orphan*/ EC_KEY;

/* Variables and functions */
int /*<<< orphan*/ EC_KEY_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_KEY_new_by_curve_name(int /*<<< orphan*/);
int EC_KEY_oct2key(int /*<<< orphan*/ *, int /*<<< orphan*/ const *, size_t,
                   int /*<<< orphan*/ *);
int /*<<< orphan*/ NID_X9_62_prime256v1;
EC_KEY *ece_import_public_key(const uint8_t *rawKey, size_t rawKeyLen) {
  EC_KEY *key = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1);
  if (!key) {
    return NULL;
  }
  if (EC_KEY_oct2key(key, rawKey, rawKeyLen, NULL) != 1) {
    EC_KEY_free(key);
    return NULL;
  }
  return key;
}


x86 assembly (clang, -O0):
<ece_import_public_key>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
call   1050 <EC_KEY_new_by_curve_name@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116a <ece_import_public_key+0x3a>
movq   $0x0,-0x8(%rbp)
jmp    11a6 <ece_import_public_key+0x76>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <EC_KEY_oct2key@plt>
cmp    $0x1,%eax
je     119e <ece_import_public_key+0x6e>
mov    -0x20(%rbp),%rdi
call   1040 <EC_KEY_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11a6 <ece_import_public_key+0x76>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ece_import_public_key>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
call   1050 <EC_KEY_new_by_curve_name@plt>
test   %rax,%rax
je     116e <ece_import_public_key+0x3e>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1030 <EC_KEY_oct2key@plt>
cmp    $0x1,%eax
je     1170 <ece_import_public_key+0x40>
mov    %rbx,%rdi
call   1040 <EC_KEY_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@NID_X9_62_prime256v1 = global i32 0
define i32* @ece_import_public_key(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i64
%6 = alloca i32*
store i32* %0, i32** %4
store i64 %1, i64* %5
%7 = load i32, i32* @NID_X9_62_prime256v1
%8 = call i32* @EC_KEY_new_by_curve_name(i32 %7)
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp ne i32* %9, null
br i1 %10, label %12, label %11
11: ; preds = %2
store i32* null, i32** %3
br label %23
12: ; preds = %2
%13 = load i32*, i32** %6
%14 = load i32*, i32** %4
%15 = load i64, i64* %5
%16 = call i32 @EC_KEY_oct2key(i32* %13, i32* %14, i64 %15, i32* null)
%17 = icmp ne i32 %16, 1
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i32*, i32** %6
%20 = call i32 @EC_KEY_free(i32* %19)
store i32* null, i32** %3
br label %23
21: ; preds = %12
%22 = load i32*, i32** %6
store i32* %22, i32** %3
br label %23
23: ; preds = %21, %18, %11
%24 = load i32*, i32** %3
ret i32* %24
}

LLVM IR (-O2):
@NID_X9_62_prime256v1 = global i32 0
define i32* @ece_import_public_key(i32* %0, i64 %1) {
%3 = load i32, i32* @NID_X9_62_prime256v1
%4 = tail call i32* @EC_KEY_new_by_curve_name(i32 %3)
%5 = icmp eq i32* %4, null
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = tail call i32 @EC_KEY_oct2key(i32* %4, i32* %0, i64 %1, i32* null)
%8 = icmp eq i32 %7, 1
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @EC_KEY_free(i32* %4)
br label %11
11: ; preds = %6, %2, %9
%12 = phi i32* [ null, %9 ], [ null, %2 ], [ %4, %6 ]
ret i32* %12
}