#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 long num = 600851475143LL;
  long fac = 1;
  while (num > 1) {
    fac++;
    while (num % fac == 0)
      num /= fac;
  }
  printf("%ld\n", fac);
  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   $0x1,-0x18(%rbp)
cmpq   $0x1,-0x10(%rbp)
jle    117b <main+0x6b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
cmp    $0x0,%rdx
jne    1176 <main+0x66>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    114c <main+0x3c>
jmp    1135 <main+0x25>
mov    -0x18(%rbp),%rsi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
movabs $0x8be589eac7,%rcx
mov    $0x1,%esi
jmp    1136 <main+0x26>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x2,%rcx
jl     1191 <main+0x81>
add    $0x1,%rsi
jmp    114b <main+0x3b>
nopl   0x0(%rax)
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() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
store i64 600851475143, i64* %2
store i64 1, i64* %3
br label %4
4: ; preds = %19, %0
%5 = load i64, i64* %2
%6 = icmp sgt i64 %5, 1
br i1 %6, label %7, label %20
7: ; preds = %4
%8 = load i64, i64* %3
%9 = add nsw i64 %8, 1
store i64 %9, i64* %3
br label %10
10: ; preds = %15, %7
%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 %4
20: ; preds = %4
%21 = load i64, i64* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64 %21)
ret i32 0
}

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