#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*/ level3(int);
int omp_get_active_level();
int omp_get_level();
int omp_get_num_threads();
int omp_get_thread_num();
int /*<<< orphan*/ printf(char *, int, int, int, int, int);
void level2(int parent) {
#pragma omp parallel num_threads(3)
  {
#pragma omp critical
    printf("L2: parent %d, thread %d / %d, level %d (nested regions %d)\n",
           parent, omp_get_thread_num(), omp_get_num_threads(),
           omp_get_active_level(), omp_get_level());
    level3(omp_get_thread_num());
  }
}


x86 assembly (clang, -O0):
<level2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <omp_get_num_threads@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1080 <omp_get_active_level@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <omp_get_level@plt>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    %eax,%r9d
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%edi
call   1040 <level3@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<level2>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1060 <omp_get_num_threads@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <omp_get_active_level@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1070 <omp_get_level@plt>
lea    0xe6c(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
mov    %ebp,%r8d
mov    %eax,%r9d
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
mov    %eax,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <level3@plt>

LLVM IR (-O0):
@.str = [61 x i8] c"L2: parent %d, thread %d / %d, level %d (nested regions %d)\0A\00"
define void @level2(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = call i32 (...) @omp_get_thread_num()
%5 = call i32 (...) @omp_get_num_threads()
%6 = call i32 (...) @omp_get_active_level()
%7 = call i32 (...) @omp_get_level()
%8 = call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %3, i32 %4, i32 %5, i32 %6, i32 %7)
%9 = call i32 (...) @omp_get_thread_num()
%10 = call i32 @level3(i32 %9)
ret void
}

LLVM IR (-O2):
@.str = [61 x i8] c"L2: parent %d, thread %d / %d, level %d (nested regions %d)\0A\00"
define void @level2(i32 %0) {
%2 = tail call i32 (...) @omp_get_thread_num()
%3 = tail call i32 (...) @omp_get_num_threads()
%4 = tail call i32 (...) @omp_get_active_level()
%5 = tail call i32 (...) @omp_get_level()
%6 = tail call i32 @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %2, i32 %3, i32 %4, i32 %5)
%7 = tail call i32 (...) @omp_get_thread_num()
%8 = tail call i32 @level3(i32 %7)
ret void
}