#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__ prime(int);
int /*<<< orphan*/ printf(char *, unsigned long long);
int /*<<< orphan*/ system(char *);
int main(void) {
  unsigned long long int numTest = 600851475143;
  unsigned long long int biggest;
  for (int i = 1; i <= numTest; i++) {
    if (numTest % i == 0) {
      if (prime(i)) {
        biggest = i;
      } else {
      }
    }
  }
  printf("The largest prime is: %llu\n", biggest);
  system("PAUSE");
  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   $0x1,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     11b5 <main+0x85>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xor    %edx,%edx
div    %rcx
cmp    $0x0,%rdx
jne    11a2 <main+0x72>
mov    -0x1c(%rbp),%edi
call   1050 <prime@plt>
cmp    $0x0,%rax
je     1198 <main+0x68>
movslq -0x1c(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    119d <main+0x6d>
jmp    119d <main+0x6d>
jmp    11a2 <main+0x72>
jmp    11a7 <main+0x77>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1154 <main+0x24>
mov    -0x18(%rbp),%rsi
lea    0xe40(%rip),%rdi
call   1040 <printf@plt>
lea    0xe50(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x1,%ebx
movabs $0x8be589eac7,%r14
jmp    1134 <main+0x24>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
mov    %r14,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    1130 <main+0x20>
mov    %ebx,%edi
call   1030 <prime@plt>
jmp    1130 <main+0x20>

LLVM IR (-O0):
@.str = [28 x i8] c"The largest prime is: %llu\0A\00"
@.str.1 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
store i32 0, i32* %1
store i64 600851475143, i64* %2
store i32 1, i32* %4
br label %5
5: ; preds = %26, %0
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = load i64, i64* %2
%9 = icmp ule i64 %7, %8
br i1 %9, label %10, label %29
10: ; preds = %5
%11 = load i64, i64* %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = urem i64 %11, %13
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %10
%17 = load i32, i32* %4
%18 = call i64 @prime(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
store i64 %22, i64* %3
br label %24
23: ; preds = %16
br label %24
24: ; preds = %23, %20
br label %25
25: ; preds = %24, %10
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %5
29: ; preds = %5
%30 = load i64, i64* %3
%31 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i64 %30)
%32 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %8, %0
%2 = phi i64 [ %9, %8 ], [ 1, %0 ]
%3 = urem i64 600851475143, %2
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = trunc i64 %2 to i32
%7 = tail call i64 @prime(i32 %6)
br label %8
8: ; preds = %5, %1
%9 = add nuw i64 %2, 1
br label %1
}