#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 *, long);
int main() {
  long n = 600851475143;
  int i = 2;
  while (i * i < n) {
    while (n % i == 0) {
      n /= i;
    }
    i++;
  }
  printf("%ld\n", n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movabs $0x8be589eac7,%rax
mov    %rax,-0x10(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%eax
imul   -0x14(%rbp),%eax
cltq
cmp    -0x10(%rbp),%rax
jge    1187 <main+0x77>
jmp    114c <main+0x3c>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1179 <main+0x69>
movslq -0x14(%rbp),%rcx
mov    -0x10(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    114c <main+0x3c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <main+0x24>
mov    -0x10(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%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
cqto
idiv   %rcx
mov    %rax,%rsi
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1170 <main+0x60>
mov    %rsi,%rax
cqto
idiv   %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
mov    %ecx,%eax
imul   %eax,%eax
cmp    %rax,%rsi
jg     113b <main+0x2b>
push   %rax
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"%ld\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 = srem 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 = sdiv i64 %7, %2
%9 = srem 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 nsw i64 %2, 1
%14 = mul i64 %13, %13
%15 = and i64 %14, 4294967295
%16 = icmp sgt i64 %12, %15
br i1 %16, label %1, label %17
17: ; preds = %11
%18 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %12)
ret i32 0
}