#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 stackEM_getThreadID();
int /*<<< orphan*/ stackEM_nop();
int /*<<< orphan*/ stackEmBarrier_register(unsigned int *);
int /*<<< orphan*/ stackEmBarrier_wait(unsigned int *, unsigned int *);
int main(int argc, char **argv) {
  unsigned int *address = ((unsigned int *)0x0000A000);
  *((unsigned int *)0x0000A000) = 0;
  *(((unsigned int *)0x0000A000) + 1) = 0;
  *(((unsigned int *)0x0000A000) + 2) = 0;
  *((unsigned int *)((stackEM_getThreadID() << 25) + (0xA000))) = 0;
  for (int j = 0; j < 3; j++) {
    stackEM_nop();
  }
  stackEmBarrier_register(address);
  for (int i = 0; i < (1); i++) {
    for (int j = 0; j < (0); j++) {
      stackEM_nop();
    }
    stackEmBarrier_wait(address, ((unsigned int *)(0xA000)));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xa000,%eax
mov    %rax,-0x18(%rbp)
mov    $0xa000,%eax
movl   $0x0,(%rax)
mov    $0xa000,%eax
movl   $0x0,0x4(%rax)
mov    $0xa000,%eax
movl   $0x0,0x8(%rax)
mov    $0x0,%al
call   1040 <stackEM_getThreadID@plt>
shl    $0x19,%eax
add    $0xa000,%eax
cltq
movl   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11bf <main+0x7f>
mov    $0x0,%al
call   1050 <stackEM_nop@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a0 <main+0x60>
mov    -0x18(%rbp),%rdi
call   1030 <stackEmBarrier_register@plt>
movl   $0x0,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jge    121b <main+0xdb>
movl   $0x0,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11ff <main+0xbf>
mov    $0x0,%al
call   1050 <stackEM_nop@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11e0 <main+0xa0>
mov    -0x18(%rbp),%rdi
mov    $0xa000,%esi
call   1060 <stackEmBarrier_wait@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11cf <main+0x8f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,0xa000
movl   $0x0,0xa004
movl   $0x0,0xa008
xor    %eax,%eax
call   1040 <stackEM_getThreadID@plt>
shl    $0x19,%eax
cltq
movl   $0x0,0xa000(%rax)
xor    %eax,%eax
call   1050 <stackEM_nop@plt>
xor    %eax,%eax
call   1050 <stackEM_nop@plt>
xor    %eax,%eax
call   1050 <stackEM_nop@plt>
mov    $0xa000,%edi
call   1030 <stackEmBarrier_register@plt>
mov    $0xa000,%edi
mov    $0xa000,%esi
call   1060 <stackEmBarrier_wait@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* inttoptr (i64 40960 to i32*), i32** %6
store i32 0, i32* inttoptr (i64 40960 to i32*)
store i32 0, i32* getelementptr inbounds (i32, i32* inttoptr (i64 40960 to i32*), i64 1)
store i32 0, i32* getelementptr inbounds (i32, i32* inttoptr (i64 40960 to i32*), i64 2)
%10 = call i32 (...) @stackEM_getThreadID()
%11 = shl i32 %10, 25
%12 = add nsw i32 %11, 40960
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i32*
store i32 0, i32* %14
store i32 0, i32* %7
br label %15
15: ; preds = %20, %2
%16 = load i32, i32* %7
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = call i32 (...) @stackEM_nop()
br label %20
20: ; preds = %18
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %15
23: ; preds = %15
%24 = load i32*, i32** %6
%25 = call i32 @stackEmBarrier_register(i32* %24)
store i32 0, i32* %8
br label %26
26: ; preds = %41, %23
%27 = load i32, i32* %8
%28 = icmp slt i32 %27, 1
br i1 %28, label %29, label %44
29: ; preds = %26
store i32 0, i32* %9
br label %30
30: ; preds = %35, %29
%31 = load i32, i32* %9
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = call i32 (...) @stackEM_nop()
br label %35
35: ; preds = %33
%36 = load i32, i32* %9
%37 = add nsw i32 %36, 1
store i32 %37, i32* %9
br label %30
38: ; preds = %30
%39 = load i32*, i32** %6
%40 = call i32 @stackEmBarrier_wait(i32* %39, i32* inttoptr (i64 40960 to i32*))
br label %41
41: ; preds = %38
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %26
44: ; preds = %26
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
store i32 0, i32* inttoptr (i64 40960 to i32*)
store i32 0, i32* inttoptr (i64 40964 to i32*)
store i32 0, i32* inttoptr (i64 40968 to i32*)
%3 = tail call i32 (...) @stackEM_getThreadID()
%4 = shl i32 %3, 25
%5 = or i32 %4, 40960
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i32*
store i32 0, i32* %7
%8 = tail call i32 (...) @stackEM_nop()
%9 = tail call i32 (...) @stackEM_nop()
%10 = tail call i32 (...) @stackEM_nop()
%11 = tail call i32 @stackEmBarrier_register(i32* inttoptr (i64 40960 to i32*))
%12 = tail call i32 @stackEmBarrier_wait(i32* inttoptr (i64 40960 to i32*), i32* inttoptr (i64 40960 to i32*))
ret i32 0
}