int instr_lookup(char *instr) {
  static char reverse_ops[][7] = {"cmov", "sload", "sstore", "add",  "mult",
                                  "div",  "nand",  "halt",   "map",  "unmap",
                                  "out",  "in",    "loadp",  "loadv"};
  static int NUM_INSTRS = 14;
  for (int i = 0; i < NUM_INSTRS; i++) {
    if (strcmp(instr, reverse_ops[i]) == 0) {
      return i;
    }
  }
  return -1;
}


x86 assembly (clang, -O0):
<instr_lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    0x2f68(%rip),%eax
jge    1174 <instr_lookup+0x64>
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
lea    0x2eef(%rip),%rsi
imul   $0x7,%rax,%rax
add    %rax,%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1161 <instr_lookup+0x51>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    117b <instr_lookup+0x6b>
jmp    1166 <instr_lookup+0x56>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <instr_lookup+0x13>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<instr_lookup>:
push   %rbx
mov    %rdi,%rbx
lea    0x2f15(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     124c <instr_lookup+0x13c>
lea    0x2f08(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1250 <instr_lookup+0x140>
lea    0x2ef8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1257 <instr_lookup+0x147>
lea    0x2ee8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     125e <instr_lookup+0x14e>
lea    0x2ed8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1265 <instr_lookup+0x155>
lea    0x2ec8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     126c <instr_lookup+0x15c>
lea    0x2eb8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1273 <instr_lookup+0x163>
lea    0x2ea8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     127a <instr_lookup+0x16a>
lea    0x2e98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1281 <instr_lookup+0x171>
lea    0x2e88(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1288 <instr_lookup+0x178>
lea    0x2e78(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     128f <instr_lookup+0x17f>
lea    0x2e68(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1296 <instr_lookup+0x186>
lea    0x2e5c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     129d <instr_lookup+0x18d>
lea    0x2e50(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
neg    %eax
sbb    %eax,%eax
or     $0xd,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret
mov    $0x2,%eax
pop    %rbx
ret
mov    $0x3,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret
mov    $0x5,%eax
pop    %rbx
ret
mov    $0x6,%eax
pop    %rbx
ret
mov    $0x7,%eax
pop    %rbx
ret
mov    $0x8,%eax
pop    %rbx
ret
mov    $0x9,%eax
pop    %rbx
ret
mov    $0xa,%eax
pop    %rbx
ret
mov    $0xb,%eax
pop    %rbx
ret
mov    $0xc,%eax
pop    %rbx
ret

LLVM IR (-O0):
@instr_lookup.reverse_ops = internal global [14 x [7 x i8]] [[7 x i8] c"cmov\00\00\00", [7 x i8] c"sload\00\00", [7 x i8] c"sstore\00", [7 x i8] c"add\00\00\00\00", [7 x i8] c"mult\00\00\00", [7 x i8] c"div\00\00\00\00", [7 x i8] c"nand\00\00\00", [7 x i8] c"halt\00\00\00", [7 x i8] c"map\00\00\00\00", [7 x i8] c"unmap\00\00", [7 x i8] c"out\00\00\00\00", [7 x i8] c"in\00\00\00\00\00", [7 x i8] c"loadp\00\00", [7 x i8] c"loadv\00\00"]
@instr_lookup.NUM_INSTRS = internal global i32 14
define i32 @instr_lookup(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %20, %1
%6 = load i32, i32* %4
%7 = load i32, i32* @instr_lookup.NUM_INSTRS
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %23
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i32, i32* %4
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 %12
%14 = getelementptr inbounds [7 x i8], [7 x i8]* %13, i64 0, i64 0
%15 = call i32 @strcmp(i8* %10, i8* %14)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %9
%18 = load i32, i32* %4
store i32 %18, i32* %2
br label %24
19: ; preds = %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %5
23: ; preds = %5
store i32 -1, i32* %2
br label %24
24: ; preds = %23, %17
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@instr_lookup.reverse_ops = internal global [14 x [7 x i8]] [[7 x i8] c"cmov\00\00\00", [7 x i8] c"sload\00\00", [7 x i8] c"sstore\00", [7 x i8] c"add\00\00\00\00", [7 x i8] c"mult\00\00\00", [7 x i8] c"div\00\00\00\00", [7 x i8] c"nand\00\00\00", [7 x i8] c"halt\00\00\00", [7 x i8] c"map\00\00\00\00", [7 x i8] c"unmap\00\00", [7 x i8] c"out\00\00\00\00", [7 x i8] c"in\00\00\00\00\00", [7 x i8] c"loadp\00\00", [7 x i8] c"loadv\00\00"]
define i32 @instr_lookup(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %44, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 1, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %44, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 2, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %44, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 3, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %44, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 4, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %44, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 5, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %44, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 6, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %44, label %22
22: ; preds = %19
%23 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 7, i64 0))
%24 = icmp eq i32 %23, 0
br i1 %24, label %44, label %25
25: ; preds = %22
%26 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 8, i64 0))
%27 = icmp eq i32 %26, 0
br i1 %27, label %44, label %28
28: ; preds = %25
%29 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 9, i64 0))
%30 = icmp eq i32 %29, 0
br i1 %30, label %44, label %31
31: ; preds = %28
%32 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 10, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %44, label %34
34: ; preds = %31
%35 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 11, i64 0))
%36 = icmp eq i32 %35, 0
br i1 %36, label %44, label %37
37: ; preds = %34
%38 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 12, i64 0))
%39 = icmp eq i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %37
%41 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [7 x i8]], [14 x [7 x i8]]* @instr_lookup.reverse_ops, i64 0, i64 13, i64 0))
%42 = icmp eq i32 %41, 0
%43 = select i1 %42, i32 13, i32 -1
br label %44
44: ; preds = %40, %37, %34, %31, %28, %25, %22, %19, %16, %13, %10, %7, %4, %1
%45 = phi i32 [ 0, %1 ], [ 1, %4 ], [ 2, %7 ], [ 3, %10 ], [ 4, %13 ], [ 5, %16 ], [ 6, %19 ], [ 7, %22 ], [ 8, %25 ], [ 9, %28 ], [ 10, %31 ], [ 11, %34 ], [ 12, %37 ], [ %43, %40 ]
ret i32 %45
}