#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, unsigned long long);
unsigned long long sqrt(unsigned long long);
int main() {
  unsigned long long result = 1, target = 600851475143, max = sqrt(target);
  while (target % 2 == 0) {
    target /= 2;
    result = 2;
  }
  for (unsigned long long i = 3; i < max; i += 2) {
    while (target % i == 0) {
      target /= i;
      result = i;
    }
  }
  printf("%llu\n", result);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x1,-0x10(%rbp)
movabs $0x8be589eac7,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <sqrt@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
jne    117d <main+0x5d>
mov    -0x18(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x18(%rbp)
movq   $0x2,-0x10(%rbp)
jmp    1152 <main+0x32>
movq   $0x3,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11e2 <main+0xc2>
jmp    1198 <main+0x78>
mov    -0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x28(%rbp)
cmp    $0x0,%rdx
jne    11cc <main+0xac>
mov    -0x28(%rbp),%rcx
mov    -0x18(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1198 <main+0x78>
jmp    11d1 <main+0xb1>
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
jmp    1185 <main+0x65>
mov    -0x10(%rbp),%rsi
lea    0xe13(%rip),%rdi
call   1030 <printf@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
movabs $0x8be589eac7,%rbx
mov    %rbx,%rdi
call   1040 <sqrt@plt>
mov    $0x1,%esi
cmp    $0x4,%rax
jb     11f4 <main+0xd4>
mov    %rax,%rcx
mov    $0x1,%esi
mov    $0x3,%edi
jmp    1170 <main+0x50>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rdi,%rsi
add    $0x2,%rdi
cmp    %rcx,%rdi
jae    11f4 <main+0xd4>
mov    %rbx,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     1190 <main+0x70>
mov    %rbx,%rax
xor    %edx,%edx
div    %rdi
test   %rdx,%rdx
jne    1163 <main+0x43>
jmp    11ad <main+0x8d>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
jne    1163 <main+0x43>
jmp    11ad <main+0x8d>
nopl   (%rax)
mov    %rbx,%rax
xor    %edx,%edx
div    %rdi
test   %rdx,%rdx
jne    1160 <main+0x40>
mov    %rbx,%rax
or     %rdi,%rax
shr    $0x20,%rax
je     11d0 <main+0xb0>
mov    %rbx,%rax
xor    %edx,%edx
div    %rdi
mov    %rax,%rbx
jmp    11d8 <main+0xb8>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %edi
mov    %eax,%ebx
mov    %rbx,%rax
or     %rdi,%rax
shr    $0x20,%rax
jne    11a0 <main+0x80>
mov    %ebx,%eax
xor    %edx,%edx
div    %edi
test   %rdx,%rdx
je     11ad <main+0x8d>
jmp    1160 <main+0x40>
lea    0xe05(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%llu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
store i64 1, i64* %2
store i64 600851475143, i64* %3
%6 = load i64, i64* %3
%7 = call i64 @sqrt(i64 %6)
store i64 %7, i64* %4
br label %8
8: ; preds = %12, %0
%9 = load i64, i64* %3
%10 = urem i64 %9, 2
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i64, i64* %3
%14 = udiv i64 %13, 2
store i64 %14, i64* %3
store i64 2, i64* %2
br label %8
15: ; preds = %8
store i64 3, i64* %5
br label %16
16: ; preds = %32, %15
%17 = load i64, i64* %5
%18 = load i64, i64* %4
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
br label %21
21: ; preds = %26, %20
%22 = load i64, i64* %3
%23 = load i64, i64* %5
%24 = urem i64 %22, %23
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %21
%27 = load i64, i64* %5
%28 = load i64, i64* %3
%29 = udiv i64 %28, %27
store i64 %29, i64* %3
%30 = load i64, i64* %5
store i64 %30, i64* %2
br label %21
31: ; preds = %21
br label %32
32: ; preds = %31
%33 = load i64, i64* %5
%34 = add i64 %33, 2
store i64 %34, i64* %5
br label %16
35: ; preds = %16
%36 = load i64, i64* %2
%37 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %36)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}

LLVM IR (-O2):
@.str = [6 x i8] c"%llu\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i64 @sqrt(i64 600851475143)
%2 = icmp ugt i64 %1, 3
br i1 %2, label %3, label %9
3: ; preds = %0, %18
%4 = phi i64 [ %21, %18 ], [ 3, %0 ]
%5 = phi i64 [ %20, %18 ], [ 1, %0 ]
%6 = phi i64 [ %19, %18 ], [ 600851475143, %0 ]
%7 = urem i64 %6, %4
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %18
9: ; preds = %18, %0
%10 = phi i64 [ 1, %0 ], [ %20, %18 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %10)
%12 = load i32, i32* @EXIT_SUCCESS
ret i32 %12
13: ; preds = %3, %13
%14 = phi i64 [ %15, %13 ], [ %6, %3 ]
%15 = udiv i64 %14, %4
%16 = urem i64 %15, %4
%17 = icmp eq i64 %16, 0
br i1 %17, label %13, label %18
18: ; preds = %13, %3
%19 = phi i64 [ %6, %3 ], [ %15, %13 ]
%20 = phi i64 [ %5, %3 ], [ %4, %13 ]
%21 = add nuw i64 %4, 2
%22 = icmp ult i64 %21, %1
br i1 %22, label %3, label %9
}