#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*/ BN_CTX;

/* Variables and functions */
int /*<<< orphan*/ BN_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_CTX_new();
int /*<<< orphan*/ *BN_CTX_secure_new();
scalar_t__ test_ctx_check_ct_flag(int /*<<< orphan*/ *);
scalar_t__ test_ctx_set_ct_flag(int /*<<< orphan*/ *);
int /*<<< orphan*/ test_ptr(char *, int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ test_true(char *, int, char *, int);
int test_ctx_consttime_flag(void) {
  BN_CTX *nctx = NULL;
  BN_CTX *sctx = NULL;
  size_t i = 0;
  int st = 0;
  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/bntest.c",
                2336, "nctx = BN_CTX_new()", nctx = BN_CTX_new()) ||
      !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/bntest.c",
                2337, "sctx = BN_CTX_secure_new()", sctx = BN_CTX_secure_new()))
    goto err;
  for (i = 0; i < 2; i++) {
    BN_CTX *c = i == 0 ? nctx : sctx;
    if (!test_true(
            "/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/bntest.c",
            2342, "test_ctx_set_ct_flag(c)", (test_ctx_set_ct_flag(c)) != 0) ||
        !test_true(
            "/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/bntest.c",
            2343, "test_ctx_check_ct_flag(c)",
            (test_ctx_check_ct_flag(c)) != 0))
      goto err;
  }
  st = 1;
err:
  BN_CTX_free(nctx);
  BN_CTX_free(sctx);
  return st;
}


