#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);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ free(int *);
int *malloc(int);
int omp_get_max_threads();
int omp_get_thread_num();
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stdout;
int main(void) {
  int np = omp_get_max_threads();
  if (np < 2)
    exit(1);
  int *A = malloc(np * sizeof(int));
#pragma omp parallel shared(A)
  {
    int me = omp_get_thread_num();
    int B = 134;
    if (me == 0)
      A[1] = B;
#pragma omp barrier
    if (me == 1)
      printf("A@1=%d\n", A[1]);
    fflush(stdout);
  }
  free(A);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <omp_get_max_threads@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119d <main+0x2d>
mov    $0x1,%edi
call   1090 <exit@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <omp_get_thread_num@plt>
mov    %eax,-0x14(%rbp)
movl   $0x86,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11d5 <main+0x65>
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
cmpl   $0x1,-0x14(%rbp)
jne    11f2 <main+0x82>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%esi
lea    0xe13(%rip),%rdi
call   1050 <printf@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1080 <omp_get_max_threads@plt>
cmp    $0x1,%eax
jle    11cc <main+0x5c>
shl    $0x2,%eax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1040 <omp_get_thread_num@plt>
cmp    $0x1,%eax
je     11a3 <main+0x33>
test   %eax,%eax
jne    11b2 <main+0x42>
movl   $0x86,0x4(%rbx)
jmp    11b2 <main+0x42>
mov    0x4(%rbx),%esi
lea    0xe53(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"A@1=%d\0A\00"
@stdout = global i32 0
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_max_threads()
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @exit(i32 1)
unreachable
11: ; preds = %0
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = mul i64 %13, 4
%15 = trunc i64 %14 to i32
%16 = call i32* @malloc(i32 %15)
store i32* %16, i32** %3
%17 = call i32 (...) @omp_get_thread_num()
store i32 %17, i32* %4
store i32 134, i32* %5
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %11
%21 = load i32, i32* %5
%22 = load i32*, i32** %3
%23 = getelementptr inbounds i32, i32* %22, i64 1
store i32 %21, i32* %23
br label %24
24: ; preds = %20, %11
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32*, i32** %3
%29 = getelementptr inbounds i32, i32* %28, i64 1
%30 = load i32, i32* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %27, %24
%33 = load i32, i32* @stdout
%34 = call i32 @fflush(i32 %33)
%35 = load i32*, i32** %3
%36 = call i32 @free(i32* %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"A@1=%d\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @omp_get_max_threads()
%2 = icmp slt i32 %1, 2
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @exit(i32 1)
unreachable
5: ; preds = %0
%6 = shl i32 %1, 2
%7 = tail call i32* @malloc(i32 %6)
%8 = tail call i32 (...) @omp_get_thread_num()
switch i32 %8, label %15 [
i32 0, label %9
i32 1, label %11
]
9: ; preds = %5
%10 = getelementptr inbounds i32, i32* %7, i64 1
store i32 134, i32* %10
br label %15
11: ; preds = %5
%12 = getelementptr inbounds i32, i32* %7, i64 1
%13 = load i32, i32* %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %9, %5, %11
%16 = load i32, i32* @stdout
%17 = tail call i32 @fflush(i32 %16)
%18 = tail call i32 @free(i32* %7)
ret i32 0
}