#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_partition_num_places();
int /*<<< orphan*/ omp_get_partition_place_nums(int *);
int omp_get_place_num();
int /*<<< orphan*/ printf(char *, int, ...);
void print_place_var(void) {
  int place = omp_get_place_num();
  int num_places = omp_get_partition_num_places();
  int *ids = get_buf(num_places);
  omp_get_partition_place_nums(ids);
  printf("place %d\n", place);
  if (num_places)
    printf("partition %d-%d\n", ids[0], ids[num_places - 1]);
}


x86 assembly (clang, -O0):
<print_place_var>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <omp_get_place_num@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1030 <omp_get_partition_num_places@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <get_buf@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <omp_get_partition_place_nums@plt>
mov    -0x4(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11c0 <print_place_var+0x70>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_place_var>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1060 <omp_get_place_num@plt>
mov    %eax,%ebp
xor    %eax,%eax
call   1030 <omp_get_partition_num_places@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1070 <get_buf@plt>
mov    %rax,%r14
mov    %rax,%rdi
call   1050 <omp_get_partition_place_nums@plt>
lea    0xe81(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
je     11a9 <print_place_var+0x59>
mov    (%r14),%esi
movslq %ebx,%rax
mov    -0x4(%r14,%rax,4),%edx
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"place %d\0A\00"
@.str.1 = [17 x i8] c"partition %d-%d\0A\00"
define void @print_place_var() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = call i32 (...) @omp_get_place_num()
store i32 %4, i32* %1
%5 = call i32 (...) @omp_get_partition_num_places()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = call i32* @get_buf(i32 %6)
store i32* %7, i32** %3
%8 = load i32*, i32** %3
%9 = call i32 @omp_get_partition_place_nums(i32* %8)
%10 = load i32, i32* %1
%11 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %25
14: ; preds = %0
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 0
%17 = load i32, i32* %16
%18 = load i32*, i32** %3
%19 = load i32, i32* %2
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %18, i64 %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %23)
br label %25
25: ; preds = %14, %0
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"place %d\0A\00"
@.str.1 = [17 x i8] c"partition %d-%d\0A\00"
define void @print_place_var() {
%1 = tail call i32 (...) @omp_get_place_num()
%2 = tail call i32 (...) @omp_get_partition_num_places()
%3 = tail call i32* @get_buf(i32 %2)
%4 = tail call i32 @omp_get_partition_place_nums(i32* %3)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %1)
%6 = icmp eq i32 %2, 0
br i1 %6, label %14, label %7
7: ; preds = %0
%8 = load i32, i32* %3
%9 = add nsw i32 %2, -1
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %3, i64 %10
%12 = load i32, i32* %11
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %12)
br label %14
14: ; preds = %7, %0
ret void
}