x86 assembly (clang, -O0):
<test_ctx_consttime_flag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movq   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1080 <BN_CTX_new@plt>
mov    %rax,%rcx
mov    %rcx,-0x8(%rbp)
lea    0xe54(%rip),%rdi
mov    $0x920,%esi
lea    0xef2(%rip),%rdx
call   1040 <test_ptr@plt>
cmp    $0x0,%eax
je     11f5 <test_ctx_consttime_flag+0x85>
mov    $0x0,%al
call   1070 <BN_CTX_secure_new@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xe25(%rip),%rdi
mov    $0x921,%esi
lea    0xed7(%rip),%rdx
call   1040 <test_ptr@plt>
cmp    $0x0,%eax
jne    11fa <test_ctx_consttime_flag+0x8a>
jmp    12c3 <test_ctx_consttime_flag+0x153>
movq   $0x0,-0x18(%rbp)
cmpq   $0x2,-0x18(%rbp)
jae    12bc <test_ctx_consttime_flag+0x14c>
cmpq   $0x0,-0x18(%rbp)
jne    1225 <test_ctx_consttime_flag+0xb5>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    122d <test_ctx_consttime_flag+0xbd>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1090 <test_ctx_set_ct_flag@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xdaf(%rip),%rdi
mov    $0x926,%esi
lea    0xe7c(%rip),%rdx
call   1030 <test_true@plt>
cmp    $0x0,%eax
je     12a1 <test_ctx_consttime_flag+0x131>
mov    -0x28(%rbp),%rdi
call   1060 <test_ctx_check_ct_flag@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xd79(%rip),%rdi
mov    $0x927,%esi
lea    0xe5e(%rip),%rdx
call   1030 <test_true@plt>
cmp    $0x0,%eax
jne    12a6 <test_ctx_consttime_flag+0x136>
jmp    12c3 <test_ctx_consttime_flag+0x153>
jmp    12ab <test_ctx_consttime_flag+0x13b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1202 <test_ctx_consttime_flag+0x92>
movl   $0x1,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <BN_CTX_free@plt>
mov    -0x10(%rbp),%rdi
call   1050 <BN_CTX_free@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ctx_consttime_flag>:
push   %r15
push   %r14
push   %rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <BN_CTX_new@plt>
mov    %rax,%rbx
lea    0xe77(%rip),%rdi
lea    0xf1a(%rip),%rdx
mov    $0x920,%esi
mov    %rax,%rcx
call   1040 <test_ptr@plt>
test   %eax,%eax
je     1290 <test_ctx_consttime_flag+0x120>
xor    %r14d,%r14d
xor    %eax,%eax
call   1070 <BN_CTX_secure_new@plt>
mov    %rax,%r15
lea    0xe47(%rip),%rdi
lea    0xefe(%rip),%rdx
mov    $0x921,%esi
mov    %rax,%rcx
call   1040 <test_ptr@plt>
test   %eax,%eax
je     1293 <test_ctx_consttime_flag+0x123>
mov    %rbx,%rdi
call   1090 <test_ctx_set_ct_flag@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xe14(%rip),%rdi
lea    0xee6(%rip),%rdx
mov    $0x926,%esi
call   1030 <test_true@plt>
test   %eax,%eax
je     1293 <test_ctx_consttime_flag+0x123>
mov    %rbx,%rdi
call   1060 <test_ctx_check_ct_flag@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xde4(%rip),%rdi
lea    0xece(%rip),%rdx
mov    $0x927,%esi
call   1030 <test_true@plt>
test   %eax,%eax
je     1293 <test_ctx_consttime_flag+0x123>
mov    %r15,%rdi
call   1090 <test_ctx_set_ct_flag@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xdb8(%rip),%rdi
lea    0xe8a(%rip),%rdx
mov    $0x926,%esi
call   1030 <test_true@plt>
test   %eax,%eax
je     1293 <test_ctx_consttime_flag+0x123>
mov    %r15,%rdi
call   1060 <test_ctx_check_ct_flag@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xd8c(%rip),%rdi
lea    0xe76(%rip),%rdx
mov    $0x927,%esi
call   1030 <test_true@plt>
xor    %r14d,%r14d
test   %eax,%eax
setne  %r14b
jmp    1293 <test_ctx_consttime_flag+0x123>
xor    %r15d,%r15d
mov    %rbx,%rdi
call   1050 <BN_CTX_free@plt>
mov    %r15,%rdi
call   1050 <BN_CTX_free@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [170 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/bntest.c\00"
@.str.1 = [20 x i8] c"nctx = BN_CTX_new()\00"
@.str.2 = [27 x i8] c"sctx = BN_CTX_secure_new()\00"
@.str.3 = [24 x i8] c"test_ctx_set_ct_flag(c)\00"
@.str.4 = [26 x i8] c"test_ctx_check_ct_flag(c)\00"
define i32 @test_ctx_consttime_flag() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32*
store i32* null, i32** %1
store i32* null, i32** %2
store i64 0, i64* %3
store i32 0, i32* %4
%6 = call i32* (...) @BN_CTX_new()
store i32* %6, i32** %1
%7 = call i32 @test_ptr(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2336, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %0
%10 = call i32* (...) @BN_CTX_secure_new()
store i32* %10, i32** %2
%11 = call i32 @test_ptr(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2337, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %9, %0
br label %46
14: ; preds = %9
store i64 0, i64* %3
br label %15
15: ; preds = %42, %14
%16 = load i64, i64* %3
%17 = icmp ult i64 %16, 2
br i1 %17, label %18, label %45
18: ; preds = %15
%19 = load i64, i64* %3
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = load i32*, i32** %1
br label %25
23: ; preds = %18
%24 = load i32*, i32** %2
br label %25
25: ; preds = %23, %21
%26 = phi i32* [ %22, %21 ], [ %24, %23 ]
store i32* %26, i32** %5
%27 = load i32*, i32** %5
%28 = call i64 @test_ctx_set_ct_flag(i32* %27)
%29 = icmp ne i64 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @test_true(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2342, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %40
33: ; preds = %25
%34 = load i32*, i32** %5
%35 = call i64 @test_ctx_check_ct_flag(i32* %34)
%36 = icmp ne i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @test_true(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2343, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %33, %25
br label %46
41: ; preds = %33
br label %42
42: ; preds = %41
%43 = load i64, i64* %3
%44 = add i64 %43, 1
store i64 %44, i64* %3
br label %15
45: ; preds = %15
store i32 1, i32* %4
br label %46
46: ; preds = %45, %40, %13
%47 = load i32*, i32** %1
%48 = call i32 @BN_CTX_free(i32* %47)
%49 = load i32*, i32** %2
%50 = call i32 @BN_CTX_free(i32* %49)
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
@.str = [170 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/bntest.c\00"
@.str.1 = [20 x i8] c"nctx = BN_CTX_new()\00"
@.str.2 = [27 x i8] c"sctx = BN_CTX_secure_new()\00"
@.str.3 = [24 x i8] c"test_ctx_set_ct_flag(c)\00"
@.str.4 = [26 x i8] c"test_ctx_check_ct_flag(c)\00"
define i32 @test_ctx_consttime_flag() {
%1 = tail call i32* (...) @BN_CTX_new()
%2 = tail call i32 @test_ptr(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2336, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%3 = icmp eq i32 %2, 0
br i1 %3, label %33, label %4
4: ; preds = %0
%5 = tail call i32* (...) @BN_CTX_secure_new()
%6 = tail call i32 @test_ptr(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2337, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %33, label %8
8: ; preds = %4
%9 = tail call i64 @test_ctx_set_ct_flag(i32* %1)
%10 = icmp ne i64 %9, 0
%11 = zext i1 %10 to i32
%12 = tail call i32 @test_true(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2342, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %11)
%13 = icmp eq i32 %12, 0
br i1 %13, label %33, label %27
14: ; preds = %27
%15 = tail call i64 @test_ctx_set_ct_flag(i32* %5)
%16 = icmp ne i64 %15, 0
%17 = zext i1 %16 to i32
%18 = tail call i32 @test_true(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2342, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %33, label %20
20: ; preds = %14
%21 = tail call i64 @test_ctx_check_ct_flag(i32* %5)
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @test_true(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2343, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i32
br label %33
27: ; preds = %8
%28 = tail call i64 @test_ctx_check_ct_flag(i32* %1)
%29 = icmp ne i64 %28, 0
%30 = zext i1 %29 to i32
%31 = tail call i32 @test_true(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2343, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %14
33: ; preds = %20, %27, %8, %14, %0, %4
%34 = phi i32* [ %5, %4 ], [ null, %0 ], [ %5, %14 ], [ %5, %8 ], [ %5, %27 ], [ %5, %20 ]
%35 = phi i32 [ 0, %4 ], [ 0, %0 ], [ 0, %14 ], [ 0, %8 ], [ 0, %27 ], [ %26, %20 ]
%36 = tail call i32 @BN_CTX_free(i32* %1)
%37 = tail call i32 @BN_CTX_free(i32* %34)
ret i32 %35
}