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

/* Variables and functions */
int /*<<< orphan*/ *BN_copy(int /*<<< orphan*/ const *,
                            int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ const *);
int BN_mod_sqr(int /*<<< orphan*/ const *, int /*<<< orphan*/ const *,
               int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ const *BN_new();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int F0(BIGNUM *r, const BIGNUM *x, const BIGNUM *N, BN_CTX *bn_ctx) {
  int ret, ok;
  BIGNUM *rprime = NULL;
  if (x == r) {
    if ((rprime = 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",
              142);
      fflush(stderr);
      ;
      goto err;
    };
    ok = (BN_mod_sqr(rprime, 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",
              143);
      fflush(stderr);
      ;
      goto err;
    };
    if ((BN_copy(r, rprime)) == 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",
              144);
      fflush(stderr);
      ;
      goto err;
    };
  } else {
    ok = (BN_mod_sqr(r, 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",
              146);
      fflush(stderr);
      ;
      goto err;
    };
  }
  ret = 1;
  goto cleanup;
err:
  ret = 0;
cleanup:
  if (x == r) {
    BN_free(rprime);
  }
  return ret;
}


x86 assembly (clang, -O0):
<F0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    127d <F0+0x11d>
mov    $0x0,%al
call   1030 <BN_new@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11d7 <F0+0x77>
mov    0x2e36(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
lea    0xe55(%rip),%rdx
mov    $0x8e,%ecx
call   1060 <fprintf@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    12e4 <F0+0x184>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1080 <BN_mod_sqr@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     122d <F0+0xcd>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
lea    0xdf7(%rip),%rsi
lea    0xdff(%rip),%rdx
mov    $0x8f,%ecx
call   1060 <fprintf@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    12e4 <F0+0x184>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <BN_copy@plt>
cmp    $0x0,%rax
jne    1278 <F0+0x118>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
lea    0xdac(%rip),%rsi
lea    0xdb4(%rip),%rdx
mov    $0x90,%ecx
call   1060 <fprintf@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    12e4 <F0+0x184>
jmp    12d8 <F0+0x178>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
call   1080 <BN_mod_sqr@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     12d3 <F0+0x173>
mov    0x2d3a(%rip),%rax
mov    (%rax),%edi
lea    0xd51(%rip),%rsi
lea    0xd59(%rip),%rdx
mov    $0x92,%ecx
call   1060 <fprintf@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
jmp    12e4 <F0+0x184>
jmp    12d8 <F0+0x178>
movl   $0x1,-0x24(%rbp)
jmp    12eb <F0+0x18b>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
jne    1302 <F0+0x1a2>
mov    -0x30(%rbp),%rdi
call   1040 <BN_free@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<F0>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
cmp    %rdi,%rsi
je     11be <F0+0x5e>
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
call   1080 <BN_mod_sqr@plt>
mov    $0x1,%ebx
cmp    $0x1,%eax
je     1236 <F0+0xd6>
mov    0x2e47(%rip),%rbx
mov    (%rbx),%edi
lea    0xe5e(%rip),%rsi
lea    0xe66(%rip),%rdx
mov    $0x92,%ecx
call   1060 <fprintf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
xor    %ebx,%ebx
jmp    1236 <F0+0xd6>
xor    %eax,%eax
call   1030 <BN_new@plt>
mov    %rax,%r14
test   %rax,%rax
je     1204 <F0+0xa4>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
call   1080 <BN_mod_sqr@plt>
mov    $0x8f,%ecx
cmp    $0x1,%eax
jne    1209 <F0+0xa9>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <BN_copy@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    122e <F0+0xce>
mov    $0x90,%ecx
jmp    1209 <F0+0xa9>
mov    $0x8e,%ecx
mov    0x2dd0(%rip),%rbx
mov    (%rbx),%edi
lea    0xde7(%rip),%rsi
lea    0xdef(%rip),%rdx
call   1060 <fprintf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1040 <BN_free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
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 @F0(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*
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
%12 = load i32*, i32** %6
%13 = load i32*, i32** %5
%14 = icmp eq i32* %12, %13
br i1 %14, label %15, label %47
15: ; preds = %4
%16 = call i32* (...) @BN_new()
store i32* %16, i32** %11
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, 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 142)
%21 = load i32, i32* @stderr
%22 = call i32 @fflush(i32 %21)
br label %62
23: ; preds = %15
%24 = load i32*, i32** %11
%25 = load i32*, i32** %6
%26 = load i32*, i32** %7
%27 = load i32*, i32** %8
%28 = call i32 @BN_mod_sqr(i32* %24, i32* %25, i32* %26, i32* %27)
store i32 %28, i32* %10
%29 = load i32, i32* %10
%30 = icmp ne i32 %29, 1
br i1 %30, label %31, label %36
31: ; preds = %23
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, 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 143)
%34 = load i32, i32* @stderr
%35 = call i32 @fflush(i32 %34)
br label %62
36: ; preds = %23
%37 = load i32*, i32** %5
%38 = load i32*, i32** %11
%39 = call i32* @BN_copy(i32* %37, i32* %38)
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, 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 144)
%44 = load i32, i32* @stderr
%45 = call i32 @fflush(i32 %44)
br label %62
46: ; preds = %36
br label %61
47: ; preds = %4
%48 = load i32*, i32** %5
%49 = load i32*, i32** %6
%50 = load i32*, i32** %7
%51 = load i32*, i32** %8
%52 = call i32 @BN_mod_sqr(i32* %48, i32* %49, i32* %50, i32* %51)
store i32 %52, i32* %10
%53 = load i32, i32* %10
%54 = icmp ne i32 %53, 1
br i1 %54, label %55, label %60
55: ; preds = %47
%56 = load i32, i32* @stderr
%57 = call i32 @fprintf(i32 %56, 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 146)
%58 = load i32, i32* @stderr
%59 = call i32 @fflush(i32 %58)
br label %62
60: ; preds = %47
br label %61
61: ; preds = %60, %46
store i32 1, i32* %9
br label %63
62: ; preds = %55, %41, %31, %18
store i32 0, i32* %9
br label %63
63: ; preds = %62, %61
%64 = load i32*, i32** %6
%65 = load i32*, i32** %5
%66 = icmp eq i32* %64, %65
br i1 %66, label %67, label %70
67: ; preds = %63
%68 = load i32*, i32** %11
%69 = call i32 @BN_free(i32* %68)
br label %70
70: ; preds = %67, %63
%71 = load i32, i32* %9
ret i32 %71
}

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 @F0(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = icmp eq i32* %1, %0
br i1 %5, label %6, label %15
6: ; preds = %4
%7 = tail call i32* (...) @BN_new()
%8 = icmp eq i32* %7, null
br i1 %8, label %23, label %9
9: ; preds = %6
%10 = tail call i32 @BN_mod_sqr(i32* %7, i32* %1, i32* %2, i32* %3)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %23
12: ; preds = %9
%13 = tail call i32* @BN_copy(i32* %1, i32* %7)
%14 = icmp eq i32* %13, null
br i1 %14, label %23, label %29
15: ; preds = %4
%16 = tail call i32 @BN_mod_sqr(i32* %0, i32* %1, i32* %2, i32* %3)
%17 = icmp eq i32 %16, 1
br i1 %17, label %32, label %18
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, 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 146)
%21 = load i32, i32* @stderr
%22 = tail call i32 @fflush(i32 %21)
br label %32
23: ; preds = %12, %9, %6
%24 = phi i32 [ 142, %6 ], [ 143, %9 ], [ 144, %12 ]
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, 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 %24)
%27 = load i32, i32* @stderr
%28 = tail call i32 @fflush(i32 %27)
br label %29
29: ; preds = %23, %12
%30 = phi i32 [ 1, %12 ], [ 0, %23 ]
%31 = tail call i32 @BN_free(i32* %7)
br label %32
32: ; preds = %15, %18, %29
%33 = phi i32 [ %30, %29 ], [ 1, %15 ], [ 0, %18 ]
ret i32 %33
}