#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 */
scalar_t__ isPrime(int);
int /*<<< orphan*/ printf(char *, int);
int sqrt(double);
int main() {
  long int num = 600851475143;
  int i = 3;
  int cur = 0;
  for (; i <= sqrt((double)num); i++) {
    if (isPrime(i)) {
      if (num % i == 0) {
        cur = i;
      }
    }
  }
  printf("%d\n", cur);
  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)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm0
call   1050 <sqrt@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jg     11c0 <main+0x90>
mov    -0x14(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     11ad <main+0x7d>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11a8 <main+0x78>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11ad <main+0x7d>
jmp    11b2 <main+0x82>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <main+0x2b>
mov    -0x18(%rbp),%esi
lea    0xe36(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movsd  0xec0(%rip),%xmm0
call   1050 <sqrt@plt>
xor    %r14d,%r14d
cmp    $0x3,%eax
jge    116a <main+0x3a>
lea    0xeb4(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
xor    %r14d,%r14d
mov    $0x3,%ebx
movabs $0x8be589eac7,%r15
jmp    119e <main+0x6e>
xchg   %ax,%ax
mov    %eax,%r14d
lea    0x1(%rbx),%r12
movsd  0xe71(%rip),%xmm0
call   1050 <sqrt@plt>
cltq
cmp    %rax,%rbx
mov    %r12,%rbx
jge    114d <main+0x1d>
mov    %ebx,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1183 <main+0x53>
mov    %r15,%rax
xor    %edx,%edx
div    %rbx
mov    %ebx,%eax
test   %rdx,%rdx
je     1180 <main+0x50>
mov    %r14d,%eax
jmp    1180 <main+0x50>

LLVM IR (-O0):
@.str = [4 x i8] c"%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
store i32 0, i32* %4
br label %5
5: ; preds = %25, %0
%6 = load i32, i32* %3
%7 = load i64, i64* %2
%8 = sitofp i64 %7 to double
%9 = call i32 @sqrt(double %8)
%10 = icmp sle i32 %6, %9
br i1 %10, label %11, label %28
11: ; preds = %5
%12 = load i32, i32* %3
%13 = call i64 @isPrime(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load i64, i64* %2
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = srem i64 %16, %18
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = load i32, i32* %3
store i32 %22, i32* %4
br label %23
23: ; preds = %21, %15
br label %24
24: ; preds = %23, %11
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %5
28: ; preds = %5
%29 = load i32, i32* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %29)
ret i32 0
}

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