#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*/ salt;
typedef int /*<<< orphan*/ out;
typedef int /*<<< orphan*/ key;
typedef int /*<<< orphan*/ info;
typedef int /*<<< orphan*/ expected;
typedef int /*<<< orphan*/ EVP_PKEY_CTX;

/* Variables and functions */
int /*<<< orphan*/ EVP_PKEY_CTX_add1_hkdf_info(int /*<<< orphan*/ *,
                                               unsigned char *, int);
int /*<<< orphan*/ EVP_PKEY_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EVP_PKEY_CTX_new_id(int /*<<< orphan*/,
                                        int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_PKEY_CTX_set1_hkdf_key(int /*<<< orphan*/ *,
                                              unsigned char *, int);
int /*<<< orphan*/ EVP_PKEY_CTX_set1_hkdf_salt(int /*<<< orphan*/ *,
                                               unsigned char *, int);
int /*<<< orphan*/ EVP_PKEY_CTX_set_hkdf_md(int /*<<< orphan*/ *,
                                            int /*<<< orphan*/);
int /*<<< orphan*/ EVP_PKEY_HKDF;
int /*<<< orphan*/ EVP_PKEY_derive(int /*<<< orphan*/ *, unsigned char *,
                                   size_t *);
int /*<<< orphan*/ EVP_PKEY_derive_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_sha256();
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, size_t);
int /*<<< orphan*/ test_int_gt(char *, int, char *, char *, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ test_mem_eq(char *, int, char *, char *, unsigned char *,
                               size_t, unsigned char const *, size_t);
int /*<<< orphan*/ test_ptr(char *, int, char *, int /*<<< orphan*/ *);
int test_HKDF(void) {
  EVP_PKEY_CTX *pctx;
  unsigned char out[20];
  size_t outlen;
  int i, ret = 0;
  unsigned char salt[] = "0123456789";
  unsigned char key[] = "012345678901234567890123456789";
  unsigned char info[] = "infostring";
  const unsigned char expected[] = {0xe5, 0x07, 0x70, 0x7f, 0xc6, 0x78, 0xd6,
                                    0x54, 0x32, 0x5f, 0x7e, 0xc5, 0x7b, 0x59,
                                    0x3e, 0xd8, 0x03, 0x6b, 0xed, 0xca};
  size_t expectedlen = sizeof(expected);
  if (!test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/"
                "refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
                1011, "pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL)",
                pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL)))
    goto done;
  for (i = 0; i < 2; i++) {
    outlen = sizeof(out);
    memset(out, 0, outlen);
    if (!test_int_gt(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
            "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
            1019, "EVP_PKEY_derive_init(pctx)", "0", EVP_PKEY_derive_init(pctx),
            0) ||
        !test_int_gt(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
            "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
            1020, "EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256())", "0",
            EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256()), 0) ||
        !test_int_gt(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
            "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
            1021, "EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, sizeof(salt) - 1)",
            "0", EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, sizeof(salt) - 1),
            0) ||
        !test_int_gt(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
            "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
            1023, "EVP_PKEY_CTX_set1_hkdf_key(pctx, key, sizeof(key) - 1)", "0",
            EVP_PKEY_CTX_set1_hkdf_key(pctx, key, sizeof(key) - 1), 0) ||
        !test_int_gt(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
            "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
            1025, "EVP_PKEY_CTX_add1_hkdf_info(pctx, info, sizeof(info) - 1)",
            "0", EVP_PKEY_CTX_add1_hkdf_info(pctx, info, sizeof(info) - 1),
            0) ||
        !test_int_gt(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
            "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
            1027, "EVP_PKEY_derive(pctx, out, &outlen)", "0",
            EVP_PKEY_derive(pctx, out, &outlen), 0) ||
        !test_mem_eq(
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
            "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
            1028, "out", "expected", out, outlen, expected, expectedlen))
      goto done;
  }
  ret = 1;
done:
  EVP_PKEY_CTX_free(pctx);
  return ret;
}


