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


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
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jge    11a0 <main+0x90>
jmp    1160 <main+0x50>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
cmp    $0x0,%rdx
jne    118a <main+0x7a>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    1160 <main+0x50>
jmp    118f <main+0x7f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1135 <main+0x25>
mov    -0x10(%rbp),%rsi
lea    0xe55(%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    %rsi,%rax
shr    $0x3f,%rax
add    %rsi,%rax
sar    %rax
cmp    %rax,%rcx
jl     113b <main+0x2b>
push   %rax
lea    0xe67(%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 i64
store i32 0, i32* %1
store i64 600851475143, i64* %2
store i64 2, i64* %3
br label %4
4: ; preds = %20, %0
%5 = load i64, i64* %3
%6 = load i64, i64* %2
%7 = sdiv i64 %6, 2
%8 = icmp slt i64 %5, %7
br i1 %8, label %9, label %23
9: ; preds = %4
br label %10
10: ; preds = %15, %9
%11 = load i64, i64* %2
%12 = load i64, i64* %3
%13 = srem i64 %11, %12
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i64, i64* %3
%17 = load i64, i64* %2
%18 = sdiv i64 %17, %16
store i64 %18, i64* %2
br label %10
19: ; preds = %10
br label %20
20: ; preds = %19
%21 = load i64, i64* %3
%22 = add nsw i64 %21, 1
store i64 %22, i64* %3
br label %4
23: ; preds = %4
%24 = load i64, i64* %2
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %24)
%26 = load i32, i32* %1
ret i32 %26
}

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 = sdiv i64 %12, 2
%15 = icmp slt i64 %13, %14
br i1 %15, label %1, label %16
16: ; preds = %11
%17 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %12)
ret i32 0
}