#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*/ BN_CTX;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ BN_CTX_end(int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_CTX_new();
int /*<<< orphan*/ BN_CTX_start(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_KEY_get0_group(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_KEY_get0_private_key(int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_KEY_set_public_key(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_POINT_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_POINT_mul(int /*<<< orphan*/ const *,
                                int /*<<< orphan*/ *,
                                int /*<<< orphan*/ const *,
                                int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_POINT_new(int /*<<< orphan*/ const *);
int /*<<< orphan*/ ERR_GOST_error(int, int, char *, int);
int ERR_R_EC_LIB;
int gost2001_compute_public(EC_KEY *ec) {
  const EC_GROUP *group = EC_KEY_get0_group(ec);
  EC_POINT *pub_key = NULL;
  const BIGNUM *priv_key = NULL;
  BN_CTX *ctx = NULL;
  int ok = 0;
  if (!group) {
    ERR_GOST_error((104), (114),
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/caidongyun/"
                   "nginx-openresty-windows/refs/heads/master/Ouroboros/"
                   "External/OpenSSL/openssl-1.0.0e/engines/ccgost/gost2001.c",
                   286);
    return 0;
  }
  ctx = BN_CTX_new();
  BN_CTX_start(ctx);
  if (!(priv_key = EC_KEY_get0_private_key(ec))) {
    ERR_GOST_error((104), (ERR_R_EC_LIB),
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/caidongyun/"
                   "nginx-openresty-windows/refs/heads/master/Ouroboros/"
                   "External/OpenSSL/openssl-1.0.0e/engines/ccgost/gost2001.c",
                   293);
    goto err;
  }
  pub_key = EC_POINT_new(group);
  if (!EC_POINT_mul(group, pub_key, priv_key, NULL, NULL, ctx)) {
    ERR_GOST_error((104), (ERR_R_EC_LIB),
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/caidongyun/"
                   "nginx-openresty-windows/refs/heads/master/Ouroboros/"
                   "External/OpenSSL/openssl-1.0.0e/engines/ccgost/gost2001.c",
                   300);
    goto err;
  }
  if (!EC_KEY_set_public_key(ec, pub_key)) {
    ERR_GOST_error((104), (ERR_R_EC_LIB),
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/caidongyun/"
                   "nginx-openresty-windows/refs/heads/master/Ouroboros/"
                   "External/OpenSSL/openssl-1.0.0e/engines/ccgost/gost2001.c",
                   305);
    goto err;
  }
  ok = 256;
err:
  BN_CTX_end(ctx);
  EC_POINT_free(pub_key);
  BN_CTX_free(ctx);
  return ok;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   10a0 <EC_KEY_get0_group@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121a <gost2001_compute_public+0x6a>
mov    $0x68,%edi
mov    $0x72,%esi
lea    0xdfc(%rip),%rdx
mov    $0x11e,%ecx
call   10b0 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    1322 <gost2001_compute_public+0x172>
mov    $0x0,%al
call   1090 <BN_CTX_new@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1080 <BN_CTX_start@plt>
mov    -0x10(%rbp),%rdi
call   1050 <EC_KEY_get0_private_key@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1269 <gost2001_compute_public+0xb9>
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
mov    $0x68,%edi
lea    0xda6(%rip),%rdx
mov    $0x125,%ecx
call   10b0 <ERR_GOST_error@plt>
jmp    1301 <gost2001_compute_public+0x151>
mov    -0x18(%rbp),%rdi
call   10d0 <EC_POINT_new@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%r9
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rcx
call   1040 <EC_POINT_mul@plt>
cmp    $0x0,%eax
jne    12c0 <gost2001_compute_public+0x110>
mov    0x2d45(%rip),%rax
mov    (%rax),%esi
mov    $0x68,%edi
lea    0xd4f(%rip),%rdx
mov    $0x12c,%ecx
call   10b0 <ERR_GOST_error@plt>
jmp    1301 <gost2001_compute_public+0x151>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <EC_KEY_set_public_key@plt>
cmp    $0x0,%eax
jne    12fa <gost2001_compute_public+0x14a>
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
mov    $0x68,%edi
lea    0xd15(%rip),%rdx
mov    $0x131,%ecx
call   10b0 <ERR_GOST_error@plt>
jmp    1301 <gost2001_compute_public+0x151>
movl   $0x100,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
call   1070 <BN_CTX_end@plt>
mov    -0x20(%rbp),%rdi
call   10c0 <EC_POINT_free@plt>
mov    -0x30(%rbp),%rdi
call   1060 <BN_CTX_free@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
call   10a0 <EC_KEY_get0_group@plt>
test   %rax,%rax
je     122c <gost2001_compute_public+0x7c>
mov    %rax,%rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1090 <BN_CTX_new@plt>
mov    %rax,%r12
mov    %rax,%rdi
call   1080 <BN_CTX_start@plt>
mov    %r13,%rdi
call   1050 <EC_KEY_get0_private_key@plt>
test   %rax,%rax
je     124c <gost2001_compute_public+0x9c>
mov    %rax,%rbp
mov    %rbx,%rdi
call   10d0 <EC_POINT_new@plt>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %rax,%rsi
mov    %rbp,%rdx
xor    %ecx,%ecx
xor    %r8d,%r8d
mov    %r12,%r9
call   1040 <EC_POINT_mul@plt>
test   %eax,%eax
je     1256 <gost2001_compute_public+0xa6>
mov    %r13,%rdi
mov    %r15,%rsi
call   1030 <EC_KEY_set_public_key@plt>
test   %eax,%eax
je     125d <gost2001_compute_public+0xad>
mov    $0x100,%r14d
jmp    127c <gost2001_compute_public+0xcc>
lea    0xdcd(%rip),%rdx
mov    $0x68,%edi
mov    $0x72,%esi
mov    $0x11e,%ecx
call   10b0 <ERR_GOST_error@plt>
xor    %r14d,%r14d
jmp    1294 <gost2001_compute_public+0xe4>
mov    $0x125,%ecx
xor    %r15d,%r15d
jmp    1262 <gost2001_compute_public+0xb2>
mov    $0x12c,%ecx
jmp    1262 <gost2001_compute_public+0xb2>
mov    $0x131,%ecx
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
lea    0xd8e(%rip),%rdx
mov    $0x68,%edi
call   10b0 <ERR_GOST_error@plt>
mov    %r12,%rdi
call   1070 <BN_CTX_end@plt>
mov    %r15,%rdi
call   10c0 <EC_POINT_free@plt>
mov    %r12,%rdi
call   1060 <BN_CTX_free@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [211 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/caidongyun/nginx-openresty-windows/refs/heads/master/Ouroboros/External/OpenSSL/openssl-1.0.0e/engines/ccgost/gost2001.c\00"
@ERR_R_EC_LIB = global i32 0
define i32 @gost2001_compute_public(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32* %0, i32** %3
%9 = load i32*, i32** %3
%10 = call i32* @EC_KEY_get0_group(i32* %9)
store i32* %10, i32** %4
store i32* null, i32** %5
store i32* null, i32** %6
store i32* null, i32** %7
store i32 0, i32* %8
%11 = load i32*, i32** %4
%12 = icmp ne i32* %11, null
br i1 %12, label %15, label %13
13: ; preds = %1
%14 = call i32 @ERR_GOST_error(i32 104, i32 114, i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str, i64 0, i64 0), i32 286)
store i32 0, i32* %2
br label %54
15: ; preds = %1
%16 = call i32* (...) @BN_CTX_new()
store i32* %16, i32** %7
%17 = load i32*, i32** %7
%18 = call i32 @BN_CTX_start(i32* %17)
%19 = load i32*, i32** %3
%20 = call i32* @EC_KEY_get0_private_key(i32* %19)
store i32* %20, i32** %6
%21 = icmp ne i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %15
%23 = load i32, i32* @ERR_R_EC_LIB
%24 = call i32 @ERR_GOST_error(i32 104, i32 %23, i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str, i64 0, i64 0), i32 293)
br label %46
25: ; preds = %15
%26 = load i32*, i32** %4
%27 = call i32* @EC_POINT_new(i32* %26)
store i32* %27, i32** %5
%28 = load i32*, i32** %4
%29 = load i32*, i32** %5
%30 = load i32*, i32** %6
%31 = load i32*, i32** %7
%32 = call i32 @EC_POINT_mul(i32* %28, i32* %29, i32* %30, i32* null, i32* null, i32* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %25
%35 = load i32, i32* @ERR_R_EC_LIB
%36 = call i32 @ERR_GOST_error(i32 104, i32 %35, i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str, i64 0, i64 0), i32 300)
br label %46
37: ; preds = %25
%38 = load i32*, i32** %3
%39 = load i32*, i32** %5
%40 = call i32 @EC_KEY_set_public_key(i32* %38, i32* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %37
%43 = load i32, i32* @ERR_R_EC_LIB
%44 = call i32 @ERR_GOST_error(i32 104, i32 %43, i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str, i64 0, i64 0), i32 305)
br label %46
45: ; preds = %37
store i32 256, i32* %8
br label %46
46: ; preds = %45, %42, %34, %22
%47 = load i32*, i32** %7
%48 = call i32 @BN_CTX_end(i32* %47)
%49 = load i32*, i32** %5
%50 = call i32 @EC_POINT_free(i32* %49)
%51 = load i32*, i32** %7
%52 = call i32 @BN_CTX_free(i32* %51)
%53 = load i32, i32* %8
store i32 %53, i32* %2
br label %54
54: ; preds = %46, %13
%55 = load i32, i32* %2
ret i32 %55
}

LLVM IR (-O2):
@.str = [211 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/caidongyun/nginx-openresty-windows/refs/heads/master/Ouroboros/External/OpenSSL/openssl-1.0.0e/engines/ccgost/gost2001.c\00"
@ERR_R_EC_LIB = global i32 0
define i32 @gost2001_compute_public(i32* %0) {
%2 = tail call i32* @EC_KEY_get0_group(i32* %0)
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @ERR_GOST_error(i32 104, i32 114, i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str, i64 0, i64 0), i32 286)
br label %29
6: ; preds = %1
%7 = tail call i32* (...) @BN_CTX_new()
%8 = tail call i32 @BN_CTX_start(i32* %7)
%9 = tail call i32* @EC_KEY_get0_private_key(i32* %0)
%10 = icmp eq i32* %9, null
br i1 %10, label %18, label %11
11: ; preds = %6
%12 = tail call i32* @EC_POINT_new(i32* %2)
%13 = tail call i32 @EC_POINT_mul(i32* %2, i32* %12, i32* %9, i32* null, i32* null, i32* %7)
%14 = icmp eq i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %11
%16 = tail call i32 @EC_KEY_set_public_key(i32* %0, i32* %12)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %15, %11, %6
%19 = phi i32 [ 293, %6 ], [ 300, %11 ], [ 305, %15 ]
%20 = phi i32* [ null, %6 ], [ %12, %11 ], [ %12, %15 ]
%21 = load i32, i32* @ERR_R_EC_LIB
%22 = tail call i32 @ERR_GOST_error(i32 104, i32 %21, i8* getelementptr inbounds ([211 x i8], [211 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %23
23: ; preds = %18, %15
%24 = phi i32* [ %12, %15 ], [ %20, %18 ]
%25 = phi i32 [ 256, %15 ], [ 0, %18 ]
%26 = tail call i32 @BN_CTX_end(i32* %7)
%27 = tail call i32 @EC_POINT_free(i32* %24)
%28 = tail call i32 @BN_CTX_free(i32* %7)
br label %29
29: ; preds = %23, %4
%30 = phi i32 [ %25, %23 ], [ 0, %4 ]
ret i32 %30
}