#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 */
typedef scalar_t__ clock_t;

/* Variables and functions */
double CLOCKS_PER_SEC;
scalar_t__ clock();
unsigned long long fib(unsigned int);
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ printf(char *, double);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
int main(int argc, char *argv[]) {
  unsigned int n = 30;
  if (argc > 1) {
    int are_all_digits = 1;
    char *cp;
    for (cp = argv[1]; cp && *cp == ' '; ++cp)
      if (!isdigit(*cp)) {
        are_all_digits = 0;
        break;
      }
    if (are_all_digits)
      sscanf(argv[1], "%u", &n);
  }
  clock_t start, end;
  double cpu_time_used;
  start = clock();
  unsigned long long nth_fib = fib(n);
  end = clock();
  cpu_time_used = ((double)(end - start)) / CLOCKS_PER_SEC;
  printf("%llu\n", nth_fib);
  printf("\x1B[34m"
         "Algorithm execution seconds: %lf\n"
         "\033[0m",
         cpu_time_used);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1e,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1218 <main+0xc8>
movl   $0x1,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x20(%rbp)
mov    %al,-0x41(%rbp)
je     11aa <main+0x5a>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
sete   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    11ba <main+0x6a>
jmp    11f1 <main+0xa1>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11db <main+0x8b>
movl   $0x0,-0x18(%rbp)
jmp    11f1 <main+0xa1>
jmp    11e0 <main+0x90>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    118a <main+0x3a>
cmpl   $0x0,-0x18(%rbp)
je     1213 <main+0xc3>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe16(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
jmp    1218 <main+0xc8>
xor    %eax,%eax
mov    %al,-0x42(%rbp)
call   1040 <clock@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <fib@plt>
mov    %rax,%rcx
mov    -0x42(%rbp),%al
mov    %rcx,-0x40(%rbp)
call   1040 <clock@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
cvtsi2sd %rax,%xmm0
mov    0x2d90(%rip),%rax
movsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movaps 0xd94(%rip),%xmm1
movq   -0x40(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xd93(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
lea    0xd90(%rip),%rdi
call   1050 <printf@plt>
movsd  -0x38(%rbp),%xmm0
lea    0xd85(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movl   $0x1e,0xc(%rsp)
cmp    $0x2,%edi
jl     11b0 <main+0x60>
mov    %rsi,%r14
mov    0x8(%rsi),%rbx
test   %rbx,%rbx
je     119d <main+0x4d>
cmpb   $0x20,(%rbx)
jne    1197 <main+0x47>
add    $0x1,%rbx
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     11b0 <main+0x60>
cmpb   $0x20,(%rbx)
lea    0x1(%rbx),%rbx
je     1180 <main+0x30>
mov    0x8(%r14),%rdi
jmp    119f <main+0x4f>
xor    %edi,%edi
lea    0xe7a(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1060 <sscanf@plt>
xor    %eax,%eax
call   1040 <clock@plt>
mov    %rax,%r14
mov    0xc(%rsp),%edi
call   1070 <fib@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <clock@plt>
sub    %r14,%rax
cvtsi2sd %rax,%xmm0
mov    0x2e0c(%rip),%rax
divsd  (%rax),%xmm0
movsd  %xmm0,0x10(%rsp)
movq   %rbx,%xmm1
punpckldq 0xe0d(%rip),%xmm1
subpd  0xe15(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
lea    0xe15(%rip),%rdi
call   1050 <printf@plt>
lea    0xe0f(%rip),%rdi
movsd  0x10(%rsp),%xmm0
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%u\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [6 x i8] c"%llu\0A\00"
@.str.2 = [43 x i8] c"\1B[34mAlgorithm execution seconds: %lf\0A\1B[0m\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca double
%12 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 30, i32* %6
%13 = load i32, i32* %4
%14 = icmp sgt i32 %13, 1
br i1 %14, label %15, label %48
15: ; preds = %2
store i32 1, i32* %7
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
store i8* %18, i8** %8
br label %19
19: ; preds = %36, %15
%20 = load i8*, i8** %8
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i8*, i8** %8
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 32
br label %27
27: ; preds = %22, %19
%28 = phi i1 [ false, %19 ], [ %26, %22 ]
br i1 %28, label %29, label %39
29: ; preds = %27
%30 = load i8*, i8** %8
%31 = load i8, i8* %30
%32 = call i32 @isdigit(i8 signext %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %29
store i32 0, i32* %7
br label %39
35: ; preds = %29
br label %36
36: ; preds = %35
%37 = load i8*, i8** %8
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %8
br label %19
39: ; preds = %34, %27
%40 = load i32, i32* %7
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %47
42: ; preds = %39
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 @sscanf(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
br label %47
47: ; preds = %42, %39
br label %48
48: ; preds = %47, %2
%49 = call i64 (...) @clock()
store i64 %49, i64* %9
%50 = load i32, i32* %6
%51 = call i64 @fib(i32 %50)
store i64 %51, i64* %12
%52 = call i64 (...) @clock()
store i64 %52, i64* %10
%53 = load i64, i64* %10
%54 = load i64, i64* %9
%55 = sub nsw i64 %53, %54
%56 = sitofp i64 %55 to double
%57 = load double, double* @CLOCKS_PER_SEC
%58 = fdiv double %56, %57
store double %58, double* %11
%59 = load i64, i64* %12
%60 = uitofp i64 %59 to double
%61 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %60)
%62 = load double, double* %11
%63 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), double %62)
ret i32 1
}

LLVM IR (-O2):
@.str = [3 x i8] c"%u\00"
@CLOCKS_PER_SEC = global double 0.000000e+00
@.str.1 = [6 x i8] c"%llu\0A\00"
@.str.2 = [43 x i8] c"\1B[34mAlgorithm execution seconds: %lf\0A\1B[0m\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 30, i32* %3
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %26
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %23, label %10
10: ; preds = %6
%11 = load i8, i8* %8
%12 = icmp eq i8 %11, 32
br i1 %12, label %16, label %21
13: ; preds = %16
%14 = load i8, i8* %20
%15 = icmp eq i8 %14, 32
br i1 %15, label %16, label %21
16: ; preds = %10, %13
%17 = phi i8* [ %20, %13 ], [ %8, %10 ]
%18 = tail call i32 @isdigit(i8 signext 32)
%19 = icmp eq i32 %18, 0
%20 = getelementptr inbounds i8, i8* %17, i64 1
br i1 %19, label %26, label %13
21: ; preds = %13, %10
%22 = load i8*, i8** %7
br label %23
23: ; preds = %21, %6
%24 = phi i8* [ %22, %21 ], [ null, %6 ]
%25 = call i32 @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
br label %26
26: ; preds = %16, %23, %2
%27 = call i64 (...) @clock()
%28 = load i32, i32* %3
%29 = call i64 @fib(i32 %28)
%30 = call i64 (...) @clock()
%31 = sub nsw i64 %30, %27
%32 = sitofp i64 %31 to double
%33 = load double, double* @CLOCKS_PER_SEC
%34 = fdiv double %32, %33
%35 = uitofp i64 %29 to double
%36 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %35)
%37 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), double %34)
ret i32 1
}