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

/* Variables and functions */
int /*<<< orphan*/ EC_KEY_get0_group(int /*<<< orphan*/ const *);
scalar_t__ EC_KEY_get0_private_key(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_KEY_new();
int /*<<< orphan*/ EC_KEY_set_group(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ ERR_GOST_error(int, int, char *, int);
int /*<<< orphan*/ EVP_PKEY_assign(int /*<<< orphan*/ const *, scalar_t__,
                                   int /*<<< orphan*/ *);
scalar_t__ EVP_PKEY_base_id(int /*<<< orphan*/ const *);
void *EVP_PKEY_get0(int /*<<< orphan*/ const *);
int /*<<< orphan*/ gost2001_compute_public(int /*<<< orphan*/ *);
int param_copy_gost01(EVP_PKEY *to, const EVP_PKEY *from) {
  EC_KEY *eto = EVP_PKEY_get0(to);
  const EC_KEY *efrom = EVP_PKEY_get0((EVP_PKEY *)from);
  if (EVP_PKEY_base_id(from) != EVP_PKEY_base_id(to)) {
    ERR_GOST_error((116), (105),
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/caidongyun/"
                   "nginx-openresty-windows/refs/heads/master/nginx/objs/lib/"
                   "openssl-1.0.1g/engines/ccgost/gost_ameth.c",
                   563);
    return 0;
  }
  if (!efrom) {
    ERR_GOST_error((116), (115),
                   "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/caidongyun/"
                   "nginx-openresty-windows/refs/heads/master/nginx/objs/lib/"
                   "openssl-1.0.1g/engines/ccgost/gost_ameth.c",
                   569);
    return 0;
  }
  if (!eto) {
    eto = EC_KEY_new();
    EVP_PKEY_assign(to, EVP_PKEY_base_id(from), eto);
  }
  EC_KEY_set_group(eto, EC_KEY_get0_group(efrom));
  if (EC_KEY_get0_private_key(eto)) {
    gost2001_compute_public(eto);
  }
  return 1;
}


x86 assembly (clang, -O0):
<param_copy_gost01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <EVP_PKEY_get0@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <EVP_PKEY_get0@plt>
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <EVP_PKEY_base_id@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <EVP_PKEY_base_id@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
je     1207 <param_copy_gost01+0x77>
mov    $0x74,%edi
mov    $0x69,%esi
lea    0xe0f(%rip),%rdx
mov    $0x233,%ecx
call   1090 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    12af <param_copy_gost01+0x11f>
cmpq   $0x0,-0x28(%rbp)
jne    1239 <param_copy_gost01+0xa9>
mov    $0x74,%edi
mov    $0x73,%esi
lea    0xddd(%rip),%rdx
mov    $0x239,%ecx
call   1090 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    12af <param_copy_gost01+0x11f>
cmpq   $0x0,-0x20(%rbp)
jne    1270 <param_copy_gost01+0xe0>
mov    $0x0,%al
call   10a0 <EC_KEY_new@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <EVP_PKEY_base_id@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
mov    -0x20(%rbp),%rdx
call   1080 <EVP_PKEY_assign@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <EC_KEY_get0_group@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,%esi
call   10b0 <EC_KEY_set_group@plt>
mov    -0x20(%rbp),%rdi
call   1060 <EC_KEY_get0_private_key@plt>
cmp    $0x0,%rax
je     12a8 <param_copy_gost01+0x118>
mov    -0x20(%rbp),%rdi
call   1040 <gost2001_compute_public@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<param_copy_gost01>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r13
mov    %rdi,%r12
call   1050 <EVP_PKEY_get0@plt>
mov    %rax,%r15
mov    %r13,%rdi
call   1050 <EVP_PKEY_get0@plt>
mov    %rax,%r14
mov    %r13,%rdi
call   1030 <EVP_PKEY_base_id@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1030 <EVP_PKEY_base_id@plt>
cmp    %rax,%rbx
jne    1222 <param_copy_gost01+0x92>
test   %r14,%r14
je     123a <param_copy_gost01+0xaa>
test   %r15,%r15
jne    11f4 <param_copy_gost01+0x64>
xor    %eax,%eax
call   10a0 <EC_KEY_new@plt>
mov    %rax,%r15
mov    %r13,%rdi
call   1030 <EVP_PKEY_base_id@plt>
mov    %r12,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
call   1080 <EVP_PKEY_assign@plt>
mov    %r14,%rdi
call   1070 <EC_KEY_get0_group@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   10b0 <EC_KEY_set_group@plt>
mov    %r15,%rdi
call   1060 <EC_KEY_get0_private_key@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     1257 <param_copy_gost01+0xc7>
mov    %r15,%rdi
call   1040 <gost2001_compute_public@plt>
jmp    1257 <param_copy_gost01+0xc7>
lea    0xdd7(%rip),%rdx
mov    $0x74,%edi
mov    $0x69,%esi
mov    $0x233,%ecx
jmp    1250 <param_copy_gost01+0xc0>
lea    0xdbf(%rip),%rdx
mov    $0x74,%edi
mov    $0x73,%esi
mov    $0x239,%ecx
call   1090 <ERR_GOST_error@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [201 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/nginx/objs/lib/openssl-1.0.1g/engines/ccgost/gost_ameth.c\00"
define i32 @param_copy_gost01(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
%8 = load i32*, i32** %4
%9 = call i8* @EVP_PKEY_get0(i32* %8)
%10 = bitcast i8* %9 to i32*
store i32* %10, i32** %6
%11 = load i32*, i32** %5
%12 = call i8* @EVP_PKEY_get0(i32* %11)
%13 = bitcast i8* %12 to i32*
store i32* %13, i32** %7
%14 = load i32*, i32** %5
%15 = call i64 @EVP_PKEY_base_id(i32* %14)
%16 = load i32*, i32** %4
%17 = call i64 @EVP_PKEY_base_id(i32* %16)
%18 = icmp ne i64 %15, %17
br i1 %18, label %19, label %21
19: ; preds = %2
%20 = call i32 @ERR_GOST_error(i32 116, i32 105, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0), i32 563)
store i32 0, i32* %3
br label %48
21: ; preds = %2
%22 = load i32*, i32** %7
%23 = icmp ne i32* %22, null
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = call i32 @ERR_GOST_error(i32 116, i32 115, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0), i32 569)
store i32 0, i32* %3
br label %48
26: ; preds = %21
%27 = load i32*, i32** %6
%28 = icmp ne i32* %27, null
br i1 %28, label %36, label %29
29: ; preds = %26
%30 = call i32* (...) @EC_KEY_new()
store i32* %30, i32** %6
%31 = load i32*, i32** %4
%32 = load i32*, i32** %5
%33 = call i64 @EVP_PKEY_base_id(i32* %32)
%34 = load i32*, i32** %6
%35 = call i32 @EVP_PKEY_assign(i32* %31, i64 %33, i32* %34)
br label %36
36: ; preds = %29, %26
%37 = load i32*, i32** %6
%38 = load i32*, i32** %7
%39 = call i32 @EC_KEY_get0_group(i32* %38)
%40 = call i32 @EC_KEY_set_group(i32* %37, i32 %39)
%41 = load i32*, i32** %6
%42 = call i64 @EC_KEY_get0_private_key(i32* %41)
%43 = icmp ne i64 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %36
%45 = load i32*, i32** %6
%46 = call i32 @gost2001_compute_public(i32* %45)
br label %47
47: ; preds = %44, %36
store i32 1, i32* %3
br label %48
48: ; preds = %47, %24, %19
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [201 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/nginx/objs/lib/openssl-1.0.1g/engines/ccgost/gost_ameth.c\00"
define i32 @param_copy_gost01(i32* %0, i32* %1) {
%3 = tail call i8* @EVP_PKEY_get0(i32* %0)
%4 = bitcast i8* %3 to i32*
%5 = tail call i8* @EVP_PKEY_get0(i32* %1)
%6 = bitcast i8* %5 to i32*
%7 = tail call i64 @EVP_PKEY_base_id(i32* %1)
%8 = tail call i64 @EVP_PKEY_base_id(i32* %0)
%9 = icmp eq i64 %7, %8
br i1 %9, label %12, label %10
10: ; preds = %2
%11 = tail call i32 @ERR_GOST_error(i32 116, i32 105, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0), i32 563)
br label %30
12: ; preds = %2
%13 = icmp eq i8* %5, null
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = tail call i32 @ERR_GOST_error(i32 116, i32 115, i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0), i32 569)
br label %30
16: ; preds = %12
%17 = icmp eq i8* %3, null
br i1 %17, label %18, label %22
18: ; preds = %16
%19 = tail call i32* (...) @EC_KEY_new()
%20 = tail call i64 @EVP_PKEY_base_id(i32* %1)
%21 = tail call i32 @EVP_PKEY_assign(i32* %0, i64 %20, i32* %19)
br label %22
22: ; preds = %18, %16
%23 = phi i32* [ %4, %16 ], [ %19, %18 ]
%24 = tail call i32 @EC_KEY_get0_group(i32* %6)
%25 = tail call i32 @EC_KEY_set_group(i32* %23, i32 %24)
%26 = tail call i64 @EC_KEY_get0_private_key(i32* %23)
%27 = icmp eq i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %22
%29 = tail call i32 @gost2001_compute_public(i32* %23)
br label %30
30: ; preds = %22, %28, %14, %10
%31 = phi i32 [ 0, %10 ], [ 0, %14 ], [ 1, %28 ], [ 1, %22 ]
ret i32 %31
}