#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 getRAM(int);
scalar_t__ malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
char *opcodeName(int offset) {
  char *tmp = (char *)malloc(sizeof(char) * 64);
  switch (getRAM(offset)) {
  default:
    sprintf(tmp, "%02x", getRAM(offset));
    break;
  case 0x00:
    sprintf(tmp, "NUL");
    break;
  case 0x01:
    sprintf(tmp, "MOV %04x %04x",
            (getRAM(offset + 1)) << 8 + getRAM(offset + 2),
            (getRAM(offset + 3) << 8) + getRAM(offset + 4));
    break;
  case 0x02:
    sprintf(tmp, "ADD");
    break;
  case 0x03:
    sprintf(tmp, "SUB");
    break;
  case 0x04:
    sprintf(tmp, "MUL");
    break;
  case 0x05:
    sprintf(tmp, "DIV");
    break;
  case 0x06:
    sprintf(tmp, "JMP");
    break;
  case 0x07:
    sprintf(tmp, "CMP");
    break;
  case 0x08:
    sprintf(tmp, "JE");
    break;
  case 0x09:
    sprintf(tmp, "JNE");
    break;
  case 0x0A:
    sprintf(tmp, "JG");
    break;
  case 0x0B:
    sprintf(tmp, "JL");
    break;
  case 0x0C:
    sprintf(tmp, "INT");
    break;
  case 0x0D:
    sprintf(tmp, "MOVP");
    break;
  }
  return tmp;
}


