#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ cli_exit();
int /*<<< orphan*/ cli_get_device_reset();
int /*<<< orphan*/ cli_get_exit_simulation();
int /*<<< orphan*/ cli_init();
int /*<<< orphan*/ cli_process();
int /*<<< orphan*/ lockcontroller_init();
int /*<<< orphan*/ lockcontroller_process();
int /*<<< orphan*/ lockcontroller_tick();
int /*<<< orphan*/ usleep(int);
int main() {
  uint8_t i = 0;
  do {
    cli_init();
    lockcontroller_init();
    while (!cli_get_device_reset() && !cli_get_exit_simulation()) {
      for (i = 0; i < 5; i++) {
        lockcontroller_process();
        usleep(200);
      }
      lockcontroller_tick();
      cli_process();
    }
  } while (!cli_get_exit_simulation());
  cli_exit();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1090 <cli_init@plt>
mov    $0x0,%al
call   1040 <lockcontroller_init@plt>
mov    $0x0,%al
call   1080 <cli_get_device_reset@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
jne    11dd <main+0x4d>
mov    $0x0,%al
call   1060 <cli_get_exit_simulation@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    11ed <main+0x5d>
jmp    1230 <main+0xa0>
movl   $0x0,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    121d <main+0x8d>
mov    $0x0,%al
call   1070 <lockcontroller_process@plt>
mov    $0xc8,%edi
call   10b0 <usleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11f4 <main+0x64>
mov    $0x0,%al
call   1050 <lockcontroller_tick@plt>
mov    $0x0,%al
call   1030 <cli_process@plt>
jmp    11b4 <main+0x24>
jmp    1235 <main+0xa5>
mov    $0x0,%al
call   1060 <cli_get_exit_simulation@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11a6 <main+0x16>
mov    $0x0,%al
call   10a0 <cli_exit@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
jmp    11af <main+0x1f>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1060 <cli_get_exit_simulation@plt>
test   %eax,%eax
jne    123b <main+0xab>
xor    %eax,%eax
call   1090 <cli_init@plt>
xor    %eax,%eax
call   1040 <lockcontroller_init@plt>
nopl   (%rax)
xor    %eax,%eax
call   1080 <cli_get_device_reset@plt>
test   %eax,%eax
jne    11a0 <main+0x10>
xor    %eax,%eax
call   1060 <cli_get_exit_simulation@plt>
test   %eax,%eax
jne    11a0 <main+0x10>
xor    %eax,%eax
call   1070 <lockcontroller_process@plt>
mov    $0xc8,%edi
call   10b0 <usleep@plt>
xor    %eax,%eax
call   1070 <lockcontroller_process@plt>
mov    $0xc8,%edi
call   10b0 <usleep@plt>
xor    %eax,%eax
call   1070 <lockcontroller_process@plt>
mov    $0xc8,%edi
call   10b0 <usleep@plt>
xor    %eax,%eax
call   1070 <lockcontroller_process@plt>
mov    $0xc8,%edi
call   10b0 <usleep@plt>
xor    %eax,%eax
call   1070 <lockcontroller_process@plt>
mov    $0xc8,%edi
call   10b0 <usleep@plt>
xor    %eax,%eax
call   1050 <lockcontroller_tick@plt>
xor    %eax,%eax
call   1030 <cli_process@plt>
jmp    11c0 <main+0x30>
xor    %eax,%eax
call   10a0 <cli_exit@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %29, %0
%4 = call i32 (...) @cli_init()
%5 = call i32 (...) @lockcontroller_init()
br label %6
6: ; preds = %25, %3
%7 = call i32 (...) @cli_get_device_reset()
%8 = icmp ne i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = call i32 (...) @cli_get_exit_simulation()
%11 = icmp ne i32 %10, 0
%12 = xor i1 %11, true
br label %13
13: ; preds = %9, %6
%14 = phi i1 [ false, %6 ], [ %12, %9 ]
br i1 %14, label %15, label %28
15: ; preds = %13
store i32 0, i32* %2
br label %16
16: ; preds = %22, %15
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 5
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = call i32 (...) @lockcontroller_process()
%21 = call i32 @usleep(i32 200)
br label %22
22: ; preds = %19
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %16
25: ; preds = %16
%26 = call i32 (...) @lockcontroller_tick()
%27 = call i32 (...) @cli_process()
br label %6
28: ; preds = %13
br label %29
29: ; preds = %28
%30 = call i32 (...) @cli_get_exit_simulation()
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
br i1 %32, label %3, label %33
33: ; preds = %29
%34 = call i32 (...) @cli_exit()
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
br label %1
1: ; preds = %24, %0
%2 = tail call i32 (...) @cli_init()
%3 = tail call i32 (...) @lockcontroller_init()
%4 = tail call i32 (...) @cli_get_device_reset()
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %24
6: ; preds = %1, %9
%7 = tail call i32 (...) @cli_get_exit_simulation()
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %6
%10 = tail call i32 (...) @lockcontroller_process()
%11 = tail call i32 @usleep(i32 200)
%12 = tail call i32 (...) @lockcontroller_process()
%13 = tail call i32 @usleep(i32 200)
%14 = tail call i32 (...) @lockcontroller_process()
%15 = tail call i32 @usleep(i32 200)
%16 = tail call i32 (...) @lockcontroller_process()
%17 = tail call i32 @usleep(i32 200)
%18 = tail call i32 (...) @lockcontroller_process()
%19 = tail call i32 @usleep(i32 200)
%20 = tail call i32 (...) @lockcontroller_tick()
%21 = tail call i32 (...) @cli_process()
%22 = tail call i32 (...) @cli_get_device_reset()
%23 = icmp eq i32 %22, 0
br i1 %23, label %6, label %24
24: ; preds = %9, %6, %1
%25 = tail call i32 (...) @cli_get_exit_simulation()
%26 = icmp eq i32 %25, 0
br i1 %26, label %1, label %27
27: ; preds = %24
%28 = tail call i32 (...) @cli_exit()
ret i32 0
}