#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__ isPrime(unsigned long long);
int /*<<< orphan*/ printf(char *, unsigned long long);
int main(int argc, const char *argv[]) {
  unsigned long long int n = 600851475143ULL;
  unsigned long long int i = 2;
  while (!isPrime(n)) {
    if (isPrime(i) && n % i == 0) {
      n /= i;
      printf("%lld\n", i);
    } else {
      i++;
    }
  }
  printf("%lld\n", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movabs $0x8be589eac7,%rax
mov    %rax,-0x18(%rbp)
movq   $0x2,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    116b <main+0x4b>
jmp    11cb <main+0xab>
mov    -0x20(%rbp),%rdi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     11ba <main+0x9a>
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x20(%rbp)
cmp    $0x0,%rdx
jne    11ba <main+0x9a>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
jmp    11c6 <main+0xa6>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    114c <main+0x2c>
mov    -0x18(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movabs $0x8be589eac7,%r14
mov    %r14,%rdi
call   1040 <isPrime@plt>
test   %rax,%rax
je     115c <main+0x3c>
lea    0xeba(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    $0x2,%ebx
lea    0xe98(%rip),%r15
jmp    1181 <main+0x61>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <isPrime@plt>
test   %rax,%rax
jne    113f <main+0x1f>
mov    %rbx,%rdi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1170 <main+0x50>
mov    %r14,%rax
or     %rbx,%rax
shr    $0x20,%rax
je     11b0 <main+0x90>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
mov    %rax,%r12
test   %rdx,%rdx
jne    1170 <main+0x50>
jmp    11bf <main+0x9f>
nopl   0x0(%rax)
mov    %r14d,%eax
xor    %edx,%edx
div    %ebx
mov    %eax,%r12d
test   %rdx,%rdx
jne    1170 <main+0x50>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r12,%r14
jmp    1174 <main+0x54>

LLVM IR (-O0):
@.str = [6 x i8] c"%lld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 600851475143, i64* %6
store i64 2, i64* %7
br label %8
8: ; preds = %31, %2
%9 = load i64, i64* %6
%10 = call i64 @isPrime(i64 %9)
%11 = icmp ne i64 %10, 0
%12 = xor i1 %11, true
br i1 %12, label %13, label %32
13: ; preds = %8
%14 = load i64, i64* %7
%15 = call i64 @isPrime(i64 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %13
%18 = load i64, i64* %6
%19 = load i64, i64* %7
%20 = urem i64 %18, %19
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %17
%23 = load i64, i64* %7
%24 = load i64, i64* %6
%25 = udiv i64 %24, %23
store i64 %25, i64* %6
%26 = load i64, i64* %7
%27 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %26)
br label %31
28: ; preds = %17, %13
%29 = load i64, i64* %7
%30 = add i64 %29, 1
store i64 %30, i64* %7
br label %31
31: ; preds = %28, %22
br label %8
32: ; preds = %8
%33 = load i64, i64* %6
%34 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%lld\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 @isPrime(i64 600851475143)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %23
5: ; preds = %2, %18
%6 = phi i64 [ %20, %18 ], [ 2, %2 ]
%7 = phi i64 [ %19, %18 ], [ 600851475143, %2 ]
%8 = tail call i64 @isPrime(i64 %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %5
%11 = urem i64 %7, %6
%12 = udiv i64 %7, %6
%13 = icmp eq i64 %11, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %6)
br label %18
16: ; preds = %10, %5
%17 = add i64 %6, 1
br label %18
18: ; preds = %16, %14
%19 = phi i64 [ %12, %14 ], [ %7, %16 ]
%20 = phi i64 [ %6, %14 ], [ %17, %16 ]
%21 = tail call i64 @isPrime(i64 %19)
%22 = icmp eq i64 %21, 0
br i1 %22, label %5, label %23
23: ; preds = %18, %2
%24 = phi i64 [ 600851475143, %2 ], [ %19, %18 ]
%25 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %24)
ret i32 0
}