#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 int clock_t;

/* Variables and functions */
int clock();
int /*<<< orphan*/ improved_fibo(int);
int /*<<< orphan*/ improved_process();
int /*<<< orphan*/ original_fibo(int);
int /*<<< orphan*/ original_process();
double check_time_functions(int opFunction) {
  clock_t ti, te, tt;
  tt = 0;
  int i = 0;
#pragma omp parallel for if (PARALLELISM == 1)
  for (i = 0; i < 10; i++) {
    ti = clock();
    if (opFunction == 0) {
      original_fibo(35);
      ;
#pragma omp critical
      {
        te = clock();
        tt += (te - ti);
      }
      continue;
    }
    if (opFunction == 1) {
      improved_fibo(35);
      ;
#pragma omp critical
      {
        te = clock();
        tt += (te - ti);
      }
      continue;
    }
    if (opFunction == 2) {
      original_process();
      ;
#pragma omp critical
      {
        te = clock();
        tt += (te - ti);
      }
      continue;
    }
    if (opFunction == 3) {
      improved_process();
      ;
#pragma omp critical
      {
        te = clock();
        tt += (te - ti);
      }
      continue;
    }
  }
  return tt / 10;
}


x86 assembly (clang, -O0):
<check_time_functions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    124d <check_time_functions+0xfd>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    11b3 <check_time_functions+0x63>
mov    $0x23,%edi
call   1040 <original_fibo@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    123f <check_time_functions+0xef>
cmpl   $0x1,-0x4(%rbp)
jne    11e2 <check_time_functions+0x92>
mov    $0x23,%edi
call   1050 <improved_fibo@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    123f <check_time_functions+0xef>
cmpl   $0x2,-0x4(%rbp)
jne    120e <check_time_functions+0xbe>
mov    $0x0,%al
call   1070 <original_process@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    123f <check_time_functions+0xef>
cmpl   $0x3,-0x4(%rbp)
jne    123a <check_time_functions+0xea>
mov    $0x0,%al
call   1060 <improved_process@plt>
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    123f <check_time_functions+0xef>
jmp    123f <check_time_functions+0xef>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1170 <check_time_functions+0x20>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_time_functions>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
mov    $0xa,%ebx
mov    %edi,%r15d
lea    0xe93(%rip),%r12
xor    %ebp,%ebp
jmp    1198 <check_time_functions+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <improved_process@plt>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r13d,%ebp
add    %eax,%ebp
add    $0xffffffff,%ebx
je     11d9 <check_time_functions+0x89>
xor    %eax,%eax
call   1030 <clock@plt>
cmp    $0x3,%r14d
ja     1193 <check_time_functions+0x43>
mov    %eax,%r13d
movslq (%r12,%r15,4),%rax
add    %r12,%rax
jmp    *%rax
mov    $0x23,%edi
call   1040 <original_fibo@plt>
jmp    1187 <check_time_functions+0x37>
nopl   (%rax)
mov    $0x23,%edi
call   1050 <improved_fibo@plt>
jmp    1187 <check_time_functions+0x37>
nopl   0x0(%rax)
xor    %eax,%eax
call   1070 <original_process@plt>
jmp    1187 <check_time_functions+0x37>
movslq %ebp,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @check_time_functions(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %7
7: ; preds = %56, %1
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %59
10: ; preds = %7
%11 = call i32 (...) @clock()
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %10
%15 = call i32 @original_fibo(i32 35)
%16 = call i32 (...) @clock()
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = load i32, i32* %3
%19 = sub nsw i32 %17, %18
%20 = load i32, i32* %5
%21 = add nsw i32 %20, %19
store i32 %21, i32* %5
br label %56
22: ; preds = %10
%23 = load i32, i32* %2
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %33
25: ; preds = %22
%26 = call i32 @improved_fibo(i32 35)
%27 = call i32 (...) @clock()
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = load i32, i32* %3
%30 = sub nsw i32 %28, %29
%31 = load i32, i32* %5
%32 = add nsw i32 %31, %30
store i32 %32, i32* %5
br label %56
33: ; preds = %22
%34 = load i32, i32* %2
%35 = icmp eq i32 %34, 2
br i1 %35, label %36, label %44
36: ; preds = %33
%37 = call i32 (...) @original_process()
%38 = call i32 (...) @clock()
store i32 %38, i32* %4
%39 = load i32, i32* %4
%40 = load i32, i32* %3
%41 = sub nsw i32 %39, %40
%42 = load i32, i32* %5
%43 = add nsw i32 %42, %41
store i32 %43, i32* %5
br label %56
44: ; preds = %33
%45 = load i32, i32* %2
%46 = icmp eq i32 %45, 3
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = call i32 (...) @improved_process()
%49 = call i32 (...) @clock()
store i32 %49, i32* %4
%50 = load i32, i32* %4
%51 = load i32, i32* %3
%52 = sub nsw i32 %50, %51
%53 = load i32, i32* %5
%54 = add nsw i32 %53, %52
store i32 %54, i32* %5
br label %56
55: ; preds = %44
br label %56
56: ; preds = %55, %47, %36, %25, %14
%57 = load i32, i32* %6
%58 = add nsw i32 %57, 1
store i32 %58, i32* %6
br label %7
59: ; preds = %7
%60 = load i32, i32* %5
%61 = sdiv i32 %60, 10
%62 = sitofp i32 %61 to double
ret double %62
}

LLVM IR (-O2):
define double @check_time_functions(i32 %0) {
br label %2
2: ; preds = %1, %18
%3 = phi i32 [ 0, %1 ], [ %20, %18 ]
%4 = phi i32 [ 0, %1 ], [ %19, %18 ]
%5 = tail call i32 (...) @clock()
switch i32 %0, label %18 [
i32 0, label %6
i32 1, label %8
i32 2, label %10
i32 3, label %12
]
6: ; preds = %2
%7 = tail call i32 @original_fibo(i32 35)
br label %14
8: ; preds = %2
%9 = tail call i32 @improved_fibo(i32 35)
br label %14
10: ; preds = %2
%11 = tail call i32 (...) @original_process()
br label %14
12: ; preds = %2
%13 = tail call i32 (...) @improved_process()
br label %14
14: ; preds = %6, %8, %10, %12
%15 = tail call i32 (...) @clock()
%16 = sub i32 %4, %5
%17 = add i32 %16, %15
br label %18
18: ; preds = %14, %2
%19 = phi i32 [ %4, %2 ], [ %17, %14 ]
%20 = add nuw nsw i32 %3, 1
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %2
22: ; preds = %18
%23 = sdiv i32 %19, 10
%24 = sitofp i32 %23 to double
ret double %24
}