#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 uint8_t;
typedef int /*<<< orphan*/ EVP_PKEY_CTX;
typedef int /*<<< orphan*/ EVP_PKEY;
typedef int /*<<< orphan*/ EVP_MD;

/* Variables and functions */
int EVP_PKEY_CTX_get_signature_md(int /*<<< orphan*/ *, int /*<<< orphan*/ **);
int /*<<< orphan*/ *EVP_PKEY_CTX_new(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
scalar_t__ EVP_PKEY_CTX_set_signature_md(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/);
int /*<<< orphan*/ EVP_PKEY_free(int /*<<< orphan*/ *);
scalar_t__ EVP_PKEY_sign(int /*<<< orphan*/ *, int *, size_t *, int *, size_t);
scalar_t__ EVP_PKEY_sign_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_sha256();
int /*<<< orphan*/ *get_evp_pkey(char const *);
int *malloc(size_t);
int /*<<< orphan*/ printf(char *, ...);
int sign_by_pkey(const char *pkey_file, uint8_t *sign_data, size_t sdata_len,
                 uint8_t **out) {
  size_t sign_len = 0;
  EVP_PKEY_CTX *ctx;
  EVP_PKEY *pkey = NULL;
  do {
    if (!out)
      break;
    if (!(pkey = get_evp_pkey(pkey_file))) {
      printf("Failed to load private key."
             "\n");
      break;
    }
    ctx = EVP_PKEY_CTX_new(pkey, NULL);
    if (!ctx) {
      printf("Failed to create pkey ctx"
             "\n");
      break;
    }
    if (EVP_PKEY_sign_init(ctx) <= 0) {
      printf("Failed to do sign init"
             "\n");
      break;
    }
    EVP_MD *md_ptr = NULL;
    int md_type = EVP_PKEY_CTX_get_signature_md(ctx, &md_ptr);
    printf("md_type = %d%s\n", md_type, md_ptr ? "not null" : "null");
    if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0) {
      printf("Fail to set signature md"
             "\n");
      break;
    }
    if (EVP_PKEY_sign(ctx, NULL, &sign_len, sign_data, sdata_len) <= 0) {
      printf("Failed to get sign len"
             "\n");
      break;
    }
    *out = malloc(sign_len);
    if (!*out) {
      printf("Failed to allocate mem for sign"
             "\n");
      break;
    }
    if (EVP_PKEY_sign(ctx, *out, &sign_len, sign_data, sdata_len) <= 0) {
      printf("Failed to sign with pkey"
             "\n");
      break;
    }
  } while (0);
  EVP_PKEY_free(pkey);
  printf("sign_len = %d\n", sign_len);
  for (int i = 0; i < sign_len; i++) {
    printf("%02x ", (*out)[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<sign_by_pkey>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d8 <sign_by_pkey+0x38>
jmp    1379 <sign_by_pkey+0x1d9>
mov    -0x8(%rbp),%rdi
call   10b0 <get_evp_pkey@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    1202 <sign_by_pkey+0x62>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1379 <sign_by_pkey+0x1d9>
mov    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <EVP_PKEY_CTX_new@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1231 <sign_by_pkey+0x91>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1379 <sign_by_pkey+0x1d9>
mov    -0x30(%rbp),%rdi
call   1090 <EVP_PKEY_sign_init@plt>
cmp    $0x0,%rax
jg     1257 <sign_by_pkey+0xb7>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1379 <sign_by_pkey+0x1d9>
movq   $0x0,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1040 <EVP_PKEY_CTX_get_signature_md@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%esi
mov    -0x40(%rbp),%rcx
lea    0xde7(%rip),%rdx
lea    0xddc(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   10c0 <EVP_sha256@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1050 <EVP_PKEY_CTX_set_signature_md@plt>
cmp    $0x0,%rax
jg     12d1 <sign_by_pkey+0x131>
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1379 <sign_by_pkey+0x1d9>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
xor    %eax,%eax
mov    %eax,%esi
lea    -0x28(%rbp),%rdx
call   10a0 <EVP_PKEY_sign@plt>
cmp    $0x0,%rax
jg     1307 <sign_by_pkey+0x167>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1379 <sign_by_pkey+0x1d9>
mov    -0x28(%rbp),%rdi
call   1080 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    133b <sign_by_pkey+0x19b>
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1379 <sign_by_pkey+0x1d9>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
lea    -0x28(%rbp),%rdx
call   10a0 <EVP_PKEY_sign@plt>
cmp    $0x0,%rax
jg     1374 <sign_by_pkey+0x1d4>
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1379 <sign_by_pkey+0x1d9>
jmp    1379 <sign_by_pkey+0x1d9>
mov    -0x38(%rbp),%rdi
call   1070 <EVP_PKEY_free@plt>
mov    -0x28(%rbp),%rsi
lea    0xd49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x48(%rbp)
movslq -0x48(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    13d3 <sign_by_pkey+0x233>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x48(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    139b <sign_by_pkey+0x1fb>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sign_by_pkey>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r15
movq   $0x0,0x8(%rsp)
test   %rcx,%rcx
je     12b5 <sign_by_pkey+0x105>
mov    %rdx,%rbx
mov    %rsi,%r12
call   10c0 <get_evp_pkey@plt>
test   %rax,%rax
je     12ba <sign_by_pkey+0x10a>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
call   1030 <EVP_PKEY_CTX_new@plt>
test   %rax,%rax
je     12cb <sign_by_pkey+0x11b>
mov    %rax,%r13
mov    %rax,%rdi
call   10a0 <EVP_PKEY_sign_init@plt>
test   %rax,%rax
jle    12d4 <sign_by_pkey+0x124>
movq   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %r13,%rdi
call   1050 <EVP_PKEY_CTX_get_signature_md@plt>
cmpq   $0x0,0x10(%rsp)
lea    0xde0(%rip),%rcx
lea    0xdd5(%rip),%rdx
cmove  %rcx,%rdx
lea    0xdba(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   10d0 <EVP_sha256@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1060 <EVP_PKEY_CTX_set_signature_md@plt>
test   %rax,%rax
jle    12dd <sign_by_pkey+0x12d>
lea    0x8(%rsp),%rdx
mov    %r13,%rdi
xor    %esi,%esi
mov    %r12,%rcx
mov    %rbx,%r8
call   10b0 <EVP_PKEY_sign@plt>
test   %rax,%rax
jle    12e6 <sign_by_pkey+0x136>
mov    0x8(%rsp),%rdi
call   1090 <malloc@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     12ef <sign_by_pkey+0x13f>
lea    0x8(%rsp),%rdx
mov    %r13,%rdi
mov    %rax,%rsi
mov    %r12,%rcx
mov    %rbx,%r8
call   10b0 <EVP_PKEY_sign@plt>
test   %rax,%rax
jg     12fb <sign_by_pkey+0x14b>
lea    0xdd1(%rip),%rdi
jmp    12f6 <sign_by_pkey+0x146>
xor    %r14d,%r14d
jmp    12fb <sign_by_pkey+0x14b>
lea    0xd6d(%rip),%rdi
call   1040 <puts@plt>
xor    %r14d,%r14d
jmp    12fb <sign_by_pkey+0x14b>
lea    0xd78(%rip),%rdi
jmp    12f6 <sign_by_pkey+0x146>
lea    0xdf2(%rip),%rdi
jmp    12f6 <sign_by_pkey+0x146>
lea    0xdd0(%rip),%rdi
jmp    12f6 <sign_by_pkey+0x146>
lea    0xdb0(%rip),%rdi
jmp    12f6 <sign_by_pkey+0x146>
lea    0xd6e(%rip),%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1080 <EVP_PKEY_free@plt>
mov    0x8(%rsp),%rsi
lea    0xd0a(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
cmpq   $0x0,0x8(%rsp)
je     134b <sign_by_pkey+0x19b>
lea    0xd03(%rip),%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    (%r15),%rax
mov    (%rax,%rbp,4),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,0x8(%rsp)
ja     1330 <sign_by_pkey+0x180>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Failed to load private key.\0A\00"
@.str.1 = [27 x i8] c"Failed to create pkey ctx\0A\00"
@.str.2 = [24 x i8] c"Failed to do sign init\0A\00"
@.str.3 = [16 x i8] c"md_type = %d%s\0A\00"
@.str.4 = [9 x i8] c"not null\00"
@.str.5 = [5 x i8] c"null\00"
@.str.6 = [26 x i8] c"Fail to set signature md\0A\00"
@.str.7 = [24 x i8] c"Failed to get sign len\0A\00"
@.str.8 = [33 x i8] c"Failed to allocate mem for sign\0A\00"
@.str.9 = [26 x i8] c"Failed to sign with pkey\0A\00"
@.str.10 = [15 x i8] c"sign_len = %d\0A\00"
@.str.11 = [6 x i8] c"%02x \00"
define i32 @sign_by_pkey(i8* %0, i32* %1, i64 %2, i32** %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32**
%9 = alloca i64
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i64 %2, i64* %7
store i32** %3, i32*** %8
store i64 0, i64* %9
store i32* null, i32** %11
br label %15
15: ; preds = %4
%16 = load i32**, i32*** %8
%17 = icmp ne i32** %16, null
br i1 %17, label %19, label %18
18: ; preds = %15
br label %81
19: ; preds = %15
%20 = load i8*, i8** %5
%21 = call i32* @get_evp_pkey(i8* %20)
store i32* %21, i32** %11
%22 = icmp ne i32* %21, null
br i1 %22, label %25, label %23
23: ; preds = %19
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %81
25: ; preds = %19
%26 = load i32*, i32** %11
%27 = call i32* @EVP_PKEY_CTX_new(i32* %26, i32* null)
store i32* %27, i32** %10
%28 = load i32*, i32** %10
%29 = icmp ne i32* %28, null
br i1 %29, label %32, label %30
30: ; preds = %25
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %81
32: ; preds = %25
%33 = load i32*, i32** %10
%34 = call i64 @EVP_PKEY_sign_init(i32* %33)
%35 = icmp sle i64 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %81
38: ; preds = %32
store i32* null, i32** %12
%39 = load i32*, i32** %10
%40 = call i32 @EVP_PKEY_CTX_get_signature_md(i32* %39, i32** %12)
store i32 %40, i32* %13
%41 = load i32, i32* %13
%42 = load i32*, i32** %12
%43 = icmp ne i32* %42, null
%44 = zext i1 %43 to i64
%45 = select i1 %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %41, i8* %45)
%47 = load i32*, i32** %10
%48 = call i32 (...) @EVP_sha256()
%49 = call i64 @EVP_PKEY_CTX_set_signature_md(i32* %47, i32 %48)
%50 = icmp sle i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %38
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
br label %81
53: ; preds = %38
%54 = load i32*, i32** %10
%55 = load i32*, i32** %6
%56 = load i64, i64* %7
%57 = call i64 @EVP_PKEY_sign(i32* %54, i32* null, i64* %9, i32* %55, i64 %56)
%58 = icmp sle i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %81
61: ; preds = %53
%62 = load i64, i64* %9
%63 = call i32* @malloc(i64 %62)
%64 = load i32**, i32*** %8
store i32* %63, i32** %64
%65 = load i32**, i32*** %8
%66 = load i32*, i32** %65
%67 = icmp ne i32* %66, null
br i1 %67, label %70, label %68
68: ; preds = %61
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
br label %81
70: ; preds = %61
%71 = load i32*, i32** %10
%72 = load i32**, i32*** %8
%73 = load i32*, i32** %72
%74 = load i32*, i32** %6
%75 = load i64, i64* %7
%76 = call i64 @EVP_PKEY_sign(i32* %71, i32* %73, i64* %9, i32* %74, i64 %75)
%77 = icmp sle i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %70
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0))
br label %81
80: ; preds = %70
br label %81
81: ; preds = %80, %78, %68, %59, %51, %36, %30, %23, %18
%82 = load i32*, i32** %11
%83 = call i32 @EVP_PKEY_free(i32* %82)
%84 = load i64, i64* %9
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i64 %84)
store i32 0, i32* %14
br label %86
86: ; preds = %99, %81
%87 = load i32, i32* %14
%88 = sext i32 %87 to i64
%89 = load i64, i64* %9
%90 = icmp ult i64 %88, %89
br i1 %90, label %91, label %102
91: ; preds = %86
%92 = load i32**, i32*** %8
%93 = load i32*, i32** %92
%94 = load i32, i32* %14
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i32, i32* %93, i64 %95
%97 = load i32, i32* %96
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %97)
br label %99
99: ; preds = %91
%100 = load i32, i32* %14
%101 = add nsw i32 %100, 1
store i32 %101, i32* %14
br label %86
102: ; preds = %86
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [16 x i8] c"md_type = %d%s\0A\00"
@.str.4 = [9 x i8] c"not null\00"
@.str.5 = [5 x i8] c"null\00"
@.str.10 = [15 x i8] c"sign_len = %d\0A\00"
@.str.11 = [6 x i8] c"%02x \00"
@str = [28 x i8] c"Failed to load private key.\00"
@str.12 = [26 x i8] c"Failed to create pkey ctx\00"
@str.13 = [32 x i8] c"Failed to allocate mem for sign\00"
@str.14 = [25 x i8] c"Failed to sign with pkey\00"
@str.15 = [23 x i8] c"Failed to get sign len\00"
@str.16 = [25 x i8] c"Fail to set signature md\00"
@str.17 = [23 x i8] c"Failed to do sign init\00"
define i32 @sign_by_pkey(i8* %0, i32* %1, i64 %2, i32** %3) {
%5 = alloca i64
%6 = alloca i32*
%7 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%8 = icmp eq i32** %3, null
br i1 %8, label %48, label %9
9: ; preds = %4
%10 = tail call i32* @get_evp_pkey(i8* %0)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %48
14: ; preds = %9
%15 = tail call i32* @EVP_PKEY_CTX_new(i32* %10, i32* null)
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.12, i64 0, i64 0))
br label %48
19: ; preds = %14
%20 = tail call i64 @EVP_PKEY_sign_init(i32* %15)
%21 = icmp slt i64 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.17, i64 0, i64 0))
br label %48
24: ; preds = %19
%25 = bitcast i32** %6 to i8*
store i32* null, i32** %6
%26 = call i32 @EVP_PKEY_CTX_get_signature_md(i32* %15, i32** %6)
%27 = load i32*, i32** %6
%28 = icmp eq i32* %27, null
%29 = select i1 %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %26, i8* %29)
%31 = call i32 (...) @EVP_sha256()
%32 = call i64 @EVP_PKEY_CTX_set_signature_md(i32* %15, i32 %31)
%33 = icmp slt i64 %32, 1
br i1 %33, label %44, label %34
34: ; preds = %24
%35 = call i64 @EVP_PKEY_sign(i32* %15, i32* null, i64* %5, i32* %1, i64 %2)
%36 = icmp slt i64 %35, 1
br i1 %36, label %44, label %37
37: ; preds = %34
%38 = load i64, i64* %5
%39 = call i32* @malloc(i64 %38)
store i32* %39, i32** %3
%40 = icmp eq i32* %39, null
br i1 %40, label %44, label %41
41: ; preds = %37
%42 = call i64 @EVP_PKEY_sign(i32* %15, i32* %39, i64* %5, i32* %1, i64 %2)
%43 = icmp slt i64 %42, 1
br i1 %43, label %44, label %47
44: ; preds = %41, %37, %34, %24
%45 = phi i8* [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0), %24 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.15, i64 0, i64 0), %34 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.13, i64 0, i64 0), %37 ], [ getelementptr inbounds ([25 x i8], [25 x i8]* @str.14, i64 0, i64 0), %41 ]
%46 = call i32 @puts(i8* dereferenceable(1) %45)
br label %47
47: ; preds = %44, %41
br label %48
48: ; preds = %47, %4, %22, %17, %12
%49 = phi i32* [ %10, %22 ], [ %10, %47 ], [ %10, %17 ], [ null, %12 ], [ null, %4 ]
%50 = call i32 @EVP_PKEY_free(i32* %49)
%51 = load i64, i64* %5
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0), i64 %51)
%53 = load i64, i64* %5
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %56, %48
ret i32 0
56: ; preds = %48, %56
%57 = phi i64 [ %62, %56 ], [ 0, %48 ]
%58 = load i32*, i32** %3
%59 = getelementptr inbounds i32, i32* %58, i64 %57
%60 = load i32, i32* %59
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32 %60)
%62 = add nuw i64 %57, 1
%63 = load i64, i64* %5
%64 = icmp ugt i64 %63, %62
br i1 %64, label %56, label %55
}