#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 cleanup(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  int init(void);
  int load(void);
  int execute(void);
  init();
  puts("*** Welcome to Simpletron! ***");
  puts("*** Please enter your program one instruction ***");
  puts("*** (or data word) at a time. I will type the ***");
  puts("*** location number and a question mark (?).  ***");
  puts("*** You then type the word for that location. ***");
  printf("*** Type the sentinel %05X to stop entering ***", (0xFFFFF));
  puts("*** your program. ***");
  load();
  execute();
  return cleanup((0));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
call   1060 <init@plt>
lea    0xe85(%rip),%rdi
call   1030 <puts@plt>
lea    0xe98(%rip),%rdi
call   1030 <puts@plt>
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0xee4(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf30(%rip),%rdi
mov    $0xfffff,%esi
call   1040 <printf@plt>
lea    0xf4f(%rip),%rdi
call   1030 <puts@plt>
call   1080 <load@plt>
call   1050 <execute@plt>
xor    %edi,%edi
call   1070 <cleanup@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1060 <init@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xef2(%rip),%rdi
call   1030 <puts@plt>
lea    0xf18(%rip),%rdi
call   1030 <puts@plt>
lea    0xf3e(%rip),%rdi
mov    $0xfffff,%esi
call   1040 <printf@plt>
lea    0xf5d(%rip),%rdi
call   1030 <puts@plt>
call   1080 <load@plt>
call   1050 <execute@plt>
xor    %edi,%edi
pop    %rax
jmp    1070 <cleanup@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"*** Welcome to Simpletron! ***\00"
@.str.1 = [50 x i8] c"*** Please enter your program one instruction ***\00"
@.str.2 = [50 x i8] c"*** (or data word) at a time. I will type the ***\00"
@.str.3 = [50 x i8] c"*** location number and a question mark (?). ***\00"
@.str.4 = [50 x i8] c"*** You then type the word for that location. ***\00"
@.str.5 = [48 x i8] c"*** Type the sentinel %05X to stop entering ***\00"
@.str.6 = [22 x i8] c"*** your program. ***\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @init()
%3 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @puts(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @puts(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @puts(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @puts(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 1048575)
%9 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @load()
%11 = call i32 @execute()
%12 = call i32 @cleanup(i32 0)
ret i32 %12
}

LLVM IR (-O2):
@.str = [31 x i8] c"*** Welcome to Simpletron! ***\00"
@.str.1 = [50 x i8] c"*** Please enter your program one instruction ***\00"
@.str.2 = [50 x i8] c"*** (or data word) at a time. I will type the ***\00"
@.str.3 = [50 x i8] c"*** location number and a question mark (?). ***\00"
@.str.4 = [50 x i8] c"*** You then type the word for that location. ***\00"
@.str.5 = [48 x i8] c"*** Type the sentinel %05X to stop entering ***\00"
@.str.6 = [22 x i8] c"*** your program. ***\00"
define i32 @main() {
%1 = tail call i32 @init()
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%7 = tail call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i32 1048575)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%9 = tail call i32 @load()
%10 = tail call i32 @execute()
%11 = tail call i32 @cleanup(i32 0)
ret i32 %11
}