#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int typename2int(char *name) {
  char *typenames[] = {"standard", "unload", "load", "noop",
                       NULL,       NULL,     NULL,   "reload"};
  int i;
  for (i = 0; i < 8; i++) {
    if (typenames[i] == NULL)
      continue;
    if (strcmp(typenames[i], name) == 0) {
      return i;
    }
  }
  fprintf(stderr, "Invalid message type <%s>\n", name);
  return -1;
}


x86 assembly (clang, -O0):
<typename2int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
lea    0xead(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xeab(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xeae(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe9c(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x8,-0x54(%rbp)
jge    11e3 <typename2int+0xb3>
movslq -0x54(%rbp),%rax
cmpq   $0x0,-0x50(%rbp,%rax,8)
jne    11a9 <typename2int+0x79>
jmp    11d5 <typename2int+0xa5>
movslq -0x54(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d0 <typename2int+0xa0>
mov    -0x54(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1203 <typename2int+0xd3>
jmp    11d5 <typename2int+0xa5>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    118a <typename2int+0x5a>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe25(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<typename2int>:
push   %rbx
mov    %rdi,%rbx
lea    0xed5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a7 <typename2int+0x87>
lea    0xeca(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ab <typename2int+0x8b>
lea    0xec4(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b2 <typename2int+0x92>
lea    0xea9(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b9 <typename2int+0x99>
lea    0xe9a(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c0 <typename2int+0xa0>
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe84(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    $0xffffffff,%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    $0x7,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"standard\00"
@.str.1 = [7 x i8] c"unload\00"
@.str.2 = [5 x i8] c"load\00"
@.str.3 = [5 x i8] c"noop\00"
@.str.4 = [7 x i8] c"reload\00"
@stderr = global i32 0
@.str.5 = [27 x i8] c"Invalid message type <%s>\0A\00"
define i32 @typename2int(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [8 x i8*]
%5 = alloca i32
store i8* %0, i8** %3
%6 = bitcast [8 x i8*]* %4 to i8*
%7 = bitcast i8* %6 to [8 x i8*]*
%8 = getelementptr inbounds [8 x i8*], [8 x i8*]* %7, i32 0, i32 0
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [8 x i8*], [8 x i8*]* %7, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [8 x i8*], [8 x i8*]* %7, i32 0, i32 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [8 x i8*], [8 x i8*]* %7, i32 0, i32 3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [8 x i8*], [8 x i8*]* %7, i32 0, i32 7
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i32 0, i32 0), i8** %12
store i32 0, i32* %5
br label %13
13: ; preds = %34, %1
%14 = load i32, i32* %5
%15 = icmp slt i32 %14, 8
br i1 %15, label %16, label %37
16: ; preds = %13
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [8 x i8*], [8 x i8*]* %4, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %23
22: ; preds = %16
br label %34
23: ; preds = %16
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x i8*], [8 x i8*]* %4, i64 0, i64 %25
%27 = load i8*, i8** %26
%28 = load i8*, i8** %3
%29 = call i64 @strcmp(i8* %27, i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = load i32, i32* %5
store i32 %32, i32* %2
br label %41
33: ; preds = %23
br label %34
34: ; preds = %33, %22
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %13
37: ; preds = %13
%38 = load i32, i32* @stderr
%39 = load i8*, i8** %3
%40 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %39)
store i32 -1, i32* %2
br label %41
41: ; preds = %37, %31
%42 = load i32, i32* %2
ret i32 %42
}

LLVM IR (-O2):
@.str = [9 x i8] c"standard\00"
@.str.1 = [7 x i8] c"unload\00"
@.str.2 = [5 x i8] c"load\00"
@.str.3 = [5 x i8] c"noop\00"
@.str.4 = [7 x i8] c"reload\00"
@stderr = global i32 0
@.str.5 = [27 x i8] c"Invalid message type <%s>\0A\00"
define i32 @typename2int(i8* %0) {
%2 = tail call i64 @strcmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %1, %4, %7, %10, %13, %16
%20 = phi i32 [ -1, %16 ], [ 0, %1 ], [ 1, %4 ], [ 2, %7 ], [ 3, %10 ], [ 7, %13 ]
ret i32 %20
}