#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 omp_get_max_active_levels();
int omp_get_max_threads();
int omp_get_num_threads();
int /*<<< orphan*/ omp_set_dynamic(int /*<<< orphan*/);
int /*<<< orphan*/ omp_set_max_active_levels(int);
int /*<<< orphan*/ omp_set_nested(int);
int /*<<< orphan*/ omp_set_num_threads(int);
int /*<<< orphan*/ printf(char *, int, int, int);
int main(void) {
  omp_set_nested(1);
  omp_set_max_active_levels(8);
  omp_set_dynamic(0);
  omp_set_num_threads(2);
#pragma omp parallel
  {
    omp_set_num_threads(3);
#pragma omp parallel
    {
      omp_set_num_threads(4);
#pragma omp single
      {
        printf("\n\t\t Inner: max_act_lev=%d, num_thds=%d,max_thds=%d\n",
               omp_get_max_active_levels(), omp_get_num_threads(),
               omp_get_max_threads());
      }
    }
#pragma omp barrier
#pragma omp single
    {
      printf("\n\t\t Outer: max_act_lev=%d, num_thds=%d,max_thds=%d\n",
             omp_get_max_active_levels(), omp_get_num_threads(),
             omp_get_max_threads());
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
call   1080 <omp_set_nested@plt>
mov    $0x8,%edi
call   1030 <omp_set_max_active_levels@plt>
xor    %edi,%edi
call   1070 <omp_set_dynamic@plt>
mov    $0x2,%edi
call   1090 <omp_set_num_threads@plt>
mov    $0x3,%edi
call   1090 <omp_set_num_threads@plt>
mov    $0x4,%edi
call   1090 <omp_set_num_threads@plt>
mov    $0x0,%al
call   1040 <omp_get_max_active_levels@plt>
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1060 <omp_get_num_threads@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   10a0 <omp_get_max_threads@plt>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    %eax,%ecx
lea    0xe15(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <omp_get_max_active_levels@plt>
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <omp_get_num_threads@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   10a0 <omp_get_max_threads@plt>
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    %eax,%ecx
lea    0xe1a(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%edi
call   1080 <omp_set_nested@plt>
mov    $0x8,%edi
call   1030 <omp_set_max_active_levels@plt>
xor    %edi,%edi
call   1070 <omp_set_dynamic@plt>
mov    $0x2,%edi
call   1090 <omp_set_num_threads@plt>
mov    $0x3,%edi
call   1090 <omp_set_num_threads@plt>
mov    $0x4,%edi
call   1090 <omp_set_num_threads@plt>
xor    %eax,%eax
call   1040 <omp_get_max_active_levels@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10a0 <omp_get_max_threads@plt>
lea    0xe24(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <omp_get_max_active_levels@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   10a0 <omp_get_max_threads@plt>
lea    0xe2d(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [52 x i8] c"\0A\09\09 Inner: max_act_lev=%d, num_thds=%d,max_thds=%d\0A\00"
@.str.1 = [52 x i8] c"\0A\09\09 Outer: max_act_lev=%d, num_thds=%d,max_thds=%d\0A\00"
define i32 @main() {
%1 = call i32 @omp_set_nested(i32 1)
%2 = call i32 @omp_set_max_active_levels(i32 8)
%3 = call i32 @omp_set_dynamic(i32 0)
%4 = call i32 @omp_set_num_threads(i32 2)
%5 = call i32 @omp_set_num_threads(i32 3)
%6 = call i32 @omp_set_num_threads(i32 4)
%7 = call i32 (...) @omp_get_max_active_levels()
%8 = call i32 (...) @omp_get_num_threads()
%9 = call i32 (...) @omp_get_max_threads()
%10 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8, i32 %9)
%11 = call i32 (...) @omp_get_max_active_levels()
%12 = call i32 (...) @omp_get_num_threads()
%13 = call i32 (...) @omp_get_max_threads()
%14 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12, i32 %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [52 x i8] c"\0A\09\09 Inner: max_act_lev=%d, num_thds=%d,max_thds=%d\0A\00"
@.str.1 = [52 x i8] c"\0A\09\09 Outer: max_act_lev=%d, num_thds=%d,max_thds=%d\0A\00"
define i32 @main() {
%1 = tail call i32 @omp_set_nested(i32 1)
%2 = tail call i32 @omp_set_max_active_levels(i32 8)
%3 = tail call i32 @omp_set_dynamic(i32 0)
%4 = tail call i32 @omp_set_num_threads(i32 2)
%5 = tail call i32 @omp_set_num_threads(i32 3)
%6 = tail call i32 @omp_set_num_threads(i32 4)
%7 = tail call i32 (...) @omp_get_max_active_levels()
%8 = tail call i32 (...) @omp_get_num_threads()
%9 = tail call i32 (...) @omp_get_max_threads()
%10 = tail call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %8, i32 %9)
%11 = tail call i32 (...) @omp_get_max_active_levels()
%12 = tail call i32 (...) @omp_get_num_threads()
%13 = tail call i32 (...) @omp_get_max_threads()
%14 = tail call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12, i32 %13)
ret i32 0
}