#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*/ console_init();
int /*<<< orphan*/ console_write(char *, int);
int /*<<< orphan*/ set_act_state(int);
int /*<<< orphan*/ wait();
int main(void) {
  int i;
  for (i = 0; i < 5; i++) {
    set_act_state(1);
    wait();
    set_act_state(0);
    wait();
  }
  console_init();
  wait();
  wait();
  console_write("Hello world", 11);
  while (1)
    ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    118d <main+0x4d>
mov    $0x1,%edi
call   1040 <set_act_state@plt>
mov    $0x0,%al
call   1060 <wait@plt>
xor    %edi,%edi
call   1040 <set_act_state@plt>
mov    $0x0,%al
call   1060 <wait@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1156 <main+0x16>
mov    $0x0,%al
call   1030 <console_init@plt>
mov    $0x0,%al
call   1060 <wait@plt>
mov    $0x0,%al
call   1060 <wait@plt>
lea    0xe57(%rip),%rdi
mov    $0xb,%esi
call   1050 <console_write@plt>
jmp    11b3 <main+0x73>

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
xor    %edi,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
mov    $0x1,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
xor    %edi,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
mov    $0x1,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
xor    %edi,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
mov    $0x1,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
xor    %edi,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
mov    $0x1,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
xor    %edi,%edi
call   1040 <set_act_state@plt>
xor    %eax,%eax
call   1060 <wait@plt>
xor    %eax,%eax
call   1030 <console_init@plt>
xor    %eax,%eax
call   1060 <wait@plt>
xor    %eax,%eax
call   1060 <wait@plt>
lea    0xe08(%rip),%rdi
mov    $0xb,%esi
call   1050 <console_write@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
jmp    1210 <main+0xd0>

LLVM IR (-O0):
@.str = [12 x i8] c"Hello world\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %11, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 5
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = call i32 @set_act_state(i32 1)
%8 = call i32 (...) @wait()
%9 = call i32 @set_act_state(i32 0)
%10 = call i32 (...) @wait()
br label %11
11: ; preds = %6
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
store i32 %13, i32* %2
br label %3
14: ; preds = %3
%15 = call i32 (...) @console_init()
%16 = call i32 (...) @wait()
%17 = call i32 (...) @wait()
%18 = call i32 @console_write(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
br label %19
19: ; preds = %14, %19
br label %19
}

LLVM IR (-O2):
@.str = [12 x i8] c"Hello world\00"
define i32 @main() {
%1 = tail call i32 @set_act_state(i32 1)
%2 = tail call i32 (...) @wait()
%3 = tail call i32 @set_act_state(i32 0)
%4 = tail call i32 (...) @wait()
%5 = tail call i32 @set_act_state(i32 1)
%6 = tail call i32 (...) @wait()
%7 = tail call i32 @set_act_state(i32 0)
%8 = tail call i32 (...) @wait()
%9 = tail call i32 @set_act_state(i32 1)
%10 = tail call i32 (...) @wait()
%11 = tail call i32 @set_act_state(i32 0)
%12 = tail call i32 (...) @wait()
%13 = tail call i32 @set_act_state(i32 1)
%14 = tail call i32 (...) @wait()
%15 = tail call i32 @set_act_state(i32 0)
%16 = tail call i32 (...) @wait()
%17 = tail call i32 @set_act_state(i32 1)
%18 = tail call i32 (...) @wait()
%19 = tail call i32 @set_act_state(i32 0)
%20 = tail call i32 (...) @wait()
%21 = tail call i32 (...) @console_init()
%22 = tail call i32 (...) @wait()
%23 = tail call i32 (...) @wait()
%24 = tail call i32 @console_write(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
br label %25
25: ; preds = %25, %0
br label %25
}