#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 */
scalar_t__ assign_memaddr();
scalar_t__ convert_to_bin();
int /*<<< orphan*/ create_optab_file();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ initialise();
scalar_t__ load_optab();
scalar_t__ printcode();
int /*<<< orphan*/ printf(char *);
main() {
  printf("\n*******************************************************************"
         "********\n");
  printf("\n\t\t\tASSEMBLY LANGUAGE EMULATER\n\n");
  printf("\n*******************************************************************"
         "********\n\n");
  printf("Please press enter to continue...");
  getch();
  if (printcode()) {
    printf("Error printing the code!!");
  }
  if (assign_memaddr()) {
    printf("Error assigning memory addresses!!");
  }
  initialise();
  if (load_optab()) {
    printf("Error loading the optab");
  }
  create_optab_file();
  if (convert_to_bin()) {
    printf("Error converting instructions to binary");
  }
  printf("\n|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
         "|||||||||||||\n");
  printf("\n----------------------Assembly completed "
         "successfully--------------------------\n");
  printf("\n|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
         "|||||||||||||\n");
  printf("\nNOTE: Please run the binrun.exe to view the result of the "
         "instruction\n");
  getch();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1090 <getch@plt>
mov    $0x0,%al
call   1050 <printcode@plt>
cmp    $0x0,%rax
je     11e3 <main+0x63>
lea    0xf02(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1080 <assign_memaddr@plt>
cmp    $0x0,%rax
je     1200 <main+0x80>
lea    0xeff(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   10a0 <initialise@plt>
mov    $0x0,%al
call   1040 <load_optab@plt>
cmp    $0x0,%rax
je     1224 <main+0xa4>
lea    0xefe(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <create_optab_file@plt>
mov    $0x0,%al
call   1070 <convert_to_bin@plt>
cmp    $0x0,%rax
je     1248 <main+0xc8>
lea    0xef2(%rip),%rdi
call   1030 <printf@plt>
lea    0xf0e(%rip),%rdi
call   1030 <printf@plt>
lea    0xf55(%rip),%rdi
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
call   1030 <printf@plt>
lea    0xf8f(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1090 <getch@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xf48(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe44(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   10a0 <getch@plt>
xor    %eax,%eax
call   1060 <printcode@plt>
test   %rax,%rax
je     11e0 <main+0x50>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1090 <assign_memaddr@plt>
test   %rax,%rax
je     11f8 <main+0x68>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   10b0 <initialise@plt>
xor    %eax,%eax
call   1050 <load_optab@plt>
test   %rax,%rax
je     1217 <main+0x87>
lea    0xe4d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
call   1070 <create_optab_file@plt>
xor    %eax,%eax
call   1080 <convert_to_bin@plt>
test   %rax,%rax
je     1236 <main+0xa6>
lea    0xe46(%rip),%rdi
call   1040 <printf@plt>
lea    0xf6e(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xf0e(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xf9d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   10a0 <getch@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [78 x i8] c"\0A***************************************************************************\0A\00"
@.str.1 = [33 x i8] c"\0A\09\09\09ASSEMBLY LANGUAGE EMULATER\0A\0A\00"
@.str.2 = [79 x i8] c"\0A***************************************************************************\0A\0A\00"
@.str.3 = [34 x i8] c"Please press enter to continue...\00"
@.str.4 = [26 x i8] c"Error printing the code!!\00"
@.str.5 = [35 x i8] c"Error assigning memory addresses!!\00"
@.str.6 = [24 x i8] c"Error loading the optab\00"
@.str.7 = [40 x i8] c"Error converting instructions to binary\00"
@.str.8 = [83 x i8] c"\0A||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\0A\00"
@.str.9 = [82 x i8] c"\0A----------------------Assembly completed successfully--------------------------\0A\00"
@.str.10 = [72 x i8] c"\0ANOTE: Please run the binrun.exe to view the result of the instruction\0A\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 (...) @getch()
%7 = call i64 (...) @printcode()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
%12 = call i64 (...) @assign_memaddr()
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %16
16: ; preds = %14, %11
%17 = call i32 (...) @initialise()
%18 = call i64 (...) @load_optab()
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %22
22: ; preds = %20, %16
%23 = call i32 (...) @create_optab_file()
%24 = call i64 (...) @convert_to_bin()
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
br label %28
28: ; preds = %26, %22
%29 = call i32 @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.8, i64 0, i64 0))
%30 = call i32 @printf(i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.9, i64 0, i64 0))
%31 = call i32 @printf(i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.8, i64 0, i64 0))
%32 = call i32 @printf(i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.10, i64 0, i64 0))
%33 = call i32 (...) @getch()
%34 = load i32, i32* %1
ret i32 %34
}

LLVM IR (-O2):
@.str.3 = [34 x i8] c"Please press enter to continue...\00"
@.str.4 = [26 x i8] c"Error printing the code!!\00"
@.str.5 = [35 x i8] c"Error assigning memory addresses!!\00"
@.str.6 = [24 x i8] c"Error loading the optab\00"
@.str.7 = [40 x i8] c"Error converting instructions to binary\00"
@str = [77 x i8] c"\0A***************************************************************************\00"
@str.11 = [32 x i8] c"\0A\09\09\09ASSEMBLY LANGUAGE EMULATER\0A\00"
@str.12 = [78 x i8] c"\0A***************************************************************************\0A\00"
@str.14 = [81 x i8] c"\0A----------------------Assembly completed successfully--------------------------\00"
@str.15 = [82 x i8] c"\0A||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\00"
@str.16 = [71 x i8] c"\0ANOTE: Please run the binrun.exe to view the result of the instruction\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.11, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.12, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 (...) @getch()
%6 = tail call i64 (...) @printcode()
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = tail call i64 (...) @assign_memaddr()
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = tail call i32 (...) @initialise()
%17 = tail call i64 (...) @load_optab()
%18 = icmp eq i64 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
%22 = tail call i32 (...) @create_optab_file()
%23 = tail call i64 (...) @convert_to_bin()
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.15, i64 0, i64 0))
%29 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([81 x i8], [81 x i8]* @str.14, i64 0, i64 0))
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([82 x i8], [82 x i8]* @str.15, i64 0, i64 0))
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @str.16, i64 0, i64 0))
%32 = tail call i32 (...) @getch()
ret i32 0
}