x86 assembly (clang, -O0):
<opcodeName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <getRAM@plt>
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xd,%eax
ja     1174 <opcodeName+0x44>
mov    -0x18(%rbp),%rax
lea    0xe95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <getRAM@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xea7(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edi
add    $0x1,%edi
call   1030 <getRAM@plt>
mov    %eax,-0x38(%rbp)
mov    -0x4(%rbp),%edi
add    $0x2,%edi
call   1030 <getRAM@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    $0x8,%ecx
shl    %cl,%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
add    $0x3,%edi
call   1030 <getRAM@plt>
shl    $0x8,%eax
mov    %eax,-0x34(%rbp)
mov    -0x4(%rbp),%edi
add    $0x4,%edi
call   1030 <getRAM@plt>
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%edx
add    %eax,%ecx
lea    0xe30(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xe27(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xe14(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xe01(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xdee(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xdc8(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xdb5(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xda1(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xd8e(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xd7a(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xd66(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
jmp    132c <opcodeName+0x1fc>
mov    -0x10(%rbp),%rdi
lea    0xd53(%rip),%rsi
mov    $0x0,%al
call   1050 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opcodeName>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x40,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1030 <getRAM@plt>
cmp    $0xd,%eax
ja     1170 <opcodeName+0x40>
mov    %eax,%eax
lea    0xea5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x4c554e,(%r14)
jmp    1254 <opcodeName+0x124>
mov    %ebx,%edi
call   1030 <getRAM@plt>
lea    0xeba(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    1254 <opcodeName+0x124>
lea    0x1(%rbx),%edi
call   1030 <getRAM@plt>
mov    %eax,%r15d
lea    0x2(%rbx),%edi
call   1030 <getRAM@plt>
lea    0x8(%rax),%ecx
shl    %cl,%r15d
lea    0x3(%rbx),%edi
call   1030 <getRAM@plt>
mov    %eax,%ebp
shl    $0x8,%ebp
add    $0x4,%ebx
mov    %ebx,%edi
call   1030 <getRAM@plt>
add    %eax,%ebp
lea    0xe75(%rip),%rsi
mov    %r14,%rdi
mov    %r15d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <sprintf@plt>
jmp    1254 <opcodeName+0x124>
movl   $0x444441,(%r14)
jmp    1254 <opcodeName+0x124>
movl   $0x425553,(%r14)
jmp    1254 <opcodeName+0x124>
movl   $0x4c554d,(%r14)
jmp    1254 <opcodeName+0x124>
movl   $0x564944,(%r14)
jmp    1254 <opcodeName+0x124>
movl   $0x504d4a,(%r14)
jmp    1254 <opcodeName+0x124>
movl   $0x504d43,(%r14)
jmp    1254 <opcodeName+0x124>
movb   $0x0,0x2(%r14)
movw   $0x454a,(%r14)
jmp    1254 <opcodeName+0x124>
movl   $0x454e4a,(%r14)
jmp    1254 <opcodeName+0x124>
movb   $0x0,0x2(%r14)
movw   $0x474a,(%r14)
jmp    1254 <opcodeName+0x124>
movb   $0x0,0x2(%r14)
movw   $0x4c4a,(%r14)
jmp    1254 <opcodeName+0x124>
movl   $0x544e49,(%r14)
jmp    1254 <opcodeName+0x124>
movb   $0x0,0x4(%r14)
movl   $0x50564f4d,(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
@.str.1 = [4 x i8] c"NUL\00"
@.str.2 = [14 x i8] c"MOV %04x %04x\00"
@.str.3 = [4 x i8] c"ADD\00"
@.str.4 = [4 x i8] c"SUB\00"
@.str.5 = [4 x i8] c"MUL\00"
@.str.6 = [4 x i8] c"DIV\00"
@.str.7 = [4 x i8] c"JMP\00"
@.str.8 = [4 x i8] c"CMP\00"
@.str.9 = [3 x i8] c"JE\00"
@.str.10 = [4 x i8] c"JNE\00"
@.str.11 = [3 x i8] c"JG\00"
@.str.12 = [3 x i8] c"JL\00"
@.str.13 = [4 x i8] c"INT\00"
@.str.14 = [5 x i8] c"MOVP\00"
define i8* @opcodeName(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = call i64 @malloc(i32 64)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = load i32, i32* %2
%7 = call i32 @getRAM(i32 %6)
switch i32 %7, label %8 [
i32 0, label %13
i32 1, label %16
i32 2, label %35
i32 3, label %38
i32 4, label %41
i32 5, label %44
i32 6, label %47
i32 7, label %50
i32 8, label %53
i32 9, label %56
i32 10, label %59
i32 11, label %62
i32 12, label %65
i32 13, label %68
]
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i32, i32* %2
%11 = call i32 @getRAM(i32 %10)
%12 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %71
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 (i8*, i8*, ...) @sprintf(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %71
16: ; preds = %1
%17 = load i8*, i8** %3
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
%20 = call i32 @getRAM(i32 %19)
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 2
%23 = call i32 @getRAM(i32 %22)
%24 = add nsw i32 8, %23
%25 = shl i32 %20, %24
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 3
%28 = call i32 @getRAM(i32 %27)
%29 = shl i32 %28, 8
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 4
%32 = call i32 @getRAM(i32 %31)
%33 = add nsw i32 %29, %32
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %33)
br label %71
35: ; preds = %1
%36 = load i8*, i8** %3
%37 = call i32 (i8*, i8*, ...) @sprintf(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %71
38: ; preds = %1
%39 = load i8*, i8** %3
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %71
41: ; preds = %1
%42 = load i8*, i8** %3
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %71
44: ; preds = %1
%45 = load i8*, i8** %3
%46 = call i32 (i8*, i8*, ...) @sprintf(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %71
47: ; preds = %1
%48 = load i8*, i8** %3
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
br label %71
50: ; preds = %1
%51 = load i8*, i8** %3
%52 = call i32 (i8*, i8*, ...) @sprintf(i8* %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
br label %71
53: ; preds = %1
%54 = load i8*, i8** %3
%55 = call i32 (i8*, i8*, ...) @sprintf(i8* %54, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0))
br label %71
56: ; preds = %1
%57 = load i8*, i8** %3
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0))
br label %71
59: ; preds = %1
%60 = load i8*, i8** %3
%61 = call i32 (i8*, i8*, ...) @sprintf(i8* %60, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0))
br label %71
62: ; preds = %1
%63 = load i8*, i8** %3
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
br label %71
65: ; preds = %1
%66 = load i8*, i8** %3
%67 = call i32 (i8*, i8*, ...) @sprintf(i8* %66, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0))
br label %71
68: ; preds = %1
%69 = load i8*, i8** %3
%70 = call i32 (i8*, i8*, ...) @sprintf(i8* %69, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0))
br label %71
71: ; preds = %68, %65, %62, %59, %56, %53, %50, %47, %44, %41, %38, %35, %16, %13, %8
%72 = load i8*, i8** %3
ret i8* %72
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
@.str.2 = [14 x i8] c"MOV %04x %04x\00"
@.str.9 = [3 x i8] c"JE\00"
@.str.11 = [3 x i8] c"JG\00"
@.str.12 = [3 x i8] c"JL\00"
@.str.14 = [5 x i8] c"MOVP\00"
define i8* @opcodeName(i32 %0) {
%2 = tail call i64 @malloc(i32 64)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @getRAM(i32 %0)
switch i32 %4, label %5 [
i32 0, label %8
i32 1, label %10
i32 2, label %24
i32 3, label %26
i32 4, label %28
i32 5, label %30
i32 6, label %32
i32 7, label %34
i32 8, label %36
i32 9, label %37
i32 10, label %39
i32 11, label %40
i32 12, label %41
i32 13, label %43
]
5: ; preds = %1
%6 = tail call i32 @getRAM(i32 %0)
%7 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %44
8: ; preds = %1
%9 = inttoptr i64 %2 to i32*
store i32 5002574, i32* %9
br label %44
10: ; preds = %1
%11 = add nsw i32 %0, 1
%12 = tail call i32 @getRAM(i32 %11)
%13 = add nsw i32 %0, 2
%14 = tail call i32 @getRAM(i32 %13)
%15 = add nsw i32 %14, 8
%16 = shl i32 %12, %15
%17 = add nsw i32 %0, 3
%18 = tail call i32 @getRAM(i32 %17)
%19 = shl i32 %18, 8
%20 = add nsw i32 %0, 4
%21 = tail call i32 @getRAM(i32 %20)
%22 = add nsw i32 %19, %21
%23 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %22)
br label %44
24: ; preds = %1
%25 = inttoptr i64 %2 to i32*
store i32 4473921, i32* %25
br label %44
26: ; preds = %1
%27 = inttoptr i64 %2 to i32*
store i32 4347219, i32* %27
br label %44
28: ; preds = %1
%29 = inttoptr i64 %2 to i32*
store i32 5002573, i32* %29
br label %44
30: ; preds = %1
%31 = inttoptr i64 %2 to i32*
store i32 5654852, i32* %31
br label %44
32: ; preds = %1
%33 = inttoptr i64 %2 to i32*
store i32 5262666, i32* %33
br label %44
34: ; preds = %1
%35 = inttoptr i64 %2 to i32*
store i32 5262659, i32* %35
br label %44
36: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %3, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i64 3, i1 false)
br label %44
37: ; preds = %1
%38 = inttoptr i64 %2 to i32*
store i32 4542026, i32* %38
br label %44
39: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %3, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i64 3, i1 false)
br label %44
40: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %3, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i64 3, i1 false)
br label %44
41: ; preds = %1
%42 = inttoptr i64 %2 to i32*
store i32 5525065, i32* %42
br label %44
43: ; preds = %1
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(5) %3, i8* align 1 dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i64 5, i1 false)
br label %44
44: ; preds = %43, %41, %40, %39, %37, %36, %34, %32, %30, %28, %26, %24, %10, %8, %5
ret i8* %3
}