x86 assembly (clang, -O0):
<test_HKDF>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x30(%rbp)
mov    0xe17(%rip),%rax
mov    %rax,-0x3b(%rbp)
mov    0xe14(%rip),%ax
mov    %ax,-0x33(%rbp)
mov    0xe0c(%rip),%al
mov    %al,-0x31(%rbp)
mov    0x1018(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0x1015(%rip),%rax
mov    %rax,-0x58(%rbp)
mov    0x1012(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0x1010(%rip),%eax
mov    %eax,-0x48(%rbp)
mov    0x100a(%rip),%ax
mov    %ax,-0x44(%rbp)
mov    0x1002(%rip),%al
mov    %al,-0x42(%rbp)
mov    0xdc5(%rip),%rax
mov    %rax,-0x6b(%rbp)
mov    0xdc2(%rip),%ax
mov    %ax,-0x63(%rbp)
mov    0xdba(%rip),%al
mov    %al,-0x61(%rbp)
mov    0xfdb(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    0xfd8(%rip),%rax
mov    %rax,-0x78(%rbp)
mov    0xfd6(%rip),%eax
mov    %eax,-0x70(%rbp)
movq   $0x14,-0x88(%rbp)
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   10b0 <EVP_PKEY_CTX_new_id@plt>
mov    %rax,%rcx
mov    %rcx,-0x8(%rbp)
lea    0xd6e(%rip),%rdi
mov    $0x3f3,%esi
lea    0xe14(%rip),%rdx
call   1060 <test_ptr@plt>
cmp    $0x0,%eax
jne    12c7 <test_HKDF+0xf7>
jmp    14d6 <test_HKDF+0x306>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jge    14cf <test_HKDF+0x2ff>
movq   $0x14,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
xor    %esi,%esi
call   1070 <memset@plt>
mov    -0x8(%rbp),%rdi
call   1090 <EVP_PKEY_derive_init@plt>
mov    %eax,%r8d
lea    0xd14(%rip),%rdi
mov    $0x3fb,%esi
lea    0xdea(%rip),%rdx
lea    0xdfe(%rip),%rcx
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
cmp    $0x0,%eax
je     14b7 <test_HKDF+0x2e7>
mov    -0x8(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    $0x0,%al
call   10e0 <EVP_sha256@plt>
mov    -0x90(%rbp),%rdi
mov    %eax,%esi
call   10a0 <EVP_PKEY_CTX_set_hkdf_md@plt>
mov    %eax,%r8d
lea    0xcc6(%rip),%rdi
mov    $0x3fc,%esi
lea    0xdb9(%rip),%rdx
lea    0xdb0(%rip),%rcx
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
cmp    $0x0,%eax
je     14b7 <test_HKDF+0x2e7>
mov    -0x8(%rbp),%rdi
lea    -0x3b(%rbp),%rsi
mov    $0xa,%edx
call   1080 <EVP_PKEY_CTX_set1_hkdf_salt@plt>
mov    %eax,%r8d
lea    0xc86(%rip),%rdi
mov    $0x3fd,%esi
lea    0xda6(%rip),%rdx
lea    0xd70(%rip),%rcx
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
cmp    $0x0,%eax
je     14b7 <test_HKDF+0x2e7>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x1e,%edx
call   1050 <EVP_PKEY_CTX_set1_hkdf_key@plt>
mov    %eax,%r8d
lea    0xc46(%rip),%rdi
mov    $0x3ff,%esi
lea    0xda0(%rip),%rdx
lea    0xd30(%rip),%rcx
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
cmp    $0x0,%eax
je     14b7 <test_HKDF+0x2e7>
mov    -0x8(%rbp),%rdi
lea    -0x6b(%rbp),%rsi
mov    $0xa,%edx
call   1030 <EVP_PKEY_CTX_add1_hkdf_info@plt>
mov    %eax,%r8d
lea    0xc06(%rip),%rdi
mov    $0x401,%esi
lea    0xd97(%rip),%rdx
lea    0xcf0(%rip),%rcx
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
cmp    $0x0,%eax
je     14b7 <test_HKDF+0x2e7>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   10c0 <EVP_PKEY_derive@plt>
mov    %eax,%r8d
lea    0xbc7(%rip),%rdi
mov    $0x403,%esi
lea    0xd92(%rip),%rdx
lea    0xcb1(%rip),%rcx
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
cmp    $0x0,%eax
je     14b7 <test_HKDF+0x2e7>
lea    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
lea    -0x80(%rbp),%r10
mov    -0x88(%rbp),%rax
lea    0xb89(%rip),%rdi
mov    $0x404,%esi
lea    0xd78(%rip),%rdx
lea    0xd75(%rip),%rcx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   10d0 <test_mem_eq@plt>
cmp    $0x0,%eax
jne    14bc <test_HKDF+0x2ec>
jmp    14d6 <test_HKDF+0x306>
jmp    14c1 <test_HKDF+0x2f1>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    12ce <test_HKDF+0xfe>
movl   $0x1,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   10f0 <EVP_PKEY_CTX_free@plt>
mov    -0x30(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_HKDF>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
movabs $0x3736353433323130,%rax
35 36 37
mov    %rax,0x20(%rsp)
movl   $0x393837,0x27(%rsp)
movups 0x1030(%rip),%xmm0
movups %xmm0,0x5f(%rsp)
movaps 0x1015(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movabs $0x697274736f666e69,%rax
74 72 69
mov    %rax,0x10(%rsp)
movl   $0x676e69,0x17(%rsp)
movaps 0x1012(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movl   $0xcaed6b03,0x40(%rsp)
ca
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
xor    %ebp,%ebp
xor    %esi,%esi
call   10b0 <EVP_PKEY_CTX_new_id@plt>
mov    %rax,%rbx
lea    0xdbf(%rip),%rdi
lea    0xe6a(%rip),%rdx
mov    $0x3f3,%esi
mov    %rax,%rcx
call   1060 <test_ptr@plt>
test   %eax,%eax
je     1433 <test_HKDF+0x263>
xor    %r12d,%r12d
lea    0x70(%rsp),%r14
lea    0xd94(%rip),%r15
lea    0xe8a(%rip),%r13
nopl   0x0(%rax)
movq   $0x14,0x8(%rsp)
mov    $0x14,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
mov    %rbx,%rdi
call   1090 <EVP_PKEY_derive_init@plt>
mov    %r15,%rdi
mov    $0x3fb,%esi
lea    0xe39(%rip),%rdx
mov    %r13,%rcx
mov    %eax,%r8d
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1433 <test_HKDF+0x263>
xor    %eax,%eax
call   10e0 <EVP_sha256@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10a0 <EVP_PKEY_CTX_set_hkdf_md@plt>
mov    %r15,%rdi
mov    $0x3fc,%esi
lea    0xe1e(%rip),%rdx
mov    %r13,%rcx
mov    %eax,%r8d
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
test   %eax,%eax
je     1433 <test_HKDF+0x263>
mov    %rbx,%rdi
lea    0x20(%rsp),%rsi
mov    $0xa,%edx
call   1080 <EVP_PKEY_CTX_set1_hkdf_salt@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    $0x3fd,%esi
lea    0xe12(%rip),%rdx
mov    %r13,%rcx
mov    %eax,%r8d
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
test   %eax,%eax
je     1433 <test_HKDF+0x263>
mov    %rbx,%rdi
lea    0x50(%rsp),%rsi
mov    $0x1e,%edx
call   1050 <EVP_PKEY_CTX_set1_hkdf_key@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    $0x3ff,%esi
lea    0xe13(%rip),%rdx
mov    %r13,%rcx
mov    %eax,%r8d
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
test   %eax,%eax
je     1433 <test_HKDF+0x263>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
mov    $0xa,%edx
call   1030 <EVP_PKEY_CTX_add1_hkdf_info@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    $0x401,%esi
lea    0xe11(%rip),%rdx
mov    %r13,%rcx
mov    %eax,%r8d
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
test   %eax,%eax
je     1433 <test_HKDF+0x263>
mov    %rbx,%rdi
mov    %r14,%rsi
lea    0x8(%rsp),%rdx
call   10c0 <EVP_PKEY_derive@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
mov    $0x403,%esi
lea    0xe18(%rip),%rdx
mov    %r13,%rcx
mov    %eax,%r8d
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
test   %eax,%eax
je     1433 <test_HKDF+0x263>
mov    0x8(%rsp),%r9
mov    %r15,%rdi
mov    $0x404,%esi
lea    0xe16(%rip),%rdx
lea    0xe13(%rip),%rcx
mov    %r14,%r8
push   $0x14
lea    0x38(%rsp),%rax
push   %rax
call   10d0 <test_mem_eq@plt>
add    $0x10,%rsp
test   %eax,%eax
setne  %cl
xor    $0x1,%r12b
test   %r12b,%cl
mov    $0x1,%r12b
jne    1290 <test_HKDF+0xc0>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %rbx,%rdi
call   10f0 <EVP_PKEY_CTX_free@plt>
mov    %ebp,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.test_HKDF.salt = [11 x i8] c"0123456789\00"
@__const.test_HKDF.key = [31 x i8] c"012345678901234567890123456789\00"
@__const.test_HKDF.info = [11 x i8] c"infostring\00"
@__const.test_HKDF.expected = [20 x i8] c"\E5\07p\7F\C6x\D6T2_~\C5{Y>\D8\03k\ED\CA"
@.str = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c\00"
@.str.1 = [48 x i8] c"pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL)\00"
@EVP_PKEY_HKDF = global i32 0
@.str.2 = [27 x i8] c"EVP_PKEY_derive_init(pctx)\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [45 x i8] c"EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256())\00"
@.str.5 = [58 x i8] c"EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, sizeof(salt) - 1)\00"
@.str.6 = [55 x i8] c"EVP_PKEY_CTX_set1_hkdf_key(pctx, key, sizeof(key) - 1)\00"
@.str.7 = [58 x i8] c"EVP_PKEY_CTX_add1_hkdf_info(pctx, info, sizeof(info) - 1)\00"
@.str.8 = [36 x i8] c"EVP_PKEY_derive(pctx, out, &outlen)\00"
@.str.9 = [4 x i8] c"out\00"
@.str.10 = [9 x i8] c"expected\00"
define i32 @test_HKDF() {
%1 = alloca i32*
%2 = alloca [20 x i8]
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca [11 x i8]
%7 = alloca [31 x i8]
%8 = alloca [11 x i8]
%9 = alloca [20 x i8]
%10 = alloca i64
store i32 0, i32* %5
%11 = bitcast [11 x i8]* %6 to i8*
%12 = bitcast [31 x i8]* %7 to i8*
%13 = bitcast [11 x i8]* %8 to i8*
%14 = bitcast [20 x i8]* %9 to i8*
store i64 20, i64* %10
%15 = load i32, i32* @EVP_PKEY_HKDF
%16 = call i32* @EVP_PKEY_CTX_new_id(i32 %15, i32* null)
store i32* %16, i32** %1
%17 = call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1011, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %0
br label %75
20: ; preds = %0
store i32 0, i32* %4
br label %21
21: ; preds = %71, %20
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 2
br i1 %23, label %24, label %74
24: ; preds = %21
store i64 20, i64* %3
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%26 = load i64, i64* %3
%27 = call i32 @memset(i8* %25, i32 0, i64 %26)
%28 = load i32*, i32** %1
%29 = call i32 @EVP_PKEY_derive_init(i32* %28)
%30 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1019, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 0)
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %69
32: ; preds = %24
%33 = load i32*, i32** %1
%34 = call i32 (...) @EVP_sha256()
%35 = call i32 @EVP_PKEY_CTX_set_hkdf_md(i32* %33, i32 %34)
%36 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1020, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 0)
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %69
38: ; preds = %32
%39 = load i32*, i32** %1
%40 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%41 = call i32 @EVP_PKEY_CTX_set1_hkdf_salt(i32* %39, i8* %40, i32 10)
%42 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1021, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 0)
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %69
44: ; preds = %38
%45 = load i32*, i32** %1
%46 = getelementptr inbounds [31 x i8], [31 x i8]* %7, i64 0, i64 0
%47 = call i32 @EVP_PKEY_CTX_set1_hkdf_key(i32* %45, i8* %46, i32 30)
%48 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %47, i32 0)
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %69
50: ; preds = %44
%51 = load i32*, i32** %1
%52 = getelementptr inbounds [11 x i8], [11 x i8]* %8, i64 0, i64 0
%53 = call i32 @EVP_PKEY_CTX_add1_hkdf_info(i32* %51, i8* %52, i32 10)
%54 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1025, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %53, i32 0)
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %69
56: ; preds = %50
%57 = load i32*, i32** %1
%58 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%59 = call i32 @EVP_PKEY_derive(i32* %57, i8* %58, i64* %3)
%60 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1027, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %59, i32 0)
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %69
62: ; preds = %56
%63 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%64 = load i64, i64* %3
%65 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%66 = load i64, i64* %10
%67 = call i32 @test_mem_eq(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1028, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %63, i64 %64, i8* %65, i64 %66)
%68 = icmp ne i32 %67, 0
br i1 %68, label %70, label %69
69: ; preds = %62, %56, %50, %44, %38, %32, %24
br label %75
70: ; preds = %62
br label %71
71: ; preds = %70
%72 = load i32, i32* %4
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
br label %21
74: ; preds = %21
store i32 1, i32* %5
br label %75
75: ; preds = %74, %69, %19
%76 = load i32*, i32** %1
%77 = call i32 @EVP_PKEY_CTX_free(i32* %76)
%78 = load i32, i32* %5
ret i32 %78
}

