#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 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;
    const unsigned long long start_time = current_time_ns();
#pragma omp taskloop default(none) private(i)
    for (i = 0; i < 100000; i++) {
    }
    const unsigned long long end_time = current_time_ns();
    printf("METRIC recursive_parallel_iters %d %.20f\n", 100000,
           (double)100000 / ((double)(end_time - start_time) / 1000.0));
    printf("METRIC flat_parallel_iters %d %.20f\n", 100000,
           (double)100000 / ((double)(end_time - start_time) / 1000.0));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <omp_get_num_threads@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <current_time_ns@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x186a0,-0x18(%rbp)
jge    1193 <main+0x63>
jmp    1185 <main+0x55>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1173 <main+0x43>
xor    %eax,%eax
call   1050 <current_time_ns@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
movq   %rax,%xmm1
movaps 0xe5b(%rip),%xmm0
movaps %xmm0,-0x50(%rbp)
punpckldq %xmm0,%xmm1
movapd 0xe5b(%rip),%xmm0
movaps %xmm0,-0x40(%rbp)
subpd  %xmm0,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xe28(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xe14(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xe52(%rip),%rdi
mov    $0x186a0,%esi
mov    $0x1,%al
call   1030 <printf@plt>
movaps -0x50(%rbp),%xmm2
movaps -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    %rcx,%rax
movq   %rax,%xmm1
punpckldq %xmm2,%xmm1
subpd  %xmm0,%xmm1
movaps %xmm1,%xmm0
unpckhpd %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdd2(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdbe(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xe26(%rip),%rdi
mov    $0x186a0,%esi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <omp_get_num_threads@plt>
lea    0xeed(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1050 <current_time_ns@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <current_time_ns@plt>
sub    %rbx,%rax
movq   %rax,%xmm0
punpckldq 0xe93(%rip),%xmm0
subpd  0xe9b(%rip),%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  0xe97(%rip),%xmm1
movsd  0xe97(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xea7(%rip),%rdi
mov    $0x186a0,%esi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
mov    $0x186a0,%esi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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