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

/* Variables and functions */
scalar_t__ EVP_PKEY_CTX_add1_tls1_prf_seed(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ EVP_PKEY_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EVP_PKEY_CTX_new_id(int /*<<< orphan*/,
                                        int /*<<< orphan*/ *);
scalar_t__ EVP_PKEY_CTX_set1_tls1_prf_secret(int /*<<< orphan*/ *, char *, int);
scalar_t__ EVP_PKEY_CTX_set_tls1_prf_md(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ EVP_PKEY_TLS1_PRF;
scalar_t__ EVP_PKEY_derive(int /*<<< orphan*/ *, unsigned char *, size_t *);
scalar_t__ EVP_PKEY_derive_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_sha256();
int /*<<< orphan*/ test_error(char *, int, char *);
int /*<<< orphan*/ test_mem_eq(char *, int, char *, char *, unsigned char *,
                               int, unsigned char const *, int);
int test_kdf_tls1_prf(void) {
  EVP_PKEY_CTX *pctx;
  unsigned char out[16];
  size_t outlen = sizeof(out);
  pctx = EVP_PKEY_CTX_new_id(EVP_PKEY_TLS1_PRF, NULL);
  if (EVP_PKEY_derive_init(pctx) <= 0) {
    test_error(
        "/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/pkey_meth_kdf_test.c",
        26, "EVP_PKEY_derive_init");
    return 0;
  }
  if (EVP_PKEY_CTX_set_tls1_prf_md(pctx, EVP_sha256()) <= 0) {
    test_error(
        "/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/pkey_meth_kdf_test.c",
        30, "EVP_PKEY_CTX_set_tls1_prf_md");
    return 0;
  }
  if (EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, "secret", 6) <= 0) {
    test_error(
        "/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/pkey_meth_kdf_test.c",
        34, "EVP_PKEY_CTX_set1_tls1_prf_secret");
    return 0;
  }
  if (EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, "seed", 4) <= 0) {
    test_error(
        "/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/pkey_meth_kdf_test.c",
        38, "EVP_PKEY_CTX_add1_tls1_prf_seed");
    return 0;
  }
  if (EVP_PKEY_derive(pctx, out, &outlen) <= 0) {
    test_error(
        "/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/pkey_meth_kdf_test.c",
        42, "EVP_PKEY_derive");
    return 0;
  }
  {
    const unsigned char expected[sizeof(out)] = {
        0x8e, 0x4d, 0x93, 0x25, 0x30, 0xd7, 0x65, 0xa0,
        0xaa, 0xe9, 0x74, 0xc3, 0x04, 0x73, 0x5e, 0xcc};
    if (!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/pkey_meth_kdf_test.c",
            51, "out", "expected", out, sizeof(out), expected,
            sizeof(expected))) {
      return 0;
    }
  }
  EVP_PKEY_CTX_free(pctx);
  return 1;
}


