#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(int argc, char **argv) {
  long n = 600851475143;
  long i = 3;
  for (; n > 1; ++i) {
    while (n % i == 0) {
      n /= i;
    }
  }
  printf("%ld\n", --i);
}


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   $0x3,-0x20(%rbp)
cmpq   $0x1,-0x18(%rbp)
jle    118c <main+0x7c>
jmp    114c <main+0x3c>
mov    -0x18(%rbp),%rax
cqto
idivq  -0x20(%rbp)
cmp    $0x0,%rdx
jne    1176 <main+0x66>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
jmp    114c <main+0x3c>
jmp    117b <main+0x6b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    113c <main+0x2c>
mov    -0x20(%rbp),%rsi
add    $0xffffffffffffffff,%rsi
mov    %rsi,-0x20(%rbp)
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
movabs $0x8be589eac7,%rcx
mov    $0x3,%eax
jmp    113a <main+0x2a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0x1(%rsi),%rax
cmp    $0x1,%rcx
jle    1191 <main+0x81>
mov    %rax,%rsi
jmp    114b <main+0x3b>
nop
mov    %rcx,%rax
cqto
idiv   %rsi
mov    %rax,%rcx
mov    %rcx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     1170 <main+0x60>
mov    %rcx,%rax
cqto
idiv   %rsi
test   %rdx,%rdx
je     117b <main+0x6b>
jmp    1130 <main+0x20>
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
test   %rdx,%rdx
jne    1130 <main+0x20>
mov    %rcx,%rax
or     %rsi,%rax
shr    $0x20,%rax
jne    1140 <main+0x30>
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
mov    %eax,%ecx
jmp    114b <main+0x3b>
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(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 3, i64* %7
br label %8
8: ; preds = %22, %2
%9 = load i64, i64* %6
%10 = icmp sgt i64 %9, 1
br i1 %10, label %11, label %25
11: ; preds = %8
br label %12
12: ; preds = %17, %11
%13 = load i64, i64* %6
%14 = load i64, i64* %7
%15 = srem i64 %13, %14
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = load i64, i64* %7
%19 = load i64, i64* %6
%20 = sdiv i64 %19, %18
store i64 %20, i64* %6
br label %12
21: ; preds = %12
br label %22
22: ; preds = %21
%23 = load i64, i64* %7
%24 = add nsw i64 %23, 1
store i64 %24, i64* %7
br label %8
25: ; preds = %8
%26 = load i64, i64* %7
%27 = add nsw i64 %26, -1
store i64 %27, i64* %7
%28 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %27)
%29 = load i32, i32* %3
ret i32 %29
}

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