#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_dynamic();
int omp_get_max_threads();
int omp_get_nested();
int omp_get_num_procs();
int omp_get_num_threads();
int omp_get_thread_num();
int omp_in_parallel();
int /*<<< orphan*/ printf(char *, int);
int main(int argc, char *argv[]) {
  int nthreads, tid, procs, maxt, inpar, dynamic, nested;
#pragma omp parallel private(nthreads, tid)
  {
    tid = omp_get_thread_num();
    if (tid == 0) {
      printf("Thread %d getting environment info...\n", tid);
      procs = omp_get_num_procs();
      nthreads = omp_get_num_threads();
      maxt = omp_get_max_threads();
      inpar = omp_in_parallel();
      dynamic = omp_get_dynamic();
      nested = omp_get_nested();
      printf("Number of processors = %d\n", procs);
      printf("Number of threads = %d\n", nthreads);
      printf("Max threads = %d\n", maxt);
      printf("In parallel? = %d\n", inpar);
      printf("Dynamic threads enabled? = %d\n", dynamic);
      printf("Nested parallelism supported? = %d\n", nested);
    }
  }
}


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   1040 <omp_get_thread_num@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    124f <main+0xcf>
mov    -0x18(%rbp),%esi
lea    0xe4c(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <omp_get_num_procs@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1060 <omp_get_num_threads@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1090 <omp_get_max_threads@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <omp_in_parallel@plt>
mov    %eax,-0x24(%rbp)
mov    $0x0,%al
call   10a0 <omp_get_dynamic@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1070 <omp_get_nested@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe28(%rip),%rdi
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe34(%rip),%rdi
call   1050 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe40(%rip),%rdi
call   1050 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe44(%rip),%rdi
call   1050 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe54(%rip),%rdi
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
test   %eax,%eax
jne    123a <main+0xba>
lea    0xe5f(%rip),%rdi
xor    %esi,%esi
call   1050 <printf@plt>
xor    %eax,%eax
call   1080 <omp_get_num_procs@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <omp_get_num_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1090 <omp_get_max_threads@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   1030 <omp_in_parallel@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   10a0 <omp_get_dynamic@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1070 <omp_get_nested@plt>
mov    %eax,%r14d
lea    0xe3e(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
lea    0xe4b(%rip),%rdi
mov    %ebp,%esi
call   1050 <printf@plt>
lea    0xe55(%rip),%rdi
mov    %r13d,%esi
call   1050 <printf@plt>
lea    0xe58(%rip),%rdi
mov    %r12d,%esi
call   1050 <printf@plt>
lea    0xe5c(%rip),%rdi
mov    %r15d,%esi
call   1050 <printf@plt>
lea    0xe6c(%rip),%rdi
mov    %r14d,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [39 x i8] c"Thread %d getting environment info...\0A\00"
@.str.1 = [27 x i8] c"Number of processors = %d\0A\00"
@.str.2 = [24 x i8] c"Number of threads = %d\0A\00"
@.str.3 = [18 x i8] c"Max threads = %d\0A\00"
@.str.4 = [19 x i8] c"In parallel? = %d\0A\00"
@.str.5 = [31 x i8] c"Dynamic threads enabled? = %d\0A\00"
@.str.6 = [36 x i8] c"Nested parallelism supported? = %d\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 i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 (...) @omp_get_thread_num()
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %37
16: ; preds = %2
%17 = load i32, i32* %7
%18 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = call i32 (...) @omp_get_num_procs()
store i32 %19, i32* %8
%20 = call i32 (...) @omp_get_num_threads()
store i32 %20, i32* %6
%21 = call i32 (...) @omp_get_max_threads()
store i32 %21, i32* %9
%22 = call i32 (...) @omp_in_parallel()
store i32 %22, i32* %10
%23 = call i32 (...) @omp_get_dynamic()
store i32 %23, i32* %11
%24 = call i32 (...) @omp_get_nested()
store i32 %24, i32* %12
%25 = load i32, i32* %8
%26 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %6
%28 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %9
%30 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %10
%32 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %11
%34 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %12
%36 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %16, %2
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [39 x i8] c"Thread %d getting environment info...\0A\00"
@.str.1 = [27 x i8] c"Number of processors = %d\0A\00"
@.str.2 = [24 x i8] c"Number of threads = %d\0A\00"
@.str.3 = [18 x i8] c"Max threads = %d\0A\00"
@.str.4 = [19 x i8] c"In parallel? = %d\0A\00"
@.str.5 = [31 x i8] c"Dynamic threads enabled? = %d\0A\00"
@.str.6 = [36 x i8] c"Nested parallelism supported? = %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @omp_get_thread_num()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %19
5: ; preds = %2
%6 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 0)
%7 = tail call i32 (...) @omp_get_num_procs()
%8 = tail call i32 (...) @omp_get_num_threads()
%9 = tail call i32 (...) @omp_get_max_threads()
%10 = tail call i32 (...) @omp_in_parallel()
%11 = tail call i32 (...) @omp_get_dynamic()
%12 = tail call i32 (...) @omp_get_nested()
%13 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%16 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %10)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %11)
%18 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32 %12)
br label %19
19: ; preds = %5, %2
ret i32 0
}