#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 *, long long);
int sqrt(long long const);
int main(void) {
  const long long int num = 600851475143, lim = sqrt(num) + 1;
  long long i, j, k, lim2;
  int bad;
  for (i = 3; i < lim; i += 2) {
    if (num % i == 0) {
      lim2 = sqrt(i) + 1;
      bad = 0;
      for (j = 3; j < lim2; j += 2) {
        if (i % j == 0) {
          bad = 1;
          break;
        }
      }
      if (!bad)
        k = i;
    }
  }
  printf("%lld\n", k);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movabs $0x8be589eac7,%rax
mov    %rax,-0x10(%rbp)
movabs $0x8be589eac7,%rdi
call   1040 <sqrt@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x18(%rbp)
movq   $0x3,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1217 <main+0xf7>
movabs $0x8be589eac7,%rax
cqto
idivq  -0x20(%rbp)
cmp    $0x0,%rdx
jne    1201 <main+0xe1>
mov    -0x20(%rbp),%rdi
call   1040 <sqrt@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movq   $0x3,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x38(%rbp),%rax
jge    11ea <main+0xca>
mov    -0x20(%rbp),%rax
cqto
idivq  -0x28(%rbp)
cmp    $0x0,%rdx
jne    11d4 <main+0xb4>
movl   $0x1,-0x3c(%rbp)
jmp    11ea <main+0xca>
jmp    11d9 <main+0xb9>
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
jmp    11a6 <main+0x86>
cmpl   $0x0,-0x3c(%rbp)
jne    11fc <main+0xdc>
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1201 <main+0xe1>
jmp    1206 <main+0xe6>
mov    -0x20(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    115d <main+0x3d>
mov    -0x30(%rbp),%rsi
lea    0xdde(%rip),%rdi
call   1030 <printf@plt>
mov    0x2db2(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movabs $0x8be589eac7,%r14
mov    %r14,%rdi
call   1040 <sqrt@plt>
mov    %eax,%r15d
add    $0x1,%r15d
mov    $0x3,%ebx
jmp    115c <main+0x3c>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rsi
add    $0x2,%rbx
cmp    %r15,%rbx
jae    11c9 <main+0xa9>
mov    %rsi,%r12
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    1150 <main+0x30>
mov    %rbx,%rdi
call   1040 <sqrt@plt>
mov    %rbx,%rsi
cmp    $0x3,%eax
jl     1153 <main+0x33>
add    $0x1,%eax
movslq %eax,%rcx
mov    $0x3,%esi
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     11b0 <main+0x90>
mov    %rbx,%rax
xor    %edx,%edx
div    %rsi
test   %rdx,%rdx
jne    11bb <main+0x9b>
jmp    1150 <main+0x30>
nopl   0x0(%rax,%rax,1)
mov    %ebx,%eax
xor    %edx,%edx
div    %esi
test   %rdx,%rdx
je     1150 <main+0x30>
add    $0x2,%rsi
cmp    %rcx,%rsi
jl     1190 <main+0x70>
mov    %rbx,%rsi
jmp    1153 <main+0x33>
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e04(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%lld\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
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
store i32 0, i32* %1
store i64 600851475143, i64* %2
%9 = call i32 @sqrt(i64 600851475143)
%10 = add nsw i32 %9, 1
%11 = sext i32 %10 to i64
store i64 %11, i64* %3
store i64 3, i64* %4
br label %12
12: ; preds = %46, %0
%13 = load i64, i64* %4
%14 = load i64, i64* %3
%15 = icmp slt i64 %13, %14
br i1 %15, label %16, label %49
16: ; preds = %12
%17 = load i64, i64* %4
%18 = srem i64 600851475143, %17
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %45
20: ; preds = %16
%21 = load i64, i64* %4
%22 = call i32 @sqrt(i64 %21)
%23 = add nsw i32 %22, 1
%24 = sext i32 %23 to i64
store i64 %24, i64* %7
store i32 0, i32* %8
store i64 3, i64* %5
br label %25
25: ; preds = %36, %20
%26 = load i64, i64* %5
%27 = load i64, i64* %7
%28 = icmp slt i64 %26, %27
br i1 %28, label %29, label %39
29: ; preds = %25
%30 = load i64, i64* %4
%31 = load i64, i64* %5
%32 = srem i64 %30, %31
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %29
store i32 1, i32* %8
br label %39
35: ; preds = %29
br label %36
36: ; preds = %35
%37 = load i64, i64* %5
%38 = add nsw i64 %37, 2
store i64 %38, i64* %5
br label %25
39: ; preds = %34, %25
%40 = load i32, i32* %8
%41 = icmp ne i32 %40, 0
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = load i64, i64* %4
store i64 %43, i64* %6
br label %44
44: ; preds = %42, %39
br label %45
45: ; preds = %44, %16
br label %46
46: ; preds = %45
%47 = load i64, i64* %4
%48 = add nsw i64 %47, 2
store i64 %48, i64* %4
br label %12
49: ; preds = %12
%50 = load i64, i64* %6
%51 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %50)
%52 = load i32, i32* @EXIT_SUCCESS
ret i32 %52
}

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