#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 char4_hexvalue(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ memdmp_lst(unsigned char *, int, int);
int /*<<< orphan*/ memdmp_poke(unsigned char *, char *);
int /*<<< orphan*/ memdmp_read(unsigned char *, int, char *);
int /*<<< orphan*/ memdmp_write(unsigned char *, int, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strtok(char *, char *);
int memdmp_editor(unsigned char *mem_p) {
  int startpt, length;
  char *nextarg;
  char command1[128];
  char firstcmd[16];
  char startptstr[16];
  char lengthstr[16];
  char contstr[33];
  char filename[128];
  char *place_p;
  printf("\nMiscellaneous functions (currently memory dump"
         " loading and saving).\n");
  printf("WARNING - THIS PART OF PROGRAM IS BETA VERSION!\n");
  printf("\nType:\n\n");
  printf("i [start in 4-digit hex] [amount of bytes in 4-digit hex]\n");
  printf("for dumping mem contents on screen.\n\n");
  printf("o [start in 4-digit hex] [bytes in 2-digit hex each]\n");
  printf("for POKE [address],[byte1], POKE [address],[byte2] etc.\n\n");
  printf("l [start in 4-digit hex] [amount of bytes in 4-digit hex]");
  printf(" [filename]\nfor loading.\n\n");
  printf("s [start in 4-digit hex] [amount of bytes in 4-digit hex]");
  printf(" [filename]\nfor saving.\n\n");
  printf("q to quit.\n\n");
  fgets(command1, 127, stdin);
  nextarg = strtok(command1, " ");
  strncpy(firstcmd, nextarg, 15);
  if ((firstcmd[0] == 'o') || (firstcmd[0] == 'O')) {
    nextarg = strtok(NULL, " ");
    strncpy(startptstr, nextarg, 15);
    nextarg = strtok(NULL, " ");
    strncpy(contstr, nextarg, 33);
    startpt = char4_hexvalue(startptstr);
    memdmp_poke(&(mem_p[startpt]), contstr);
    printf("Memory successfully POKEd.\n");
  }
  if ((firstcmd[0] == 'l') || (firstcmd[0] == 's') || (firstcmd[0] == 'i') ||
      (firstcmd[0] == 'L') || (firstcmd[0] == 'S') || (firstcmd[0] == 'I')) {
    nextarg = strtok(NULL, " ");
    strncpy(startptstr, nextarg, 15);
    nextarg = strtok(NULL, " ");
    strncpy(lengthstr, nextarg, 15);
    nextarg = strtok(NULL, " ");
    if (nextarg != NULL) {
      strncpy(filename, nextarg, 127);
    } else {
      strncpy(filename, "DUMMY.MEM", 127);
    }
    startpt = char4_hexvalue(startptstr);
    length = char4_hexvalue(lengthstr);
    for (place_p = filename; place_p <= (filename + 127); place_p++) {
      if (*place_p == 10) {
        *place_p = 0;
        break;
      }
    }
    if ((firstcmd[0] == 'l') || (firstcmd[0] == 'L')) {
      memdmp_read(&mem_p[startpt], length, filename);
      printf("Memory successfully read.\n");
    } else if ((firstcmd[0] == 's') || (firstcmd[0] == 'S')) {
      memdmp_write(&mem_p[startpt], length, filename);
      printf("Memory successfully written.\n");
    } else if ((firstcmd[0] == 'i') || (firstcmd[0] == 'I')) {
      memdmp_lst(&mem_p[(startpt & 0xFFF0)], length, startpt);
      printf("Memory contents successfully listed.\n");
    }
  }
  printf("Exiting Miscellaneous functions menu.\n");
  return 1;
}


x86 assembly (clang, -O0):
<memdmp_editor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x190,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xe5a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe94(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb9(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb6(%rip),%rdi
call   1050 <printf@plt>
lea    0xee5(%rip),%rdi
call   1050 <printf@plt>
lea    0xeff(%rip),%rdi
call   1050 <printf@plt>
lea    0xf29(%rip),%rdi
call   1050 <printf@plt>
lea    0xf57(%rip),%rdi
call   1050 <printf@plt>
lea    0xf85(%rip),%rdi
call   1050 <printf@plt>
lea    0xf94(%rip),%rdi
call   1050 <printf@plt>
lea    0xfc2(%rip),%rdi
call   1050 <printf@plt>
lea    0xfd0(%rip),%rdi
call   1050 <printf@plt>
lea    -0xa0(%rbp),%rdi
mov    0x2dab(%rip),%rax
mov    (%rax),%edx
mov    $0x7f,%esi
call   1060 <fgets@plt>
lea    -0xa0(%rbp),%rdi
lea    0xfb0(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    -0xb0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
movsbl -0xb0(%rbp),%eax
cmp    $0x6f,%eax
je     1295 <memdmp_editor+0x105>
movsbl -0xb0(%rbp),%eax
cmp    $0x4f,%eax
jne    1319 <memdmp_editor+0x189>
xor    %eax,%eax
mov    %eax,%edi
lea    0xf67(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    -0xc0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xf3e(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    -0x100(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x21,%edx
call   1030 <strncpy@plt>
lea    -0xc0(%rbp),%rdi
call   10b0 <char4_hexvalue@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
lea    -0x100(%rbp),%rsi
call   10a0 <memdmp_poke@plt>
lea    0xef5(%rip),%rdi
call   1050 <printf@plt>
movsbl -0xb0(%rbp),%eax
cmp    $0x6c,%eax
je     1379 <memdmp_editor+0x1e9>
movsbl -0xb0(%rbp),%eax
cmp    $0x73,%eax
je     1379 <memdmp_editor+0x1e9>
movsbl -0xb0(%rbp),%eax
cmp    $0x69,%eax
je     1379 <memdmp_editor+0x1e9>
movsbl -0xb0(%rbp),%eax
cmp    $0x4c,%eax
je     1379 <memdmp_editor+0x1e9>
movsbl -0xb0(%rbp),%eax
cmp    $0x53,%eax
je     1379 <memdmp_editor+0x1e9>
movsbl -0xb0(%rbp),%eax
cmp    $0x49,%eax
jne    158e <memdmp_editor+0x3fe>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe83(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    -0xc0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe5a(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
lea    -0xd0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe31(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1404 <memdmp_editor+0x274>
lea    -0x180(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x7f,%edx
call   1030 <strncpy@plt>
jmp    141c <memdmp_editor+0x28c>
lea    -0x180(%rbp),%rdi
lea    0xe13(%rip),%rsi
mov    $0x7f,%edx
call   1030 <strncpy@plt>
lea    -0xc0(%rbp),%rdi
call   10b0 <char4_hexvalue@plt>
mov    %eax,-0xc(%rbp)
lea    -0xd0(%rbp),%rdi
call   10b0 <char4_hexvalue@plt>
mov    %eax,-0x10(%rbp)
lea    -0x180(%rbp),%rax
mov    %rax,-0x188(%rbp)
mov    -0x188(%rbp),%rax
lea    -0x180(%rbp),%rcx
add    $0x7f,%rcx
cmp    %rcx,%rax
ja     14a1 <memdmp_editor+0x311>
mov    -0x188(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1485 <memdmp_editor+0x2f5>
mov    -0x188(%rbp),%rax
movb   $0x0,(%rax)
jmp    14a1 <memdmp_editor+0x311>
jmp    148a <memdmp_editor+0x2fa>
mov    -0x188(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x188(%rbp)
jmp    1448 <memdmp_editor+0x2b8>
movsbl -0xb0(%rbp),%eax
cmp    $0x6c,%eax
je     14c1 <memdmp_editor+0x331>
movsbl -0xb0(%rbp),%eax
cmp    $0x4c,%eax
jne    14ec <memdmp_editor+0x35c>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%esi
lea    -0x180(%rbp),%rdx
call   1070 <memdmp_read@plt>
lea    0xd4d(%rip),%rdi
call   1050 <printf@plt>
jmp    1589 <memdmp_editor+0x3f9>
movsbl -0xb0(%rbp),%eax
cmp    $0x73,%eax
je     150c <memdmp_editor+0x37c>
movsbl -0xb0(%rbp),%eax
cmp    $0x53,%eax
jne    1537 <memdmp_editor+0x3a7>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%esi
lea    -0x180(%rbp),%rdx
call   1090 <memdmp_write@plt>
lea    0xd1d(%rip),%rdi
call   1050 <printf@plt>
jmp    1584 <memdmp_editor+0x3f4>
movsbl -0xb0(%rbp),%eax
cmp    $0x69,%eax
je     1557 <memdmp_editor+0x3c7>
movsbl -0xb0(%rbp),%eax
cmp    $0x49,%eax
jne    157f <memdmp_editor+0x3ef>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%eax
and    $0xfff0,%eax
cltq
add    %rax,%rdi
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1040 <memdmp_lst@plt>
lea    0xcee(%rip),%rdi
call   1050 <printf@plt>
jmp    1584 <memdmp_editor+0x3f4>
jmp    1589 <memdmp_editor+0x3f9>
jmp    158e <memdmp_editor+0x3fe>
lea    0xcf9(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x190,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<memdmp_editor>:
push   %rbp
push   %r14
push   %rbx
sub    $0x160,%rsp
mov    %rdi,%r14
lea    0xecb(%rip),%rdi
call   1040 <puts@plt>
lea    0xf04(%rip),%rdi
call   1040 <puts@plt>
lea    0xf28(%rip),%rdi
call   1040 <puts@plt>
lea    0xf24(%rip),%rdi
call   1040 <puts@plt>
lea    0xf52(%rip),%rdi
call   1040 <puts@plt>
lea    0xf6b(%rip),%rdi
call   1040 <puts@plt>
lea    0xf94(%rip),%rdi
call   1040 <puts@plt>
lea    0xdf7(%rip),%rdi
call   1060 <printf@plt>
lea    0xfb5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe19(%rip),%rdi
call   1060 <printf@plt>
lea    0xfb7(%rip),%rdi
call   1040 <puts@plt>
lea    0xfc4(%rip),%rdi
call   1040 <puts@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edx
lea    0xe0(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x7f,%esi
call   1070 <fgets@plt>
lea    0xe11(%rip),%rsi
mov    %rbp,%rdi
call   1090 <strtok@plt>
mov    %rsp,%rdi
mov    %rax,%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
mov    (%rsp),%al
mov    %eax,%ecx
and    $0xdf,%cl
cmp    $0x4f,%cl
jne    12f5 <memdmp_editor+0x155>
lea    0xde5(%rip),%rbp
xor    %edi,%edi
mov    %rbp,%rsi
call   1090 <strtok@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   1090 <strtok@plt>
lea    0xb0(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
mov    $0x21,%edx
call   1030 <strncpy@plt>
mov    %rbx,%rdi
call   10c0 <char4_hexvalue@plt>
movslq %eax,%rdi
add    %r14,%rdi
mov    %rbp,%rsi
call   10b0 <memdmp_poke@plt>
lea    0xf9e(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%al
add    $0xb7,%al
cmp    $0x2a,%al
ja     1437 <memdmp_editor+0x297>
movzbl %al,%eax
movabs $0x40900000409,%rcx
bt     %rax,%rcx
jae    1437 <memdmp_editor+0x297>
lea    0xd57(%rip),%rbp
xor    %edi,%edi
mov    %rbp,%rsi
call   1090 <strtok@plt>
lea    0x10(%rsp),%rdi
mov    %rax,%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   1090 <strtok@plt>
lea    0x20(%rsp),%rdi
mov    %rax,%rsi
mov    $0xf,%edx
call   1030 <strncpy@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   1090 <strtok@plt>
test   %rax,%rax
je     136e <memdmp_editor+0x1ce>
lea    0x30(%rsp),%rdi
mov    %rax,%rsi
jmp    137a <memdmp_editor+0x1da>
lea    0xd01(%rip),%rsi
lea    0x30(%rsp),%rdi
mov    $0x7f,%edx
call   1030 <strncpy@plt>
lea    0x30(%rsp),%rbx
lea    0x10(%rsp),%rdi
call   10c0 <char4_hexvalue@plt>
mov    %eax,%ebp
lea    0x20(%rsp),%rdi
call   10c0 <char4_hexvalue@plt>
lea    0xaf(%rsp),%rcx
nopw   0x0(%rax,%rax,1)
cmpb   $0xa,(%rbx)
je     13c0 <memdmp_editor+0x220>
add    $0x1,%rbx
cmp    %rcx,%rbx
jbe    13b0 <memdmp_editor+0x210>
jmp    13c3 <memdmp_editor+0x223>
movb   $0x0,(%rbx)
mov    (%rsp),%cl
and    $0xdf,%cl
cmp    $0x49,%cl
je     13f6 <memdmp_editor+0x256>
cmp    $0x53,%cl
je     1416 <memdmp_editor+0x276>
cmp    $0x4c,%cl
jne    1437 <memdmp_editor+0x297>
movslq %ebp,%rcx
add    %rcx,%r14
lea    0x30(%rsp),%rdx
mov    %r14,%rdi
mov    %eax,%esi
call   1080 <memdmp_read@plt>
lea    0xe7d(%rip),%rdi
jmp    1432 <memdmp_editor+0x292>
mov    %ebp,%ecx
and    $0xfff0,%ecx
add    %rcx,%r14
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebp,%edx
call   1050 <memdmp_lst@plt>
lea    0xe1b(%rip),%rdi
jmp    1432 <memdmp_editor+0x292>
movslq %ebp,%rcx
add    %rcx,%r14
lea    0x30(%rsp),%rdx
mov    %r14,%rdi
mov    %eax,%esi
call   10a0 <memdmp_write@plt>
lea    0xe22(%rip),%rdi
call   1040 <puts@plt>
lea    0xdcb(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x160,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [70 x i8] c"\0AMiscellaneous functions (currently memory dump loading and saving).\0A\00"
@.str.1 = [49 x i8] c"WARNING - THIS PART OF PROGRAM IS BETA VERSION!\0A\00"
@.str.2 = [9 x i8] c"\0AType:\0A\0A\00"
@.str.3 = [59 x i8] c"i [start in 4-digit hex] [amount of bytes in 4-digit hex]\0A\00"
@.str.4 = [38 x i8] c"for dumping mem contents on screen.\0A\0A\00"
@.str.5 = [54 x i8] c"o [start in 4-digit hex] [bytes in 2-digit hex each]\0A\00"
@.str.6 = [58 x i8] c"for POKE [address],[byte1], POKE [address],[byte2] etc.\0A\0A\00"
@.str.7 = [58 x i8] c"l [start in 4-digit hex] [amount of bytes in 4-digit hex]\00"
@.str.8 = [27 x i8] c" [filename]\0Afor loading.\0A\0A\00"
@.str.9 = [58 x i8] c"s [start in 4-digit hex] [amount of bytes in 4-digit hex]\00"
@.str.10 = [26 x i8] c" [filename]\0Afor saving.\0A\0A\00"
@.str.11 = [13 x i8] c"q to quit.\0A\0A\00"
@stdin = global i32 0
@.str.12 = [2 x i8] c" \00"
@.str.13 = [28 x i8] c"Memory successfully POKEd.\0A\00"
@.str.14 = [10 x i8] c"DUMMY.MEM\00"
@.str.15 = [27 x i8] c"Memory successfully read.\0A\00"
@.str.16 = [30 x i8] c"Memory successfully written.\0A\00"
@.str.17 = [38 x i8] c"Memory contents successfully listed.\0A\00"
@.str.18 = [39 x i8] c"Exiting Miscellaneous functions menu.\0A\00"
define i32 @memdmp_editor(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [128 x i8]
%7 = alloca [16 x i8]
%8 = alloca [16 x i8]
%9 = alloca [16 x i8]
%10 = alloca [33 x i8]
%11 = alloca [128 x i8]
%12 = alloca i8*
store i8* %0, i8** %2
%13 = call i32 @printf(i8* getelementptr inbounds ([70 x i8], [70 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.6, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.11, i64 0, i64 0))
%25 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %25, i32 127, i32 %26)
%28 = getelementptr inbounds [128 x i8], [128 x i8]* %6, i64 0, i64 0
%29 = call i8* @strtok(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i8* %29, i8** %5
%30 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%31 = load i8*, i8** %5
%32 = call i32 @strncpy(i8* %30, i8* %31, i32 15)
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 111
br i1 %36, label %42, label %37
37: ; preds = %1
%38 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %40, 79
br i1 %41, label %42, label %60
42: ; preds = %37, %1
%43 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i8* %43, i8** %5
%44 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%45 = load i8*, i8** %5
%46 = call i32 @strncpy(i8* %44, i8* %45, i32 15)
%47 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i8* %47, i8** %5
%48 = getelementptr inbounds [33 x i8], [33 x i8]* %10, i64 0, i64 0
%49 = load i8*, i8** %5
%50 = call i32 @strncpy(i8* %48, i8* %49, i32 33)
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%52 = call i32 @char4_hexvalue(i8* %51)
store i32 %52, i32* %3
%53 = load i8*, i8** %2
%54 = load i32, i32* %3
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
%57 = getelementptr inbounds [33 x i8], [33 x i8]* %10, i64 0, i64 0
%58 = call i32 @memdmp_poke(i8* %56, i8* %57)
%59 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
br label %60
60: ; preds = %42, %37
%61 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 108
br i1 %64, label %90, label %65
65: ; preds = %60
%66 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 115
br i1 %69, label %90, label %70
70: ; preds = %65
%71 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp eq i32 %73, 105
br i1 %74, label %90, label %75
75: ; preds = %70
%76 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp eq i32 %78, 76
br i1 %79, label %90, label %80
80: ; preds = %75
%81 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%82 = load i8, i8* %81
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 83
br i1 %84, label %90, label %85
85: ; preds = %80
%86 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 73
br i1 %89, label %90, label %192
90: ; preds = %85, %80, %75, %70, %65, %60
%91 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i8* %91, i8** %5
%92 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%93 = load i8*, i8** %5
%94 = call i32 @strncpy(i8* %92, i8* %93, i32 15)
%95 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i8* %95, i8** %5
%96 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%97 = load i8*, i8** %5
%98 = call i32 @strncpy(i8* %96, i8* %97, i32 15)
%99 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i8* %99, i8** %5
%100 = load i8*, i8** %5
%101 = icmp ne i8* %100, null
br i1 %101, label %102, label %106
102: ; preds = %90
%103 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%104 = load i8*, i8** %5
%105 = call i32 @strncpy(i8* %103, i8* %104, i32 127)
br label %109
106: ; preds = %90
%107 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%108 = call i32 @strncpy(i8* %107, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 127)
br label %109
109: ; preds = %106, %102
%110 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%111 = call i32 @char4_hexvalue(i8* %110)
store i32 %111, i32* %3
%112 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%113 = call i32 @char4_hexvalue(i8* %112)
store i32 %113, i32* %4
%114 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
store i8* %114, i8** %12
br label %115
115: ; preds = %128, %109
%116 = load i8*, i8** %12
%117 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%118 = getelementptr inbounds i8, i8* %117, i64 127
%119 = icmp ule i8* %116, %118
br i1 %119, label %120, label %131
120: ; preds = %115
%121 = load i8*, i8** %12
%122 = load i8, i8* %121
%123 = sext i8 %122 to i32
%124 = icmp eq i32 %123, 10
br i1 %124, label %125, label %127
125: ; preds = %120
%126 = load i8*, i8** %12
store i8 0, i8* %126
br label %131
127: ; preds = %120
br label %128
128: ; preds = %127
%129 = load i8*, i8** %12
%130 = getelementptr inbounds i8, i8* %129, i32 1
store i8* %130, i8** %12
br label %115
131: ; preds = %125, %115
%132 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp eq i32 %134, 108
br i1 %135, label %141, label %136
136: ; preds = %131
%137 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%138 = load i8, i8* %137
%139 = sext i8 %138 to i32
%140 = icmp eq i32 %139, 76
br i1 %140, label %141, label %150
141: ; preds = %136, %131
%142 = load i8*, i8** %2
%143 = load i32, i32* %3
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds i8, i8* %142, i64 %144
%146 = load i32, i32* %4
%147 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%148 = call i32 @memdmp_read(i8* %145, i32 %146, i8* %147)
%149 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.15, i64 0, i64 0))
br label %191
150: ; preds = %136
%151 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%152 = load i8, i8* %151
%153 = sext i8 %152 to i32
%154 = icmp eq i32 %153, 115
br i1 %154, label %160, label %155
155: ; preds = %150
%156 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%157 = load i8, i8* %156
%158 = sext i8 %157 to i32
%159 = icmp eq i32 %158, 83
br i1 %159, label %160, label %169
160: ; preds = %155, %150
%161 = load i8*, i8** %2
%162 = load i32, i32* %3
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds i8, i8* %161, i64 %163
%165 = load i32, i32* %4
%166 = getelementptr inbounds [128 x i8], [128 x i8]* %11, i64 0, i64 0
%167 = call i32 @memdmp_write(i8* %164, i32 %165, i8* %166)
%168 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.16, i64 0, i64 0))
br label %190
169: ; preds = %155
%170 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%171 = load i8, i8* %170
%172 = sext i8 %171 to i32
%173 = icmp eq i32 %172, 105
br i1 %173, label %179, label %174
174: ; preds = %169
%175 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%176 = load i8, i8* %175
%177 = sext i8 %176 to i32
%178 = icmp eq i32 %177, 73
br i1 %178, label %179, label %189
179: ; preds = %174, %169
%180 = load i8*, i8** %2
%181 = load i32, i32* %3
%182 = and i32 %181, 65520
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i8, i8* %180, i64 %183
%185 = load i32, i32* %4
%186 = load i32, i32* %3
%187 = call i32 @memdmp_lst(i8* %184, i32 %185, i32 %186)
%188 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.17, i64 0, i64 0))
br label %189
189: ; preds = %179, %174
br label %190
190: ; preds = %189, %160
br label %191
191: ; preds = %190, %141
br label %192
192: ; preds = %191, %85
%193 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.18, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str.7 = [58 x i8] c"l [start in 4-digit hex] [amount of bytes in 4-digit hex]\00"
@.str.9 = [58 x i8] c"s [start in 4-digit hex] [amount of bytes in 4-digit hex]\00"
@stdin = global i32 0
@.str.12 = [2 x i8] c" \00"
@.str.14 = [10 x i8] c"DUMMY.MEM\00"
@str = [69 x i8] c"\0AMiscellaneous functions (currently memory dump loading and saving).\00"
@str.19 = [48 x i8] c"WARNING - THIS PART OF PROGRAM IS BETA VERSION!\00"
@str.20 = [8 x i8] c"\0AType:\0A\00"
@str.21 = [58 x i8] c"i [start in 4-digit hex] [amount of bytes in 4-digit hex]\00"
@str.22 = [37 x i8] c"for dumping mem contents on screen.\0A\00"
@str.23 = [53 x i8] c"o [start in 4-digit hex] [bytes in 2-digit hex each]\00"
@str.24 = [57 x i8] c"for POKE [address],[byte1], POKE [address],[byte2] etc.\0A\00"
@str.25 = [26 x i8] c" [filename]\0Afor loading.\0A\00"
@str.26 = [25 x i8] c" [filename]\0Afor saving.\0A\00"
@str.27 = [12 x i8] c"q to quit.\0A\00"
@str.28 = [38 x i8] c"Exiting Miscellaneous functions menu.\00"
@str.29 = [37 x i8] c"Memory contents successfully listed.\00"
@str.30 = [29 x i8] c"Memory successfully written.\00"
@str.31 = [26 x i8] c"Memory successfully read.\00"
@str.32 = [27 x i8] c"Memory successfully POKEd.\00"
define i32 @memdmp_editor(i8* %0) {
%2 = alloca [128 x i8]
%3 = alloca [16 x i8]
%4 = alloca [16 x i8]
%5 = alloca [16 x i8]
%6 = alloca [33 x i8]
%7 = alloca [128 x i8]
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.19, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.20, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @str.21, i64 0, i64 0))
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.22, i64 0, i64 0))
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.23, i64 0, i64 0))
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.24, i64 0, i64 0))
%21 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0))
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.25, i64 0, i64 0))
%23 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.9, i64 0, i64 0))
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.26, i64 0, i64 0))
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.27, i64 0, i64 0))
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %8, i32 127, i32 %26)
%28 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%29 = call i32 @strncpy(i8* %9, i8* %28, i32 15)
%30 = load i8, i8* %9
%31 = and i8 %30, -33
%32 = icmp eq i8 %31, 79
br i1 %32, label %33, label %44
33: ; preds = %1
%34 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%35 = call i32 @strncpy(i8* %10, i8* %34, i32 15)
%36 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%37 = call i32 @strncpy(i8* %12, i8* %36, i32 33)
%38 = call i32 @char4_hexvalue(i8* %10)
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %0, i64 %39
%41 = call i32 @memdmp_poke(i8* %40, i8* %12)
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.32, i64 0, i64 0))
%43 = load i8, i8* %9
br label %44
44: ; preds = %1, %33
%45 = phi i8 [ %30, %1 ], [ %43, %33 ]
switch i8 %45, label %88 [
i8 115, label %46
i8 108, label %46
i8 105, label %46
i8 83, label %46
i8 76, label %46
i8 73, label %46
]
46: ; preds = %44, %44, %44, %44, %44, %44
%47 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%48 = call i32 @strncpy(i8* %10, i8* %47, i32 15)
%49 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%50 = call i32 @strncpy(i8* %11, i8* %49, i32 15)
%51 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%52 = icmp eq i8* %51, null
br i1 %52, label %55, label %53
53: ; preds = %46
%54 = call i32 @strncpy(i8* %13, i8* %51, i32 127)
br label %57
55: ; preds = %46
%56 = call i32 @strncpy(i8* %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.14, i64 0, i64 0), i32 127)
br label %57
57: ; preds = %55, %53
%58 = call i32 @char4_hexvalue(i8* %10)
%59 = call i32 @char4_hexvalue(i8* %11)
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 127
br label %61
61: ; preds = %57, %66
%62 = phi i8* [ %13, %57 ], [ %67, %66 ]
%63 = load i8, i8* %62
%64 = icmp eq i8 %63, 10
br i1 %64, label %65, label %66
65: ; preds = %61
store i8 0, i8* %62
br label %69
66: ; preds = %61
%67 = getelementptr inbounds i8, i8* %62, i64 1
%68 = icmp ugt i8* %67, %60
br i1 %68, label %69, label %61
69: ; preds = %66, %65
%70 = load i8, i8* %9
%71 = and i8 %70, -33
switch i8 %71, label %88 [
i8 76, label %72
i8 83, label %76
i8 73, label %80
]
72: ; preds = %69
%73 = sext i32 %58 to i64
%74 = getelementptr inbounds i8, i8* %0, i64 %73
%75 = call i32 @memdmp_read(i8* %74, i32 %59, i8* %13)
br label %85
76: ; preds = %69
%77 = sext i32 %58 to i64
%78 = getelementptr inbounds i8, i8* %0, i64 %77
%79 = call i32 @memdmp_write(i8* %78, i32 %59, i8* %13)
br label %85
80: ; preds = %69
%81 = and i32 %58, 65520
%82 = zext i32 %81 to i64
%83 = getelementptr inbounds i8, i8* %0, i64 %82
%84 = call i32 @memdmp_lst(i8* %83, i32 %59, i32 %58)
br label %85
85: ; preds = %76, %80, %72
%86 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @str.31, i64 0, i64 0), %72 ], [ getelementptr inbounds ([37 x i8], [37 x i8]* @str.29, i64 0, i64 0), %80 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.30, i64 0, i64 0), %76 ]
%87 = call i32 @puts(i8* dereferenceable(1) %86)
br label %88
88: ; preds = %85, %69, %44
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.28, i64 0, i64 0))
ret i32 1
}