#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 sqrt(long long);
int main() {
  int largest;
  int check = 3;
  long long target = 600851475143;
  while (check <= sqrt(target)) {
    if (target % check == 0) {
      target = target / check;
      largest = check;
    } else
      check = check + 2;
  }
  if (target > largest) {
    largest = target;
  }
  printf("%d ", largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0xc(%rbp)
movabs $0x8be589eac7,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <sqrt@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jg     11a1 <main+0x81>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1193 <main+0x73>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    119c <main+0x7c>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    1144 <main+0x24>
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jle    11b9 <main+0x99>
mov    -0x18(%rbp),%rax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe3d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
movabs $0x8be589eac7,%rbx
mov    %rbx,%rdi
call   1040 <sqrt@plt>
cmp    $0x3,%eax
jge    1157 <main+0x37>
movslq %r14d,%rsi
cmp    %rsi,%rbx
cmovg  %ebx,%esi
lea    0xeb5(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x3,%ecx
jmp    1187 <main+0x67>
xchg   %ax,%ax
mov    %rbx,%rax
cqto
idiv   %rsi
lea    0x2(%rcx),%ebp
test   %rdx,%rdx
cmove  %ecx,%r14d
cmove  %ecx,%ebp
cmove  %rax,%rbx
mov    %rbx,%rdi
call   1040 <sqrt@plt>
mov    %ebp,%ecx
cmp    %eax,%ebp
jg     113b <main+0x1b>
movslq %ecx,%rsi
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
jne    1160 <main+0x40>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
jmp    1168 <main+0x48>

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

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