#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 ERR_R_INTERNAL_ERROR;
int ERR_R_MALLOC_FAILURE;
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/Orav/kbengine/refs/heads/master/kbe/src/lib/"
        "dependencies/openssl/engines/ccgost/gost_ameth.c",
        549);
    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/Orav/kbengine/refs/heads/master/kbe/src/lib/"
        "dependencies/openssl/engines/ccgost/gost_ameth.c",
        553);
    return 0;
  }
  if (!eto) {
    eto = EC_KEY_new();
    if (!eto) {
      ERR_GOST_error(
          (116), (ERR_R_MALLOC_FAILURE),
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/Orav/kbengine/refs/heads/master/kbe/src/"
          "lib/dependencies/openssl/engines/ccgost/gost_ameth.c",
          559);
      return 0;
    }
    if (!EVP_PKEY_assign(to, EVP_PKEY_base_id(from), eto)) {
      ERR_GOST_error(
          (116), (ERR_R_INTERNAL_ERROR),
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/Orav/kbengine/refs/heads/master/kbe/src/"
          "lib/dependencies/openssl/engines/ccgost/gost_ameth.c",
          563);
      return 0;
    }
  }
  if (!EC_KEY_set_group(eto, EC_KEY_get0_group(efrom))) {
    ERR_GOST_error(
        (116), (ERR_R_INTERNAL_ERROR),
        "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
        "2022-01-22/02-19-57/repos/Orav/kbengine/refs/heads/master/kbe/src/lib/"
        "dependencies/openssl/engines/ccgost/gost_ameth.c",
        568);
    return 0;
  }
  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    $0x225,%ecx
call   1090 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    1352 <param_copy_gost01+0x1c2>
cmpq   $0x0,-0x28(%rbp)
jne    1239 <param_copy_gost01+0xa9>
mov    $0x74,%edi
mov    $0x73,%esi
lea    0xddd(%rip),%rdx
mov    $0x229,%ecx
call   1090 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    1352 <param_copy_gost01+0x1c2>
cmpq   $0x0,-0x20(%rbp)
jne    12df <param_copy_gost01+0x14f>
mov    $0x0,%al
call   10a0 <EC_KEY_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1285 <param_copy_gost01+0xf5>
mov    0x2d87(%rip),%rax
mov    (%rax),%esi
mov    $0x74,%edi
lea    0xd91(%rip),%rdx
mov    $0x22f,%ecx
call   1090 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    1352 <param_copy_gost01+0x1c2>
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>
cmp    $0x0,%eax
jne    12da <param_copy_gost01+0x14a>
mov    0x2d2a(%rip),%rax
mov    (%rax),%esi
mov    $0x74,%edi
lea    0xd3c(%rip),%rdx
mov    $0x233,%ecx
call   1090 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    1352 <param_copy_gost01+0x1c2>
jmp    12df <param_copy_gost01+0x14f>
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>
cmp    $0x0,%eax
jne    132f <param_copy_gost01+0x19f>
mov    0x2cd5(%rip),%rax
mov    (%rax),%esi
mov    $0x74,%edi
lea    0xce7(%rip),%rdx
mov    $0x238,%ecx
call   1090 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    1352 <param_copy_gost01+0x1c2>
mov    -0x20(%rbp),%rdi
call   1060 <EC_KEY_get0_private_key@plt>
cmp    $0x0,%rax
je     134b <param_copy_gost01+0x1bb>
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   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbp
mov    %rdi,%r13
call   1050 <EVP_PKEY_get0@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1050 <EVP_PKEY_get0@plt>
mov    %rax,%r15
mov    %rbp,%rdi
call   1030 <EVP_PKEY_base_id@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1030 <EVP_PKEY_base_id@plt>
cmp    %rax,%rbx
jne    1214 <param_copy_gost01+0x84>
test   %r15,%r15
je     122c <param_copy_gost01+0x9c>
test   %r14,%r14
je     1244 <param_copy_gost01+0xb4>
mov    %r15,%rdi
call   1070 <EC_KEY_get0_group@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   10b0 <EC_KEY_set_group@plt>
test   %eax,%eax
je     1290 <param_copy_gost01+0x100>
mov    %r14,%rdi
call   1060 <EC_KEY_get0_private_key@plt>
mov    $0x1,%r12d
test   %rax,%rax
je     12b2 <param_copy_gost01+0x122>
mov    %r14,%rdi
call   1040 <gost2001_compute_public@plt>
jmp    12b2 <param_copy_gost01+0x122>
lea    0xde5(%rip),%rdx
mov    $0x74,%edi
mov    $0x69,%esi
mov    $0x225,%ecx
jmp    12aa <param_copy_gost01+0x11a>
lea    0xdcd(%rip),%rdx
mov    $0x74,%edi
mov    $0x73,%esi
mov    $0x229,%ecx
jmp    12aa <param_copy_gost01+0x11a>
xor    %r12d,%r12d
xor    %eax,%eax
call   10a0 <EC_KEY_new@plt>
test   %rax,%rax
je     12c4 <param_copy_gost01+0x134>
mov    %rax,%r14
mov    %rbp,%rdi
call   1030 <EVP_PKEY_base_id@plt>
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r14,%rdx
call   1080 <EVP_PKEY_assign@plt>
test   %eax,%eax
jne    11d6 <param_copy_gost01+0x46>
mov    0x2d65(%rip),%rax
mov    (%rax),%esi
lea    0xd7c(%rip),%rdx
mov    $0x74,%edi
mov    $0x233,%ecx
jmp    12aa <param_copy_gost01+0x11a>
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
lea    0xd60(%rip),%rdx
mov    $0x74,%edi
mov    $0x238,%ecx
call   1090 <ERR_GOST_error@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d1d(%rip),%rax
mov    (%rax),%esi
lea    0xd2c(%rip),%rdx
mov    $0x74,%edi
mov    $0x22f,%ecx
call   1090 <ERR_GOST_error@plt>
jmp    12b2 <param_copy_gost01+0x122>

