#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 */
int /*<<< orphan*/ getchar();
scalar_t__ isPrime(long long);
int /*<<< orphan*/ printf(char *, long long);
long long sqrt(long long);
int main() {
  long long num;
  num = 600851475143;
  long long i, bigPrime = 0;
  for (i = 1; i < sqrt(num); i++) {
    if (num % i == 0 && isPrime(i) && i > bigPrime) {
      bigPrime = i;
      printf("maior: %lld\n", bigPrime);
    }
  }
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movabs $0x8be589eac7,%rax
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <sqrt@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jge    11f1 <main+0xb1>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x18(%rbp)
cmp    $0x0,%rdx
jne    11db <main+0x9b>
mov    -0x18(%rbp),%rdi
call   1040 <isPrime@plt>
cmp    $0x0,%rax
je     11db <main+0x9b>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jle    11db <main+0x9b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1030 <printf@plt>
jmp    11e0 <main+0xa0>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    116d <main+0x2d>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
movabs $0x8be589eac7,%r14
mov    %r14,%rdi
call   1060 <sqrt@plt>
cmp    $0x2,%rax
jl     11c0 <main+0x80>
mov    $0x1,%ebx
xor    %r13d,%r13d
movabs $0x8be589eac7,%r15
lea    0xe86(%rip),%r12
jmp    1191 <main+0x51>
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %r14,%rdi
call   1060 <sqrt@plt>
cmp    %rax,%rbx
jge    11c0 <main+0x80>
mov    %r15,%rax
xor    %edx,%edx
div    %rbx
test   %rdx,%rdx
jne    1180 <main+0x40>
mov    %rbx,%rdi
call   1040 <isPrime@plt>
test   %rax,%rax
je     1180 <main+0x40>
cmp    %r13,%rbx
jle    1180 <main+0x40>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %rbx,%r13
jmp    1180 <main+0x40>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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