#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 */
typedef int /*<<< orphan*/ size_names;

/* Variables and functions */
int bsii(char const *, char const **, int);
int parse_size(const char *str) {
  static const char *size_names[] = {"byte",  "dword", "oword", "qword",
                                     "tword", "word",  "yword"};
  static const int sizes[] = {0, 1, 4, 16, 8, 10, 2, 32};
  return sizes[bsii(str, size_names,
                    (sizeof(size_names) / sizeof((size_names)[0]))) +
               1];
}


x86 assembly (clang, -O0):
<parse_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0x2f09(%rip),%rsi
mov    $0x7,%edx
call   1030 <bsii@plt>
add    $0x1,%eax
movslq %eax,%rcx
lea    0xef2(%rip),%rax
mov    (%rax,%rcx,4),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_size>:
push   %rax
lea    0x2f18(%rip),%rsi
mov    $0x7,%edx
call   1030 <bsii@plt>
cltq
lea    0xf05(%rip),%rcx
mov    0x4(%rcx,%rax,4),%eax
pop    %rcx
ret

LLVM IR (-O0):
@parse_size.size_names = internal global [7 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0)]
@.str = [5 x i8] c"byte\00"
@.str.1 = [6 x i8] c"dword\00"
@.str.2 = [6 x i8] c"oword\00"
@.str.3 = [6 x i8] c"qword\00"
@.str.4 = [6 x i8] c"tword\00"
@.str.5 = [5 x i8] c"word\00"
@.str.6 = [6 x i8] c"yword\00"
@parse_size.sizes = internal constant [8 x i32] [i32 0, i32 1, i32 4, i32 16, i32 8, i32 10, i32 2, i32 32]
define i32 @parse_size(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i32 @bsii(i8* %3, i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @parse_size.size_names, i64 0, i64 0), i32 7)
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds [8 x i32], [8 x i32]* @parse_size.sizes, i64 0, i64 %6
%8 = load i32, i32* %7
ret i32 %8
}

LLVM IR (-O2):
@parse_size.size_names = internal global [7 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i32 0, i32 0)]
@.str = [5 x i8] c"byte\00"
@.str.1 = [6 x i8] c"dword\00"
@.str.2 = [6 x i8] c"oword\00"
@.str.3 = [6 x i8] c"qword\00"
@.str.4 = [6 x i8] c"tword\00"
@.str.5 = [5 x i8] c"word\00"
@.str.6 = [6 x i8] c"yword\00"
@parse_size.sizes = internal unnamed_addr constant [8 x i32] [i32 0, i32 1, i32 4, i32 16, i32 8, i32 10, i32 2, i32 32]
define i32 @parse_size(i8* %0) {
%2 = tail call i32 @bsii(i8* %0, i8** getelementptr inbounds ([7 x i8*], [7 x i8*]* @parse_size.size_names, i64 0, i64 0), i32 7)
%3 = add nsw i32 %2, 1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds [8 x i32], [8 x i32]* @parse_size.sizes, i64 0, i64 %4
%6 = load i32, i32* %5
ret i32 %6
}