#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*/ stackEmLock_acquire(unsigned int *);
int /*<<< orphan*/ stackEmLock_release(unsigned int *);
int main(int argc, char **argv) {
  unsigned int *address = (0xFF00A000);
  *address = 0;
  for (int i = 0; i < (10); i++) {
    while (!stackEmLock_acquire(address)) {
    }
    stackEmLock_release(address);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xff00a000,%eax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    1199 <main+0x79>
jmp    115f <main+0x3f>
mov    -0x18(%rbp),%rdi
call   1030 <stackEmLock_acquire@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    117d <main+0x5d>
jmp    1182 <main+0x62>
jmp    115f <main+0x3f>
mov    -0x18(%rbp),%rdi
call   1040 <stackEmLock_release@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1150 <main+0x30>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xff00a000,%eax
movl   $0x0,(%rax)
nopl   0x0(%rax)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     1130 <main+0x10>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     1150 <main+0x30>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     1170 <main+0x50>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     1190 <main+0x70>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     11b0 <main+0x90>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     11d0 <main+0xb0>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     11f0 <main+0xd0>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     1210 <main+0xf0>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     1230 <main+0x110>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@plt>
nopl   0x0(%rax,%rax,1)
mov    $0xff00a000,%edi
call   1030 <stackEmLock_acquire@plt>
test   %eax,%eax
je     1250 <main+0x130>
mov    $0xff00a000,%edi
call   1040 <stackEmLock_release@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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* inttoptr (i64 4278231040 to i32*), i32** %6
%8 = load i32*, i32** %6
store i32 0, i32* %8
store i32 0, i32* %7
br label %9
9: ; preds = %22, %2
%10 = load i32, i32* %7
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %25
12: ; preds = %9
br label %13
13: ; preds = %18, %12
%14 = load i32*, i32** %6
%15 = call i32 @stackEmLock_acquire(i32* %14)
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %19
18: ; preds = %13
br label %13
19: ; preds = %13
%20 = load i32*, i32** %6
%21 = call i32 @stackEmLock_release(i32* %20)
br label %22
22: ; preds = %19
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %9
25: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
store i32 0, i32* inttoptr (i64 4278231040 to i32*)
br label %3
3: ; preds = %2, %3
%4 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%5 = icmp eq i32 %4, 0
br i1 %5, label %3, label %6
6: ; preds = %3
%7 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
br label %8
8: ; preds = %8, %6
%9 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%10 = icmp eq i32 %9, 0
br i1 %10, label %8, label %11
11: ; preds = %8
%12 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
br label %13
13: ; preds = %13, %11
%14 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%15 = icmp eq i32 %14, 0
br i1 %15, label %13, label %16
16: ; preds = %13
%17 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
br label %18
18: ; preds = %18, %16
%19 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%20 = icmp eq i32 %19, 0
br i1 %20, label %18, label %21
21: ; preds = %18
%22 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
br label %23
23: ; preds = %23, %21
%24 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%25 = icmp eq i32 %24, 0
br i1 %25, label %23, label %26
26: ; preds = %23
%27 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
br label %28
28: ; preds = %28, %26
%29 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%30 = icmp eq i32 %29, 0
br i1 %30, label %28, label %31
31: ; preds = %28
%32 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
br label %33
33: ; preds = %33, %31
%34 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%35 = icmp eq i32 %34, 0
br i1 %35, label %33, label %36
36: ; preds = %33
%37 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
br label %38
38: ; preds = %38, %36
%39 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%40 = icmp eq i32 %39, 0
br i1 %40, label %38, label %41
41: ; preds = %38
%42 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
br label %43
43: ; preds = %43, %41
%44 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%45 = icmp eq i32 %44, 0
br i1 %45, label %43, label %46
46: ; preds = %43
%47 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
br label %48
48: ; preds = %48, %46
%49 = tail call i32 @stackEmLock_acquire(i32* inttoptr (i64 4278231040 to i32*))
%50 = icmp eq i32 %49, 0
br i1 %50, label %48, label %51
51: ; preds = %48
%52 = tail call i32 @stackEmLock_release(i32* inttoptr (i64 4278231040 to i32*))
ret i32 0
}