#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*/ OpADD(unsigned short);
int /*<<< orphan*/ OpAND(unsigned short);
int /*<<< orphan*/ OpBR(unsigned short);
int /*<<< orphan*/ OpJMP_RET(unsigned short);
int /*<<< orphan*/ OpJSR_JSRR(unsigned short);
int /*<<< orphan*/ OpLD(unsigned short);
int /*<<< orphan*/ OpLDI(unsigned short);
int /*<<< orphan*/ OpLDR(unsigned short);
int /*<<< orphan*/ OpLEA(unsigned short);
int /*<<< orphan*/ OpNOT(unsigned short);
int /*<<< orphan*/ OpST(unsigned short);
int /*<<< orphan*/ OpSTI(unsigned short);
int /*<<< orphan*/ OpSTR(unsigned short);
int /*<<< orphan*/ OpTRAP(unsigned short);
void Decode(unsigned short instr) {
  switch (instr >> 12) {
  case 0x1:
    OpADD(instr);
    break;
  case 0x5:
    OpAND(instr);
    break;
  case 0x9:
    OpNOT(instr);
    break;
  case 0x3:
    OpST(instr);
    break;
  case 0xb:
    OpSTI(instr);
    break;
  case 0x7:
    OpSTR(instr);
    break;
  case 0x2:
    OpLD(instr);
    break;
  case 0xa:
    OpLDI(instr);
    break;
  case 0x6:
    OpLDR(instr);
    break;
  case 0xe:
    OpLEA(instr);
    break;
  case 0x0:
    OpBR(instr);
    break;
  case 0x4:
    OpJSR_JSRR(instr);
    break;
  case 0xf:
    OpTRAP(instr);
    break;
  case 0xc:
    OpJMP_RET(instr);
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<Decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
shr    $0xc,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0xf,%eax
ja     12dd <Decode+0xfd>
mov    -0x10(%rbp),%rax
lea    0xdf0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzwl -0x2(%rbp),%edi
call   1080 <OpADD@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   10d0 <OpAND@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   10a0 <OpNOT@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   10c0 <OpST@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   1090 <OpSTI@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   1030 <OpSTR@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   1070 <OpLD@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   1060 <OpLDI@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   10e0 <OpLDR@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   10b0 <OpLEA@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   1040 <OpBR@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   1100 <OpJSR_JSRR@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   1050 <OpTRAP@plt>
jmp    12e2 <Decode+0x102>
movzwl -0x2(%rbp),%edi
call   10f0 <OpJMP_RET@plt>
jmp    12e2 <Decode+0x102>
jmp    12e2 <Decode+0x102>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Decode>:
mov    %edi,%eax
shr    $0xc,%eax
cmp    $0xf,%ax
ja     123b <Decode+0x5b>
lea    0xe0e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzwl %di,%edi
jmp    1040 <OpBR@plt>
movzwl %di,%edi
jmp    1080 <OpADD@plt>
movzwl %di,%edi
jmp    1070 <OpLD@plt>
movzwl %di,%edi
jmp    10c0 <OpST@plt>
movzwl %di,%edi
jmp    1100 <OpJSR_JSRR@plt>
movzwl %di,%edi
jmp    10d0 <OpAND@plt>
movzwl %di,%edi
jmp    10e0 <OpLDR@plt>
movzwl %di,%edi
jmp    1030 <OpSTR@plt>
ret
movzwl %di,%edi
jmp    10a0 <OpNOT@plt>
movzwl %di,%edi
jmp    1060 <OpLDI@plt>
movzwl %di,%edi
jmp    1090 <OpSTI@plt>
movzwl %di,%edi
jmp    10f0 <OpJMP_RET@plt>
movzwl %di,%edi
jmp    10b0 <OpLEA@plt>
movzwl %di,%edi
jmp    1050 <OpTRAP@plt>

LLVM IR (-O0):
define void @Decode(i16 zeroext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
%4 = zext i16 %3 to i32
%5 = ashr i32 %4, 12
switch i32 %5, label %48 [
i32 1, label %6
i32 5, label %9
i32 9, label %12
i32 3, label %15
i32 11, label %18
i32 7, label %21
i32 2, label %24
i32 10, label %27
i32 6, label %30
i32 14, label %33
i32 0, label %36
i32 4, label %39
i32 15, label %42
i32 12, label %45
]
6: ; preds = %1
%7 = load i16, i16* %2
%8 = call i32 @OpADD(i16 zeroext %7)
br label %49
9: ; preds = %1
%10 = load i16, i16* %2
%11 = call i32 @OpAND(i16 zeroext %10)
br label %49
12: ; preds = %1
%13 = load i16, i16* %2
%14 = call i32 @OpNOT(i16 zeroext %13)
br label %49
15: ; preds = %1
%16 = load i16, i16* %2
%17 = call i32 @OpST(i16 zeroext %16)
br label %49
18: ; preds = %1
%19 = load i16, i16* %2
%20 = call i32 @OpSTI(i16 zeroext %19)
br label %49
21: ; preds = %1
%22 = load i16, i16* %2
%23 = call i32 @OpSTR(i16 zeroext %22)
br label %49
24: ; preds = %1
%25 = load i16, i16* %2
%26 = call i32 @OpLD(i16 zeroext %25)
br label %49
27: ; preds = %1
%28 = load i16, i16* %2
%29 = call i32 @OpLDI(i16 zeroext %28)
br label %49
30: ; preds = %1
%31 = load i16, i16* %2
%32 = call i32 @OpLDR(i16 zeroext %31)
br label %49
33: ; preds = %1
%34 = load i16, i16* %2
%35 = call i32 @OpLEA(i16 zeroext %34)
br label %49
36: ; preds = %1
%37 = load i16, i16* %2
%38 = call i32 @OpBR(i16 zeroext %37)
br label %49
39: ; preds = %1
%40 = load i16, i16* %2
%41 = call i32 @OpJSR_JSRR(i16 zeroext %40)
br label %49
42: ; preds = %1
%43 = load i16, i16* %2
%44 = call i32 @OpTRAP(i16 zeroext %43)
br label %49
45: ; preds = %1
%46 = load i16, i16* %2
%47 = call i32 @OpJMP_RET(i16 zeroext %46)
br label %49
48: ; preds = %1
br label %49
49: ; preds = %48, %45, %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6
ret void
}

LLVM IR (-O2):
define void @Decode(i16 zeroext %0) {
%2 = lshr i16 %0, 12
%3 = zext i16 %2 to i32
switch i32 %3, label %32 [
i32 1, label %4
i32 5, label %6
i32 9, label %8
i32 3, label %10
i32 11, label %12
i32 7, label %14
i32 2, label %16
i32 10, label %18
i32 6, label %20
i32 14, label %22
i32 0, label %24
i32 4, label %26
i32 15, label %28
i32 12, label %30
]
4: ; preds = %1
%5 = tail call i32 @OpADD(i16 zeroext %0)
br label %32
6: ; preds = %1
%7 = tail call i32 @OpAND(i16 zeroext %0)
br label %32
8: ; preds = %1
%9 = tail call i32 @OpNOT(i16 zeroext %0)
br label %32
10: ; preds = %1
%11 = tail call i32 @OpST(i16 zeroext %0)
br label %32
12: ; preds = %1
%13 = tail call i32 @OpSTI(i16 zeroext %0)
br label %32
14: ; preds = %1
%15 = tail call i32 @OpSTR(i16 zeroext %0)
br label %32
16: ; preds = %1
%17 = tail call i32 @OpLD(i16 zeroext %0)
br label %32
18: ; preds = %1
%19 = tail call i32 @OpLDI(i16 zeroext %0)
br label %32
20: ; preds = %1
%21 = tail call i32 @OpLDR(i16 zeroext %0)
br label %32
22: ; preds = %1
%23 = tail call i32 @OpLEA(i16 zeroext %0)
br label %32
24: ; preds = %1
%25 = tail call i32 @OpBR(i16 zeroext %0)
br label %32
26: ; preds = %1
%27 = tail call i32 @OpJSR_JSRR(i16 zeroext %0)
br label %32
28: ; preds = %1
%29 = tail call i32 @OpTRAP(i16 zeroext %0)
br label %32
30: ; preds = %1
%31 = tail call i32 @OpJMP_RET(i16 zeroext %0)
br label %32
32: ; preds = %1, %30, %28, %26, %24, %22, %20, %18, %16, %14, %12, %10, %8, %6, %4
ret void
}