#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*/ bar(int);
int /*<<< orphan*/ foo(int);
int omp_get_thread_num();
scalar_t__ omp_get_wtime();
int /*<<< orphan*/ printf(char *, double);
int main(void) {
  double elapsed = 0.0;
  elapsed -= omp_get_wtime();
#pragma omp parallel
  {
    int my_id = omp_get_thread_num();
#pragma omp task
    foo(my_id);
#pragma omp barrier
#pragma omp single
    {
#pragma omp task
      bar(my_id);
    }
  }
  elapsed += omp_get_wtime();
  printf("Completed in %lf\n", elapsed);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
cvtsi2sd %rax,%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <foo@plt>
mov    -0xc(%rbp),%edi
call   1050 <bar@plt>
mov    $0x0,%al
call   1040 <omp_get_wtime@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    0xe4a(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
cvtsi2sd %rax,%xmm0
xorpd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1070 <foo@plt>
mov    %ebx,%edi
call   1050 <bar@plt>
xor    %eax,%eax
call   1040 <omp_get_wtime@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0x8(%rsp),%xmm0
lea    0xe5e(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Completed in %lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca i32
store double 0.000000e+00, double* %1
%3 = call i64 (...) @omp_get_wtime()
%4 = sitofp i64 %3 to double
%5 = load double, double* %1
%6 = fsub double %5, %4
store double %6, double* %1
%7 = call i32 (...) @omp_get_thread_num()
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = call i32 @foo(i32 %8)
%10 = load i32, i32* %2
%11 = call i32 @bar(i32 %10)
%12 = call i64 (...) @omp_get_wtime()
%13 = sitofp i64 %12 to double
%14 = load double, double* %1
%15 = fadd double %14, %13
store double %15, double* %1
%16 = load double, double* %1
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %16)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"Completed in %lf\0A\00"
define i32 @main() {
%1 = tail call i64 (...) @omp_get_wtime()
%2 = sitofp i64 %1 to double
%3 = fsub double 0.000000e+00, %2
%4 = tail call i32 (...) @omp_get_thread_num()
%5 = tail call i32 @foo(i32 %4)
%6 = tail call i32 @bar(i32 %4)
%7 = tail call i64 (...) @omp_get_wtime()
%8 = sitofp i64 %7 to double
%9 = fadd double %3, %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), double %9)
ret i32 0
}