x86 assembly (clang, -O0):
<test_kdf_tls1_prf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movq   $0x10,-0x28(%rbp)
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <EVP_PKEY_CTX_new_id@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <EVP_PKEY_derive_init@plt>
cmp    $0x0,%rax
jg     11fd <test_kdf_tls1_prf+0x5d>
lea    0xe20(%rip),%rdi
mov    $0x1a,%esi
lea    0xeca(%rip),%rdx
call   10b0 <test_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_kdf_tls1_prf+0x1de>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   10a0 <EVP_sha256@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
call   1090 <EVP_PKEY_CTX_set_tls1_prf_md@plt>
cmp    $0x0,%rax
jg     1245 <test_kdf_tls1_prf+0xa5>
lea    0xdd8(%rip),%rdi
mov    $0x1e,%esi
lea    0xe97(%rip),%rdx
call   10b0 <test_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_kdf_tls1_prf+0x1de>
mov    -0x10(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x6,%edx
call   1040 <EVP_PKEY_CTX_set1_tls1_prf_secret@plt>
cmp    $0x0,%rax
jg     1288 <test_kdf_tls1_prf+0xe8>
lea    0xd95(%rip),%rdi
mov    $0x22,%esi
lea    0xe71(%rip),%rdx
call   10b0 <test_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_kdf_tls1_prf+0x1de>
mov    -0x10(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0x4,%edx
call   1050 <EVP_PKEY_CTX_add1_tls1_prf_seed@plt>
cmp    $0x0,%rax
jg     12cb <test_kdf_tls1_prf+0x12b>
lea    0xd52(%rip),%rdi
mov    $0x26,%esi
lea    0xe50(%rip),%rdx
call   10b0 <test_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_kdf_tls1_prf+0x1de>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1070 <EVP_PKEY_derive@plt>
cmp    $0x0,%rax
jg     130a <test_kdf_tls1_prf+0x16a>
lea    0xd13(%rip),%rdi
mov    $0x2a,%esi
lea    0xe31(%rip),%rdx
call   10b0 <test_error@plt>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_kdf_tls1_prf+0x1de>
mov    0xe3f(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe3c(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    -0x20(%rbp),%r8
lea    -0x40(%rbp),%rax
lea    0xcd1(%rip),%rdi
mov    $0x33,%esi
lea    0xdff(%rip),%rdx
lea    0xdfc(%rip),%rcx
mov    $0x10,%r9d
mov    %rax,(%rsp)
movl   $0x10,0x8(%rsp)
call   1080 <test_mem_eq@plt>
cmp    $0x0,%eax
jne    136e <test_kdf_tls1_prf+0x1ce>
movl   $0x0,-0x4(%rbp)
jmp    137e <test_kdf_tls1_prf+0x1de>
mov    -0x10(%rbp),%rdi
call   10c0 <EVP_PKEY_CTX_free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_kdf_tls1_prf>:
push   %r14
push   %rbx
sub    $0x38,%rsp
movq   $0x10,0x8(%rsp)
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
xor    %ebx,%ebx
xor    %esi,%esi
call   1060 <EVP_PKEY_CTX_new_id@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1030 <EVP_PKEY_derive_init@plt>
test   %rax,%rax
jle    12a0 <test_kdf_tls1_prf+0x100>
xor    %ebx,%ebx
xor    %eax,%eax
call   10a0 <EVP_sha256@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1090 <EVP_PKEY_CTX_set_tls1_prf_md@plt>
test   %rax,%rax
jle    12ba <test_kdf_tls1_prf+0x11a>
lea    0xf0a(%rip),%rsi
mov    %r14,%rdi
mov    $0x6,%edx
call   1040 <EVP_PKEY_CTX_set1_tls1_prf_secret@plt>
test   %rax,%rax
jle    12d4 <test_kdf_tls1_prf+0x134>
lea    0xf0f(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1050 <EVP_PKEY_CTX_add1_tls1_prf_seed@plt>
test   %rax,%rax
jle    12e9 <test_kdf_tls1_prf+0x149>
lea    0x20(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %r14,%rdi
call   1070 <EVP_PKEY_derive@plt>
test   %rax,%rax
jle    12fe <test_kdf_tls1_prf+0x15e>
movaps 0xf02(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rax
lea    0xda1(%rip),%rdi
lea    0xed4(%rip),%rdx
lea    0xed1(%rip),%rcx
lea    0x20(%rsp),%r8
mov    $0x33,%esi
mov    $0x10,%r9d
push   $0x10
push   %rax
call   1080 <test_mem_eq@plt>
add    $0x10,%rsp
test   %eax,%eax
je     1316 <test_kdf_tls1_prf+0x176>
mov    %r14,%rdi
call   10c0 <EVP_PKEY_CTX_free@plt>
mov    $0x1,%ebx
jmp    1318 <test_kdf_tls1_prf+0x178>
lea    0xd59(%rip),%rdi
lea    0xe08(%rip),%rdx
mov    $0x1a,%esi
call   10b0 <test_error@plt>
jmp    1318 <test_kdf_tls1_prf+0x178>
lea    0xd3f(%rip),%rdi
lea    0xe03(%rip),%rdx
mov    $0x1e,%esi
call   10b0 <test_error@plt>
jmp    1318 <test_kdf_tls1_prf+0x178>
lea    0xd25(%rip),%rdi
lea    0xe06(%rip),%rdx
mov    $0x22,%esi
jmp    1311 <test_kdf_tls1_prf+0x171>
lea    0xd10(%rip),%rdi
lea    0xe13(%rip),%rdx
mov    $0x26,%esi
jmp    1311 <test_kdf_tls1_prf+0x171>
lea    0xcfb(%rip),%rdi
lea    0xe1e(%rip),%rdx
mov    $0x2a,%esi
call   10b0 <test_error@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@EVP_PKEY_TLS1_PRF = global i32 0
@.str = [182 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/pkey_meth_kdf_test.c\00"
@.str.1 = [21 x i8] c"EVP_PKEY_derive_init\00"
@.str.2 = [29 x i8] c"EVP_PKEY_CTX_set_tls1_prf_md\00"
@.str.3 = [7 x i8] c"secret\00"
@.str.4 = [34 x i8] c"EVP_PKEY_CTX_set1_tls1_prf_secret\00"
@.str.5 = [5 x i8] c"seed\00"
@.str.6 = [32 x i8] c"EVP_PKEY_CTX_add1_tls1_prf_seed\00"
@.str.7 = [16 x i8] c"EVP_PKEY_derive\00"
@__const.test_kdf_tls1_prf.expected = [16 x i8] c"\8EM\93%0\D7e\A0\AA\E9t\C3\04s^\CC"
@.str.8 = [4 x i8] c"out\00"
@.str.9 = [9 x i8] c"expected\00"
define i32 @test_kdf_tls1_prf() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [16 x i8]
%4 = alloca i64
%5 = alloca [16 x i8]
store i64 16, i64* %4
%6 = load i32, i32* @EVP_PKEY_TLS1_PRF
%7 = call i32* @EVP_PKEY_CTX_new_id(i32 %6, i32* null)
store i32* %7, i32** %2
%8 = load i32*, i32** %2
%9 = call i64 @EVP_PKEY_derive_init(i32* %8)
%10 = icmp sle i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %49
13: ; preds = %0
%14 = load i32*, i32** %2
%15 = call i32 (...) @EVP_sha256()
%16 = call i64 @EVP_PKEY_CTX_set_tls1_prf_md(i32* %14, i32 %15)
%17 = icmp sle i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 30, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %49
20: ; preds = %13
%21 = load i32*, i32** %2
%22 = call i64 @EVP_PKEY_CTX_set1_tls1_prf_secret(i32* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%23 = icmp sle i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
br label %49
26: ; preds = %20
%27 = load i32*, i32** %2
%28 = call i64 @EVP_PKEY_CTX_add1_tls1_prf_seed(i32* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%29 = icmp sle i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 38, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %1
br label %49
32: ; preds = %26
%33 = load i32*, i32** %2
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%35 = call i64 @EVP_PKEY_derive(i32* %33, i8* %34, i64* %4)
%36 = icmp sle i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
store i32 0, i32* %1
br label %49
39: ; preds = %32
%40 = bitcast [16 x i8]* %5 to i8*
%41 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%43 = call i32 @test_mem_eq(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %41, i32 16, i8* %42, i32 16)
%44 = icmp ne i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %39
store i32 0, i32* %1
br label %49
46: ; preds = %39
%47 = load i32*, i32** %2
%48 = call i32 @EVP_PKEY_CTX_free(i32* %47)
store i32 1, i32* %1
br label %49
49: ; preds = %46, %45, %37, %30, %24, %18, %11
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
@EVP_PKEY_TLS1_PRF = global i32 0
@.str = [182 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/pkey_meth_kdf_test.c\00"
@.str.1 = [21 x i8] c"EVP_PKEY_derive_init\00"
@.str.2 = [29 x i8] c"EVP_PKEY_CTX_set_tls1_prf_md\00"
@.str.3 = [7 x i8] c"secret\00"
@.str.4 = [34 x i8] c"EVP_PKEY_CTX_set1_tls1_prf_secret\00"
@.str.5 = [5 x i8] c"seed\00"
@.str.6 = [32 x i8] c"EVP_PKEY_CTX_add1_tls1_prf_seed\00"
@.str.7 = [16 x i8] c"EVP_PKEY_derive\00"
@__const.test_kdf_tls1_prf.expected = [16 x i8] c"\8EM\93%0\D7e\A0\AA\E9t\C3\04s^\CC"
@.str.8 = [4 x i8] c"out\00"
@.str.9 = [9 x i8] c"expected\00"
define i32 @test_kdf_tls1_prf() {
%1 = alloca [16 x i8]
%2 = alloca i64
%3 = alloca [16 x i8]
%4 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%5 = bitcast i64* %2 to i8*
store i64 16, i64* %2
%6 = load i32, i32* @EVP_PKEY_TLS1_PRF
%7 = tail call i32* @EVP_PKEY_CTX_new_id(i32 %6, i32* null)
%8 = tail call i64 @EVP_PKEY_derive_init(i32* %7)
%9 = icmp slt i64 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 26, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %39
12: ; preds = %0
%13 = tail call i32 (...) @EVP_sha256()
%14 = tail call i64 @EVP_PKEY_CTX_set_tls1_prf_md(i32* %7, i32 %13)
%15 = icmp slt i64 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 30, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %39
18: ; preds = %12
%19 = tail call i64 @EVP_PKEY_CTX_set1_tls1_prf_secret(i32* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i32 6)
%20 = icmp slt i64 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = tail call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 34, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %39
23: ; preds = %18
%24 = tail call i64 @EVP_PKEY_CTX_add1_tls1_prf_seed(i32* %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4)
%25 = icmp slt i64 %24, 1
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = tail call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 38, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %39
28: ; preds = %23
%29 = call i64 @EVP_PKEY_derive(i32* %7, i8* %4, i64* %2)
%30 = icmp slt i64 %29, 1
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @test_error(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 42, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %39
33: ; preds = %28
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%35 = call i32 @test_mem_eq(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str, i64 0, i64 0), i32 51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0), i8* %4, i32 16, i8* %34, i32 16)
%36 = icmp eq i32 %35, 0
br i1 %36, label %39, label %37
37: ; preds = %33
%38 = call i32 @EVP_PKEY_CTX_free(i32* %7)
br label %39
39: ; preds = %33, %37, %31, %26, %21, %16, %10
%40 = phi i32 [ 0, %10 ], [ 0, %16 ], [ 0, %21 ], [ 0, %26 ], [ 0, %31 ], [ 1, %37 ], [ 0, %33 ]
ret i32 %40
}