#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 main() {
  for (unsigned long int i = 2; i < 600851475143; i++) {
    if (600851475143 % i == 0) {
      long quotient = 600851475143 / i;
      if (isPrime(quotient)) {
        printf("%ld", quotient);
        return 0;
      }
    }
  }
  printf(" Is the number prime  ? %s", isPrime(17) ? "true" : "false");
  printf(" Is the number prime  ? %s", isPrime(8) ? "true" : "false");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x2,-0x10(%rbp)
movabs $0x8be589eac7,%rax
cmp    %rax,-0x10(%rbp)
jae    11cb <main+0xab>
movabs $0x8be589eac7,%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
cmp    $0x0,%rdx
jne    11b5 <main+0x95>
movabs $0x8be589eac7,%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,%edi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     11b0 <main+0x90>
mov    -0x18(%rbp),%rsi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1234 <main+0x114>
jmp    11b5 <main+0x95>
jmp    11ba <main+0x9a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1137 <main+0x17>
mov    $0x11,%edi
call   1040 <isPrime@plt>
mov    %rax,%rcx
lea    0xe45(%rip),%rsi
lea    0xe39(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x8,%edi
call   1040 <isPrime@plt>
mov    %rax,%rcx
lea    0xe14(%rip),%rsi
lea    0xe08(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x2,%ebx
movabs $0x8be589eac7,%r14
jmp    1149 <main+0x29>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    %r14,%rbx
je     1172 <main+0x52>
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    1140 <main+0x20>
mov    %rax,%r15
mov    %r15d,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1140 <main+0x20>
lea    0xe93(%rip),%rdi
mov    %r15,%rsi
jmp    11bc <main+0x9c>
mov    $0x11,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
lea    0xe9e(%rip),%r15
lea    0xe92(%rip),%rbx
mov    %rbx,%rsi
cmove  %r15,%rsi
lea    0xe69(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x8,%edi
call   1040 <isPrime@plt>
test   %rax,%rax
cmove  %r15,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [27 x i8] c" Is the number prime ? %s\00"
@.str.2 = [5 x i8] c"true\00"
@.str.3 = [6 x i8] c"false\00"
define i32 @main() {
br label %1
1: ; preds = %0, %10
%2 = phi i64 [ 2, %0 ], [ %11, %10 ]
%3 = urem i64 600851475143, %2
%4 = udiv i64 600851475143, %2
%5 = icmp eq i64 %3, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = trunc i64 %4 to i32
%8 = tail call i64 @isPrime(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6, %1
%11 = add nuw nsw i64 %2, 1
%12 = icmp eq i64 %11, 600851475143
br i1 %12, label %15, label %1
13: ; preds = %6
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %4)
br label %24
15: ; preds = %10
%16 = tail call i64 @isPrime(i32 17)
%17 = icmp eq i64 %16, 0
%18 = select i1 %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = tail call i64 @isPrime(i32 8)
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %13, %15
ret i32 0
}