#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*/ SYS_gettid;
int fib(int);
int omp_get_thread_num();
scalar_t__ omp_get_wtime();
int /*<<< orphan*/ printf(char *, double, ...);
scalar_t__ syscall(int /*<<< orphan*/);
int main(void) {
  const int N = 30;
  double elapsed = 0.0;
  int i;
  elapsed -= omp_get_wtime();
#pragma omp parallel
  {
    int my_id = omp_get_thread_num();
#pragma omp for
    for (i = 1; i <= N; ++i) {
      printf("[%d][tid.%d] fib(%d) = %d\n", my_id, (int)syscall(SYS_gettid), i,
             fib(i));
    }
  }
  elapsed += omp_get_wtime();
  printf("Completed in %lfs\n", elapsed);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1e,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x10(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x1e,-0x14(%rbp)
jg     11f5 <main+0xa5>
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
call   1060 <syscall@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <fib@plt>
movsd  -0x28(%rbp),%xmm0
mov    -0x20(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
lea    0xe20(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1199 <main+0x49>
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
lea    0xe04(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%ebp
mov    0x2e65(%rip),%r12
lea    0xe76(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    (%r12),%edi
call   1060 <syscall@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1070 <fib@plt>
mov    %r15,%rdi
movsd  0x8(%rsp),%xmm0
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
mov    $0x1,%al
call   1050 <printf@plt>
add    $0x1,%ebp
cmp    $0x1f,%ebp
jne    1190 <main+0x40>
xorps  %xmm0,%xmm0
cvtsi2sd %r14,%xmm0
xorpd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"[%d][tid.%d] fib(%d) = %d\0A\00"
@SYS_gettid = global i32 0
@.str.1 = [19 x i8] c"Completed in %lfs\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 30, i32* %2
store double 0.000000e+00, double* %3
%6 = call i64 (...) @omp_get_wtime()
%7 = sitofp i64 %6 to double
%8 = load double, double* %3
%9 = fsub double %8, %7
store double %9, double* %3
%10 = call i32 (...) @omp_get_thread_num()
store i32 %10, i32* %5
store i32 1, i32* %4
br label %11
11: ; preds = %24, %0
%12 = load i32, i32* %4
%13 = icmp sle i32 %12, 30
br i1 %13, label %14, label %27
14: ; preds = %11
%15 = load i32, i32* %5
%16 = sitofp i32 %15 to double
%17 = load i32, i32* @SYS_gettid
%18 = call i64 @syscall(i32 %17)
%19 = trunc i64 %18 to i32
%20 = load i32, i32* %4
%21 = load i32, i32* %4
%22 = call i32 @fib(i32 %21)
%23 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %16, i32 %19, i32 %20, i32 %22)
br label %24
24: ; preds = %14
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %11
27: ; preds = %11
%28 = call i64 (...) @omp_get_wtime()
%29 = sitofp i64 %28 to double
%30 = load double, double* %3
%31 = fadd double %30, %29
store double %31, double* %3
%32 = load double, double* %3
%33 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %32)
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str = [27 x i8] c"[%d][tid.%d] fib(%d) = %d\0A\00"
@SYS_gettid = global i32 0
@.str.1 = [19 x i8] c"Completed in %lfs\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @omp_get_wtime()
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = sitofp i32 %2 to double
br label %4
4: ; preds = %0, %4
%5 = phi i32 [ 1, %0 ], [ %11, %4 ]
%6 = load i32, i32* @SYS_gettid
%7 = tail call i64 @syscall(i32 %6)
%8 = trunc i64 %7 to i32
%9 = tail call i32 @fib(i32 %5)
%10 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %3, i32 %8, i32 %5, i32 %9)
%11 = add nuw nsw i32 %5, 1
%12 = icmp eq i32 %11, 31
br i1 %12, label %13, label %4
13: ; preds = %4
%14 = sitofp i64 %1 to double
%15 = fsub double 0.000000e+00, %14
%16 = tail call i64 (...) @omp_get_wtime()
%17 = sitofp i64 %16 to double
%18 = fadd double %15, %17
%19 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), double %18)
ret i32 0
}