#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void usage(void) {
  fprintf(stderr, "usage: emulator [options] <hex image file>\n");
  fprintf(stderr, "options:\n");
  fprintf(stderr,
          "  -v Verbose, will print register transfer traces to stdout\n");
  fprintf(stderr, "  -m Mode, one of:\n");
  fprintf(stderr, "     normal  Run to completion (default)\n");
  fprintf(stderr, "     cosim   Cosimulation validation mode\n");
  fprintf(stderr, "     gdb     Start GDB listener on port 8000\n");
  fprintf(stderr,
          "  -f <width>x<height> Display frame buffer output in window\n");
  fprintf(stderr, "  -d <filename>,<start>,<length>  Dump memory\n");
  fprintf(stderr, "  -b <filename> Load file into a virtual block device\n");
  fprintf(stderr, "  -t <num> Threads per core (default 4)\n");
  fprintf(stderr, "  -p <num> Number of cores (default 1)\n");
  fprintf(stderr, "  -c <size> Total amount of memory\n");
  fprintf(stderr,
          "  -r <cycles> Refresh rate, cycles between each screen update\n");
  fprintf(stderr, "  -s <file> Memory map file as shared memory\n");
  fprintf(stderr, "  -i <file> Named pipe to receive interrupts. Pipe must "
                  "already be created.\n");
  fprintf(stderr, "  -o <file> Named pipe to send interrupts. Pipe must "
                  "already be created\n");
  fprintf(stderr, "  -a Enable random thread scheduling (slower)");
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
lea    0xedc(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2eb0(%rip),%rax
mov    (%rax),%edi
lea    0xef3(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
lea    0xee8(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xf10(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xf0f(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e5c(%rip),%rax
mov    (%rax),%edi
lea    0xf24(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
lea    0xf3a(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xf53(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xf7b(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
lea    0xf95(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
lea    0xfb7(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xfcb(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
lea    0xfde(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
lea    0xfed(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d9f(%rip),%rax
mov    (%rax),%edi
lea    0x1017(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0x1030(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    0x1068(%rip),%rsi
call   1030 <fprintf@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%edi
lea    0x109c(%rip),%rsi
call   1030 <fprintf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %rbx
mov    0x2ec8(%rip),%rbx
mov    (%rbx),%edi
lea    0xedf(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xefd(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xef9(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf28(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf2e(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf4a(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf67(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xf87(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xfb6(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0xfd7(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1000(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x101b(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1035(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x104b(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x107c(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x109c(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x10db(%rip),%rsi
call   1030 <fprintf@plt>
mov    (%rbx),%edi
lea    0x1116(%rip),%rsi
pop    %rbx
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"usage: emulator [options] <hex image file>\0A\00"
@.str.1 = [10 x i8] c"options:\0A\00"
@.str.2 = [61 x i8] c" -v Verbose, will print register transfer traces to stdout\0A\00"
@.str.3 = [20 x i8] c" -m Mode, one of:\0A\00"
@.str.4 = [42 x i8] c" normal Run to completion (default)\0A\00"
@.str.5 = [43 x i8] c" cosim Cosimulation validation mode\0A\00"
@.str.6 = [46 x i8] c" gdb Start GDB listener on port 8000\0A\00"
@.str.7 = [61 x i8] c" -f <width>x<height> Display frame buffer output in window\0A\00"
@.str.8 = [47 x i8] c" -d <filename>,<start>,<length> Dump memory\0A\00"
@.str.9 = [55 x i8] c" -b <filename> Load file into a virtual block device\0A\00"
@.str.10 = [41 x i8] c" -t <num> Threads per core (default 4)\0A\00"
@.str.11 = [40 x i8] c" -p <num> Number of cores (default 1)\0A\00"
@.str.12 = [36 x i8] c" -c <size> Total amount of memory\0A\00"
@.str.13 = [63 x i8] c" -r <cycles> Refresh rate, cycles between each screen update\0A\00"
@.str.14 = [46 x i8] c" -s <file> Memory map file as shared memory\0A\00"
@.str.15 = [77 x i8] c" -i <file> Named pipe to receive interrupts. Pipe must already be created.\0A\00"
@.str.16 = [73 x i8] c" -o <file> Named pipe to send interrupts. Pipe must already be created\0A\00"
@.str.17 = [46 x i8] c" -a Enable random thread scheduling (slower)\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stderr
%4 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.13, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.15, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.16, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.17, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"usage: emulator [options] <hex image file>\0A\00"
@.str.1 = [10 x i8] c"options:\0A\00"
@.str.2 = [61 x i8] c" -v Verbose, will print register transfer traces to stdout\0A\00"
@.str.3 = [20 x i8] c" -m Mode, one of:\0A\00"
@.str.4 = [42 x i8] c" normal Run to completion (default)\0A\00"
@.str.5 = [43 x i8] c" cosim Cosimulation validation mode\0A\00"
@.str.6 = [46 x i8] c" gdb Start GDB listener on port 8000\0A\00"
@.str.7 = [61 x i8] c" -f <width>x<height> Display frame buffer output in window\0A\00"
@.str.8 = [47 x i8] c" -d <filename>,<start>,<length> Dump memory\0A\00"
@.str.9 = [55 x i8] c" -b <filename> Load file into a virtual block device\0A\00"
@.str.10 = [41 x i8] c" -t <num> Threads per core (default 4)\0A\00"
@.str.11 = [40 x i8] c" -p <num> Number of cores (default 1)\0A\00"
@.str.12 = [36 x i8] c" -c <size> Total amount of memory\0A\00"
@.str.13 = [63 x i8] c" -r <cycles> Refresh rate, cycles between each screen update\0A\00"
@.str.14 = [46 x i8] c" -s <file> Memory map file as shared memory\0A\00"
@.str.15 = [77 x i8] c" -i <file> Named pipe to receive interrupts. Pipe must already be created.\0A\00"
@.str.16 = [73 x i8] c" -o <file> Named pipe to send interrupts. Pipe must already be created\0A\00"
@.str.17 = [46 x i8] c" -a Enable random thread scheduling (slower)\00"
define void @usage() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.7, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.9, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.10, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.11, i64 0, i64 0))
%25 = load i32, i32* @stderr
%26 = tail call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.12, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.13, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = tail call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%31 = load i32, i32* @stderr
%32 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.15, i64 0, i64 0))
%33 = load i32, i32* @stderr
%34 = tail call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.16, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.17, i64 0, i64 0))
ret void
}