#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*/ exit(int);
int /*<<< orphan*/ halt();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push_to_stack(int);
char *decode_instruction(char opcode, int level, int modifier) {
  switch (opcode) {
  case 1:
    push_to_stack(modifier);
    return "LIT";
  case 2:
    return "OPR";
  case 3:
    return "LOD";
  case 4:
    return "STO";
  case 5:
    return "CAL";
  case 6:
    return "INC";
  case 7:
    return "JMP";
  case 8:
    return "JPC";
  case 9:
    switch (modifier) {
    case 1:
      break;
    case 2:
      break;
    case 3:
      halt();
    default:
      printf("Invalid modifier #d", modifier);
    }
    return "SIO";
  default:
    printf("Encoutered Unexpected Opcode %s", &opcode);
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<decode_instruction>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x8,%eax
ja     126e <decode_instruction+0x12e>
mov    -0x20(%rbp),%rax
lea    0xe8b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x14(%rbp),%edi
call   1040 <push_to_stack@plt>
lea    0xe97(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128a <decode_instruction+0x14a>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128a <decode_instruction+0x14a>
lea    0xe7f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128a <decode_instruction+0x14a>
lea    0xe73(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128a <decode_instruction+0x14a>
lea    0xe67(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128a <decode_instruction+0x14a>
lea    0xe5b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128a <decode_instruction+0x14a>
lea    0xe4f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128a <decode_instruction+0x14a>
lea    0xe43(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128a <decode_instruction+0x14a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x1,%eax
je     123c <decode_instruction+0xfc>
jmp    121a <decode_instruction+0xda>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
je     1241 <decode_instruction+0x101>
jmp    122b <decode_instruction+0xeb>
mov    -0x24(%rbp),%eax
sub    $0x3,%eax
je     1246 <decode_instruction+0x106>
jmp    124d <decode_instruction+0x10d>
jmp    125e <decode_instruction+0x11e>
jmp    125e <decode_instruction+0x11e>
mov    $0x0,%al
call   1050 <halt@plt>
mov    -0x14(%rbp),%esi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdf3(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    128a <decode_instruction+0x14a>
lea    0xde7(%rip),%rdi
lea    -0x9(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decode_instruction>:
push   %r14
push   %rbx
push   %rax
mov    %dil,0x7(%rsp)
add    $0xffffffff,%edi
cmp    $0x8,%edi
ja     11ef <decode_instruction+0xaf>
mov    %edx,%r14d
lea    0xec9(%rip),%rbx
lea    0xe9a(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %r14d,%edi
call   1040 <push_to_stack@plt>
lea    0xea6(%rip),%rbx
jmp    11e4 <decode_instruction+0xa4>
lea    0xea5(%rip),%rbx
jmp    11e4 <decode_instruction+0xa4>
lea    0xea0(%rip),%rbx
jmp    11e4 <decode_instruction+0xa4>
lea    0xe9b(%rip),%rbx
jmp    11e4 <decode_instruction+0xa4>
lea    0xe96(%rip),%rbx
jmp    11e4 <decode_instruction+0xa4>
lea    0xe91(%rip),%rbx
jmp    11e4 <decode_instruction+0xa4>
lea    0xe8c(%rip),%rbx
jmp    11e4 <decode_instruction+0xa4>
lea    0xe9b(%rip),%rbx
lea    -0x1(%r14),%eax
cmp    $0x2,%eax
jb     11e4 <decode_instruction+0xa4>
cmp    $0x3,%r14d
jne    11d3 <decode_instruction+0x93>
xor    %eax,%eax
call   1050 <halt@plt>
lea    0xe6a(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe66(%rip),%rdi
lea    0x7(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"LIT\00"
@.str.1 = [4 x i8] c"OPR\00"
@.str.2 = [4 x i8] c"LOD\00"
@.str.3 = [4 x i8] c"STO\00"
@.str.4 = [4 x i8] c"CAL\00"
@.str.5 = [4 x i8] c"INC\00"
@.str.6 = [4 x i8] c"JMP\00"
@.str.7 = [4 x i8] c"JPC\00"
@.str.8 = [20 x i8] c"Invalid modifier #d\00"
@.str.9 = [4 x i8] c"SIO\00"
@.str.10 = [32 x i8] c"Encoutered Unexpected Opcode %s\00"
define i8* @decode_instruction(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i8 %0, i8* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
switch i32 %9, label %30 [
i32 1, label %10
i32 2, label %13
i32 3, label %14
i32 4, label %15
i32 5, label %16
i32 6, label %17
i32 7, label %18
i32 8, label %19
i32 9, label %20
]
10: ; preds = %3
%11 = load i32, i32* %7
%12 = call i32 @push_to_stack(i32 %11)
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %4
br label %33
13: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %33
14: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %33
15: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %4
br label %33
16: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %4
br label %33
17: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %4
br label %33
18: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %4
br label %33
19: ; preds = %3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8** %4
br label %33
20: ; preds = %3
%21 = load i32, i32* %7
switch i32 %21, label %26 [
i32 1, label %22
i32 2, label %23
i32 3, label %24
]
22: ; preds = %20
br label %29
23: ; preds = %20
br label %29
24: ; preds = %20
%25 = call i32 (...) @halt()
br label %26
26: ; preds = %20, %24
%27 = load i32, i32* %7
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %26, %23, %22
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i8** %4
br label %33
30: ; preds = %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %5)
%32 = call i32 @exit(i32 -1)
unreachable
33: ; preds = %29, %19, %18, %17, %16, %15, %14, %13, %10
%34 = load i8*, i8** %4
ret i8* %34
}

LLVM IR (-O2):
@.str = [4 x i8] c"LIT\00"
@.str.1 = [4 x i8] c"OPR\00"
@.str.2 = [4 x i8] c"LOD\00"
@.str.3 = [4 x i8] c"STO\00"
@.str.4 = [4 x i8] c"CAL\00"
@.str.5 = [4 x i8] c"INC\00"
@.str.6 = [4 x i8] c"JMP\00"
@.str.7 = [4 x i8] c"JPC\00"
@.str.8 = [20 x i8] c"Invalid modifier #d\00"
@.str.9 = [4 x i8] c"SIO\00"
@.str.10 = [32 x i8] c"Encoutered Unexpected Opcode %s\00"
define i8* @decode_instruction(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i8
store i8 %0, i8* %4
%5 = sext i8 %0 to i32
switch i32 %5, label %19 [
i32 1, label %6
i32 2, label %22
i32 3, label %8
i32 4, label %9
i32 5, label %10
i32 6, label %11
i32 7, label %12
i32 8, label %13
i32 9, label %14
]
6: ; preds = %3
%7 = tail call i32 @push_to_stack(i32 %2)
br label %22
8: ; preds = %3
br label %22
9: ; preds = %3
br label %22
10: ; preds = %3
br label %22
11: ; preds = %3
br label %22
12: ; preds = %3
br label %22
13: ; preds = %3
br label %22
14: ; preds = %3
switch i32 %2, label %17 [
i32 1, label %22
i32 2, label %22
i32 3, label %15
]
15: ; preds = %14
%16 = tail call i32 (...) @halt()
br label %17
17: ; preds = %14, %15
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i32 %2)
br label %22
19: ; preds = %3
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0), i8* %4)
%21 = call i32 @exit(i32 -1)
unreachable
22: ; preds = %14, %14, %17, %3, %13, %12, %11, %10, %9, %8, %6
%23 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), %13 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), %12 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %11 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), %10 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), %9 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %8 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %6 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), %17 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), %14 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), %14 ]
ret i8* %23
}