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

/* Variables and functions */
scalar_t__ isPrime003(long);
int pow(long, double);
int /*<<< orphan*/ printf(char *, long);
int problem003() {
  long num = 600851475143;
  long i = pow(num, 0.5) + 1;
  while (i -= 2) {
    if (!(num % i) && isPrime003(i)) {
      break;
    }
  }
  printf("%ld", i);
  return 0;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movabs $0x8be589eac7,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
movsd  0xeae(%rip),%xmm0
call   1050 <pow@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x2,%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11a7 <problem003+0x77>
mov    -0x8(%rbp),%rax
cqto
idivq  -0x10(%rbp)
cmp    $0x0,%rdx
jne    11a2 <problem003+0x72>
mov    -0x10(%rbp),%rdi
call   1040 <isPrime003@plt>
cmp    $0x0,%rax
je     11a2 <problem003+0x72>
jmp    11a7 <problem003+0x77>
jmp    1160 <problem003+0x30>
mov    -0x10(%rbp),%rsi
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r14
push   %rbx
push   %rax
movabs $0x8be589eac7,%rdi
movsd  0xeba(%rip),%xmm0
call   1050 <pow@plt>
movslq %eax,%rbx
add    $0xffffffffffffffff,%rbx
je     1182 <problem003+0x52>
movabs $0x8be589eac7,%r14
jmp    1166 <problem003+0x36>
add    $0xfffffffffffffffe,%rbx
je     1182 <problem003+0x52>
mov    %r14,%rax
xor    %edx,%edx
idiv   %rbx
test   %rdx,%rdx
jne    1160 <problem003+0x30>
mov    %rbx,%rdi
call   1040 <isPrime003@plt>
test   %rax,%rax
je     1160 <problem003+0x30>
jmp    1184 <problem003+0x54>
xor    %ebx,%ebx
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
define i32 @problem003() {
%1 = alloca i64
%2 = alloca i64
store i64 600851475143, i64* %1
%3 = load i64, i64* %1
%4 = call i32 @pow(i64 %3, double 5.000000e-01)
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
store i64 %6, i64* %2
br label %7
7: ; preds = %21, %0
%8 = load i64, i64* %2
%9 = sub nsw i64 %8, 2
store i64 %9, i64* %2
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %7
%12 = load i64, i64* %1
%13 = load i64, i64* %2
%14 = srem i64 %12, %13
%15 = icmp ne i64 %14, 0
br i1 %15, label %21, label %16
16: ; preds = %11
%17 = load i64, i64* %2
%18 = call i64 @isPrime003(i64 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
br label %22
21: ; preds = %16, %11
br label %7
22: ; preds = %20, %7
%23 = load i64, i64* %2
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
define i32 @problem003() {
%1 = tail call i32 @pow(i64 600851475143, double 5.000000e-01)
%2 = sext i32 %1 to i64
%3 = add nsw i64 %2, -1
%4 = icmp eq i64 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %0, %12
%6 = phi i64 [ %13, %12 ], [ %3, %0 ]
%7 = srem i64 600851475143, %6
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = tail call i64 @isPrime003(i64 %6)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9, %5
%13 = add nsw i64 %6, -2
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %5
15: ; preds = %12, %9, %0
%16 = phi i64 [ 0, %0 ], [ %6, %9 ], [ 0, %12 ]
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %16)
ret i32 0
}