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

/* Variables and functions */
long mpqs_factor0(int /*<<< orphan*/, size_t, int /*<<< orphan*/ **, int);
long mpqs_factor(mpz_t N, size_t max_bits, mpz_t **factors) {
  long err;
  err = mpqs_factor0(N, max_bits, factors, 0);
  if (err == -4)
    err = mpqs_factor0(N, max_bits, factors, 1);
  if (err == -4)
    err = mpqs_factor0(N, max_bits, factors, 3);
  return err;
}


x86 assembly (clang, -O0):
<mpqs_factor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
xor    %ecx,%ecx
call   1030 <mpqs_factor0@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xfffffffffffffffc,-0x20(%rbp)
jne    115d <mpqs_factor+0x4d>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x1,%ecx
call   1030 <mpqs_factor0@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xfffffffffffffffc,-0x20(%rbp)
jne    1181 <mpqs_factor+0x71>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x3,%ecx
call   1030 <mpqs_factor0@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mpqs_factor>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %ecx,%ecx
call   1030 <mpqs_factor0@plt>
cmp    $0xfffffffffffffffc,%rax
jne    1157 <mpqs_factor+0x47>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x1,%ecx
call   1030 <mpqs_factor0@plt>
cmp    $0xfffffffffffffffc,%rax
jne    1157 <mpqs_factor+0x47>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    $0x3,%ecx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <mpqs_factor0@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i64 @mpqs_factor(i32 %0, i64 %1, i32** %2) {
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32**
%7 = alloca i64
store i32 %0, i32* %4
store i64 %1, i64* %5
store i32** %2, i32*** %6
%8 = load i32, i32* %4
%9 = load i64, i64* %5
%10 = load i32**, i32*** %6
%11 = call i64 @mpqs_factor0(i32 %8, i64 %9, i32** %10, i32 0)
store i64 %11, i64* %7
%12 = load i64, i64* %7
%13 = icmp eq i64 %12, -4
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = load i32, i32* %4
%16 = load i64, i64* %5
%17 = load i32**, i32*** %6
%18 = call i64 @mpqs_factor0(i32 %15, i64 %16, i32** %17, i32 1)
store i64 %18, i64* %7
br label %19
19: ; preds = %14, %3
%20 = load i64, i64* %7
%21 = icmp eq i64 %20, -4
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %4
%24 = load i64, i64* %5
%25 = load i32**, i32*** %6
%26 = call i64 @mpqs_factor0(i32 %23, i64 %24, i32** %25, i32 3)
store i64 %26, i64* %7
br label %27
27: ; preds = %22, %19
%28 = load i64, i64* %7
ret i64 %28
}

LLVM IR (-O2):
define i64 @mpqs_factor(i32 %0, i64 %1, i32** %2) {
%4 = tail call i64 @mpqs_factor0(i32 %0, i64 %1, i32** %2, i32 0)
%5 = icmp eq i64 %4, -4
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i64 @mpqs_factor0(i32 %0, i64 %1, i32** %2, i32 1)
%8 = icmp eq i64 %7, -4
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i64 @mpqs_factor0(i32 %0, i64 %1, i32** %2, i32 3)
br label %11
11: ; preds = %3, %9, %6
%12 = phi i64 [ %10, %9 ], [ %7, %6 ], [ %4, %3 ]
ret i64 %12
}