#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 */
double omp_get_wtime();
int /*<<< orphan*/ printf(char *, double, ...);
int main() {
  int iam = 0, np = 1, i = 0;
  double start = omp_get_wtime();
#pragma omp parallel private(iam, np, i)
  {
    printf("Hello from thread %d out of %d \n", iam, np);
#pragma omp for schedule(dynamic)
    for (i = 0; i < (np * 2); i++) {
      printf("Thread %d,contador %d\n", iam, i);
    }
  }
  double end = omp_get_wtime();
  printf("start time = %f\n", start);
  printf("end time = %f\n", end);
  printf("diff time = %f\n", end - start);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    11a2 <main+0x82>
cvtsi2sdl -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%esi
lea    0xe94(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116d <main+0x4d>
mov    $0x0,%al
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe7c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xe73(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xec7(%rip),%rdi
xorps  %xmm0,%xmm0
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xed2(%rip),%rbx
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_wtime@plt>
movsd  %xmm0,(%rsp)
lea    0xeb5(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
lea    0xea3(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Hello from thread %d out of %d \0A\00"
@.str.1 = [23 x i8] c"Thread %d,contador %d\0A\00"
@.str.2 = [17 x i8] c"start time = %f\0A\00"
@.str.3 = [15 x i8] c"end time = %f\0A\00"
@.str.4 = [16 x i8] c"diff time = %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
store i32 0, i32* %1
store i32 0, i32* %2
store i32 1, i32* %3
store i32 0, i32* %4
%7 = call double (...) @omp_get_wtime()
store double %7, double* %5
%8 = load i32, i32* %2
%9 = sitofp i32 %8 to double
%10 = load i32, i32* %3
%11 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double %9, i32 %10)
store i32 0, i32* %4
br label %12
12: ; preds = %22, %0
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 2
%16 = icmp slt i32 %13, %15
br i1 %16, label %17, label %25
17: ; preds = %12
%18 = load i32, i32* %2
%19 = sitofp i32 %18 to double
%20 = load i32, i32* %4
%21 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double %19, i32 %20)
br label %22
22: ; preds = %17
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %12
%26 = call double (...) @omp_get_wtime()
store double %26, double* %6
%27 = load double, double* %5
%28 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %27)
%29 = load double, double* %6
%30 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %29)
%31 = load double, double* %6
%32 = load double, double* %5
%33 = fsub double %31, %32
%34 = call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %33)
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str = [33 x i8] c"Hello from thread %d out of %d \0A\00"
@.str.1 = [23 x i8] c"Thread %d,contador %d\0A\00"
@.str.2 = [17 x i8] c"start time = %f\0A\00"
@.str.3 = [15 x i8] c"end time = %f\0A\00"
@.str.4 = [16 x i8] c"diff time = %f\0A\00"
define i32 @main() {
%1 = tail call double (...) @omp_get_wtime()
%2 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), double 0.000000e+00, i32 1)
%3 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double 0.000000e+00, i32 0)
%4 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), double 0.000000e+00, i32 1)
%5 = tail call double (...) @omp_get_wtime()
%6 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %1)
%7 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), double %5)
%8 = fsub double %5, %1
%9 = tail call i32 (i8*, double, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), double %8)
ret i32 0
}