#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_thread_num();
int /*<<< orphan*/ printf(char *, int, int);
int main() {
  int x = 2;
#pragma omp parallel num_threads(2) shared(x)
  {
    if (omp_get_thread_num() == 0)
      x = 5;
    else
      printf("1: Thread %d: x = %d\n", omp_get_thread_num(), x);
#pragma omp barrier
    printf("2: Thread %d: x = %d\n", omp_get_thread_num(), x);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
cmp    $0x0,%eax
jne    1152 <main+0x32>
movl   $0x5,-0x8(%rbp)
jmp    116a <main+0x4a>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%edx
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <omp_get_thread_num@plt>
mov    %eax,%esi
mov    -0x8(%rbp),%edx
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
test   %eax,%eax
je     114d <main+0x2d>
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0xec6(%rip),%rdi
mov    $0x2,%ebx
mov    %eax,%esi
mov    $0x2,%edx
call   1040 <printf@plt>
jmp    1152 <main+0x32>
mov    $0x5,%ebx
xor    %eax,%eax
call   1030 <omp_get_thread_num@plt>
lea    0xeb6(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [22 x i8] c"1: Thread %d: x = %d\0A\00"
@.str.1 = [22 x i8] c"2: Thread %d: x = %d\0A\00"
define i32 @main() {
%1 = tail call i32 (...) @omp_get_thread_num()
%2 = icmp eq i32 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = tail call i32 (...) @omp_get_thread_num()
%5 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %4, i32 2)
br label %6
6: ; preds = %0, %3
%7 = phi i32 [ 2, %3 ], [ 5, %0 ]
%8 = tail call i32 (...) @omp_get_thread_num()
%9 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %7)
ret i32 0
}