#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_KEY;

/* Variables and functions */
int ECDSA_verify(int /*<<< orphan*/, unsigned char const *, int,
                 unsigned char const *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_KEY_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_KEY_new();
int /*<<< orphan*/ ec_keys(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                           int /*<<< orphan*/, unsigned char const *, int, int);
int ec_verify(const unsigned char *hash, int hash_len, const unsigned char *sig,
              int sig_len, const unsigned char *pub_key, int pub_key_len,
              int curve_id) {
  EC_KEY *keys = EC_KEY_new();
  ec_keys(keys, NULL, 0, pub_key, pub_key_len, curve_id);
  int result = ECDSA_verify(0, hash, hash_len, sig, sig_len, keys);
  EC_KEY_free(keys);
  return result;
}


x86 assembly (clang, -O0):
<ec_verify>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
mov    $0x0,%al
call   1040 <EC_KEY_new@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    0x10(%rbp),%r9d
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <ec_keys@plt>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x38(%rbp),%r9
xor    %edi,%edi
call   1050 <ECDSA_verify@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <EC_KEY_free@plt>
mov    -0x3c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ec_verify>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%ebp
mov    %r8,%rbx
mov    %ecx,0x4(%rsp)
mov    %rdx,%r15
mov    %esi,%r12d
mov    %rdi,%r13
xor    %eax,%eax
call   1040 <EC_KEY_new@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    %rbx,%rcx
mov    %ebp,%r8d
mov    0x40(%rsp),%r9d
call   1060 <ec_keys@plt>
xor    %edi,%edi
mov    %r13,%rsi
mov    %r12d,%edx
mov    %r15,%rcx
mov    0x4(%rsp),%r8d
mov    %r14,%r9
call   1050 <ECDSA_verify@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1030 <EC_KEY_free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ec_verify(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
store i8* %0, i8** %8
store i32 %1, i32* %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%17 = call i32* (...) @EC_KEY_new()
store i32* %17, i32** %15
%18 = load i32*, i32** %15
%19 = load i8*, i8** %12
%20 = load i32, i32* %13
%21 = load i32, i32* %14
%22 = call i32 @ec_keys(i32* %18, i32* null, i32 0, i8* %19, i32 %20, i32 %21)
%23 = load i8*, i8** %8
%24 = load i32, i32* %9
%25 = load i8*, i8** %10
%26 = load i32, i32* %11
%27 = load i32*, i32** %15
%28 = call i32 @ECDSA_verify(i32 0, i8* %23, i32 %24, i8* %25, i32 %26, i32* %27)
store i32 %28, i32* %16
%29 = load i32*, i32** %15
%30 = call i32 @EC_KEY_free(i32* %29)
%31 = load i32, i32* %16
ret i32 %31
}

LLVM IR (-O2):
define i32 @ec_verify(i8* %0, i32 %1, i8* %2, i32 %3, i8* %4, i32 %5, i32 %6) {
%8 = tail call i32* (...) @EC_KEY_new()
%9 = tail call i32 @ec_keys(i32* %8, i32* null, i32 0, i8* %4, i32 %5, i32 %6)
%10 = tail call i32 @ECDSA_verify(i32 0, i8* %0, i32 %1, i8* %2, i32 %3, i32* %8)
%11 = tail call i32 @EC_KEY_free(i32* %8)
ret i32 %10
}