#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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ gethostname(char *, int);
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 main(int argc, char *argv[]) {
  int nthreads, tid, procs, maxt, inpar, dynamic, nested;
  char name[50];
#pragma omp parallel private(nthreads, tid)
  {
    tid = omp_get_thread_num();
    if (tid == 0) {
      printf("Thread %d getting environment info...\n", tid);
      gethostname(name, 50);
      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("Hostname = %s\n", name);
      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);
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%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    129d <main+0xfd>
mov    -0x18(%rbp),%esi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0x32,%esi
call   10a0 <gethostname@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   10c0 <omp_get_dynamic@plt>
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1070 <omp_get_nested@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x60(%rbp),%rsi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%esi
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
test   %eax,%eax
jne    1289 <main+0xe9>
lea    0xe3c(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rdi
mov    $0x32,%esi
call   10a0 <gethostname@plt>
xor    %eax,%eax
call   1080 <omp_get_num_procs@plt>
mov    %eax,%r12d
xor    %eax,%eax
call   1060 <omp_get_num_threads@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1090 <omp_get_max_threads@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_in_parallel@plt>
mov    %eax,%r13d
xor    %eax,%eax
call   10c0 <omp_get_dynamic@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   1070 <omp_get_nested@plt>
mov    %eax,%r14d
lea    0xe0c(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe0a(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe14(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1e(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe20(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe2e(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

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

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