LLVM IR (-O0):
@.str = [183 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Orav/kbengine/refs/heads/master/kbe/src/lib/dependencies/openssl/engines/ccgost/gost_ameth.c\00"
@ERR_R_MALLOC_FAILURE = global i32 0
@ERR_R_INTERNAL_ERROR = global i32 0
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 ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 549)
store i32 0, i32* %3
br label %64
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 ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 553)
store i32 0, i32* %3
br label %64
26: ; preds = %21
%27 = load i32*, i32** %6
%28 = icmp ne i32* %27, null
br i1 %28, label %47, label %29
29: ; preds = %26
%30 = call i32* (...) @EC_KEY_new()
store i32* %30, i32** %6
%31 = load i32*, i32** %6
%32 = icmp ne i32* %31, null
br i1 %32, label %36, label %33
33: ; preds = %29
%34 = load i32, i32* @ERR_R_MALLOC_FAILURE
%35 = call i32 @ERR_GOST_error(i32 116, i32 %34, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 559)
store i32 0, i32* %3
br label %64
36: ; preds = %29
%37 = load i32*, i32** %4
%38 = load i32*, i32** %5
%39 = call i64 @EVP_PKEY_base_id(i32* %38)
%40 = load i32*, i32** %6
%41 = call i32 @EVP_PKEY_assign(i32* %37, i64 %39, i32* %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %36
%44 = load i32, i32* @ERR_R_INTERNAL_ERROR
%45 = call i32 @ERR_GOST_error(i32 116, i32 %44, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 563)
store i32 0, i32* %3
br label %64
46: ; preds = %36
br label %47
47: ; preds = %46, %26
%48 = load i32*, i32** %6
%49 = load i32*, i32** %7
%50 = call i32 @EC_KEY_get0_group(i32* %49)
%51 = call i32 @EC_KEY_set_group(i32* %48, i32 %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %47
%54 = load i32, i32* @ERR_R_INTERNAL_ERROR
%55 = call i32 @ERR_GOST_error(i32 116, i32 %54, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 568)
store i32 0, i32* %3
br label %64
56: ; preds = %47
%57 = load i32*, i32** %6
%58 = call i64 @EC_KEY_get0_private_key(i32* %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %56
%61 = load i32*, i32** %6
%62 = call i32 @gost2001_compute_public(i32* %61)
br label %63
63: ; preds = %60, %56
store i32 1, i32* %3
br label %64
64: ; preds = %63, %53, %43, %33, %24, %19
%65 = load i32, i32* %3
ret i32 %65
}

LLVM IR (-O2):
@.str = [183 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Orav/kbengine/refs/heads/master/kbe/src/lib/dependencies/openssl/engines/ccgost/gost_ameth.c\00"
@ERR_R_MALLOC_FAILURE = global i32 0
@ERR_R_INTERNAL_ERROR = global i32 0
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 ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 549)
br label %44
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 ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 553)
br label %44
16: ; preds = %12
%17 = icmp eq i8* %3, null
br i1 %17, label %18, label %31
18: ; preds = %16
%19 = tail call i32* (...) @EC_KEY_new()
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @ERR_R_MALLOC_FAILURE
%23 = tail call i32 @ERR_GOST_error(i32 116, i32 %22, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 559)
br label %44
24: ; preds = %18
%25 = tail call i64 @EVP_PKEY_base_id(i32* %1)
%26 = tail call i32 @EVP_PKEY_assign(i32* %0, i64 %25, i32* %19)
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %24
%29 = load i32, i32* @ERR_R_INTERNAL_ERROR
%30 = tail call i32 @ERR_GOST_error(i32 116, i32 %29, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 563)
br label %44
31: ; preds = %24, %16
%32 = phi i32* [ %4, %16 ], [ %19, %24 ]
%33 = tail call i32 @EC_KEY_get0_group(i32* %6)
%34 = tail call i32 @EC_KEY_set_group(i32* %32, i32 %33)
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load i32, i32* @ERR_R_INTERNAL_ERROR
%38 = tail call i32 @ERR_GOST_error(i32 116, i32 %37, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 568)
br label %44
39: ; preds = %31
%40 = tail call i64 @EC_KEY_get0_private_key(i32* %32)
%41 = icmp eq i64 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = tail call i32 @gost2001_compute_public(i32* %32)
br label %44
44: ; preds = %39, %42, %36, %28, %21, %14, %10
%45 = phi i32 [ 0, %10 ], [ 0, %36 ], [ 0, %28 ], [ 0, %21 ], [ 0, %14 ], [ 1, %42 ], [ 1, %39 ]
ret i32 %45
}