#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*/ EXIT_FAILURE;
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
unsigned long long fib(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
double omp_get_wtime();
int /*<<< orphan*/ printf(char *, unsigned long long, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *awnser[] = {"bad", "ok"};
  unsigned long long int FIB[74] = {0,
                                    1,
                                    1,
                                    2,
                                    3,
                                    5,
                                    8,
                                    13,
                                    21,
                                    34,
                                    55,
                                    89,
                                    144,
                                    233,
                                    377,
                                    610,
                                    987,
                                    1597,
                                    2584,
                                    4181,
                                    6765,
                                    10946,
                                    17711,
                                    28657,
                                    46368,
                                    75025,
                                    121393,
                                    196418,
                                    317811,
                                    514229,
                                    832040,
                                    1346269,
                                    2178309,
                                    3524578,
                                    5702887,
                                    9227465,
                                    14930352,
                                    24157817,
                                    39088169,
                                    63245986,
                                    102334155,
                                    165580141,
                                    267914296,
                                    433494437,
                                    701408733,
                                    1134903170,
                                    1836311903,
                                    2971215073,
                                    4807526976,
                                    7778742049,
                                    12586269025,
                                    20365011074,
                                    32951280099,
                                    53316291173,
                                    86267571272,
                                    139583862445,
                                    225851433717,
                                    365435296162,
                                    591286729879,
                                    956722026041,
                                    1548008755920,
                                    2504730781961,
                                    4052739537881,
                                    6557470319842,
                                    10610209857723,
                                    17167680177565,
                                    27777890035288,
                                    44945570212853,
                                    72723460248141,
                                    117669030460994,
                                    190392490709135,
                                    308061521170129,
                                    498454011879264,
                                    806515533049393};
  int i, n;
  unsigned long long int r;
  double elapsed, start, end;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <nth fib>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  n = atoi(argv[1]);
  if (n > 73)
    n = 73;
  printf("fib seq: %d\n", n);
  start = omp_get_wtime();
#pragma omp parallel
  {
#pragma omp single
    r = fib(n);
  }
  end = omp_get_wtime();
  elapsed = end - start;
  printf("fibonacci is %llu, which is %s\ntime: %.3f seconds\n", r,
         awnser[r == FIB[n]], elapsed);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2c70(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c6d(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0x270(%rbp),%rdi
lea    0xeb3(%rip),%rsi
mov    $0x250,%edx
call   1060 <memcpy@plt>
cmpl   $0x2,-0x8(%rbp)
je     11eb <main+0x7b>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe2f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x278(%rbp)
cmpl   $0x49,-0x278(%rbp)
jle    1215 <main+0xa5>
movl   $0x49,-0x278(%rbp)
movslq -0x278(%rbp),%rsi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x290(%rbp)
ff
mov    -0x278(%rbp),%edi
call   1070 <fib@plt>
mov    %rax,-0x280(%rbp)
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x298(%rbp)
ff
movsd  -0x298(%rbp),%xmm0
ff
subsd  -0x290(%rbp),%xmm0
ff
movsd  %xmm0,-0x288(%rbp)
ff
mov    -0x280(%rbp),%rsi
mov    -0x280(%rbp),%rax
movslq -0x278(%rbp),%rcx
cmp    -0x270(%rbp,%rcx,8),%rax
ff
sete   %al
and    $0x1,%al
movzbl %al,%eax
cltq
mov    -0x20(%rbp,%rax,8),%rdx
movsd  -0x288(%rbp),%xmm0
ff
lea    0xd7c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11f0 <main+0x90>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
cmp    $0x49,%eax
mov    $0x49,%ecx
cmovl  %eax,%ecx
movslq %ecx,%rbx
lea    0xe91(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   1060 <fib@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
subsd  (%rsp),%xmm0
lea    0xeb2(%rip),%rax
xor    %ecx,%ecx
cmp    (%rax,%rbx,8),%r14
sete   %cl
lea    0xe92(%rip),%rax
movslq (%rax,%rcx,4),%rdx
add    %rax,%rdx
lea    0xe4d(%rip),%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe04(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"bad\00"
@.str.1 = [3 x i8] c"ok\00"
@__const.main.awnser = [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0)]
@__const.main.FIB = [74 x i64] [i64 0, i64 1, i64 1, i64 2, i64 3, i64 5, i64 8, i64 13, i64 21, i64 34, i64 55, i64 89, i64 144, i64 233, i64 377, i64 610, i64 987, i64 1597, i64 2584, i64 4181, i64 6765, i64 10946, i64 17711, i64 28657, i64 46368, i64 75025, i64 121393, i64 196418, i64 317811, i64 514229, i64 832040, i64 1346269, i64 2178309, i64 3524578, i64 5702887, i64 9227465, i64 14930352, i64 24157817, i64 39088169, i64 63245986, i64 102334155, i64 165580141, i64 267914296, i64 433494437, i64 701408733, i64 1134903170, i64 1836311903, i64 2971215073, i64 4807526976, i64 7778742049, i64 12586269025, i64 20365011074, i64 32951280099, i64 53316291173, i64 86267571272, i64 139583862445, i64 225851433717, i64 365435296162, i64 591286729879, i64 956722026041, i64 1548008755920, i64 2504730781961, i64 4052739537881, i64 6557470319842, i64 10610209857723, i64 17167680177565, i64 27777890035288, i64 44945570212853, i64 72723460248141, i64 117669030460994, i64 190392490709135, i64 308061521170129, i64 498454011879264, i64 806515533049393]
@stderr = global i32 0
@.str.2 = [21 x i8] c"Usage: %s <nth fib>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [13 x i8] c"fib seq: %d\0A\00"
@.str.4 = [51 x i8] c"fibonacci is %llu, which is %s\0Atime: %.3f seconds\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [2 x i8*]
%7 = alloca [74 x i64]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca double
%12 = alloca double
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = bitcast [2 x i8*]* %6 to i8*
%15 = bitcast [74 x i64]* %7 to i8*
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %26
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %9
%31 = load i32, i32* %9
%32 = icmp sgt i32 %31, 73
br i1 %32, label %33, label %34
33: ; preds = %26
store i32 73, i32* %9
br label %34
34: ; preds = %33, %26
%35 = load i32, i32* %9
%36 = sext i32 %35 to i64
%37 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i64 %36)
%38 = call double (...) @omp_get_wtime()
store double %38, double* %12
%39 = load i32, i32* %9
%40 = call i64 @fib(i32 %39)
store i64 %40, i64* %10
%41 = call double (...) @omp_get_wtime()
store double %41, double* %13
%42 = load double, double* %13
%43 = load double, double* %12
%44 = fsub double %42, %43
store double %44, double* %11
%45 = load i64, i64* %10
%46 = load i64, i64* %10
%47 = load i32, i32* %9
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [74 x i64], [74 x i64]* %7, i64 0, i64 %48
%50 = load i64, i64* %49
%51 = icmp eq i64 %46, %50
%52 = zext i1 %51 to i32
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [2 x i8*], [2 x i8*]* %6, i64 0, i64 %53
%55 = load i8*, i8** %54
%56 = load double, double* %11
%57 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i64 %45, i8* %55, double %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"bad\00"
@.str.1 = [3 x i8] c"ok\00"
@reltable.main = [2 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([2 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([2 x i32]* @reltable.main to i64)) to i32)]
@__const.main.FIB = [74 x i64] [i64 0, i64 1, i64 1, i64 2, i64 3, i64 5, i64 8, i64 13, i64 21, i64 34, i64 55, i64 89, i64 144, i64 233, i64 377, i64 610, i64 987, i64 1597, i64 2584, i64 4181, i64 6765, i64 10946, i64 17711, i64 28657, i64 46368, i64 75025, i64 121393, i64 196418, i64 317811, i64 514229, i64 832040, i64 1346269, i64 2178309, i64 3524578, i64 5702887, i64 9227465, i64 14930352, i64 24157817, i64 39088169, i64 63245986, i64 102334155, i64 165580141, i64 267914296, i64 433494437, i64 701408733, i64 1134903170, i64 1836311903, i64 2971215073, i64 4807526976, i64 7778742049, i64 12586269025, i64 20365011074, i64 32951280099, i64 53316291173, i64 86267571272, i64 139583862445, i64 225851433717, i64 365435296162, i64 591286729879, i64 956722026041, i64 1548008755920, i64 2504730781961, i64 4052739537881, i64 6557470319842, i64 10610209857723, i64 17167680177565, i64 27777890035288, i64 44945570212853, i64 72723460248141, i64 117669030460994, i64 190392490709135, i64 308061521170129, i64 498454011879264, i64 806515533049393]
@stderr = global i32 0
@.str.2 = [21 x i8] c"Usage: %s <nth fib>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [13 x i8] c"fib seq: %d\0A\00"
@.str.4 = [51 x i8] c"fibonacci is %llu, which is %s\0Atime: %.3f seconds\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %10, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = icmp slt i32 %13, 73
%15 = select i1 %14, i32 %13, i32 73
%16 = sext i32 %15 to i64
%17 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i64 %16)
%18 = tail call double (...) @omp_get_wtime()
%19 = tail call i64 @fib(i32 %15)
%20 = tail call double (...) @omp_get_wtime()
%21 = fsub double %20, %18
%22 = getelementptr inbounds [74 x i64], [74 x i64]* @__const.main.FIB, i64 0, i64 %16
%23 = load i64, i64* %22
%24 = icmp eq i64 %19, %23
%25 = zext i1 %24 to i64
%26 = shl i64 %25, 2
%27 = call i8* @llvm.load.relative.i64(i8* bitcast ([2 x i32]* @reltable.main to i8*), i64 %26)
%28 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i64 %19, i8* %27, double %21)
ret i32 0
}