#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 */
struct hw_device {
  int dummy;
};

/* Variables and functions */
struct hw_device *console_create();
int /*<<< orphan*/ device_define(struct hw_device *, int /*<<< orphan*/, int,
                                 int, int);
struct hw_device *disk_create(char *, struct hw_device *);
struct hw_device *mmu_create();
struct hw_device *ram_create(int);
struct hw_device *rom_create(char const *, int);
void eon_init(const char *boot_rom_file) {
  struct hw_device *dev, *ram_dev;
  device_define(mmu_create(), 0, (0xE000 + (128 * (0))), 128, 0x3 + 0x4);
  device_define(ram_dev = ram_create(0x100000), 0, 0x0000, 65536, 0x3);
  device_define(rom_create(boot_rom_file, 0x1C00), 0, 0xE400, 0x1C00, 0x1);
  device_define(dev = console_create(), 0, (0xE000 + (128 * (2))), 128, 0x3);
  device_define(dev, 0, 0xFF00, 128, 0x3);
  device_define(disk_create("disk.bin", ram_dev), 0,
                (0xE000 + (128 * (4 + (0)))), 128, 0x3);
}


x86 assembly (clang, -O0):
<eon_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <mmu_create@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xe000,%edx
mov    $0x80,%ecx
mov    $0x7,%r8d
call   1080 <device_define@plt>
mov    $0x100000,%edi
call   1070 <ram_create@plt>
mov    %rax,%rdi
mov    %rdi,-0x18(%rbp)
xor    %edx,%edx
mov    $0x10000,%ecx
mov    $0x3,%r8d
mov    %edx,%esi
call   1080 <device_define@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1c00,%esi
call   1040 <rom_create@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xe400,%edx
mov    $0x1c00,%ecx
mov    $0x1,%r8d
call   1080 <device_define@plt>
mov    $0x0,%al
call   1030 <console_create@plt>
mov    %rax,%rdi
mov    %rdi,-0x10(%rbp)
xor    %esi,%esi
mov    $0xe100,%edx
mov    $0x80,%ecx
mov    $0x3,%r8d
call   1080 <device_define@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xff00,%edx
mov    $0x80,%ecx
mov    $0x3,%r8d
call   1080 <device_define@plt>
mov    -0x18(%rbp),%rsi
lea    0xddb(%rip),%rdi
call   1060 <disk_create@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xe200,%edx
mov    $0x80,%ecx
mov    $0x3,%r8d
call   1080 <device_define@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eon_init>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
xor    %eax,%eax
call   1050 <mmu_create@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xe000,%edx
mov    $0x80,%ecx
mov    $0x7,%r8d
call   1080 <device_define@plt>
mov    $0x100000,%edi
call   1070 <ram_create@plt>
mov    %rax,%r15
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
mov    $0x10000,%ecx
mov    $0x3,%r8d
call   1080 <device_define@plt>
mov    %r14,%rdi
mov    $0x1c00,%esi
call   1040 <rom_create@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xe400,%edx
mov    $0x1c00,%ecx
mov    $0x1,%r8d
call   1080 <device_define@plt>
xor    %eax,%eax
call   1030 <console_create@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xe100,%edx
mov    $0x80,%ecx
mov    $0x3,%r8d
call   1080 <device_define@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xff00,%edx
mov    $0x80,%ecx
mov    $0x3,%r8d
call   1080 <device_define@plt>
lea    0xde7(%rip),%rdi
mov    %r15,%rsi
call   1060 <disk_create@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xe200,%edx
mov    $0x80,%ecx
mov    $0x3,%r8d
pop    %rbx
pop    %r14
pop    %r15
jmp    1080 <device_define@plt>

LLVM IR (-O0):
%struct.hw_device = type { i32 }
@.str = [9 x i8] c"disk.bin\00"
define void @eon_init(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.hw_device*
%4 = alloca %struct.hw_device*
store i8* %0, i8** %2
%5 = call %struct.hw_device* (...) @mmu_create()
%6 = call i32 @device_define(%struct.hw_device* %5, i32 0, i32 57344, i32 128, i32 7)
%7 = call %struct.hw_device* @ram_create(i32 1048576)
store %struct.hw_device* %7, %struct.hw_device** %4
%8 = call i32 @device_define(%struct.hw_device* %7, i32 0, i32 0, i32 65536, i32 3)
%9 = load i8*, i8** %2
%10 = call %struct.hw_device* @rom_create(i8* %9, i32 7168)
%11 = call i32 @device_define(%struct.hw_device* %10, i32 0, i32 58368, i32 7168, i32 1)
%12 = call %struct.hw_device* (...) @console_create()
store %struct.hw_device* %12, %struct.hw_device** %3
%13 = call i32 @device_define(%struct.hw_device* %12, i32 0, i32 57600, i32 128, i32 3)
%14 = load %struct.hw_device*, %struct.hw_device** %3
%15 = call i32 @device_define(%struct.hw_device* %14, i32 0, i32 65280, i32 128, i32 3)
%16 = load %struct.hw_device*, %struct.hw_device** %4
%17 = call %struct.hw_device* @disk_create(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.hw_device* %16)
%18 = call i32 @device_define(%struct.hw_device* %17, i32 0, i32 57856, i32 128, i32 3)
ret void
}

LLVM IR (-O2):
%struct.hw_device = type { i32 }
@.str = [9 x i8] c"disk.bin\00"
define void @eon_init(i8* %0) {
%2 = tail call %struct.hw_device* (...) @mmu_create()
%3 = tail call i32 @device_define(%struct.hw_device* %2, i32 0, i32 57344, i32 128, i32 7)
%4 = tail call %struct.hw_device* @ram_create(i32 1048576)
%5 = tail call i32 @device_define(%struct.hw_device* %4, i32 0, i32 0, i32 65536, i32 3)
%6 = tail call %struct.hw_device* @rom_create(i8* %0, i32 7168)
%7 = tail call i32 @device_define(%struct.hw_device* %6, i32 0, i32 58368, i32 7168, i32 1)
%8 = tail call %struct.hw_device* (...) @console_create()
%9 = tail call i32 @device_define(%struct.hw_device* %8, i32 0, i32 57600, i32 128, i32 3)
%10 = tail call i32 @device_define(%struct.hw_device* %8, i32 0, i32 65280, i32 128, i32 3)
%11 = tail call %struct.hw_device* @disk_create(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), %struct.hw_device* %4)
%12 = tail call i32 @device_define(%struct.hw_device* %11, i32 0, i32 57856, i32 128, i32 3)
ret void
}