#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_bin2bn(unsigned char *, int, int /*<<< orphan*/ *);
int BN_bn2bin(int /*<<< orphan*/ const *, unsigned char *);
int BN_cmp(int /*<<< orphan*/ *, int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int BN_gcd(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_is_one(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BN_new();
int BN_num_bytes(int /*<<< orphan*/ const *);
int /*<<< orphan*/ OPENSSL_free(unsigned char *);
unsigned char *OPENSSL_malloc(int);
int /*<<< orphan*/ bzero(unsigned char *, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int perm_E_forward(unsigned char *, int, unsigned char *);
int perm_E_reverse(unsigned char *, int, unsigned char *);
int /*<<< orphan*/ stderr;
int perm_Z(BIGNUM *out, const BIGNUM *in, const BIGNUM *modulus,
           const int forward, BN_CTX *ctx) {
  int ret, ok;
  unsigned char *in_b = NULL, *out_b = NULL;
  BIGNUM *tmp = NULL;
  int m_len = BN_num_bytes(modulus);
  if (m_len % 32 != 0) {
    goto err;
  }
  if (BN_num_bytes(in) > m_len) {
    goto err;
  }
  if ((in_b = OPENSSL_malloc(m_len)) == 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_id2_gq.c",
            192);
    fflush(stderr);
    ;
    goto err;
  };
  if ((out_b = OPENSSL_malloc(m_len)) == 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_id2_gq.c",
            193);
    fflush(stderr);
    ;
    goto err;
  };
  bzero(in_b, m_len);
  bzero(out_b, m_len);
  int in_len = BN_num_bytes(in);
  ok = BN_bn2bin(in, in_b + (m_len - in_len));
  if (ok > m_len) {
    goto err;
  }
  if (forward) {
    ok = (perm_E_forward(in_b, m_len, out_b));
    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_id2_gq.c",
              202);
      fflush(stderr);
      ;
      goto err;
    };
  } else {
    ok = (perm_E_reverse(in_b, m_len, out_b));
    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_id2_gq.c",
              204);
      fflush(stderr);
      ;
      goto err;
    };
  }
  if ((BN_bin2bn(out_b, m_len, out)) == 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_id2_gq.c",
            206);
    fflush(stderr);
    ;
    goto err;
  };
  if ((tmp = 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_id2_gq.c",
            207);
    fflush(stderr);
    ;
    goto err;
  };
  ok = (BN_gcd(tmp, out, modulus, 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_id2_gq.c",
            208);
    fflush(stderr);
    ;
    goto err;
  };
  if ((BN_cmp(out, modulus) >= 1) || (!BN_is_one(tmp))) {
    OPENSSL_free(in_b);
    OPENSSL_free(out_b);
    BN_free(tmp);
    return perm_Z(out, out, modulus, forward, ctx);
  }
  ret = 1;
  goto cleanup;
err:
  ret = 0;
cleanup:
  OPENSSL_free(in_b);
  OPENSSL_free(out_b);
  BN_free(tmp);
  return ret;
}


