int encode_opcode(char opcode[]) {
  int i;
  char names[14][8] = {"LOADA", "LOADB", "STOREA", "STOREB", "READ",
                       "WRITE", "ADD",   "DIF",    "LDCA",   "LDCB",
                       "JMP",   "JMPZ",  "NOP",    "HALT"};
  for (i = 0; i < 14; i++) {
    if (strcmp(opcode, names[i]) == 0)
      return i;
  }
  exit(1);
  return -1;
}


x86 assembly (clang, -O0):
<encode_opcode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x80(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x70,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0xe,-0xc(%rbp)
jge    11a5 <encode_opcode+0x75>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rax
lea    -0x80(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1192 <encode_opcode+0x62>
mov    -0xc(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret
jmp    1197 <encode_opcode+0x67>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115b <encode_opcode+0x2b>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<encode_opcode>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     126c <encode_opcode+0x14c>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1270 <encode_opcode+0x150>
lea    0xeba(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1277 <encode_opcode+0x157>
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     127e <encode_opcode+0x15e>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1285 <encode_opcode+0x165>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     128c <encode_opcode+0x16c>
lea    0xe7e(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1293 <encode_opcode+0x173>
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     129a <encode_opcode+0x17a>
lea    0xe60(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     12a1 <encode_opcode+0x181>
lea    0xe51(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     12a8 <encode_opcode+0x188>
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     12af <encode_opcode+0x18f>
lea    0xe33(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     12b6 <encode_opcode+0x196>
lea    0xe24(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     12bd <encode_opcode+0x19d>
lea    0xe19(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %eax,%ecx
mov    $0xd,%eax
test   %ecx,%ecx
je     126e <encode_opcode+0x14e>
mov    $0x1,%edi
call   1040 <exit@plt>
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):
@__const.encode_opcode.names = [14 x [8 x i8]] [[8 x i8] c"LOADA\00\00\00", [8 x i8] c"LOADB\00\00\00", [8 x i8] c"STOREA\00\00", [8 x i8] c"STOREB\00\00", [8 x i8] c"READ\00\00\00\00", [8 x i8] c"WRITE\00\00\00", [8 x i8] c"ADD\00\00\00\00\00", [8 x i8] c"DIF\00\00\00\00\00", [8 x i8] c"LDCA\00\00\00\00", [8 x i8] c"LDCB\00\00\00\00", [8 x i8] c"JMP\00\00\00\00\00", [8 x i8] c"JMPZ\00\00\00\00", [8 x i8] c"NOP\00\00\00\00\00", [8 x i8] c"HALT\00\00\00\00"]
define i32 @encode_opcode(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [14 x [8 x i8]]
store i8* %0, i8** %2
%5 = bitcast [14 x [8 x i8]]* %4 to i8*
store i32 0, i32* %3
br label %6
6: ; preds = %20, %1
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 14
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i8*, i8** %2
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [14 x [8 x i8]], [14 x [8 x i8]]* %4, i64 0, i64 %12
%14 = getelementptr inbounds [8 x i8], [8 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* %3
ret i32 %18
19: ; preds = %9
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %6
23: ; preds = %6
unreachable
}

LLVM IR (-O2):
@__const.encode_opcode.names = [14 x [8 x i8]] [[8 x i8] c"LOADA\00\00\00", [8 x i8] c"LOADB\00\00\00", [8 x i8] c"STOREA\00\00", [8 x i8] c"STOREB\00\00", [8 x i8] c"READ\00\00\00\00", [8 x i8] c"WRITE\00\00\00", [8 x i8] c"ADD\00\00\00\00\00", [8 x i8] c"DIF\00\00\00\00\00", [8 x i8] c"LDCA\00\00\00\00", [8 x i8] c"LDCB\00\00\00\00", [8 x i8] c"JMP\00\00\00\00\00", [8 x i8] c"JMPZ\00\00\00\00", [8 x i8] c"NOP\00\00\00\00\00", [8 x i8] c"HALT\00\00\00\00"]
define i32 @encode_opcode(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %42, %39, %36, %33, %30, %27, %24, %21, %18, %15, %12, %9, %6, %1
%5 = phi i32 [ 0, %1 ], [ 1, %6 ], [ 2, %9 ], [ 3, %12 ], [ 4, %15 ], [ 5, %18 ], [ 6, %21 ], [ 7, %24 ], [ 8, %27 ], [ 9, %30 ], [ 10, %33 ], [ 11, %36 ], [ 12, %39 ], [ 13, %42 ]
ret i32 %5
6: ; preds = %1
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 1, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %4, label %9
9: ; preds = %6
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 2, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %4, label %12
12: ; preds = %9
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 3, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %4, label %15
15: ; preds = %12
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 4, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %4, label %18
18: ; preds = %15
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 5, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %4, label %21
21: ; preds = %18
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 6, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %4, label %24
24: ; preds = %21
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 7, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %4, label %27
27: ; preds = %24
%28 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 8, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %4, label %30
30: ; preds = %27
%31 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 9, i64 0))
%32 = icmp eq i32 %31, 0
br i1 %32, label %4, label %33
33: ; preds = %30
%34 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 10, i64 0))
%35 = icmp eq i32 %34, 0
br i1 %35, label %4, label %36
36: ; preds = %33
%37 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 11, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %4, label %39
39: ; preds = %36
%40 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 12, i64 0))
%41 = icmp eq i32 %40, 0
br i1 %41, label %4, label %42
42: ; preds = %39
%43 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* getelementptr inbounds ([14 x [8 x i8]], [14 x [8 x i8]]* @__const.encode_opcode.names, i64 0, i64 13, i64 0))
%44 = icmp eq i32 %43, 0
br i1 %44, label %4, label %45
45: ; preds = %42
tail call void @exit(i32 1)
unreachable
}