#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 */
int /*<<< orphan*/ printf(char *, unsigned long long);
int main(void) {
  unsigned long long n = 600851475143ULL;
  unsigned long long i;
  for (i = 2ULL; i < n; i++) {
    while (n % i == 0) {
      n /= i;
    }
  }
  printf("%llu\n", n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movabs $0x8be589eac7,%rax
mov    %rax,-0x10(%rbp)
movq   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118a <main+0x7a>
jmp    1148 <main+0x38>
mov    -0x10(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
cmp    $0x0,%rdx
jne    1174 <main+0x64>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x10(%rbp)
jmp    1148 <main+0x38>
jmp    1179 <main+0x69>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1135 <main+0x25>
mov    -0x10(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
movabs $0x8be589eac7,%rsi
mov    $0x2,%ecx
jmp    113b <main+0x2b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rsi,%rax
xor    %edx,%edx
div    %rcx
mov    %rax,%rsi
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1170 <main+0x60>
mov    %rsi,%rax
xor    %edx,%edx
div    %rcx
test   %rdx,%rdx
jne    117b <main+0x6b>
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
jne    1130 <main+0x20>
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
jmp    113b <main+0x2b>
nopw   0x0(%rax,%rax,1)
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
test   %rdx,%rdx
je     1154 <main+0x44>
add    $0x1,%rcx
cmp    %rsi,%rcx
jb     113b <main+0x2b>
push   %rax
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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