#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 *, int);
int main() {
  long n = 600851475143;
  int i = 3, a;
  for (; n != 1; i += 2) {
    while (n % i == 0) {
      n /= i;
      a = i;
    }
  }
  printf("Problem 3: %d\n", a);
  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)
movl   $0x3,-0x14(%rbp)
cmpq   $0x1,-0x10(%rbp)
je     118a <main+0x7a>
jmp    1144 <main+0x34>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1177 <main+0x67>
movslq -0x14(%rbp),%rcx
mov    -0x10(%rbp),%rax
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1144 <main+0x34>
jmp    117c <main+0x6c>
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1134 <main+0x24>
mov    -0x18(%rbp),%esi
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
movabs $0x8be589eac7,%rcx
mov    $0x3,%edi
jmp    1140 <main+0x30>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %edi,%esi
add    $0x2,%rdi
cmp    $0x1,%rcx
je     11c4 <main+0xb4>
mov    %rcx,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     1160 <main+0x50>
mov    %rcx,%rax
cqto
idiv   %rdi
test   %rdx,%rdx
jne    1132 <main+0x22>
jmp    117d <main+0x6d>
nopl   0x0(%rax,%rax,1)
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
jne    1132 <main+0x22>
jmp    117d <main+0x6d>
nopl   (%rax)
mov    %rcx,%rax
cqto
idiv   %rdi
test   %rdx,%rdx
jne    1130 <main+0x20>
mov    %rcx,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     11a0 <main+0x90>
mov    %rcx,%rax
cqto
idiv   %rdi
mov    %rax,%rcx
jmp    11a8 <main+0x98>
cs nopw 0x0(%rax,%rax,1)
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
mov    %eax,%ecx
mov    %rcx,%rax
or     %rdi,%rax
shr    $0x20,%rax
jne    1170 <main+0x60>
mov    %ecx,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
je     117d <main+0x6d>
jmp    1130 <main+0x20>
push   %rax
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

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