#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 *);
long fib_number(int);
int /*<<< orphan*/ gettime(double *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  long result;
  int N = 0;
  int i;
  double initial, final, temp;
  int num_threads;
  if (argv[1] != NULL)
    N = atoi(argv[1]);
  gettime(&initial);
#pragma omp parallel
  {
#pragma omp single nowait
    {
      num_threads = 1;
      for (i = 1; i < N; i++) {
        result = fib_number(i);
        printf("%lu, ", result);
      }
    }
  }
  printf("...\n");
  gettime(&final);
  temp = final - initial;
  printf(" Final Time = %f\n Numbers %d\n", temp, num_threads);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     117c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x28(%rbp),%rdi
call   1050 <gettime@plt>
movl   $0x1,-0x3c(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11cb <main+0x8b>
mov    -0x20(%rbp),%edi
call   1060 <fib_number@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1193 <main+0x53>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1050 <gettime@plt>
movsd  -0x30(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    -0x3c(%rbp),%esi
lea    0xe0b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     11ad <main+0x5d>
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
call   1060 <gettime@plt>
cmp    $0x2,%ebx
jl     11b5 <main+0x65>
mov    $0x1,%ebp
lea    0xe7f(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1070 <fib_number@plt>
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
cmp    %ebp,%ebx
jne    1190 <main+0x40>
jmp    11b5 <main+0x65>
mov    %rsp,%rdi
call   1060 <gettime@plt>
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rdi
call   1060 <gettime@plt>
movsd  0x8(%rsp),%xmm0
subsd  (%rsp),%xmm0
lea    0xe29(%rip),%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%lu, \00"
@.str.1 = [5 x i8] c"...\0A\00"
@.str.2 = [30 x i8] c" Final Time = %f\0A Numbers %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
br label %22
22: ; preds = %17, %2
%23 = call i32 @gettime(double* %9)
store i32 1, i32* %12
store i32 1, i32* %8
br label %24
24: ; preds = %33, %22
%25 = load i32, i32* %8
%26 = load i32, i32* %7
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %36
28: ; preds = %24
%29 = load i32, i32* %8
%30 = call i64 @fib_number(i32 %29)
store i64 %30, i64* %6
%31 = load i64, i64* %6
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %31)
br label %33
33: ; preds = %28
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %24
36: ; preds = %24
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 @gettime(double* %10)
%39 = load double, double* %10
%40 = load double, double* %9
%41 = fsub double %39, %40
store double %41, double* %11
%42 = load double, double* %11
%43 = load i32, i32* %12
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %42, i32 %43)
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [6 x i8] c"%lu, \00"
@.str.2 = [30 x i8] c" Final Time = %f\0A Numbers %d\0A\00"
@str = [4 x i8] c"...\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %3 to i8*
%6 = bitcast double* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @gettime(double* %3)
br label %22
12: ; preds = %2
%13 = tail call i32 @atoi(i8* %8)
%14 = call i32 @gettime(double* %3)
%15 = icmp sgt i32 %13, 1
br i1 %15, label %16, label %22
16: ; preds = %12, %16
%17 = phi i32 [ %20, %16 ], [ 1, %12 ]
%18 = call i64 @fib_number(i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %18)
%20 = add nuw nsw i32 %17, 1
%21 = icmp eq i32 %20, %13
br i1 %21, label %22, label %16
22: ; preds = %16, %10, %12
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%24 = call i32 @gettime(double* %4)
%25 = load double, double* %4
%26 = load double, double* %3
%27 = fsub double %25, %26
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), double %27, i32 1)
ret i32 0
}