#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 /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int i;
  volatile int *lock = (10 * 1024 * 1024);
  printf("comecou\n");
  for (i = 0; i < 10; i++)
    printf("Hi Marcus!\n");
  printf("fim\n");
  if (*lock == 0) {
    printf("lock livre\n");
  } else {
    printf("lock travado\n");
  }
  printf("tentando denovo\n");
  if (*lock == 0) {
    printf("livre\n");
  } else {
    printf("lock travado\n");
  }
  printf("e se soltar ?\n");
  *lock = 0;
  if (*lock == 0) {
    printf("lock livre\n");
  } else {
    printf("lock travado\n");
  }
  exit(0);
  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    $0xa00000,%eax
mov    %rax,-0x20(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1176 <main+0x56>
lea    0xea6(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1152 <main+0x32>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    $0x0,%eax
jne    11a2 <main+0x82>
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
jmp    11ae <main+0x8e>
lea    0xe7d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    $0x0,%eax
jne    11da <main+0xba>
lea    0xe4f(%rip),%rdi
call   1030 <printf@plt>
jmp    11e6 <main+0xc6>
lea    0xe45(%rip),%rdi
call   1030 <printf@plt>
lea    0xe58(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
cmp    $0x0,%eax
jne    121c <main+0xfc>
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
jmp    1228 <main+0x108>
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0b(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xa00000
lea    0xe95(%rip),%r14
lea    0xe81(%rip),%rbx
mov    %rbx,%rdi
cmove  %r14,%rdi
call   1030 <puts@plt>
lea    0xe50(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0xa00000
lea    0xe6c(%rip),%rdi
cmovne %rbx,%rdi
call   1030 <puts@plt>
lea    0xe3c(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0xa00000
cmpl   $0x0,0xa00000
cmove  %r14,%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"comecou\0A\00"
@.str.1 = [12 x i8] c"Hi Marcus!\0A\00"
@.str.2 = [5 x i8] c"fim\0A\00"
@.str.3 = [12 x i8] c"lock livre\0A\00"
@.str.4 = [14 x i8] c"lock travado\0A\00"
@.str.5 = [17 x i8] c"tentando denovo\0A\00"
@.str.6 = [7 x i8] c"livre\0A\00"
@.str.7 = [15 x i8] c"e se soltar ?\0A\00"
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 10485760 to i32*), i32** %7
%8 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %9
9: ; preds = %14, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12
%15 = load i32, i32* %6
%16 = add nsw i32 %15, 1
store i32 %16, i32* %6
br label %9
17: ; preds = %9
%18 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32*, i32** %7
%20 = load volatile i32, i32* %19
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %26
24: ; preds = %17
%25 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %26
26: ; preds = %24, %22
%27 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%28 = load i32*, i32** %7
%29 = load volatile i32, i32* %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %26
%32 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %35
33: ; preds = %26
%34 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
%36 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
%37 = load i32*, i32** %7
store volatile i32 0, i32* %37
%38 = load i32*, i32** %7
%39 = load volatile i32, i32* %38
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %45
43: ; preds = %35
%44 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %43, %41
%46 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@str = [8 x i8] c"comecou\00"
@str.8 = [4 x i8] c"fim\00"
@str.10 = [16 x i8] c"tentando denovo\00"
@str.12 = [14 x i8] c"e se soltar ?\00"
@str.13 = [13 x i8] c"lock travado\00"
@str.15 = [6 x i8] c"livre\00"
@str.16 = [11 x i8] c"lock livre\00"
@str.17 = [11 x i8] c"Hi Marcus!\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.17, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.8, i64 0, i64 0))
%15 = load volatile i32, i32* inttoptr (i64 10485760 to i32*)
%16 = icmp eq i32 %15, 0
%17 = select i1 %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.16, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0)
%18 = tail call i32 @puts(i8* dereferenceable(1) %17)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.10, i64 0, i64 0))
%20 = load volatile i32, i32* inttoptr (i64 10485760 to i32*)
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.15, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0)
%23 = tail call i32 @puts(i8* dereferenceable(1) %22)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
store volatile i32 0, i32* inttoptr (i64 10485760 to i32*)
%25 = load volatile i32, i32* inttoptr (i64 10485760 to i32*)
%26 = icmp eq i32 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.16, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0)
%28 = tail call i32 @puts(i8* dereferenceable(1) %27)
%29 = tail call i32 @exit(i32 0)
unreachable
}