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

/* Variables and functions */
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int BN_mod_mul(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
               int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int BN_mod_sqr(int /*<<< orphan*/ *, int /*<<< orphan*/ const *,
               int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
int BN_set_word(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int F1(BIGNUM *r, const BIGNUM *x, const BIGNUM *N, BN_CTX *bn_ctx) {
  int ret, ok;
  BIGNUM *t1 = NULL, *t2 = NULL;
  if ((t1 = BN_new()) == NULL) {
    fprintf(stderr, "@@@ %s:%d @@@\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/dstebila/daps/refs/heads/master/"
            "daps_h2_mr.c",
            164);
    fflush(stderr);
    ;
    goto err;
  };
  if ((t2 = BN_new()) == NULL) {
    fprintf(stderr, "@@@ %s:%d @@@\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/dstebila/daps/refs/heads/master/"
            "daps_h2_mr.c",
            165);
    fflush(stderr);
    ;
    goto err;
  };
  ok = (BN_set_word(t1, 4));
  if (ok != 1) {
    fprintf(stderr, "@@@ %s:%d @@@\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/dstebila/daps/refs/heads/master/"
            "daps_h2_mr.c",
            166);
    fflush(stderr);
    ;
    goto err;
  };
  ok = (BN_mod_sqr(t2, x, N, bn_ctx));
  if (ok != 1) {
    fprintf(stderr, "@@@ %s:%d @@@\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/dstebila/daps/refs/heads/master/"
            "daps_h2_mr.c",
            167);
    fflush(stderr);
    ;
    goto err;
  };
  ok = (BN_mod_mul(r, t1, t2, N, bn_ctx));
  if (ok != 1) {
    fprintf(stderr, "@@@ %s:%d @@@\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/dstebila/daps/refs/heads/master/"
            "daps_h2_mr.c",
            168);
    fflush(stderr);
    ;
    goto err;
  };
  ret = 1;
  goto cleanup;
err:
  ret = 0;
cleanup:
  BN_free(t1);
  BN_free(t2);
  return ret;
}


x86 assembly (clang, -O0):
<F1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11e1 <F1+0x71>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
lea    0xe4b(%rip),%rdx
mov    $0xa4,%ecx
call   1060 <fprintf@plt>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    1335 <F1+0x1c5>
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    122a <F1+0xba>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
lea    0xdfa(%rip),%rsi
lea    0xe02(%rip),%rdx
mov    $0xa5,%ecx
call   1060 <fprintf@plt>
mov    0x2dc2(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    1335 <F1+0x1c5>
mov    -0x30(%rbp),%rdi
mov    $0x4,%esi
call   1030 <BN_set_word@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     1279 <F1+0x109>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
lea    0xdab(%rip),%rsi
lea    0xdb3(%rip),%rdx
mov    $0xa6,%ecx
call   1060 <fprintf@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    1335 <F1+0x1c5>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1090 <BN_mod_sqr@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     12cf <F1+0x15f>
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
lea    0xd55(%rip),%rsi
lea    0xd5d(%rip),%rdx
mov    $0xa7,%ecx
call   1060 <fprintf@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    1335 <F1+0x1c5>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
call   1080 <BN_mod_mul@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     1329 <F1+0x1b9>
mov    0x2ce4(%rip),%rax
mov    (%rax),%edi
lea    0xcfb(%rip),%rsi
lea    0xd03(%rip),%rdx
mov    $0xa8,%ecx
call   1060 <fprintf@plt>
mov    0x2cc3(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    1335 <F1+0x1c5>
movl   $0x1,-0x24(%rbp)
jmp    133c <F1+0x1cc>
movl   $0x0,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
call   1050 <BN_free@plt>
mov    -0x38(%rbp),%rdi
call   1050 <BN_free@plt>
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<F1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%r13
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%r14
test   %rax,%rax
je     11fe <F1+0x8e>
xor    %eax,%eax
call   1040 <BN_new@plt>
test   %rax,%rax
je     1205 <F1+0x95>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x4,%esi
call   1030 <BN_set_word@plt>
mov    $0xa6,%ecx
cmp    $0x1,%eax
jne    120c <F1+0x9c>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
call   1090 <BN_mod_sqr@plt>
mov    $0xa7,%ecx
cmp    $0x1,%eax
jne    120c <F1+0x9c>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r15,%r8
call   1080 <BN_mod_mul@plt>
mov    $0xa8,%ecx
mov    $0x1,%ebp
cmp    $0x1,%eax
jne    120c <F1+0x9c>
jmp    1233 <F1+0xc3>
mov    $0xa4,%ecx
jmp    120c <F1+0x9c>
mov    $0xa5,%ecx
xor    %ebx,%ebx
mov    0x2dcd(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xde3(%rip),%rsi
lea    0xdeb(%rip),%rdx
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
call   1070 <fflush@plt>
xor    %ebp,%ebp
mov    %r14,%rdi
call   1050 <BN_free@plt>
mov    %rbx,%rdi
call   1050 <BN_free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"@@@ %s:%d @@@\0A\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dstebila/daps/refs/heads/master/daps_h2_mr.c\00"
define i32 @F1(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32* null, i32** %11
store i32* null, i32** %12
%13 = call i32* (...) @BN_new()
store i32* %13, i32** %11
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %4
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 164)
%18 = load i32, i32* @stderr
%19 = call i32 @fflush(i32 %18)
br label %66
20: ; preds = %4
%21 = call i32* (...) @BN_new()
store i32* %21, i32** %12
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 165)
%26 = load i32, i32* @stderr
%27 = call i32 @fflush(i32 %26)
br label %66
28: ; preds = %20
%29 = load i32*, i32** %11
%30 = call i32 @BN_set_word(i32* %29, i32 4)
store i32 %30, i32* %10
%31 = load i32, i32* %10
%32 = icmp ne i32 %31, 1
br i1 %32, label %33, label %38
33: ; preds = %28
%34 = load i32, i32* @stderr
%35 = call i32 @fprintf(i32 %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 166)
%36 = load i32, i32* @stderr
%37 = call i32 @fflush(i32 %36)
br label %66
38: ; preds = %28
%39 = load i32*, i32** %12
%40 = load i32*, i32** %6
%41 = load i32*, i32** %7
%42 = load i32*, i32** %8
%43 = call i32 @BN_mod_sqr(i32* %39, i32* %40, i32* %41, i32* %42)
store i32 %43, i32* %10
%44 = load i32, i32* %10
%45 = icmp ne i32 %44, 1
br i1 %45, label %46, label %51
46: ; preds = %38
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 167)
%49 = load i32, i32* @stderr
%50 = call i32 @fflush(i32 %49)
br label %66
51: ; preds = %38
%52 = load i32*, i32** %5
%53 = load i32*, i32** %11
%54 = load i32*, i32** %12
%55 = load i32*, i32** %7
%56 = load i32*, i32** %8
%57 = call i32 @BN_mod_mul(i32* %52, i32* %53, i32* %54, i32* %55, i32* %56)
store i32 %57, i32* %10
%58 = load i32, i32* %10
%59 = icmp ne i32 %58, 1
br i1 %59, label %60, label %65
60: ; preds = %51
%61 = load i32, i32* @stderr
%62 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 168)
%63 = load i32, i32* @stderr
%64 = call i32 @fflush(i32 %63)
br label %66
65: ; preds = %51
store i32 1, i32* %9
br label %67
66: ; preds = %60, %46, %33, %23, %15
store i32 0, i32* %9
br label %67
67: ; preds = %66, %65
%68 = load i32*, i32** %11
%69 = call i32 @BN_free(i32* %68)
%70 = load i32*, i32** %12
%71 = call i32 @BN_free(i32* %70)
%72 = load i32, i32* %9
ret i32 %72
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"@@@ %s:%d @@@\0A\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/dstebila/daps/refs/heads/master/daps_h2_mr.c\00"
define i32 @F1(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = tail call i32* (...) @BN_new()
%6 = icmp eq i32* %5, null
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = tail call i32* (...) @BN_new()
%9 = icmp eq i32* %8, null
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i32 @BN_set_word(i32* %5, i32 4)
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = tail call i32 @BN_mod_sqr(i32* %8, i32* %1, i32* %2, i32* %3)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = tail call i32 @BN_mod_mul(i32* %0, i32* %5, i32* %8, i32* %2, i32* %3)
%18 = icmp eq i32 %17, 1
br i1 %18, label %26, label %19
19: ; preds = %16, %13, %10, %7, %4
%20 = phi i32 [ 164, %4 ], [ 165, %7 ], [ 166, %10 ], [ 167, %13 ], [ 168, %16 ]
%21 = phi i32* [ null, %4 ], [ null, %7 ], [ %8, %10 ], [ %8, %13 ], [ %8, %16 ]
%22 = load i32, i32* @stderr
%23 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%24 = load i32, i32* @stderr
%25 = tail call i32 @fflush(i32 %24)
br label %26
26: ; preds = %19, %16
%27 = phi i32 [ 1, %16 ], [ 0, %19 ]
%28 = phi i32* [ %8, %16 ], [ %21, %19 ]
%29 = tail call i32 @BN_free(i32* %5)
%30 = tail call i32 @BN_free(i32* %28)
ret i32 %27
}