LLVM IR (-O2):
@__const.test_HKDF.salt = [11 x i8] c"0123456789\00"
@__const.test_HKDF.key = [31 x i8] c"012345678901234567890123456789\00"
@__const.test_HKDF.info = [11 x i8] c"infostring\00"
@__const.test_HKDF.expected = [20 x i8] c"\E5\07p\7F\C6x\D6T2_~\C5{Y>\D8\03k\ED\CA"
@.str = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c\00"
@.str.1 = [48 x i8] c"pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL)\00"
@EVP_PKEY_HKDF = global i32 0
@.str.2 = [27 x i8] c"EVP_PKEY_derive_init(pctx)\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [45 x i8] c"EVP_PKEY_CTX_set_hkdf_md(pctx, EVP_sha256())\00"
@.str.5 = [58 x i8] c"EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, sizeof(salt) - 1)\00"
@.str.6 = [55 x i8] c"EVP_PKEY_CTX_set1_hkdf_key(pctx, key, sizeof(key) - 1)\00"
@.str.7 = [58 x i8] c"EVP_PKEY_CTX_add1_hkdf_info(pctx, info, sizeof(info) - 1)\00"
@.str.8 = [36 x i8] c"EVP_PKEY_derive(pctx, out, &outlen)\00"
@.str.9 = [4 x i8] c"out\00"
@.str.10 = [9 x i8] c"expected\00"
define i32 @test_HKDF() {
%1 = alloca [20 x i8]
%2 = alloca i64
%3 = alloca [11 x i8]
%4 = alloca [31 x i8]
%5 = alloca [11 x i8]
%6 = alloca [20 x i8]
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%8 = bitcast i64* %2 to i8*
%9 = getelementptr inbounds [11 x i8], [11 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [31 x i8], [31 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [11 x i8], [11 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %6, i64 0, i64 0
%13 = load i32, i32* @EVP_PKEY_HKDF
%14 = tail call i32* @EVP_PKEY_CTX_new_id(i32 %13, i32* null)
%15 = tail call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1011, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0), i32* %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %52, label %17
17: ; preds = %0, %44
%18 = phi i1 [ true, %44 ], [ false, %0 ]
store i64 20, i64* %2
%19 = call i32 @memset(i8* %7, i32 0, i64 20)
%20 = call i32 @EVP_PKEY_derive_init(i32* %14)
%21 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1019, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %20, i32 0)
%22 = icmp eq i32 %21, 0
br i1 %22, label %52, label %23
23: ; preds = %17
%24 = call i32 (...) @EVP_sha256()
%25 = call i32 @EVP_PKEY_CTX_set_hkdf_md(i32* %14, i32 %24)
%26 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1020, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %25, i32 0)
%27 = icmp eq i32 %26, 0
br i1 %27, label %52, label %28
28: ; preds = %23
%29 = call i32 @EVP_PKEY_CTX_set1_hkdf_salt(i32* %14, i8* %9, i32 10)
%30 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1021, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 0)
%31 = icmp eq i32 %30, 0
br i1 %31, label %52, label %32
32: ; preds = %28
%33 = call i32 @EVP_PKEY_CTX_set1_hkdf_key(i32* %14, i8* %10, i32 30)
%34 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1023, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %33, i32 0)
%35 = icmp eq i32 %34, 0
br i1 %35, label %52, label %36
36: ; preds = %32
%37 = call i32 @EVP_PKEY_CTX_add1_hkdf_info(i32* %14, i8* %11, i32 10)
%38 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1025, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 0)
%39 = icmp eq i32 %38, 0
br i1 %39, label %52, label %40
40: ; preds = %36
%41 = call i32 @EVP_PKEY_derive(i32* %14, i8* %7, i64* %2)
%42 = call i32 @test_int_gt(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1027, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i32 %41, i32 0)
%43 = icmp eq i32 %42, 0
br i1 %43, label %52, label %44
44: ; preds = %40
%45 = load i64, i64* %2
%46 = call i32 @test_mem_eq(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 1028, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i8* %7, i64 %45, i8* %12, i64 20)
%47 = icmp eq i32 %46, 0
%48 = or i1 %47, %18
br i1 %48, label %49, label %17
49: ; preds = %44
%50 = xor i1 %47, true
%51 = zext i1 %50 to i32
br label %52
52: ; preds = %49, %40, %36, %32, %28, %23, %17, %0
%53 = phi i32 [ 0, %0 ], [ %51, %49 ], [ 0, %40 ], [ 0, %36 ], [ 0, %32 ], [ 0, %28 ], [ 0, %23 ], [ 0, %17 ]
%54 = call i32 @EVP_PKEY_CTX_free(i32* %14)
ret i32 %53
}