#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 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
  {
    const unsigned long long start_time = current_time_ns();
#pragma omp taskgroup
    { recurse(0); }
    const unsigned long long end_time = current_time_ns();
    printf("METRIC bin_fan_out %d %.20f\n", 21,
           (double)(1 << 21) / ((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)
xor    %eax,%eax
mov    %eax,-0x30(%rbp)
mov    %al,-0x29(%rbp)
call   1050 <omp_get_num_threads@plt>
mov    %eax,%ecx
mov    -0x29(%rbp),%al
mov    %ecx,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xebb(%rip),%rdi
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
call   1060 <current_time_ns@plt>
mov    -0x30(%rbp),%edi
mov    %rax,-0x20(%rbp)
call   1030 <recurse@plt>
mov    -0x29(%rbp),%al
call   1060 <current_time_ns@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
movq   %rax,%xmm1
movaps 0xe5f(%rip),%xmm0
punpckldq %xmm0,%xmm1
movapd 0xe63(%rip),%xmm0
subpd  %xmm0,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe34(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe20(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x15,%esi
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
call   1030 <recurse@plt>
xor    %eax,%eax
call   1060 <current_time_ns@plt>
sub    %rbx,%rax
movq   %rax,%xmm0
punpckldq 0xe80(%rip),%xmm0
subpd  0xe88(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  0xe84(%rip),%xmm1
movsd  0xe84(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xe9a(%rip),%rdi
mov    $0x15,%esi
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 = [29 x i8] c"METRIC bin_fan_out %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 i64
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (...) @omp_get_num_threads()
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = call i64 (...) @current_time_ns()
store i64 %12, i64* %7
%13 = call i32 @recurse(i32 0)
%14 = call i64 (...) @current_time_ns()
store i64 %14, i64* %8
%15 = load i64, i64* %8
%16 = load i64, i64* %7
%17 = sub i64 %15, %16
%18 = uitofp i64 %17 to double
%19 = fdiv double %18, 1.000000e+03
%20 = fdiv double 0x4140000000000000, %19
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 21, double %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"Using %d OpenMP threads\0A\00"
@.str.1 = [29 x i8] c"METRIC bin_fan_out %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)
%7 = tail call i64 (...) @current_time_ns()
%8 = sub i64 %7, %5
%9 = uitofp i64 %8 to double
%10 = fdiv double %9, 1.000000e+03
%11 = fdiv double 0x4140000000000000, %10
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 21, double %11)
ret i32 0
}