#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 */
unsigned long long current_time_ns();
int omp_get_num_threads();
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ recurse(int /*<<< orphan*/, int);
int main(int argc, char **argv) {
  int nthreads;
#pragma omp parallel default(none) shared(nthreads)
#pragma omp master
  { nthreads = omp_get_num_threads(); }
  printf("Using %d OpenMP threads\n", nthreads);
#pragma omp parallel default(none)
#pragma omp master
  {
    int i;
    unsigned ntasks = 0;
    const unsigned long long start_time = current_time_ns();
#pragma omp taskgroup
    for (i = 0; i < 20; i++) {
      ntasks += (1 << (i * 1));
      recurse(0, i);
    }
    const unsigned long long end_time = current_time_ns();
    printf("METRIC unbalanced_bin_fan_out %d|%d %.20f\n", 20, 1,
           (double)ntasks / ((double)(end_time - start_time) / 1000.0));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <current_time_ns@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x14,-0x18(%rbp)
jge    11bf <main+0x7f>
mov    -0x18(%rbp),%ecx
shl    $0x0,%ecx
mov    $0x1,%eax
shl    %cl,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
xor    %edi,%edi
call   1030 <recurse@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118a <main+0x4a>
xor    %eax,%eax
call   1060 <current_time_ns@plt>
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
cvtsi2sd %rax,%xmm0
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
sub    %rcx,%rax
movq   %rax,%xmm1
movaps 0xe27(%rip),%xmm2
punpckldq %xmm2,%xmm1
movapd 0xe2b(%rip),%xmm2
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0xdf4(%rip),%xmm2
divsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
lea    0xe2e(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
lea    0xee1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1060 <current_time_ns@plt>
mov    %rax,%rbx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x2,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x3,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x4,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x5,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x6,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x7,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x8,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x9,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0xa,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0xb,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0xc,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0xd,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0xe,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0xf,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x10,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x11,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x12,%esi
call   1030 <recurse@plt>
xor    %edi,%edi
mov    $0x13,%esi
call   1030 <recurse@plt>
xor    %eax,%eax
call   1060 <current_time_ns@plt>
sub    %rbx,%rax
movq   %rax,%xmm0
punpckldq 0xd9a(%rip),%xmm0
subpd  0xda2(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  0xd9e(%rip),%xmm1
movsd  0xd9e(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xdb4(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Using %d OpenMP threads\0A\00"
@.str.1 = [43 x i8] c"METRIC unbalanced_bin_fan_out %d|%d %.20f\0A\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 i32
%9 = alloca i64
%10 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 (...) @omp_get_num_threads()
store i32 %11, i32* %6
%12 = load i32, i32* %6
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %12)
store i32 0, i32* %8
%14 = call i64 (...) @current_time_ns()
store i64 %14, i64* %9
store i32 0, i32* %7
br label %15
15: ; preds = %26, %2
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 20
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i32, i32* %7
%20 = mul nsw i32 %19, 1
%21 = shl i32 1, %20
%22 = load i32, i32* %8
%23 = add i32 %22, %21
store i32 %23, i32* %8
%24 = load i32, i32* %7
%25 = call i32 @recurse(i32 0, i32 %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %15
29: ; preds = %15
%30 = call i64 (...) @current_time_ns()
store i64 %30, i64* %10
%31 = load i32, i32* %8
%32 = uitofp i32 %31 to double
%33 = load i64, i64* %10
%34 = load i64, i64* %9
%35 = sub i64 %33, %34
%36 = uitofp i64 %35 to double
%37 = fdiv double %36, 1.000000e+03
%38 = fdiv double %32, %37
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 1, double %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Using %d OpenMP threads\0A\00"
@.str.1 = [43 x i8] c"METRIC unbalanced_bin_fan_out %d|%d %.20f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @omp_get_num_threads()
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i64 (...) @current_time_ns()
%6 = tail call i32 @recurse(i32 0, i32 0)
%7 = tail call i32 @recurse(i32 0, i32 1)
%8 = tail call i32 @recurse(i32 0, i32 2)
%9 = tail call i32 @recurse(i32 0, i32 3)
%10 = tail call i32 @recurse(i32 0, i32 4)
%11 = tail call i32 @recurse(i32 0, i32 5)
%12 = tail call i32 @recurse(i32 0, i32 6)
%13 = tail call i32 @recurse(i32 0, i32 7)
%14 = tail call i32 @recurse(i32 0, i32 8)
%15 = tail call i32 @recurse(i32 0, i32 9)
%16 = tail call i32 @recurse(i32 0, i32 10)
%17 = tail call i32 @recurse(i32 0, i32 11)
%18 = tail call i32 @recurse(i32 0, i32 12)
%19 = tail call i32 @recurse(i32 0, i32 13)
%20 = tail call i32 @recurse(i32 0, i32 14)
%21 = tail call i32 @recurse(i32 0, i32 15)
%22 = tail call i32 @recurse(i32 0, i32 16)
%23 = tail call i32 @recurse(i32 0, i32 17)
%24 = tail call i32 @recurse(i32 0, i32 18)
%25 = tail call i32 @recurse(i32 0, i32 19)
%26 = tail call i64 (...) @current_time_ns()
%27 = sub i64 %26, %5
%28 = uitofp i64 %27 to double
%29 = fdiv double %28, 1.000000e+03
%30 = fdiv double 0x412FFFFE00000000, %29
%31 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 20, i32 1, double %30)
ret i32 0
}