#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(unsigned long);
int /*<<< orphan*/ printf(char *, unsigned long);
int main(void) {
  long unsigned int i, largest = 0;
  for (i = 3; i < 600851475143; i++) {
    if (isPrime(i) && !(600851475143 % i)) {
      largest = i;
    }
  }
  printf("%lu\n", largest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x3,-0x10(%rbp)
movabs $0x8be589eac7,%rax
cmp    %rax,-0x10(%rbp)
jae    11a0 <main+0x80>
mov    -0x10(%rbp),%rdi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     118a <main+0x6a>
movabs $0x8be589eac7,%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
cmp    $0x0,%rdx
jne    118a <main+0x6a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
jmp    118f <main+0x6f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    113f <main+0x1f>
mov    -0x18(%rbp),%rsi
lea    0xe55(%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   %rbx
mov    $0x3,%ebx
xor    %r14d,%r14d
movabs $0x8be589eac7,%r15
jmp    114c <main+0x2c>
nopl   0x0(%rax)
mov    %rax,%r14
add    $0x1,%rbx
cmp    %r15,%rbx
je     116e <main+0x4e>
mov    %rbx,%rdi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1143 <main+0x23>
mov    %r15,%rax
xor    %edx,%edx
div    %rbx
mov    %rbx,%rax
test   %rdx,%rdx
je     1140 <main+0x20>
mov    %r14,%rax
jmp    1140 <main+0x20>
lea    0xe8b(%rip),%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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