#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 */
int /*<<< orphan*/ gmp_printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_clear(int /*<<< orphan*/);
int /*<<< orphan*/ mpz_divisible_p(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ mpz_init_set_str(int /*<<< orphan*/, char *,
                                    int /*<<< orphan*/);
int /*<<< orphan*/ mpz_sub_ui(int /*<<< orphan*/, int /*<<< orphan*/, int);
int Problem003_alt(void) {
  mpz_t input, test;
  mpz_init_set_str(input, "600851475143", 0);
  mpz_init_set(test, input);
  mpz_sub_ui(test, test, 1);
  while (!mpz_divisible_p(input, test)) {
    mpz_sub_ui(test, test, 1);
  }
  gmp_printf("%30Zd", test);
  mpz_clear(test);
  mpz_clear(input);
  return 0;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    -0x4(%rbp),%edi
lea    0xe8e(%rip),%rsi
xor    %edx,%edx
call   1040 <mpz_init_set_str@plt>
mov    -0x8(%rbp),%edi
mov    -0x4(%rbp),%esi
call   1080 <mpz_init_set@plt>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1050 <mpz_sub_ui@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <mpz_divisible_p@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11b4 <Problem003_alt+0x54>
jmp    11c9 <Problem003_alt+0x69>
mov    -0x8(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1050 <mpz_sub_ui@plt>
jmp    1194 <Problem003_alt+0x34>
mov    -0x8(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1070 <gmp_printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <mpz_clear@plt>
mov    -0x4(%rbp),%edi
call   1060 <mpz_clear@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rax
lea    0xe98(%rip),%rsi
xor    %edx,%edx
call   1040 <mpz_init_set_str@plt>
call   1080 <mpz_init_set@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x1,%edx
call   1050 <mpz_sub_ui@plt>
call   1030 <mpz_divisible_p@plt>
test   %eax,%eax
je     1180 <Problem003_alt+0x20>
lea    0xe73(%rip),%rdi
call   1070 <gmp_printf@plt>
call   1060 <mpz_clear@plt>
call   1060 <mpz_clear@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"600851475143\00"
@.str.1 = [6 x i8] c"%30Zd\00"
define i32 @Problem003_alt() {
%1 = alloca i32
%2 = alloca i32
%3 = load i32, i32* %1
%4 = call i32 @mpz_init_set_str(i32 %3, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0)
%5 = load i32, i32* %2
%6 = load i32, i32* %1
%7 = call i32 @mpz_init_set(i32 %5, i32 %6)
%8 = load i32, i32* %2
%9 = load i32, i32* %2
%10 = call i32 @mpz_sub_ui(i32 %8, i32 %9, i32 1)
br label %11
11: ; preds = %17, %0
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = call i32 @mpz_divisible_p(i32 %12, i32 %13)
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
br i1 %16, label %17, label %21
17: ; preds = %11
%18 = load i32, i32* %2
%19 = load i32, i32* %2
%20 = call i32 @mpz_sub_ui(i32 %18, i32 %19, i32 1)
br label %11
21: ; preds = %11
%22 = load i32, i32* %2
%23 = call i32 @gmp_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %2
%25 = call i32 @mpz_clear(i32 %24)
%26 = load i32, i32* %1
%27 = call i32 @mpz_clear(i32 %26)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"600851475143\00"
@.str.1 = [6 x i8] c"%30Zd\00"
define i32 @Problem003_alt() {
%1 = tail call i32 @mpz_init_set_str(i32 undef, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = tail call i32 @mpz_init_set(i32 undef, i32 undef)
%3 = tail call i32 @mpz_sub_ui(i32 undef, i32 undef, i32 1)
%4 = tail call i32 @mpz_divisible_p(i32 undef, i32 undef)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0, %6
%7 = tail call i32 @mpz_sub_ui(i32 undef, i32 undef, i32 1)
%8 = tail call i32 @mpz_divisible_p(i32 undef, i32 undef)
%9 = icmp eq i32 %8, 0
br i1 %9, label %6, label %10
10: ; preds = %6, %0
%11 = tail call i32 @gmp_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 undef)
%12 = tail call i32 @mpz_clear(i32 undef)
%13 = tail call i32 @mpz_clear(i32 undef)
ret i32 0
}