#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 atoi(char *);
double omp_get_wtime();
unsigned long pf(int, unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  unsigned int q = 0;
  if (argv[2] && atoi(argv[2]) == 1)
    q = 1;
  printf("Prime Finder\n");
  if (q)
    printf("1 is a prime number!\n3 is a prime number!\n");
  double startTime = omp_get_wtime();
  unsigned long primes;
  primes = pf(atoi(argv[1]), q);
  printf("Primes found: %lu in %.2f seconds.\n\n", primes,
         omp_get_wtime() - startTime);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1189 <main+0x49>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
cmp    $0x1,%eax
jne    1189 <main+0x49>
movl   $0x1,-0x14(%rbp)
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11af <main+0x6f>
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
call   1050 <pf@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
mov    -0x30(%rbp),%rsi
subsd  -0x20(%rbp),%xmm0
lea    0xe44(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
test   %rdi,%rdi
je     118e <main+0x3e>
call   1070 <atoi@plt>
mov    %eax,%ebp
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
cmp    $0x1,%ebp
jne    119d <main+0x4d>
mov    $0x1,%r14d
lea    0xea6(%rip),%rdi
jmp    1198 <main+0x48>
xor    %r14d,%r14d
lea    0xe8d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%edi
mov    %r14d,%esi
call   1060 <pf@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
subsd  0x8(%rsp),%xmm0
lea    0xe2c(%rip),%rdi
mov    %rbx,%rsi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Prime Finder\0A\00"
@.str.1 = [43 x i8] c"1 is a prime number!\0A3 is a prime number!\0A\00"
@.str.2 = [37 x i8] c"Primes found: %lu in %.2f seconds.\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca double
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 2
%11 = load i8*, i8** %10
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %20
19: ; preds = %13
store i32 1, i32* %6
br label %20
20: ; preds = %19, %13, %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* %6
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
%27 = call double (...) @omp_get_wtime()
store double %27, double* %7
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
%32 = load i32, i32* %6
%33 = call i64 @pf(i32 %31, i32 %32)
store i64 %33, i64* %8
%34 = load i64, i64* %8
%35 = call double (...) @omp_get_wtime()
%36 = load double, double* %7
%37 = fsub double %35, %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i64 %34, double %37)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [37 x i8] c"Primes found: %lu in %.2f seconds.\0A\0A\00"
@str = [13 x i8] c"Prime Finder\00"
@str.3 = [42 x i8] c"1 is a prime number!\0A3 is a prime number!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 2
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = tail call i32 @atoi(i8* %4)
%8 = icmp eq i32 %7, 1
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br i1 %8, label %10, label %14
10: ; preds = %6, %2
%11 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([42 x i8], [42 x i8]* @str.3, i64 0, i64 0), %6 ]
%12 = phi i32 [ 0, %2 ], [ 1, %6 ]
%13 = tail call i32 @puts(i8* dereferenceable(1) %11)
br label %14
14: ; preds = %10, %6
%15 = phi i32 [ 0, %6 ], [ %12, %10 ]
%16 = tail call double (...) @omp_get_wtime()
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = tail call i64 @pf(i32 %19, i32 %15)
%21 = tail call double (...) @omp_get_wtime()
%22 = fsub double %21, %16
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i64 %20, double %22)
ret i32 0
}