#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ X509_PUBKEY;
typedef int /*<<< orphan*/ X509_ALGOR;
struct TYPE_4__ {
  int length;
  unsigned char *data;
};
typedef int /*<<< orphan*/ EVP_PKEY;
typedef int /*<<< orphan*/ EC_POINT;
typedef int /*<<< orphan*/ EC_GROUP;
typedef int /*<<< orphan*/ BIGNUM;
typedef TYPE_1__ ASN1_OCTET_STRING;
typedef int /*<<< orphan*/ ASN1_OBJECT;

/* Variables and functions */
int /*<<< orphan*/ ASN1_OCTET_STRING_free(TYPE_1__ *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_KEY_get0_group(int /*<<< orphan*/);
int /*<<< orphan*/ EC_KEY_set_public_key(int /*<<< orphan*/,
                                         int /*<<< orphan*/ *);
int /*<<< orphan*/ EC_POINT_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EC_POINT_new(int /*<<< orphan*/ const *);
int /*<<< orphan*/
EC_POINT_set_affine_coordinates_GFp(int /*<<< orphan*/ const *,
                                    int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                    int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_GOST_error(int, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ ERR_R_EC_LIB;
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ EVP_PKEY_assign(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_PKEY_get0(int /*<<< orphan*/ *);
int /*<<< orphan*/ OBJ_obj2nid(int /*<<< orphan*/ *);
int /*<<< orphan*/ OPENSSL_free(unsigned char *);
unsigned char *OPENSSL_malloc(int);
int /*<<< orphan*/ X509_PUBKEY_get0_param(int /*<<< orphan*/ **,
                                          unsigned char const **, int *,
                                          int /*<<< orphan*/ **,
                                          int /*<<< orphan*/ *);
TYPE_1__ *d2i_ASN1_OCTET_STRING(int /*<<< orphan*/ *, unsigned char const **,
                                int);
int /*<<< orphan*/ decode_gost_algor_params(int /*<<< orphan*/ *,
                                            int /*<<< orphan*/ *);
int /*<<< orphan*/ *getbnfrombuf(unsigned char *, int);
int pub_decode_gost01(EVP_PKEY *pk, X509_PUBKEY *pub) {
  X509_ALGOR *palg = NULL;
  const unsigned char *pubkey_buf = NULL;
  unsigned char *databuf;
  ASN1_OBJECT *palgobj = NULL;
  int pub_len, i, j;
  EC_POINT *pub_key;
  BIGNUM *X, *Y;
  ASN1_OCTET_STRING *octet = NULL;
  int len;
  const EC_GROUP *group;
  if (!X509_PUBKEY_get0_param(&palgobj, &pubkey_buf, &pub_len, &palg, pub))
    return 0;
  EVP_PKEY_assign(pk, OBJ_obj2nid(palgobj), NULL);
  if (!decode_gost_algor_params(pk, palg))
    return 0;
  group = EC_KEY_get0_group(EVP_PKEY_get0(pk));
  octet = d2i_ASN1_OCTET_STRING(NULL, &pubkey_buf, pub_len);
  if (!octet) {
    ERR_GOST_error(
        (133), (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",
        685);
    return 0;
  }
  databuf = OPENSSL_malloc(octet->length);
  for (i = 0, j = octet->length - 1; i < octet->length; i++, j--) {
    databuf[j] = octet->data[i];
  }
  len = octet->length / 2;
  ASN1_OCTET_STRING_free(octet);
  Y = getbnfrombuf(databuf, len);
  X = getbnfrombuf(databuf + len, len);
  OPENSSL_free(databuf);
  pub_key = EC_POINT_new(group);
  if (!EC_POINT_set_affine_coordinates_GFp(group, pub_key, X, Y, NULL)) {
    ERR_GOST_error(
        (133), (ERR_R_EC_LIB),
        "/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",
        700);
    EC_POINT_free(pub_key);
    BN_free(X);
    BN_free(Y);
    return 0;
  }
  BN_free(X);
  BN_free(Y);
  if (!EC_KEY_set_public_key(EVP_PKEY_get0(pk), pub_key)) {
    ERR_GOST_error(
        (133), (ERR_R_EC_LIB),
        "/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",
        709);
    EC_POINT_free(pub_key);
    return 0;
  }
  EC_POINT_free(pub_key);
  return 1;
}


x86 assembly (clang, -O0):
<pub_decode_gost01>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x68(%rbp)
mov    -0x18(%rbp),%r8
lea    -0x38(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1090 <X509_PUBKEY_get0_param@plt>
cmp    $0x0,%eax
jne    1271 <pub_decode_gost01+0x61>
movl   $0x0,-0x4(%rbp)
jmp    14a6 <pub_decode_gost01+0x296>
mov    -0x10(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x38(%rbp),%rdi
call   1050 <OBJ_obj2nid@plt>
mov    -0x80(%rbp),%rdi
mov    %eax,%esi
xor    %eax,%eax
mov    %eax,%edx
call   10f0 <EVP_PKEY_assign@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10b0 <decode_gost_algor_params@plt>
cmp    $0x0,%eax
jne    12b3 <pub_decode_gost01+0xa3>
movl   $0x0,-0x4(%rbp)
jmp    14a6 <pub_decode_gost01+0x296>
mov    -0x10(%rbp),%rdi
call   1080 <EVP_PKEY_get0@plt>
mov    %eax,%edi
call   10c0 <EC_KEY_get0_group@plt>
mov    %rax,-0x78(%rbp)
mov    -0x3c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x28(%rbp),%rsi
call   1060 <d2i_ASN1_OCTET_STRING@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    1311 <pub_decode_gost01+0x101>
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
mov    $0x85,%edi
lea    0xd05(%rip),%rdx
mov    $0x2ad,%ecx
call   1100 <ERR_GOST_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    14a6 <pub_decode_gost01+0x296>
mov    -0x68(%rbp),%rax
mov    (%rax),%edi
call   10d0 <OPENSSL_malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x68(%rbp),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%eax
mov    -0x68(%rbp),%rcx
cmp    (%rcx),%eax
jge    1373 <pub_decode_gost01+0x163>
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x40(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x30(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    1333 <pub_decode_gost01+0x123>
mov    -0x68(%rbp),%rax
mov    (%rax),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x6c(%rbp)
mov    -0x68(%rbp),%rdi
call   1070 <ASN1_OCTET_STRING_free@plt>
mov    -0x30(%rbp),%rdi
mov    -0x6c(%rbp),%esi
call   1030 <getbnfrombuf@plt>
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%rdi
movslq -0x6c(%rbp),%rax
add    %rax,%rdi
mov    -0x6c(%rbp),%esi
call   1030 <getbnfrombuf@plt>
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
call   1110 <OPENSSL_free@plt>
mov    -0x78(%rbp),%rdi
call   1130 <EC_POINT_new@plt>
mov    %rax,-0x50(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x60(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   10e0 <EC_POINT_set_affine_coordinates_GFp@plt>
cmp    $0x0,%eax
jne    1433 <pub_decode_gost01+0x223>
mov    0x2bec(%rip),%rax
mov    (%rax),%esi
mov    $0x85,%edi
lea    0xbfe(%rip),%rdx
mov    $0x2bc,%ecx
call   1100 <ERR_GOST_error@plt>
mov    -0x50(%rbp),%rdi
call   1120 <EC_POINT_free@plt>
mov    -0x58(%rbp),%rdi
call   10a0 <BN_free@plt>
mov    -0x60(%rbp),%rdi
call   10a0 <BN_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    14a6 <pub_decode_gost01+0x296>
mov    -0x58(%rbp),%rdi
call   10a0 <BN_free@plt>
mov    -0x60(%rbp),%rdi
call   10a0 <BN_free@plt>
mov    -0x10(%rbp),%rdi
call   1080 <EVP_PKEY_get0@plt>
mov    %eax,%edi
mov    -0x50(%rbp),%rsi
call   1040 <EC_KEY_set_public_key@plt>
cmp    $0x0,%eax
jne    1496 <pub_decode_gost01+0x286>
mov    0x2b77(%rip),%rax
mov    (%rax),%esi
mov    $0x85,%edi
lea    0xb89(%rip),%rdx
mov    $0x2c5,%ecx
call   1100 <ERR_GOST_error@plt>
mov    -0x50(%rbp),%rdi
call   1120 <EC_POINT_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    14a6 <pub_decode_gost01+0x296>
mov    -0x50(%rbp),%rdi
call   1120 <EC_POINT_free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pub_decode_gost01>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r8
mov    %rdi,%r15
movq   $0x0,0x20(%rsp)
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0x18(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x20(%rsp),%rcx
call   1090 <X509_PUBKEY_get0_param@plt>
test   %eax,%eax
je     140f <pub_decode_gost01+0x1ff>
mov    0x10(%rsp),%rdi
call   1050 <OBJ_obj2nid@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   10f0 <EVP_PKEY_assign@plt>
mov    0x20(%rsp),%rsi
mov    %r15,%rdi
call   10b0 <decode_gost_algor_params@plt>
test   %eax,%eax
je     1411 <pub_decode_gost01+0x201>
mov    %r15,%rdi
call   1080 <EVP_PKEY_get0@plt>
mov    %eax,%edi
call   10c0 <EC_KEY_get0_group@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edx
xor    %ebp,%ebp
lea    0x18(%rsp),%rsi
xor    %edi,%edi
call   1060 <d2i_ASN1_OCTET_STRING@plt>
test   %rax,%rax
je     138e <pub_decode_gost01+0x17e>
mov    %rax,%rbx
mov    (%rax),%edi
call   10d0 <OPENSSL_malloc@plt>
mov    %rax,%r12
mov    (%rbx),%eax
test   %eax,%eax
jle    12fa <pub_decode_gost01+0xea>
lea    (%rax,%r12,1),%rcx
add    $0xffffffffffffffff,%rcx
xor    %edx,%edx
nopw   0x0(%rax,%rax,1)
mov    0x8(%rbx),%rax
movzbl (%rax,%rdx,1),%eax
mov    %al,(%rcx)
add    $0x1,%rdx
movslq (%rbx),%rax
add    $0xffffffffffffffff,%rcx
cmp    %rax,%rdx
jl     12e0 <pub_decode_gost01+0xd0>
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    %rbx,%rdi
call   1070 <ASN1_OCTET_STRING_free@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <getbnfrombuf@plt>
mov    %rax,%r13
movslq %ebp,%rsi
mov    %r12,%rdi
add    %rsi,%rdi
call   1030 <getbnfrombuf@plt>
mov    %rax,%rbx
mov    %r12,%rdi
call   1110 <OPENSSL_free@plt>
mov    %r14,%rdi
call   1130 <EC_POINT_new@plt>
mov    %rax,%r12
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %rax,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
xor    %r8d,%r8d
call   10e0 <EC_POINT_set_affine_coordinates_GFp@plt>
test   %eax,%eax
je     13af <pub_decode_gost01+0x19f>
mov    %rbx,%rdi
call   10a0 <BN_free@plt>
mov    %r13,%rdi
call   10a0 <BN_free@plt>
mov    %r15,%rdi
call   1080 <EVP_PKEY_get0@plt>
mov    %eax,%edi
mov    %r12,%rsi
call   1040 <EC_KEY_set_public_key@plt>
test   %eax,%eax
je     13e8 <pub_decode_gost01+0x1d8>
mov    %r12,%rdi
call   1120 <EC_POINT_free@plt>
mov    $0x1,%ebp
jmp    1411 <pub_decode_gost01+0x201>
mov    0x2c53(%rip),%rax
mov    (%rax),%esi
lea    0xc62(%rip),%rdx
mov    $0x85,%edi
mov    $0x2ad,%ecx
call   1100 <ERR_GOST_error@plt>
jmp    1411 <pub_decode_gost01+0x201>
mov    0x2c2a(%rip),%rax
mov    (%rax),%esi
lea    0xc41(%rip),%rdx
mov    $0x85,%edi
mov    $0x2bc,%ecx
call   1100 <ERR_GOST_error@plt>
mov    %r12,%rdi
call   1120 <EC_POINT_free@plt>
mov    %rbx,%rdi
call   10a0 <BN_free@plt>
mov    %r13,%rdi
call   10a0 <BN_free@plt>
jmp    1411 <pub_decode_gost01+0x201>
mov    0x2bf1(%rip),%rax
mov    (%rax),%esi
lea    0xc08(%rip),%rdx
mov    $0x85,%edi
mov    $0x2c5,%ecx
call   1100 <ERR_GOST_error@plt>
mov    %r12,%rdi
call   1120 <EC_POINT_free@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i8* }
@ERR_R_MALLOC_FAILURE = global i32 0
@.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_EC_LIB = global i32 0
define i32 @pub_decode_gost01(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca %struct.TYPE_4__*
%17 = alloca i32
%18 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* null, i32** %6
store i8* null, i8** %7
store i32* null, i32** %9
store %struct.TYPE_4__* null, %struct.TYPE_4__** %16
%19 = load i32*, i32** %5
%20 = call i32 @X509_PUBKEY_get0_param(i32** %9, i8** %7, i32* %10, i32** %6, i32* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %2
store i32 0, i32* %3
br label %129
23: ; preds = %2
%24 = load i32*, i32** %4
%25 = load i32*, i32** %9
%26 = call i32 @OBJ_obj2nid(i32* %25)
%27 = call i32 @EVP_PKEY_assign(i32* %24, i32 %26, i32* null)
%28 = load i32*, i32** %4
%29 = load i32*, i32** %6
%30 = call i32 @decode_gost_algor_params(i32* %28, i32* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %23
store i32 0, i32* %3
br label %129
33: ; preds = %23
%34 = load i32*, i32** %4
%35 = call i32 @EVP_PKEY_get0(i32* %34)
%36 = call i32* @EC_KEY_get0_group(i32 %35)
store i32* %36, i32** %18
%37 = load i32, i32* %10
%38 = call %struct.TYPE_4__* @d2i_ASN1_OCTET_STRING(i32* null, i8** %7, i32 %37)
store %struct.TYPE_4__* %38, %struct.TYPE_4__** %16
%39 = load %struct.TYPE_4__*, %struct.TYPE_4__** %16
%40 = icmp ne %struct.TYPE_4__* %39, null
br i1 %40, label %44, label %41
41: ; preds = %33
%42 = load i32, i32* @ERR_R_MALLOC_FAILURE
%43 = call i32 @ERR_GOST_error(i32 133, i32 %42, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 685)
store i32 0, i32* %3
br label %129
44: ; preds = %33
%45 = load %struct.TYPE_4__*, %struct.TYPE_4__** %16
%46 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %45, i32 0, i32 0
%47 = load i32, i32* %46
%48 = call i8* @OPENSSL_malloc(i32 %47)
store i8* %48, i8** %8
store i32 0, i32* %11
%49 = load %struct.TYPE_4__*, %struct.TYPE_4__** %16
%50 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %49, i32 0, i32 0
%51 = load i32, i32* %50
%52 = sub nsw i32 %51, 1
store i32 %52, i32* %12
br label %53
53: ; preds = %71, %44
%54 = load i32, i32* %11
%55 = load %struct.TYPE_4__*, %struct.TYPE_4__** %16
%56 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %55, i32 0, i32 0
%57 = load i32, i32* %56
%58 = icmp slt i32 %54, %57
br i1 %58, label %59, label %76
59: ; preds = %53
%60 = load %struct.TYPE_4__*, %struct.TYPE_4__** %16
%61 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %60, i32 0, i32 1
%62 = load i8*, i8** %61
%63 = load i32, i32* %11
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8, i8* %62, i64 %64
%66 = load i8, i8* %65
%67 = load i8*, i8** %8
%68 = load i32, i32* %12
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %67, i64 %69
store i8 %66, i8* %70
br label %71
71: ; preds = %59
%72 = load i32, i32* %11
%73 = add nsw i32 %72, 1
store i32 %73, i32* %11
%74 = load i32, i32* %12
%75 = add nsw i32 %74, -1
store i32 %75, i32* %12
br label %53
76: ; preds = %53
%77 = load %struct.TYPE_4__*, %struct.TYPE_4__** %16
%78 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %77, i32 0, i32 0
%79 = load i32, i32* %78
%80 = sdiv i32 %79, 2
store i32 %80, i32* %17
%81 = load %struct.TYPE_4__*, %struct.TYPE_4__** %16
%82 = call i32 @ASN1_OCTET_STRING_free(%struct.TYPE_4__* %81)
%83 = load i8*, i8** %8
%84 = load i32, i32* %17
%85 = call i32* @getbnfrombuf(i8* %83, i32 %84)
store i32* %85, i32** %15
%86 = load i8*, i8** %8
%87 = load i32, i32* %17
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
%90 = load i32, i32* %17
%91 = call i32* @getbnfrombuf(i8* %89, i32 %90)
store i32* %91, i32** %14
%92 = load i8*, i8** %8
%93 = call i32 @OPENSSL_free(i8* %92)
%94 = load i32*, i32** %18
%95 = call i32* @EC_POINT_new(i32* %94)
store i32* %95, i32** %13
%96 = load i32*, i32** %18
%97 = load i32*, i32** %13
%98 = load i32*, i32** %14
%99 = load i32*, i32** %15
%100 = call i32 @EC_POINT_set_affine_coordinates_GFp(i32* %96, i32* %97, i32* %98, i32* %99, i32* null)
%101 = icmp ne i32 %100, 0
br i1 %101, label %111, label %102
102: ; preds = %76
%103 = load i32, i32* @ERR_R_EC_LIB
%104 = call i32 @ERR_GOST_error(i32 133, i32 %103, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 700)
%105 = load i32*, i32** %13
%106 = call i32 @EC_POINT_free(i32* %105)
%107 = load i32*, i32** %14
%108 = call i32 @BN_free(i32* %107)
%109 = load i32*, i32** %15
%110 = call i32 @BN_free(i32* %109)
store i32 0, i32* %3
br label %129
111: ; preds = %76
%112 = load i32*, i32** %14
%113 = call i32 @BN_free(i32* %112)
%114 = load i32*, i32** %15
%115 = call i32 @BN_free(i32* %114)
%116 = load i32*, i32** %4
%117 = call i32 @EVP_PKEY_get0(i32* %116)
%118 = load i32*, i32** %13
%119 = call i32 @EC_KEY_set_public_key(i32 %117, i32* %118)
%120 = icmp ne i32 %119, 0
br i1 %120, label %126, label %121
121: ; preds = %111
%122 = load i32, i32* @ERR_R_EC_LIB
%123 = call i32 @ERR_GOST_error(i32 133, i32 %122, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 709)
%124 = load i32*, i32** %13
%125 = call i32 @EC_POINT_free(i32* %124)
store i32 0, i32* %3
br label %129
126: ; preds = %111
%127 = load i32*, i32** %13
%128 = call i32 @EC_POINT_free(i32* %127)
store i32 1, i32* %3
br label %129
129: ; preds = %126, %121, %102, %41, %32, %22
%130 = load i32, i32* %3
ret i32 %130
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i8* }
@ERR_R_MALLOC_FAILURE = global i32 0
@.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_EC_LIB = global i32 0
define i32 @pub_decode_gost01(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = bitcast i32** %3 to i8*
store i32* null, i32** %3
%8 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%9 = bitcast i32** %5 to i8*
store i32* null, i32** %5
%10 = bitcast i32* %6 to i8*
%11 = call i32 @X509_PUBKEY_get0_param(i32** %5, i8** %4, i32* %6, i32** %3, i32* %1)
%12 = icmp eq i32 %11, 0
br i1 %12, label %80, label %13
13: ; preds = %2
%14 = load i32*, i32** %5
%15 = call i32 @OBJ_obj2nid(i32* %14)
%16 = call i32 @EVP_PKEY_assign(i32* %0, i32 %15, i32* null)
%17 = load i32*, i32** %3
%18 = call i32 @decode_gost_algor_params(i32* %0, i32* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %80, label %20
20: ; preds = %13
%21 = call i32 @EVP_PKEY_get0(i32* %0)
%22 = call i32* @EC_KEY_get0_group(i32 %21)
%23 = load i32, i32* %6
%24 = call %struct.TYPE_4__* @d2i_ASN1_OCTET_STRING(i32* null, i8** %4, i32 %23)
%25 = icmp eq %struct.TYPE_4__* %24, null
br i1 %25, label %26, label %29
26: ; preds = %20
%27 = load i32, i32* @ERR_R_MALLOC_FAILURE
%28 = call i32 @ERR_GOST_error(i32 133, i32 %27, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 685)
br label %80
29: ; preds = %20
%30 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %24, i64 0, i32 0
%31 = load i32, i32* %30
%32 = call i8* @OPENSSL_malloc(i32 %31)
%33 = load i32, i32* %30
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %50
35: ; preds = %29
%36 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %24, i64 0, i32 1
%37 = zext i32 %33 to i64
br label %38
38: ; preds = %35, %38
%39 = phi i64 [ 0, %35 ], [ %46, %38 ]
%40 = phi i64 [ %37, %35 ], [ %41, %38 ]
%41 = add nsw i64 %40, -1
%42 = load i8*, i8** %36
%43 = getelementptr inbounds i8, i8* %42, i64 %39
%44 = load i8, i8* %43
%45 = getelementptr inbounds i8, i8* %32, i64 %41
store i8 %44, i8* %45
%46 = add nuw nsw i64 %39, 1
%47 = load i32, i32* %30
%48 = sext i32 %47 to i64
%49 = icmp slt i64 %46, %48
br i1 %49, label %38, label %50
50: ; preds = %38, %29
%51 = phi i32 [ %33, %29 ], [ %47, %38 ]
%52 = sdiv i32 %51, 2
%53 = call i32 @ASN1_OCTET_STRING_free(%struct.TYPE_4__* %24)
%54 = call i32* @getbnfrombuf(i8* %32, i32 %52)
%55 = sext i32 %52 to i64
%56 = getelementptr inbounds i8, i8* %32, i64 %55
%57 = call i32* @getbnfrombuf(i8* %56, i32 %52)
%58 = call i32 @OPENSSL_free(i8* %32)
%59 = call i32* @EC_POINT_new(i32* %22)
%60 = call i32 @EC_POINT_set_affine_coordinates_GFp(i32* %22, i32* %59, i32* %57, i32* %54, i32* null)
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %50
%63 = load i32, i32* @ERR_R_EC_LIB
%64 = call i32 @ERR_GOST_error(i32 133, i32 %63, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 700)
%65 = call i32 @EC_POINT_free(i32* %59)
%66 = call i32 @BN_free(i32* %57)
%67 = call i32 @BN_free(i32* %54)
br label %80
68: ; preds = %50
%69 = call i32 @BN_free(i32* %57)
%70 = call i32 @BN_free(i32* %54)
%71 = call i32 @EVP_PKEY_get0(i32* %0)
%72 = call i32 @EC_KEY_set_public_key(i32 %71, i32* %59)
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %68
%75 = load i32, i32* @ERR_R_EC_LIB
%76 = call i32 @ERR_GOST_error(i32 133, i32 %75, i8* getelementptr inbounds ([183 x i8], [183 x i8]* @.str, i64 0, i64 0), i32 709)
%77 = call i32 @EC_POINT_free(i32* %59)
br label %80
78: ; preds = %68
%79 = call i32 @EC_POINT_free(i32* %59)
br label %80
80: ; preds = %13, %2, %78, %74, %62, %26
%81 = phi i32 [ 1, %78 ], [ 0, %74 ], [ 0, %62 ], [ 0, %26 ], [ 0, %2 ], [ 0, %13 ]
ret i32 %81
}