#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*/ b;
typedef int /*<<< orphan*/ BN_CTX;
typedef int /*<<< orphan*/ BIGNUM;

/* Variables and functions */
int /*<<< orphan*/ BN_CTX_end(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_CTX_get(int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_CTX_start(int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_FLG_CONSTTIME;
int /*<<< orphan*/ BN_set_flags(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ test_ptr(char *, int, char *, int /*<<< orphan*/ *);
int test_ctx_set_ct_flag(BN_CTX *c) {
  int st = 0;
  size_t i;
  BIGNUM *b[15];
  BN_CTX_start(c);
  for (i = 0; i < (sizeof(b) / sizeof((b)[0])); i++) {
    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",
            2276, "b[i] = BN_CTX_get(c)", b[i] = BN_CTX_get(c)))
      goto err;
    if (i % 2 == 1)
      BN_set_flags(b[i], BN_FLG_CONSTTIME);
  }
  st = 1;
err:
  BN_CTX_end(c);
  return st;
}


x86 assembly (clang, -O0):
<test_ctx_set_ct_flag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <BN_CTX_start@plt>
movq   $0x0,-0x18(%rbp)
cmpq   $0xf,-0x18(%rbp)
jae    1202 <test_ctx_set_ct_flag+0xb2>
mov    -0x8(%rbp),%rdi
call   1030 <BN_CTX_get@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,-0x90(%rbp,%rax,8)
ff
lea    0xe5f(%rip),%rdi
mov    $0x8e4,%esi
lea    0xefd(%rip),%rdx
call   1040 <test_ptr@plt>
cmp    $0x0,%eax
jne    11c0 <test_ctx_set_ct_flag+0x70>
jmp    1209 <test_ctx_set_ct_flag+0xb9>
mov    -0x18(%rbp),%rax
and    $0x1,%rax
cmp    $0x1,%rax
jne    11ec <test_ctx_set_ct_flag+0x9c>
mov    -0x18(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdi
ff
mov    0x2e03(%rip),%rax
mov    (%rax),%esi
call   1070 <BN_set_flags@plt>
jmp    11f1 <test_ctx_set_ct_flag+0xa1>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1177 <test_ctx_set_ct_flag+0x27>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <BN_CTX_end@plt>
mov    -0xc(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ctx_set_ct_flag>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
call   1060 <BN_CTX_start@plt>
lea    0xe96(%rip),%r15
lea    0xf39(%rip),%r12
mov    0x2e70(%rip),%rbp
xor    %r14d,%r14d
jmp    118a <test_ctx_set_ct_flag+0x3a>
nopl   (%rax)
add    $0x1,%r14
cmp    $0xf,%r14
je     11bf <test_ctx_set_ct_flag+0x6f>
mov    %r13,%rdi
call   1030 <BN_CTX_get@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x8e4,%esi
mov    %r12,%rdx
mov    %rax,%rcx
call   1040 <test_ptr@plt>
test   %eax,%eax
je     11c6 <test_ctx_set_ct_flag+0x76>
test   $0x1,%r14b
je     1180 <test_ctx_set_ct_flag+0x30>
mov    0x0(%rbp),%esi
mov    %rbx,%rdi
call   1070 <BN_set_flags@plt>
jmp    1180 <test_ctx_set_ct_flag+0x30>
mov    $0x1,%ebx
jmp    11c8 <test_ctx_set_ct_flag+0x78>
xor    %ebx,%ebx
mov    %r13,%rdi
call   1050 <BN_CTX_end@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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 = [21 x i8] c"b[i] = BN_CTX_get(c)\00"
@BN_FLG_CONSTTIME = global i32 0
define i32 @test_ctx_set_ct_flag(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i64
%5 = alloca [15 x i32*]
store i32* %0, i32** %2
store i32 0, i32* %3
%6 = load i32*, i32** %2
%7 = call i32 @BN_CTX_start(i32* %6)
store i64 0, i64* %4
br label %8
8: ; preds = %30, %1
%9 = load i64, i64* %4
%10 = icmp ult i64 %9, 15
br i1 %10, label %11, label %33
11: ; preds = %8
%12 = load i32*, i32** %2
%13 = call i32* @BN_CTX_get(i32* %12)
%14 = load i64, i64* %4
%15 = getelementptr inbounds [15 x i32*], [15 x i32*]* %5, i64 0, i64 %14
store i32* %13, i32** %15
%16 = call i32 @test_ptr(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2276, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* %13)
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %11
br label %34
19: ; preds = %11
%20 = load i64, i64* %4
%21 = urem i64 %20, 2
%22 = icmp eq i64 %21, 1
br i1 %22, label %23, label %29
23: ; preds = %19
%24 = load i64, i64* %4
%25 = getelementptr inbounds [15 x i32*], [15 x i32*]* %5, i64 0, i64 %24
%26 = load i32*, i32** %25
%27 = load i32, i32* @BN_FLG_CONSTTIME
%28 = call i32 @BN_set_flags(i32* %26, i32 %27)
br label %29
29: ; preds = %23, %19
br label %30
30: ; preds = %29
%31 = load i64, i64* %4
%32 = add i64 %31, 1
store i64 %32, i64* %4
br label %8
33: ; preds = %8
store i32 1, i32* %3
br label %34
34: ; preds = %33, %18
%35 = load i32*, i32** %2
%36 = call i32 @BN_CTX_end(i32* %35)
%37 = load i32, i32* %3
ret i32 %37
}

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 = [21 x i8] c"b[i] = BN_CTX_get(c)\00"
@BN_FLG_CONSTTIME = global i32 0
define i32 @test_ctx_set_ct_flag(i32* %0) {
%2 = tail call i32 @BN_CTX_start(i32* %0)
br label %3
3: ; preds = %1, %14
%4 = phi i64 [ 0, %1 ], [ %15, %14 ]
%5 = tail call i32* @BN_CTX_get(i32* %0)
%6 = tail call i32 @test_ptr(i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str, i64 0, i64 0), i32 2276, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %3
%9 = and i64 %4, 1
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %8
%12 = load i32, i32* @BN_FLG_CONSTTIME
%13 = tail call i32 @BN_set_flags(i32* %5, i32 %12)
br label %14
14: ; preds = %8, %11
%15 = add nuw nsw i64 %4, 1
%16 = icmp eq i64 %15, 15
br i1 %16, label %17, label %3
17: ; preds = %14, %3
%18 = phi i32 [ 0, %3 ], [ 1, %14 ]
%19 = tail call i32 @BN_CTX_end(i32* %0)
ret i32 %18
}