#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_num_procs();
int omp_get_num_threads();
scalar_t__ omp_get_thread_num();
int /*<<< orphan*/ omp_set_num_threads();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int i;
  omp_set_num_threads();
#pragma omp parallel for
  for (i = 0; i <= 15; i++) {
    if (omp_get_thread_num() == 0) {
      printf("%d\n", omp_get_num_procs());
      printf("%d\n", omp_get_num_threads());
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <omp_set_num_threads@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0xf,-0x8(%rbp)
jg     11c5 <main+0x75>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
cmp    $0x0,%rax
jne    11b2 <main+0x62>
mov    $0x0,%al
call   1060 <omp_get_num_procs@plt>
mov    %eax,%esi
lea    0xe68(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <omp_get_num_threads@plt>
mov    %eax,%esi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
jmp    11b7 <main+0x67>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    116d <main+0x1d>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <omp_set_num_threads@plt>
mov    $0x10,%ebp
lea    0xe9a(%rip),%rbx
jmp    1175 <main+0x25>
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
je     11a5 <main+0x55>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
test   %rax,%rax
jne    1170 <main+0x20>
xor    %eax,%eax
call   1060 <omp_get_num_procs@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <omp_get_num_threads@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
jmp    1170 <main+0x20>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @omp_set_num_threads()
store i32 0, i32* %2
br label %4
4: ; preds = %16, %0
%5 = load i32, i32* %2
%6 = icmp sle i32 %5, 15
br i1 %6, label %7, label %19
7: ; preds = %4
%8 = call i64 (...) @omp_get_thread_num()
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = call i32 (...) @omp_get_num_procs()
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @omp_get_num_threads()
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %10, %7
br label %16
16: ; preds = %15
%17 = load i32, i32* %2
%18 = add nsw i32 %17, 1
store i32 %18, i32* %2
br label %4
19: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @omp_set_num_threads()
br label %2
2: ; preds = %0, %11
%3 = phi i32 [ 0, %0 ], [ %12, %11 ]
%4 = tail call i64 (...) @omp_get_thread_num()
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = tail call i32 (...) @omp_get_num_procs()
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = tail call i32 (...) @omp_get_num_threads()
%10 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %2, %6
%12 = add nuw nsw i32 %3, 1
%13 = icmp eq i32 %12, 16
br i1 %13, label %14, label %2
14: ; preds = %11
ret i32 0
}