#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 */
long findLargestPrime(double);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  double value = 600851475143;
  printf("Size of long double is: %lu\n", sizeof(long double));
  printf("Searching for Largest prime in %lg\n", value);
  long maxPrime = findLargestPrime(value);
  if (maxPrime == -1)
    printf("Error processing the prime\n");
  else
    printf("The largest prime calculated was %lu\n", maxPrime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xec2(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    0xebe(%rip),%rdi
mov    $0x10,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
lea    0xec3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
call   1040 <findLargestPrime@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0xffffffffffffffff,-0x20(%rbp)
jne    1195 <main+0x75>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a7 <main+0x87>
mov    -0x20(%rbp),%rsi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed0(%rip),%rdi
mov    $0x10,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeda(%rip),%rdi
movsd  0xead(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0xe9e(%rip),%xmm0
call   1050 <findLargestPrime@plt>
cmp    $0xffffffffffffffff,%rax
je     1180 <main+0x50>
lea    0xed5(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    118c <main+0x5c>
lea    0xee8(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Size of long double is: %lu\0A\00"
@.str.1 = [36 x i8] c"Searching for Largest prime in %lg\0A\00"
@.str.2 = [28 x i8] c"Error processing the prime\0A\00"
@.str.3 = [38 x i8] c"The largest prime calculated was %lu\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 0x42617CB13D58E000, double* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 16)
%9 = load double, double* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), double %9)
%11 = load double, double* %6
%12 = call i64 @findLargestPrime(double %11)
store i64 %12, i64* %7
%13 = load i64, i64* %7
%14 = icmp eq i64 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %20
17: ; preds = %2
%18 = load i64, i64* %7
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i64 %18)
br label %20
20: ; preds = %17, %15
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Size of long double is: %lu\0A\00"
@.str.1 = [36 x i8] c"Searching for Largest prime in %lg\0A\00"
@.str.3 = [38 x i8] c"The largest prime calculated was %lu\0A\00"
@str = [27 x i8] c"Error processing the prime\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i64 16)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), double 0x42617CB13D58E000)
%5 = tail call i64 @findLargestPrime(double 0x42617CB13D58E000)
%6 = icmp eq i64 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %11
9: ; preds = %2
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i64 %5)
br label %11
11: ; preds = %9, %7
ret i32 0
}