#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_clear_free(int /*<<< orphan*/ const *);
scalar_t__ BN_cmp(int /*<<< orphan*/ const *, int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_copy(int /*<<< orphan*/ const *,
                           int /*<<< orphan*/ const *);
int BN_is_bit_set(int /*<<< orphan*/ const *, int);
int BN_is_odd(int /*<<< orphan*/ const *);
scalar_t__ BN_is_one(int /*<<< orphan*/ const *);
scalar_t__ BN_is_zero(int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_mod(int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *,
                          int /*<<< orphan*/ const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ const *BN_new();
int /*<<< orphan*/ BN_rshift1(int /*<<< orphan*/ const *,
                              int /*<<< orphan*/ const *);
int /*<<< orphan*/ BN_set_word(int /*<<< orphan*/ const *, int);
int BN_jacobi_priv(const BIGNUM *A, const BIGNUM *N, int *jacobi, BN_CTX *ctx) {
  int e, returnvalue = 0, s, bit0, bit1, bit2, a1bit0, a1bit1;
  BIGNUM *zero, *a1, *n1, *three, *tmp;
  if (!jacobi) {
    return -1;
  }
  *jacobi = 1;
  if ((!A) || (!N) || (!ctx)) {
    return -1;
  }
  if (!BN_is_odd(N)) {
    return -1;
  }
  if (BN_cmp(A, N) >= 0) {
    return -1;
  }
  n1 = BN_new();
  zero = BN_new();
  a1 = BN_new();
  three = BN_new();
  tmp = BN_new();
  BN_set_word(zero, 0);
  BN_set_word(three, 3);
  if (BN_cmp(N, three) < 0) {
    returnvalue = -1;
    goto endBN_jacobi;
  }
  if (BN_cmp(zero, A) > 0) {
    returnvalue = -1;
    goto endBN_jacobi;
  }
  BN_copy(a1, A);
  BN_copy(n1, N);
startjacobistep1:
  if (BN_is_zero(a1)) {
    goto endBN_jacobi;
  }
  if (BN_is_one(a1)) {
    goto endBN_jacobi;
  }
  for (e = 0;; e++)
    if (BN_is_odd(a1)) {
      break;
    } else {
      BN_rshift1(a1, a1);
    }
  s = 1;
  bit0 = BN_is_odd(n1);
  bit1 = BN_is_bit_set(n1, 1);
  if (e % 2) {
    bit2 = BN_is_bit_set(n1, 2);
    if ((!bit2) && (bit1) && (bit0)) {
      s = -1;
    }
    if ((bit2) && (!bit1) && (bit0)) {
      s = -1;
    }
  }
  a1bit0 = BN_is_odd(a1);
  a1bit1 = BN_is_bit_set(a1, 1);
  if (((bit1) && (bit0)) && ((a1bit1) && (a1bit0))) {
    s = -s;
  }
  BN_mod(n1, n1, a1, ctx);
  BN_copy(tmp, a1);
  BN_copy(a1, n1);
  BN_copy(n1, tmp);
  *jacobi *= s;
  goto startjacobistep1;
endBN_jacobi:
  BN_clear_free(zero);
  BN_clear_free(tmp);
  BN_clear_free(a1);
  BN_clear_free(n1);
  BN_clear_free(three);
  return returnvalue;
}


x86 assembly (clang, -O0):
<BN_jacobi_priv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movl   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e6 <BN_jacobi_priv+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e1 <BN_jacobi_priv+0x331>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
cmpq   $0x0,-0x10(%rbp)
je     1211 <BN_jacobi_priv+0x61>
cmpq   $0x0,-0x18(%rbp)
je     1211 <BN_jacobi_priv+0x61>
cmpq   $0x0,-0x28(%rbp)
jne    121d <BN_jacobi_priv+0x6d>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e1 <BN_jacobi_priv+0x331>
mov    -0x18(%rbp),%rdi
call   10c0 <BN_is_odd@plt>
cmp    $0x0,%eax
jne    123b <BN_jacobi_priv+0x8b>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e1 <BN_jacobi_priv+0x331>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <BN_cmp@plt>
cmp    $0x0,%rax
jl     125e <BN_jacobi_priv+0xae>
movl   $0xffffffff,-0x4(%rbp)
jmp    14e1 <BN_jacobi_priv+0x331>
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x60(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x68(%rbp)
mov    $0x0,%al
call   1040 <BN_new@plt>
mov    %rax,-0x70(%rbp)
mov    -0x50(%rbp),%rdi
xor    %esi,%esi
call   1030 <BN_set_word@plt>
mov    -0x68(%rbp),%rdi
mov    $0x3,%esi
call   1030 <BN_set_word@plt>
mov    -0x18(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   10a0 <BN_cmp@plt>
cmp    $0x0,%rax
jge    12d1 <BN_jacobi_priv+0x121>
movl   $0xffffffff,-0x30(%rbp)
jmp    14ae <BN_jacobi_priv+0x2fe>
mov    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <BN_cmp@plt>
cmp    $0x0,%rax
jle    12f4 <BN_jacobi_priv+0x144>
movl   $0xffffffff,-0x30(%rbp)
jmp    14ae <BN_jacobi_priv+0x2fe>
mov    -0x58(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <BN_copy@plt>
mov    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <BN_copy@plt>
mov    -0x58(%rbp),%rdi
call   1080 <BN_is_zero@plt>
cmp    $0x0,%rax
je     1326 <BN_jacobi_priv+0x176>
jmp    14ae <BN_jacobi_priv+0x2fe>
mov    -0x58(%rbp),%rdi
call   10b0 <BN_is_one@plt>
cmp    $0x0,%rax
je     133e <BN_jacobi_priv+0x18e>
jmp    14ae <BN_jacobi_priv+0x2fe>
movl   $0x0,-0x2c(%rbp)
mov    -0x58(%rbp),%rdi
call   10c0 <BN_is_odd@plt>
cmp    $0x0,%eax
je     135c <BN_jacobi_priv+0x1ac>
jmp    137c <BN_jacobi_priv+0x1cc>
mov    -0x58(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1070 <BN_rshift1@plt>
jmp    136e <BN_jacobi_priv+0x1be>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1345 <BN_jacobi_priv+0x195>
movl   $0x1,-0x34(%rbp)
mov    -0x60(%rbp),%rdi
call   10c0 <BN_is_odd@plt>
mov    %eax,-0x38(%rbp)
mov    -0x60(%rbp),%rdi
mov    $0x1,%esi
call   1050 <BN_is_bit_set@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1414 <BN_jacobi_priv+0x264>
mov    -0x60(%rbp),%rdi
mov    $0x2,%esi
call   1050 <BN_is_bit_set@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jne    13ea <BN_jacobi_priv+0x23a>
cmpl   $0x0,-0x3c(%rbp)
je     13ea <BN_jacobi_priv+0x23a>
cmpl   $0x0,-0x38(%rbp)
je     13ea <BN_jacobi_priv+0x23a>
movl   $0xffffffff,-0x34(%rbp)
cmpl   $0x0,-0x40(%rbp)
je     140f <BN_jacobi_priv+0x25f>
cmpl   $0x0,-0x3c(%rbp)
jne    140f <BN_jacobi_priv+0x25f>
cmpl   $0x0,-0x38(%rbp)
je     140f <BN_jacobi_priv+0x25f>
movl   $0xffffffff,-0x34(%rbp)
jmp    1414 <BN_jacobi_priv+0x264>
mov    -0x58(%rbp),%rdi
call   10c0 <BN_is_odd@plt>
mov    %eax,-0x44(%rbp)
mov    -0x58(%rbp),%rdi
mov    $0x1,%esi
call   1050 <BN_is_bit_set@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x0,-0x3c(%rbp)
je     1461 <BN_jacobi_priv+0x2b1>
cmpl   $0x0,-0x38(%rbp)
je     1461 <BN_jacobi_priv+0x2b1>
cmpl   $0x0,-0x48(%rbp)
je     1461 <BN_jacobi_priv+0x2b1>
cmpl   $0x0,-0x44(%rbp)
je     1461 <BN_jacobi_priv+0x2b1>
xor    %eax,%eax
sub    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x60(%rbp),%rdi
mov    -0x60(%rbp),%rsi
mov    -0x58(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1090 <BN_mod@plt>
mov    -0x70(%rbp),%rdi
mov    -0x58(%rbp),%rsi
call   1060 <BN_copy@plt>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rsi
call   1060 <BN_copy@plt>
mov    -0x60(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   1060 <BN_copy@plt>
mov    -0x34(%rbp),%ecx
mov    -0x20(%rbp),%rax
imul   (%rax),%ecx
mov    %ecx,(%rax)
jmp    130e <BN_jacobi_priv+0x15e>
mov    -0x50(%rbp),%rdi
call   10d0 <BN_clear_free@plt>
mov    -0x70(%rbp),%rdi
call   10d0 <BN_clear_free@plt>
mov    -0x58(%rbp),%rdi
call   10d0 <BN_clear_free@plt>
mov    -0x60(%rbp),%rdi
call   10d0 <BN_clear_free@plt>
mov    -0x68(%rbp),%rdi
call   10d0 <BN_clear_free@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BN_jacobi_priv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    $0xffffffff,%r13d
test   %rdx,%rdx
je     1449 <BN_jacobi_priv+0x299>
mov    %rdx,%r14
mov    %rdi,%r15
movl   $0x1,(%rdx)
test   %rdi,%rdi
je     1449 <BN_jacobi_priv+0x299>
mov    %rsi,%r12
test   %rsi,%rsi
je     1449 <BN_jacobi_priv+0x299>
mov    %rcx,%rbx
test   %rcx,%rcx
je     1449 <BN_jacobi_priv+0x299>
mov    %r12,%rdi
call   10c0 <BN_is_odd@plt>
test   %eax,%eax
je     1449 <BN_jacobi_priv+0x299>
mov    %r15,%rdi
mov    %r12,%rsi
call   10a0 <BN_cmp@plt>
test   %rax,%rax
jns    1449 <BN_jacobi_priv+0x299>
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,0x18(%rsp)
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1040 <BN_new@plt>
mov    %rax,0x20(%rsp)
mov    0x18(%rsp),%rdi
xor    %esi,%esi
call   1030 <BN_set_word@plt>
mov    %r13,%rdi
mov    $0x3,%esi
call   1030 <BN_set_word@plt>
mov    %r12,%rdi
mov    %r13,0x30(%rsp)
mov    %r13,%rsi
call   10a0 <BN_cmp@plt>
mov    $0xffffffff,%r13d
test   %rax,%rax
js     1419 <BN_jacobi_priv+0x269>
mov    0x18(%rsp),%rdi
mov    %r15,%rsi
call   10a0 <BN_cmp@plt>
test   %rax,%rax
jg     1419 <BN_jacobi_priv+0x269>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <BN_copy@plt>
mov    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <BN_copy@plt>
mov    %rbp,%rdi
call   1080 <BN_is_zero@plt>
xor    %r13d,%r13d
test   %rax,%rax
jne    1419 <BN_jacobi_priv+0x269>
mov    %rbx,0x28(%rsp)
jmp    136f <BN_jacobi_priv+0x1bf>
mov    %rbp,%rdi
call   10c0 <BN_is_odd@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
mov    $0x1,%esi
call   1050 <BN_is_bit_set@plt>
mov    %r12d,%ebx
neg    %ebx
test   %r15d,%r15d
mov    0x10(%rsp),%r15
cmove  %r12d,%ebx
test   %eax,%eax
cmove  %r12d,%ebx
cmpl   $0x0,0xc(%rsp)
cmove  %r12d,%ebx
cmpl   $0x0,0x8(%rsp)
cmove  %r12d,%ebx
mov    %r15,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
mov    0x28(%rsp),%rcx
call   1090 <BN_mod@plt>
mov    0x20(%rsp),%r12
mov    %r12,%rdi
mov    %rbp,%rsi
call   1060 <BN_copy@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1060 <BN_copy@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <BN_copy@plt>
imul   (%r14),%ebx
mov    %ebx,(%r14)
mov    %rbp,%rdi
call   1080 <BN_is_zero@plt>
test   %rax,%rax
jne    1416 <BN_jacobi_priv+0x266>
mov    %rbp,%rdi
call   10b0 <BN_is_one@plt>
test   %rax,%rax
jne    1419 <BN_jacobi_priv+0x269>
mov    %rbp,%rdi
call   10c0 <BN_is_odd@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    13aa <BN_jacobi_priv+0x1fa>
xor    %ebx,%ebx
mov    %rbp,%rdi
mov    %rbp,%rsi
call   1070 <BN_rshift1@plt>
add    $0x1,%ebx
mov    %rbp,%rdi
call   10c0 <BN_is_odd@plt>
test   %eax,%eax
je     1390 <BN_jacobi_priv+0x1e0>
mov    %r15,%rdi
call   10c0 <BN_is_odd@plt>
mov    %eax,0xc(%rsp)
mov    $0x1,%r12d
mov    %r15,%rdi
mov    $0x1,%esi
call   1050 <BN_is_bit_set@plt>
mov    %eax,0x8(%rsp)
test   $0x1,%bl
je     12dd <BN_jacobi_priv+0x12d>
mov    %r15,%rdi
mov    $0x2,%esi
call   1050 <BN_is_bit_set@plt>
test   %eax,%eax
sete   %al
cmpl   $0x0,0x8(%rsp)
setne  %cl
mov    %eax,%edx
and    %cl,%dl
cmpl   $0x0,0xc(%rsp)
sete   %bl
or     %cl,%al
xor    $0x1,%al
or     %dl,%al
xor    $0x1,%al
or     %bl,%al
movzbl %al,%eax
lea    (%rax,%rax,1),%r12d
add    $0xffffffff,%r12d
jmp    12dd <BN_jacobi_priv+0x12d>
xor    %r13d,%r13d
mov    0x18(%rsp),%rdi
call   10d0 <BN_clear_free@plt>
mov    0x20(%rsp),%rdi
call   10d0 <BN_clear_free@plt>
mov    %rbp,%rdi
call   10d0 <BN_clear_free@plt>
mov    0x10(%rsp),%rdi
call   10d0 <BN_clear_free@plt>
mov    0x30(%rsp),%rdi
call   10d0 <BN_clear_free@plt>
mov    %r13d,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @BN_jacobi_priv(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
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32*
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
store i32 0, i32* %11
%23 = load i32*, i32** %8
%24 = icmp ne i32* %23, null
br i1 %24, label %26, label %25
25: ; preds = %4
store i32 -1, i32* %5
br label %181
26: ; preds = %4
%27 = load i32*, i32** %8
store i32 1, i32* %27
%28 = load i32*, i32** %6
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load i32*, i32** %7
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32*, i32** %9
%35 = icmp ne i32* %34, null
br i1 %35, label %37, label %36
36: ; preds = %33, %30, %26
store i32 -1, i32* %5
br label %181
37: ; preds = %33
%38 = load i32*, i32** %7
%39 = call i32 @BN_is_odd(i32* %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %37
store i32 -1, i32* %5
br label %181
42: ; preds = %37
%43 = load i32*, i32** %6
%44 = load i32*, i32** %7
%45 = call i64 @BN_cmp(i32* %43, i32* %44)
%46 = icmp sge i64 %45, 0
br i1 %46, label %47, label %48
47: ; preds = %42
store i32 -1, i32* %5
br label %181
48: ; preds = %42
%49 = call i32* (...) @BN_new()
store i32* %49, i32** %20
%50 = call i32* (...) @BN_new()
store i32* %50, i32** %18
%51 = call i32* (...) @BN_new()
store i32* %51, i32** %19
%52 = call i32* (...) @BN_new()
store i32* %52, i32** %21
%53 = call i32* (...) @BN_new()
store i32* %53, i32** %22
%54 = load i32*, i32** %18
%55 = call i32 @BN_set_word(i32* %54, i32 0)
%56 = load i32*, i32** %21
%57 = call i32 @BN_set_word(i32* %56, i32 3)
%58 = load i32*, i32** %7
%59 = load i32*, i32** %21
%60 = call i64 @BN_cmp(i32* %58, i32* %59)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %48
store i32 -1, i32* %11
br label %169
63: ; preds = %48
%64 = load i32*, i32** %18
%65 = load i32*, i32** %6
%66 = call i64 @BN_cmp(i32* %64, i32* %65)
%67 = icmp sgt i64 %66, 0
br i1 %67, label %68, label %69
68: ; preds = %63
store i32 -1, i32* %11
br label %169
69: ; preds = %63
%70 = load i32*, i32** %19
%71 = load i32*, i32** %6
%72 = call i32 @BN_copy(i32* %70, i32* %71)
%73 = load i32*, i32** %20
%74 = load i32*, i32** %7
%75 = call i32 @BN_copy(i32* %73, i32* %74)
br label %76
76: ; preds = %150, %69
%77 = load i32*, i32** %19
%78 = call i64 @BN_is_zero(i32* %77)
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %81
80: ; preds = %76
br label %169
81: ; preds = %76
%82 = load i32*, i32** %19
%83 = call i64 @BN_is_one(i32* %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %86
85: ; preds = %81
br label %169
86: ; preds = %81
store i32 0, i32* %10
br label %87
87: ; preds = %97, %86
%88 = load i32*, i32** %19
%89 = call i32 @BN_is_odd(i32* %88)
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %92
91: ; preds = %87
br label %100
92: ; preds = %87
%93 = load i32*, i32** %19
%94 = load i32*, i32** %19
%95 = call i32 @BN_rshift1(i32* %93, i32* %94)
br label %96
96: ; preds = %92
br label %97
97: ; preds = %96
%98 = load i32, i32* %10
%99 = add nsw i32 %98, 1
store i32 %99, i32* %10
br label %87
100: ; preds = %91
store i32 1, i32* %12
%101 = load i32*, i32** %20
%102 = call i32 @BN_is_odd(i32* %101)
store i32 %102, i32* %13
%103 = load i32*, i32** %20
%104 = call i32 @BN_is_bit_set(i32* %103, i32 1)
store i32 %104, i32* %14
%105 = load i32, i32* %10
%106 = srem i32 %105, 2
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %131
108: ; preds = %100
%109 = load i32*, i32** %20
%110 = call i32 @BN_is_bit_set(i32* %109, i32 2)
store i32 %110, i32* %15
%111 = load i32, i32* %15
%112 = icmp ne i32 %111, 0
br i1 %112, label %120, label %113
113: ; preds = %108
%114 = load i32, i32* %14
%115 = icmp ne i32 %114, 0
br i1 %115, label %116, label %120
116: ; preds = %113
%117 = load i32, i32* %13
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %120
119: ; preds = %116
store i32 -1, i32* %12
br label %120
120: ; preds = %119, %116, %113, %108
%121 = load i32, i32* %15
%122 = icmp ne i32 %121, 0
br i1 %122, label %123, label %130
123: ; preds = %120
%124 = load i32, i32* %14
%125 = icmp ne i32 %124, 0
br i1 %125, label %130, label %126
126: ; preds = %123
%127 = load i32, i32* %13
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %130
129: ; preds = %126
store i32 -1, i32* %12
br label %130
130: ; preds = %129, %126, %123, %120
br label %131
131: ; preds = %130, %100
%132 = load i32*, i32** %19
%133 = call i32 @BN_is_odd(i32* %132)
store i32 %133, i32* %16
%134 = load i32*, i32** %19
%135 = call i32 @BN_is_bit_set(i32* %134, i32 1)
store i32 %135, i32* %17
%136 = load i32, i32* %14
%137 = icmp ne i32 %136, 0
br i1 %137, label %138, label %150
138: ; preds = %131
%139 = load i32, i32* %13
%140 = icmp ne i32 %139, 0
br i1 %140, label %141, label %150
141: ; preds = %138
%142 = load i32, i32* %17
%143 = icmp ne i32 %142, 0
br i1 %143, label %144, label %150
144: ; preds = %141
%145 = load i32, i32* %16
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %150
147: ; preds = %144
%148 = load i32, i32* %12
%149 = sub nsw i32 0, %148
store i32 %149, i32* %12
br label %150
150: ; preds = %147, %144, %141, %138, %131
%151 = load i32*, i32** %20
%152 = load i32*, i32** %20
%153 = load i32*, i32** %19
%154 = load i32*, i32** %9
%155 = call i32 @BN_mod(i32* %151, i32* %152, i32* %153, i32* %154)
%156 = load i32*, i32** %22
%157 = load i32*, i32** %19
%158 = call i32 @BN_copy(i32* %156, i32* %157)
%159 = load i32*, i32** %19
%160 = load i32*, i32** %20
%161 = call i32 @BN_copy(i32* %159, i32* %160)
%162 = load i32*, i32** %20
%163 = load i32*, i32** %22
%164 = call i32 @BN_copy(i32* %162, i32* %163)
%165 = load i32, i32* %12
%166 = load i32*, i32** %8
%167 = load i32, i32* %166
%168 = mul nsw i32 %167, %165
store i32 %168, i32* %166
br label %76
169: ; preds = %85, %80, %68, %62
%170 = load i32*, i32** %18
%171 = call i32 @BN_clear_free(i32* %170)
%172 = load i32*, i32** %22
%173 = call i32 @BN_clear_free(i32* %172)
%174 = load i32*, i32** %19
%175 = call i32 @BN_clear_free(i32* %174)
%176 = load i32*, i32** %20
%177 = call i32 @BN_clear_free(i32* %176)
%178 = load i32*, i32** %21
%179 = call i32 @BN_clear_free(i32* %178)
%180 = load i32, i32* %11
store i32 %180, i32* %5
br label %181
181: ; preds = %169, %47, %41, %36, %25
%182 = load i32, i32* %5
ret i32 %182
}

LLVM IR (-O2):
define i32 @BN_jacobi_priv(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = icmp eq i32* %2, null
br i1 %5, label %94, label %6
6: ; preds = %4
store i32 1, i32* %2
%7 = icmp ne i32* %0, null
%8 = icmp ne i32* %1, null
%9 = and i1 %7, %8
%10 = icmp ne i32* %3, null
%11 = and i1 %9, %10
br i1 %11, label %12, label %94
12: ; preds = %6
%13 = tail call i32 @BN_is_odd(i32* %1)
%14 = icmp eq i32 %13, 0
br i1 %14, label %94, label %15
15: ; preds = %12
%16 = tail call i64 @BN_cmp(i32* %0, i32* %1)
%17 = icmp sgt i64 %16, -1
br i1 %17, label %94, label %18
18: ; preds = %15
%19 = tail call i32* (...) @BN_new()
%20 = tail call i32* (...) @BN_new()
%21 = tail call i32* (...) @BN_new()
%22 = tail call i32* (...) @BN_new()
%23 = tail call i32* (...) @BN_new()
%24 = tail call i32 @BN_set_word(i32* %20, i32 0)
%25 = tail call i32 @BN_set_word(i32* %22, i32 3)
%26 = tail call i64 @BN_cmp(i32* %1, i32* %22)
%27 = icmp slt i64 %26, 0
br i1 %27, label %87, label %28
28: ; preds = %18
%29 = tail call i64 @BN_cmp(i32* %20, i32* %0)
%30 = icmp sgt i64 %29, 0
br i1 %30, label %87, label %31
31: ; preds = %28
%32 = tail call i32 @BN_copy(i32* %21, i32* %0)
%33 = tail call i32 @BN_copy(i32* %19, i32* %1)
%34 = tail call i64 @BN_is_zero(i32* %21)
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %87
36: ; preds = %31, %66
%37 = tail call i64 @BN_is_one(i32* %21)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %87
39: ; preds = %36
%40 = tail call i32 @BN_is_odd(i32* %21)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %39, %42
%43 = phi i32 [ %45, %42 ], [ 0, %39 ]
%44 = tail call i32 @BN_rshift1(i32* %21, i32* %21)
%45 = add nuw nsw i32 %43, 1
%46 = tail call i32 @BN_is_odd(i32* %21)
%47 = icmp eq i32 %46, 0
br i1 %47, label %42, label %48
48: ; preds = %42, %39
%49 = phi i32 [ 0, %39 ], [ %45, %42 ]
%50 = tail call i32 @BN_is_odd(i32* %19)
%51 = tail call i32 @BN_is_bit_set(i32* %19, i32 1)
%52 = and i32 %49, 1
%53 = icmp eq i32 %52, 0
br i1 %53, label %66, label %54
54: ; preds = %48
%55 = tail call i32 @BN_is_bit_set(i32* %19, i32 2)
%56 = icmp eq i32 %55, 0
%57 = icmp ne i32 %51, 0
%58 = select i1 %56, i1 %57, i1 false
%59 = icmp ne i32 %50, 0
%60 = select i1 %58, i1 %59, i1 false
%61 = select i1 %56, i1 true, i1 %57
%62 = xor i1 %61, true
%63 = select i1 %62, i1 %59, i1 false
%64 = select i1 %63, i1 true, i1 %60
%65 = select i1 %64, i32 -1, i32 1
br label %66
66: ; preds = %54, %48
%67 = phi i32 [ 1, %48 ], [ %65, %54 ]
%68 = tail call i32 @BN_is_odd(i32* %21)
%69 = tail call i32 @BN_is_bit_set(i32* %21, i32 1)
%70 = icmp ne i32 %51, 0
%71 = icmp ne i32 %50, 0
%72 = select i1 %70, i1 %71, i1 false
%73 = icmp ne i32 %69, 0
%74 = select i1 %72, i1 %73, i1 false
%75 = icmp ne i32 %68, 0
%76 = select i1 %74, i1 %75, i1 false
%77 = sub nsw i32 0, %67
%78 = select i1 %76, i32 %77, i32 %67
%79 = tail call i32 @BN_mod(i32* %19, i32* %19, i32* %21, i32* %3)
%80 = tail call i32 @BN_copy(i32* %23, i32* %21)
%81 = tail call i32 @BN_copy(i32* %21, i32* %19)
%82 = tail call i32 @BN_copy(i32* %19, i32* %23)
%83 = load i32, i32* %2
%84 = mul nsw i32 %83, %78
store i32 %84, i32* %2
%85 = tail call i64 @BN_is_zero(i32* %21)
%86 = icmp eq i64 %85, 0
br i1 %86, label %36, label %87
87: ; preds = %66, %36, %31, %28, %18
%88 = phi i32 [ -1, %18 ], [ -1, %28 ], [ 0, %31 ], [ 0, %36 ], [ 0, %66 ]
%89 = tail call i32 @BN_clear_free(i32* %20)
%90 = tail call i32 @BN_clear_free(i32* %23)
%91 = tail call i32 @BN_clear_free(i32* %21)
%92 = tail call i32 @BN_clear_free(i32* %19)
%93 = tail call i32 @BN_clear_free(i32* %22)
br label %94
94: ; preds = %15, %12, %6, %4, %87
%95 = phi i32 [ %88, %87 ], [ -1, %4 ], [ -1, %6 ], [ -1, %12 ], [ -1, %15 ]
ret i32 %95
}