#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);
void main(void) {
  int i, j;
  for (i = sqrt((double)600851475143); i > 2; --i) {
    if (600851475143 % i == 0 && isPrime(i))
      break;
  }
  printf("%d\n", i);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  0xec0(%rip),%xmm0
call   1050 <sqrt@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x2,-0x4(%rbp)
jle    1199 <main+0x69>
movslq -0x4(%rbp),%rcx
movabs $0x8be589eac7,%rax
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    1186 <main+0x56>
mov    -0x4(%rbp),%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     1186 <main+0x56>
jmp    1199 <main+0x69>
jmp    118b <main+0x5b>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1148 <main+0x18>
mov    -0x4(%rbp),%esi
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movsd  0xec4(%rip),%xmm0
call   1050 <sqrt@plt>
mov    %eax,%ebx
cmp    $0x3,%eax
jl     118d <main+0x5d>
mov    %ebx,%ebx
movabs $0x8be589eac7,%r14
jmp    116d <main+0x3d>
cs nopw 0x0(%rax,%rax,1)
lea    -0x1(%rbx),%rax
cmp    $0x3,%rbx
mov    %rax,%rbx
jle    1188 <main+0x58>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    1160 <main+0x30>
mov    %ebx,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1160 <main+0x30>
jmp    118d <main+0x5d>
mov    $0x2,%ebx
lea    0xe74(%rip),%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

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

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