#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 *get_buf(int);
int omp_get_num_places();
int omp_get_num_threads();
int omp_get_place_num_procs(int);
int /*<<< orphan*/ omp_get_place_proc_ids(int, int *);
int omp_get_thread_num();
int /*<<< orphan*/ omp_set_nested(int);
int /*<<< orphan*/ print_place(int, int *);
int /*<<< orphan*/ print_place_var();
int /*<<< orphan*/ printf(char *, int);
int main() {
  int i, num = omp_get_num_places(), nump, *ids;
  printf("omp_get_num_places () == %d\n", num);
  for (i = 0; i < num; i++) {
    printf("place %d ", i);
    nump = omp_get_place_num_procs(i);
    ids = get_buf(nump);
    omp_get_place_proc_ids(i, ids);
    print_place(nump, ids);
  }
  print_place_var();
  omp_set_nested(1);
#pragma omp parallel
  if (omp_get_thread_num() == omp_get_num_threads() - 1) {
#pragma omp parallel
    if (omp_get_thread_num() == omp_get_num_threads() - 1)
      print_place_var();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <omp_get_num_places@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe3d(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1227 <main+0x87>
mov    -0x8(%rbp),%esi
lea    0xe38(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
call   1080 <omp_get_place_num_procs@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
call   10c0 <get_buf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   10b0 <omp_get_place_proc_ids@plt>
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1090 <print_place@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11cf <main+0x2f>
mov    $0x0,%al
call   1030 <print_place_var@plt>
mov    $0x1,%edi
call   10a0 <omp_set_nested@plt>
mov    $0x0,%al
call   1050 <omp_get_thread_num@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1070 <omp_get_num_threads@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1286 <main+0xe6>
mov    $0x0,%al
call   1050 <omp_get_thread_num@plt>
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1070 <omp_get_num_threads@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1281 <main+0xe1>
mov    $0x0,%al
call   1030 <print_place_var@plt>
jmp    1286 <main+0xe6>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <omp_get_num_places@plt>
mov    %eax,%r15d
lea    0xe45(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
test   %r15d,%r15d
jle    120b <main+0x6b>
lea    0xe4f(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
call   1060 <printf@plt>
mov    %ebx,%edi
call   1080 <omp_get_place_num_procs@plt>
mov    %eax,%r12d
mov    %eax,%edi
call   10c0 <get_buf@plt>
mov    %rax,%rbp
mov    %ebx,%edi
mov    %rax,%rsi
call   10b0 <omp_get_place_proc_ids@plt>
mov    %r12d,%edi
mov    %rbp,%rsi
call   1090 <print_place@plt>
add    $0x1,%ebx
cmp    %ebx,%r15d
jne    11d0 <main+0x30>
xor    %eax,%eax
call   1030 <print_place_var@plt>
mov    $0x1,%edi
call   10a0 <omp_set_nested@plt>
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <omp_get_num_threads@plt>
add    $0xffffffff,%eax
cmp    %eax,%ebx
jne    1251 <main+0xb1>
xor    %eax,%eax
call   1050 <omp_get_thread_num@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1070 <omp_get_num_threads@plt>
add    $0xffffffff,%eax
cmp    %eax,%ebx
jne    1251 <main+0xb1>
xor    %eax,%eax
call   1030 <print_place_var@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"omp_get_num_places () == %d\0A\00"
@.str.1 = [10 x i8] c"place %d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32*
store i32 0, i32* %1
%6 = call i32 (...) @omp_get_num_places()
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %7)
store i32 0, i32* %2
br label %9
9: ; preds = %26, %0
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %29
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %2
%17 = call i32 @omp_get_place_num_procs(i32 %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = call i32* @get_buf(i32 %18)
store i32* %19, i32** %5
%20 = load i32, i32* %2
%21 = load i32*, i32** %5
%22 = call i32 @omp_get_place_proc_ids(i32 %20, i32* %21)
%23 = load i32, i32* %4
%24 = load i32*, i32** %5
%25 = call i32 @print_place(i32 %23, i32* %24)
br label %26
26: ; preds = %13
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
br label %9
29: ; preds = %9
%30 = call i32 (...) @print_place_var()
%31 = call i32 @omp_set_nested(i32 1)
%32 = call i32 (...) @omp_get_thread_num()
%33 = call i32 (...) @omp_get_num_threads()
%34 = sub nsw i32 %33, 1
%35 = icmp eq i32 %32, %34
br i1 %35, label %36, label %44
36: ; preds = %29
%37 = call i32 (...) @omp_get_thread_num()
%38 = call i32 (...) @omp_get_num_threads()
%39 = sub nsw i32 %38, 1
%40 = icmp eq i32 %37, %39
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 (...) @print_place_var()
br label %43
43: ; preds = %41, %36
br label %44
44: ; preds = %43, %29
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"omp_get_num_places () == %d\0A\00"
@.str.1 = [10 x i8] c"place %d \00"
define i32 @main() {
%1 = tail call i32 (...) @omp_get_num_places()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %13
4: ; preds = %0, %4
%5 = phi i32 [ %11, %4 ], [ 0, %0 ]
%6 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @omp_get_place_num_procs(i32 %5)
%8 = tail call i32* @get_buf(i32 %7)
%9 = tail call i32 @omp_get_place_proc_ids(i32 %5, i32* %8)
%10 = tail call i32 @print_place(i32 %7, i32* %8)
%11 = add nuw nsw i32 %5, 1
%12 = icmp eq i32 %11, %1
br i1 %12, label %13, label %4
13: ; preds = %4, %0
%14 = tail call i32 (...) @print_place_var()
%15 = tail call i32 @omp_set_nested(i32 1)
%16 = tail call i32 (...) @omp_get_thread_num()
%17 = tail call i32 (...) @omp_get_num_threads()
%18 = add nsw i32 %17, -1
%19 = icmp eq i32 %16, %18
br i1 %19, label %20, label %27
20: ; preds = %13
%21 = tail call i32 (...) @omp_get_thread_num()
%22 = tail call i32 (...) @omp_get_num_threads()
%23 = add nsw i32 %22, -1
%24 = icmp eq i32 %21, %23
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = tail call i32 (...) @print_place_var()
br label %27
27: ; preds = %20, %25, %13
ret i32 0
}