x86 assembly (clang, -O0):
<perm_Z>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8,-0x30(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
call   10d0 <BN_num_bytes@plt>
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    $0x20,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1258 <perm_Z+0x58>
jmp    1565 <perm_Z+0x365>
mov    -0x18(%rbp),%rdi
call   10d0 <BN_num_bytes@plt>
cmp    -0x54(%rbp),%eax
jle    126f <perm_Z+0x6f>
jmp    1565 <perm_Z+0x365>
mov    -0x54(%rbp),%edi
call   10c0 <OPENSSL_malloc@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    12b9 <perm_Z+0xb9>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
lea    0xd6b(%rip),%rsi
lea    0xd73(%rip),%rdx
mov    $0xc0,%ecx
call   1080 <fprintf@plt>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1565 <perm_Z+0x365>
mov    -0x54(%rbp),%edi
call   10c0 <OPENSSL_malloc@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1303 <perm_Z+0x103>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
lea    0xd21(%rip),%rsi
lea    0xd29(%rip),%rdx
mov    $0xc1,%ecx
call   1080 <fprintf@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1565 <perm_Z+0x365>
mov    -0x40(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1100 <bzero@plt>
mov    -0x48(%rbp),%rdi
mov    -0x54(%rbp),%esi
call   1100 <bzero@plt>
mov    -0x18(%rbp),%rdi
call   10d0 <BN_num_bytes@plt>
mov    %eax,-0x58(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x54(%rbp),%eax
sub    -0x58(%rbp),%eax
cltq
add    %rax,%rsi
call   10e0 <BN_bn2bin@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x54(%rbp),%eax
jle    1353 <perm_Z+0x153>
jmp    1565 <perm_Z+0x365>
cmpl   $0x0,-0x24(%rbp)
je     13b3 <perm_Z+0x1b3>
mov    -0x40(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x48(%rbp),%rdx
call   10a0 <perm_E_forward@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x1,-0x38(%rbp)
je     13ae <perm_Z+0x1ae>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
lea    0xc76(%rip),%rsi
lea    0xc7e(%rip),%rdx
mov    $0xca,%ecx
call   1080 <fprintf@plt>
mov    0x2c3e(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1565 <perm_Z+0x365>
jmp    1409 <perm_Z+0x209>
mov    -0x40(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x48(%rbp),%rdx
call   1090 <perm_E_reverse@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x1,-0x38(%rbp)
je     1404 <perm_Z+0x204>
mov    0x2c09(%rip),%rax
mov    (%rax),%edi
lea    0xc20(%rip),%rsi
lea    0xc28(%rip),%rdx
mov    $0xcc,%ecx
call   1080 <fprintf@plt>
mov    0x2be8(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1565 <perm_Z+0x365>
jmp    1409 <perm_Z+0x209>
mov    -0x48(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1050 <BN_bin2bn@plt>
cmp    $0x0,%rax
jne    1457 <perm_Z+0x257>
mov    0x2bb6(%rip),%rax
mov    (%rax),%edi
lea    0xbcd(%rip),%rsi
lea    0xbd5(%rip),%rdx
mov    $0xce,%ecx
call   1080 <fprintf@plt>
mov    0x2b95(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1565 <perm_Z+0x365>
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    14a0 <perm_Z+0x2a0>
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
lea    0xb84(%rip),%rsi
lea    0xb8c(%rip),%rdx
mov    $0xcf,%ecx
call   1080 <fprintf@plt>
mov    0x2b4c(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1565 <perm_Z+0x365>
mov    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x30(%rbp),%rcx
call   1030 <BN_gcd@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x1,-0x38(%rbp)
je     14f6 <perm_Z+0x2f6>
mov    0x2b17(%rip),%rax
mov    (%rax),%edi
lea    0xb2e(%rip),%rsi
lea    0xb36(%rip),%rdx
mov    $0xd0,%ecx
call   1080 <fprintf@plt>
mov    0x2af6(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
jmp    1565 <perm_Z+0x365>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10f0 <BN_cmp@plt>
cmp    $0x1,%eax
jge    151e <perm_Z+0x31e>
mov    -0x50(%rbp),%rdi
call   1120 <BN_is_one@plt>
cmp    $0x0,%eax
jne    1559 <perm_Z+0x359>
mov    -0x40(%rbp),%rdi
call   1110 <OPENSSL_free@plt>
mov    -0x48(%rbp),%rdi
call   1110 <OPENSSL_free@plt>
mov    -0x50(%rbp),%rdi
call   1060 <BN_free@plt>
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x30(%rbp),%r8
call   1070 <perm_Z@plt>
mov    %eax,-0x4(%rbp)
jmp    158d <perm_Z+0x38d>
movl   $0x1,-0x34(%rbp)
jmp    156c <perm_Z+0x36c>
movl   $0x0,-0x34(%rbp)
mov    -0x40(%rbp),%rdi
call   1110 <OPENSSL_free@plt>
mov    -0x48(%rbp),%rdi
call   1110 <OPENSSL_free@plt>
mov    -0x50(%rbp),%rdi
call   1060 <BN_free@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perm_Z>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,0x20(%rsp)
mov    %ecx,0xc(%rsp)
mov    %rdx,%rbp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rdx,%rdi
call   10c0 <BN_num_bytes@plt>
mov    %eax,%r13d
xor    %edi,%edi
mov    $0x0,%r15d
mov    $0x0,%r12d
mov    $0x0,%eax
test   $0x1f,%r13b
jne    1434 <perm_Z+0x244>
mov    %rbx,0x18(%rsp)
mov    %rbp,0x10(%rsp)
mov    0x10(%rsp),%rbp
jmp    1280 <perm_Z+0x90>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1100 <OPENSSL_free@plt>
mov    %r15,%rdi
call   1100 <OPENSSL_free@plt>
mov    %r12,%rdi
call   1060 <BN_free@plt>
mov    %rbp,%rdi
call   10c0 <BN_num_bytes@plt>
mov    %eax,%r13d
mov    %rbx,%r14
test   $0x1f,%r13b
jne    13ef <perm_Z+0x1ff>
mov    %r14,%rdi
call   10c0 <BN_num_bytes@plt>
cmp    %r13d,%eax
jg     13aa <perm_Z+0x1ba>
mov    %r13d,%edi
call   10b0 <OPENSSL_malloc@plt>
test   %rax,%rax
je     13b6 <perm_Z+0x1c6>
mov    %rax,%rbx
mov    %r13d,%edi
call   10b0 <OPENSSL_malloc@plt>
test   %rax,%rax
je     13c3 <perm_Z+0x1d3>
mov    %rax,%r15
mov    %rbx,%rdi
mov    %r13d,%esi
call   10f0 <bzero@plt>
mov    %r15,%rdi
mov    %r13d,%esi
call   10f0 <bzero@plt>
mov    %r14,%rdi
call   10c0 <BN_num_bytes@plt>
mov    %r13d,%ecx
sub    %eax,%ecx
movslq %ecx,%rax
mov    %rbx,%rsi
add    %rax,%rsi
mov    %r14,%rdi
call   10d0 <BN_bn2bin@plt>
cmp    %r13d,%eax
jg     13d0 <perm_Z+0x1e0>
cmpl   $0x0,0xc(%rsp)
je     1320 <perm_Z+0x130>
mov    %rbx,%r14
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
call   1090 <perm_E_forward@plt>
cmp    $0x1,%eax
je     133a <perm_Z+0x14a>
jmp    13fb <perm_Z+0x20b>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%r14
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r15,%rdx
call   1080 <perm_E_reverse@plt>
cmp    $0x1,%eax
jne    1402 <perm_Z+0x212>
mov    %r15,%rdi
mov    %r13d,%esi
mov    0x18(%rsp),%rbx
mov    %rbx,%rdx
call   1050 <BN_bin2bn@plt>
test   %rax,%rax
je     13da <perm_Z+0x1ea>
xor    %eax,%eax
call   1040 <BN_new@plt>
test   %rax,%rax
je     13e1 <perm_Z+0x1f1>
mov    %rax,%r12
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    0x20(%rsp),%rcx
call   1030 <BN_gcd@plt>
cmp    $0x1,%eax
jne    13e8 <perm_Z+0x1f8>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10e0 <BN_cmp@plt>
test   %eax,%eax
jg     1250 <perm_Z+0x60>
mov    %r12,%rdi
call   1110 <BN_is_one@plt>
test   %eax,%eax
je     1250 <perm_Z+0x60>
mov    $0x1,%eax
jmp    1431 <perm_Z+0x241>
xor    %edi,%edi
xor    %r15d,%r15d
xor    %eax,%eax
xor    %r12d,%r12d
jmp    1434 <perm_Z+0x244>
mov    $0xc0,%ecx
xor    %r14d,%r14d
xor    %r15d,%r15d
jmp    1407 <perm_Z+0x217>
mov    %rbx,%r14
mov    $0xc1,%ecx
xor    %r15d,%r15d
jmp    1407 <perm_Z+0x217>
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rbx,%rdi
jmp    1434 <perm_Z+0x244>
mov    $0xce,%ecx
jmp    1407 <perm_Z+0x217>
mov    $0xcf,%ecx
jmp    1407 <perm_Z+0x217>
mov    $0xd0,%ecx
jmp    140a <perm_Z+0x21a>
xor    %edi,%edi
xor    %r15d,%r15d
xor    %r12d,%r12d
xor    %eax,%eax
jmp    1434 <perm_Z+0x244>
mov    $0xca,%ecx
jmp    1407 <perm_Z+0x217>
mov    $0xcc,%ecx
xor    %r12d,%r12d
mov    0x2bcf(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xbe5(%rip),%rsi
lea    0xbed(%rip),%rdx
call   1070 <fprintf@plt>
mov    0x0(%rbp),%edi
call   10a0 <fflush@plt>
xor    %eax,%eax
mov    %r14,%rdi
mov    %rax,%rbx
call   1100 <OPENSSL_free@plt>
mov    %r15,%rdi
call   1100 <OPENSSL_free@plt>
mov    %r12,%rdi
call   1060 <BN_free@plt>
mov    %ebx,%eax
add    $0x28,%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 = [136 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_id2_gq.c\00"
define i32 @perm_Z(i32* %0, i32* %1, i32* %2, i32 %3, i32* %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32
store i32* %0, i32** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i32* %4, i32** %11
store i8* null, i8** %14
store i8* null, i8** %15
store i32* null, i32** %16
%19 = load i32*, i32** %9
%20 = call i32 @BN_num_bytes(i32* %19)
store i32 %20, i32* %17
%21 = load i32, i32* %17
%22 = srem i32 %21, 32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %5
br label %154
25: ; preds = %5
%26 = load i32*, i32** %8
%27 = call i32 @BN_num_bytes(i32* %26)
%28 = load i32, i32* %17
%29 = icmp sgt i32 %27, %28
br i1 %29, label %30, label %31
30: ; preds = %25
br label %154
31: ; preds = %25
%32 = load i32, i32* %17
%33 = call i8* @OPENSSL_malloc(i32 %32)
store i8* %33, i8** %14
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 192)
%38 = load i32, i32* @stderr
%39 = call i32 @fflush(i32 %38)
br label %154
40: ; preds = %31
%41 = load i32, i32* %17
%42 = call i8* @OPENSSL_malloc(i32 %41)
store i8* %42, i8** %15
%43 = icmp eq i8* %42, null
br i1 %43, label %44, label %49
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 193)
%47 = load i32, i32* @stderr
%48 = call i32 @fflush(i32 %47)
br label %154
49: ; preds = %40
%50 = load i8*, i8** %14
%51 = load i32, i32* %17
%52 = call i32 @bzero(i8* %50, i32 %51)
%53 = load i8*, i8** %15
%54 = load i32, i32* %17
%55 = call i32 @bzero(i8* %53, i32 %54)
%56 = load i32*, i32** %8
%57 = call i32 @BN_num_bytes(i32* %56)
store i32 %57, i32* %18
%58 = load i32*, i32** %8
%59 = load i8*, i8** %14
%60 = load i32, i32* %17
%61 = load i32, i32* %18
%62 = sub nsw i32 %60, %61
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %59, i64 %63
%65 = call i32 @BN_bn2bin(i32* %58, i8* %64)
store i32 %65, i32* %13
%66 = load i32, i32* %13
%67 = load i32, i32* %17
%68 = icmp sgt i32 %66, %67
br i1 %68, label %69, label %70
69: ; preds = %49
br label %154
70: ; preds = %49
%71 = load i32, i32* %10
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %86
73: ; preds = %70
%74 = load i8*, i8** %14
%75 = load i32, i32* %17
%76 = load i8*, i8** %15
%77 = call i32 @perm_E_forward(i8* %74, i32 %75, i8* %76)
store i32 %77, i32* %13
%78 = load i32, i32* %13
%79 = icmp ne i32 %78, 1
br i1 %79, label %80, label %85
80: ; preds = %73
%81 = load i32, i32* @stderr
%82 = call i32 @fprintf(i32 %81, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 202)
%83 = load i32, i32* @stderr
%84 = call i32 @fflush(i32 %83)
br label %154
85: ; preds = %73
br label %99
86: ; preds = %70
%87 = load i8*, i8** %14
%88 = load i32, i32* %17
%89 = load i8*, i8** %15
%90 = call i32 @perm_E_reverse(i8* %87, i32 %88, i8* %89)
store i32 %90, i32* %13
%91 = load i32, i32* %13
%92 = icmp ne i32 %91, 1
br i1 %92, label %93, label %98
93: ; preds = %86
%94 = load i32, i32* @stderr
%95 = call i32 @fprintf(i32 %94, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 204)
%96 = load i32, i32* @stderr
%97 = call i32 @fflush(i32 %96)
br label %154
98: ; preds = %86
br label %99
99: ; preds = %98, %85
%100 = load i8*, i8** %15
%101 = load i32, i32* %17
%102 = load i32*, i32** %7
%103 = call i32* @BN_bin2bn(i8* %100, i32 %101, i32* %102)
%104 = icmp eq i32* %103, null
br i1 %104, label %105, label %110
105: ; preds = %99
%106 = load i32, i32* @stderr
%107 = call i32 @fprintf(i32 %106, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 206)
%108 = load i32, i32* @stderr
%109 = call i32 @fflush(i32 %108)
br label %154
110: ; preds = %99
%111 = call i32* (...) @BN_new()
store i32* %111, i32** %16
%112 = icmp eq i32* %111, null
br i1 %112, label %113, label %118
113: ; preds = %110
%114 = load i32, i32* @stderr
%115 = call i32 @fprintf(i32 %114, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 207)
%116 = load i32, i32* @stderr
%117 = call i32 @fflush(i32 %116)
br label %154
118: ; preds = %110
%119 = load i32*, i32** %16
%120 = load i32*, i32** %7
%121 = load i32*, i32** %9
%122 = load i32*, i32** %11
%123 = call i32 @BN_gcd(i32* %119, i32* %120, i32* %121, i32* %122)
store i32 %123, i32* %13
%124 = load i32, i32* %13
%125 = icmp ne i32 %124, 1
br i1 %125, label %126, label %131
126: ; preds = %118
%127 = load i32, i32* @stderr
%128 = call i32 @fprintf(i32 %127, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 208)
%129 = load i32, i32* @stderr
%130 = call i32 @fflush(i32 %129)
br label %154
131: ; preds = %118
%132 = load i32*, i32** %7
%133 = load i32*, i32** %9
%134 = call i32 @BN_cmp(i32* %132, i32* %133)
%135 = icmp sge i32 %134, 1
br i1 %135, label %140, label %136
136: ; preds = %131
%137 = load i32*, i32** %16
%138 = call i32 @BN_is_one(i32* %137)
%139 = icmp ne i32 %138, 0
br i1 %139, label %153, label %140
140: ; preds = %136, %131
%141 = load i8*, i8** %14
%142 = call i32 @OPENSSL_free(i8* %141)
%143 = load i8*, i8** %15
%144 = call i32 @OPENSSL_free(i8* %143)
%145 = load i32*, i32** %16
%146 = call i32 @BN_free(i32* %145)
%147 = load i32*, i32** %7
%148 = load i32*, i32** %7
%149 = load i32*, i32** %9
%150 = load i32, i32* %10
%151 = load i32*, i32** %11
%152 = call i32 @perm_Z(i32* %147, i32* %148, i32* %149, i32 %150, i32* %151)
store i32 %152, i32* %6
br label %163
153: ; preds = %136
store i32 1, i32* %12
br label %155
154: ; preds = %126, %113, %105, %93, %80, %69, %44, %35, %30, %24
store i32 0, i32* %12
br label %155
155: ; preds = %154, %153
%156 = load i8*, i8** %14
%157 = call i32 @OPENSSL_free(i8* %156)
%158 = load i8*, i8** %15
%159 = call i32 @OPENSSL_free(i8* %158)
%160 = load i32*, i32** %16
%161 = call i32 @BN_free(i32* %160)
%162 = load i32, i32* %12
store i32 %162, i32* %6
br label %163
163: ; preds = %155, %140
%164 = load i32, i32* %6
ret i32 %164
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"@@@ %s:%d @@@\0A\00"
@.str.1 = [136 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_id2_gq.c\00"
define i32 @perm_Z(i32* %0, i32* %1, i32* %2, i32 %3, i32* %4) {
%6 = tail call i32 @BN_num_bytes(i32* %2)
%7 = and i32 %6, 31
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %69
9: ; preds = %5
%10 = icmp eq i32 %3, 0
br label %11
11: ; preds = %9, %53
%12 = phi i32 [ %6, %9 ], [ %57, %53 ]
%13 = phi i32* [ %1, %9 ], [ %0, %53 ]
%14 = tail call i32 @BN_num_bytes(i32* %13)
%15 = icmp sgt i32 %14, %12
br i1 %15, label %69, label %16
16: ; preds = %11
%17 = tail call i8* @OPENSSL_malloc(i32 %12)
%18 = icmp eq i8* %17, null
br i1 %18, label %60, label %19
19: ; preds = %16
%20 = tail call i8* @OPENSSL_malloc(i32 %12)
%21 = icmp eq i8* %20, null
br i1 %21, label %60, label %22
22: ; preds = %19
%23 = tail call i32 @bzero(i8* %17, i32 %12)
%24 = tail call i32 @bzero(i8* %20, i32 %12)
%25 = tail call i32 @BN_num_bytes(i32* %13)
%26 = sub nsw i32 %12, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %17, i64 %27
%29 = tail call i32 @BN_bn2bin(i32* %13, i8* %28)
%30 = icmp sgt i32 %29, %12
br i1 %30, label %69, label %31
31: ; preds = %22
br i1 %10, label %35, label %32
32: ; preds = %31
%33 = tail call i32 @perm_E_forward(i8* %17, i32 %12, i8* %20)
%34 = icmp eq i32 %33, 1
br i1 %34, label %38, label %60
35: ; preds = %31
%36 = tail call i32 @perm_E_reverse(i8* %17, i32 %12, i8* %20)
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %60
38: ; preds = %35, %32
%39 = tail call i32* @BN_bin2bn(i8* %20, i32 %12, i32* %0)
%40 = icmp eq i32* %39, null
br i1 %40, label %60, label %41
41: ; preds = %38
%42 = tail call i32* (...) @BN_new()
%43 = icmp eq i32* %42, null
br i1 %43, label %60, label %44
44: ; preds = %41
%45 = tail call i32 @BN_gcd(i32* %42, i32* %0, i32* %2, i32* %4)
%46 = icmp eq i32 %45, 1
br i1 %46, label %47, label %60
47: ; preds = %44
%48 = tail call i32 @BN_cmp(i32* %0, i32* %2)
%49 = icmp sgt i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %47
%51 = tail call i32 @BN_is_one(i32* %42)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %69
53: ; preds = %50, %47
%54 = tail call i32 @OPENSSL_free(i8* %17)
%55 = tail call i32 @OPENSSL_free(i8* %20)
%56 = tail call i32 @BN_free(i32* %42)
%57 = tail call i32 @BN_num_bytes(i32* %2)
%58 = and i32 %57, 31
%59 = icmp eq i32 %58, 0
br i1 %59, label %11, label %69
60: ; preds = %44, %41, %38, %35, %32, %19, %16
%61 = phi i32 [ 192, %16 ], [ 193, %19 ], [ 202, %32 ], [ 204, %35 ], [ 206, %38 ], [ 207, %41 ], [ 208, %44 ]
%62 = phi i8* [ null, %16 ], [ %17, %19 ], [ %17, %32 ], [ %17, %35 ], [ %17, %38 ], [ %17, %41 ], [ %17, %44 ]
%63 = phi i8* [ null, %16 ], [ null, %19 ], [ %20, %32 ], [ %20, %35 ], [ %20, %38 ], [ %20, %41 ], [ %20, %44 ]
%64 = phi i32* [ null, %16 ], [ null, %19 ], [ null, %32 ], [ null, %35 ], [ null, %38 ], [ null, %41 ], [ %42, %44 ]
%65 = load i32, i32* @stderr
%66 = tail call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([136 x i8], [136 x i8]* @.str.1, i64 0, i64 0), i32 %61)
%67 = load i32, i32* @stderr
%68 = tail call i32 @fflush(i32 %67)
br label %69
69: ; preds = %50, %22, %11, %53, %60, %5
%70 = phi i8* [ null, %5 ], [ %62, %60 ], [ %17, %50 ], [ %17, %22 ], [ null, %11 ], [ null, %53 ]
%71 = phi i8* [ null, %5 ], [ %63, %60 ], [ %20, %50 ], [ %20, %22 ], [ null, %11 ], [ null, %53 ]
%72 = phi i32* [ null, %5 ], [ %64, %60 ], [ %42, %50 ], [ null, %22 ], [ null, %11 ], [ null, %53 ]
%73 = phi i32 [ 0, %5 ], [ 0, %60 ], [ 1, %50 ], [ 0, %22 ], [ 0, %11 ], [ 0, %53 ]
%74 = tail call i32 @OPENSSL_free(i8* %70)
%75 = tail call i32 @OPENSSL_free(i8* %71)
%76 = tail call i32 @BN_free(i32* %72)
ret i32 %73
}