#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*/ STDIN_FILENO;
int /*<<< orphan*/ STDOUT_FILENO;
size_t read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ roulette_init();
int /*<<< orphan*/ roulette_set_delay(int);
int /*<<< orphan*/ roulette_update();
int /*<<< orphan*/ serial_init();
int /*<<< orphan*/ serial_set_baudrate(int);
int /*<<< orphan*/ timer_init();
int /*<<< orphan*/ timer_wait_ms(int);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, size_t);
int main() {
  timer_init();
  roulette_init();
  roulette_set_delay(100);
  serial_set_baudrate(115200);
  serial_init();
  char buf[256];
  while (true) {
    size_t n = read(STDIN_FILENO, buf, 256);
    write(STDOUT_FILENO, buf, n);
    roulette_update();
    timer_wait_ms(10);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <timer_init@plt>
mov    $0x0,%al
call   10a0 <roulette_init@plt>
mov    $0x64,%edi
call   1080 <roulette_set_delay@plt>
mov    $0x1c200,%edi
call   1060 <serial_set_baudrate@plt>
mov    $0x0,%al
call   10b0 <serial_init@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1050 <read@plt>
mov    %rax,-0x118(%rbp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rsi
mov    -0x118(%rbp),%rdx
call   1040 <write@plt>
mov    $0x0,%al
call   1090 <roulette_update@plt>
mov    $0xa,%edi
call   1030 <timer_wait_ms@plt>
jmp    11cb <main+0x3b>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x100,%rsp
xor    %eax,%eax
call   1070 <timer_init@plt>
xor    %eax,%eax
call   10a0 <roulette_init@plt>
mov    $0x64,%edi
call   1080 <roulette_set_delay@plt>
mov    $0x1c200,%edi
call   1060 <serial_set_baudrate@plt>
xor    %eax,%eax
call   10b0 <serial_init@plt>
mov    0x2e0c(%rip),%r14
mov    %rsp,%rbx
mov    0x2e1a(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1050 <read@plt>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
xor    %eax,%eax
call   1090 <roulette_update@plt>
mov    $0xa,%edi
call   1030 <timer_wait_ms@plt>
jmp    11e0 <main+0x50>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 (...) @timer_init()
%5 = call i32 (...) @roulette_init()
%6 = call i32 @roulette_set_delay(i32 100)
%7 = call i32 @serial_set_baudrate(i32 115200)
%8 = call i32 (...) @serial_init()
br label %9
9: ; preds = %0, %9
%10 = load i32, i32* @STDIN_FILENO
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%12 = call i64 @read(i32 %10, i8* %11, i32 256)
store i64 %12, i64* %3
%13 = load i32, i32* @STDOUT_FILENO
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%15 = load i64, i64* %3
%16 = call i32 @write(i32 %13, i8* %14, i64 %15)
%17 = call i32 (...) @roulette_update()
%18 = call i32 @timer_wait_ms(i32 10)
br label %9
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@STDOUT_FILENO = global i32 0
define i32 @main() {
%1 = alloca [256 x i8]
%2 = tail call i32 (...) @timer_init()
%3 = tail call i32 (...) @roulette_init()
%4 = tail call i32 @roulette_set_delay(i32 100)
%5 = tail call i32 @serial_set_baudrate(i32 115200)
%6 = tail call i32 (...) @serial_init()
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
br label %8
8: ; preds = %8, %0
%9 = load i32, i32* @STDIN_FILENO
%10 = call i64 @read(i32 %9, i8* %7, i32 256)
%11 = load i32, i32* @STDOUT_FILENO
%12 = call i32 @write(i32 %11, i8* %7, i64 %10)
%13 = tail call i32 (...) @roulette_update()
%14 = tail call i32 @timer_wait_ms(i32 10)
br label %8
}