#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*/ check_interrupts();
int /*<<< orphan*/ cycle_timer();
int /*<<< orphan*/ cycle_video();
int /*<<< orphan*/ exec_instruction();
int /*<<< orphan*/ init_audio();
int /*<<< orphan*/ init_cpu();
int /*<<< orphan*/ init_interrupt();
int /*<<< orphan*/ init_joypad();
int /*<<< orphan*/ init_mem();
int /*<<< orphan*/ init_rom(char *);
int /*<<< orphan*/ init_serial();
int /*<<< orphan*/ init_timer();
int /*<<< orphan*/ init_video();
int main(int argc, char **argv) {
  init_mem();
  init_rom(argv[1]);
  init_cpu();
  init_interrupt();
  init_audio();
  init_video();
  init_timer();
  init_joypad();
  init_serial();
  while (1) {
    exec_instruction();
    check_interrupts();
    cycle_video();
    cycle_timer();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1070 <init_mem@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <init_rom@plt>
mov    $0x0,%al
call   10d0 <init_cpu@plt>
mov    $0x0,%al
call   10c0 <init_interrupt@plt>
mov    $0x0,%al
call   1030 <init_audio@plt>
mov    $0x0,%al
call   1040 <init_video@plt>
mov    $0x0,%al
call   10a0 <init_timer@plt>
mov    $0x0,%al
call   10e0 <init_joypad@plt>
mov    $0x0,%al
call   10f0 <init_serial@plt>
mov    $0x0,%al
call   1090 <exec_instruction@plt>
mov    $0x0,%al
call   1050 <check_interrupts@plt>
mov    $0x0,%al
call   1060 <cycle_video@plt>
mov    $0x0,%al
call   10b0 <cycle_timer@plt>
jmp    122b <main+0x5b>

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
xor    %eax,%eax
call   1070 <init_mem@plt>
mov    0x8(%rbx),%rdi
call   1080 <init_rom@plt>
xor    %eax,%eax
call   10d0 <init_cpu@plt>
xor    %eax,%eax
call   10c0 <init_interrupt@plt>
xor    %eax,%eax
call   1030 <init_audio@plt>
xor    %eax,%eax
call   1040 <init_video@plt>
xor    %eax,%eax
call   10a0 <init_timer@plt>
xor    %eax,%eax
call   10e0 <init_joypad@plt>
xor    %eax,%eax
call   10f0 <init_serial@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1090 <exec_instruction@plt>
xor    %eax,%eax
call   1050 <check_interrupts@plt>
xor    %eax,%eax
call   1060 <cycle_video@plt>
xor    %eax,%eax
call   10b0 <cycle_timer@plt>
jmp    1220 <main+0x50>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @init_mem()
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @init_rom(i8* %9)
%11 = call i32 (...) @init_cpu()
%12 = call i32 (...) @init_interrupt()
%13 = call i32 (...) @init_audio()
%14 = call i32 (...) @init_video()
%15 = call i32 (...) @init_timer()
%16 = call i32 (...) @init_joypad()
%17 = call i32 (...) @init_serial()
br label %18
18: ; preds = %2, %18
%19 = call i32 (...) @exec_instruction()
%20 = call i32 (...) @check_interrupts()
%21 = call i32 (...) @cycle_video()
%22 = call i32 (...) @cycle_timer()
br label %18
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 (...) @init_mem()
%4 = getelementptr inbounds i8*, i8** %1, i64 1
%5 = load i8*, i8** %4
%6 = tail call i32 @init_rom(i8* %5)
%7 = tail call i32 (...) @init_cpu()
%8 = tail call i32 (...) @init_interrupt()
%9 = tail call i32 (...) @init_audio()
%10 = tail call i32 (...) @init_video()
%11 = tail call i32 (...) @init_timer()
%12 = tail call i32 (...) @init_joypad()
%13 = tail call i32 (...) @init_serial()
br label %14
14: ; preds = %2, %14
%15 = tail call i32 (...) @exec_instruction()
%16 = tail call i32 (...) @check_interrupts()
%17 = tail call i32 (...) @cycle_video()
%18 = tail call i32 (...) @cycle_timer()
br label %14
}