#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*/ strcmp(char const *, char const *);
unsigned int type_size(const char *name) {
  static struct {
    const char *type;
    unsigned int size;
  } table[] = {
      {"u8", 1},  {"u16", 2}, {"u32", 4}, {"u64", 8},  {"s8", 1},
      {"s16", 2}, {"s32", 4}, {"s64", 8}, {"char", 1}, {},
  };
  int i;
  for (i = 0; table[i].type; i++) {
    if (!strcmp(table[i].type, name))
      return table[i].size;
  }
  return 0;
}


x86 assembly (clang, -O0):
<type_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rcx
lea    0x2f02(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
cmpq   $0x0,(%rax)
je     1196 <type_size+0x86>
movslq -0x14(%rbp),%rcx
lea    0x2ee6(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1183 <type_size+0x73>
movslq -0x14(%rbp),%rcx
lea    0x2ebf(%rip),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    119d <type_size+0x8d>
jmp    1188 <type_size+0x78>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <type_size+0x13>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<type_size>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11d6 <type_size+0xc6>
lea    0xed1(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11da <type_size+0xca>
lea    0xebe(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11e1 <type_size+0xd1>
lea    0xeab(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11e8 <type_size+0xd8>
lea    0xe9c(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11ef <type_size+0xdf>
lea    0xe8c(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11f6 <type_size+0xe6>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11fd <type_size+0xed>
lea    0xe6e(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1204 <type_size+0xf4>
lea    0xe5f(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    1218 <type_size+0x108>
mov    $0x8,%eax
jmp    1209 <type_size+0xf9>
xor    %eax,%eax
jmp    1209 <type_size+0xf9>
mov    $0x1,%eax
jmp    1209 <type_size+0xf9>
mov    $0x2,%eax
jmp    1209 <type_size+0xf9>
mov    $0x3,%eax
jmp    1209 <type_size+0xf9>
mov    $0x4,%eax
jmp    1209 <type_size+0xf9>
mov    $0x5,%eax
jmp    1209 <type_size+0xf9>
mov    $0x6,%eax
jmp    1209 <type_size+0xf9>
mov    $0x7,%eax
shl    $0x4,%rax
lea    0x2b6c(%rip),%rcx
mov    0x8(%rax,%rcx,1),%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i32 }
@type_size.table = internal global [10 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i32 1 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 2 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 4 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 8 }, %struct.anon { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i32 1 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 2 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i32 4 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i32 8 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i32 1 }, %struct.anon zeroinitializer]
@.str = [3 x i8] c"u8\00"
@.str.1 = [4 x i8] c"u16\00"
@.str.2 = [4 x i8] c"u32\00"
@.str.3 = [4 x i8] c"u64\00"
@.str.4 = [3 x i8] c"s8\00"
@.str.5 = [4 x i8] c"s16\00"
@.str.6 = [4 x i8] c"s32\00"
@.str.7 = [4 x i8] c"s64\00"
@.str.8 = [5 x i8] c"char\00"
define i32 @type_size(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 = %28, %1
%6 = load i32, i32* %4
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [10 x %struct.anon], [10 x %struct.anon]* @type_size.table, i64 0, i64 %7
%9 = getelementptr inbounds %struct.anon, %struct.anon* %8, i32 0, i32 0
%10 = load i8*, i8** %9
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %31
12: ; preds = %5
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x %struct.anon], [10 x %struct.anon]* @type_size.table, i64 0, i64 %14
%16 = getelementptr inbounds %struct.anon, %struct.anon* %15, i32 0, i32 0
%17 = load i8*, i8** %16
%18 = load i8*, i8** %3
%19 = call i32 @strcmp(i8* %17, i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %12
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10 x %struct.anon], [10 x %struct.anon]* @type_size.table, i64 0, i64 %23
%25 = getelementptr inbounds %struct.anon, %struct.anon* %24, i32 0, i32 1
%26 = load i32, i32* %25
store i32 %26, i32* %2
br label %32
27: ; preds = %12
br label %28
28: ; preds = %27
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %5
31: ; preds = %5
store i32 0, i32* %2
br label %32
32: ; preds = %31, %21
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
%struct.anon = type { i8*, i32 }
@type_size.table = internal unnamed_addr constant [10 x %struct.anon] [%struct.anon { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i32 0, i32 0), i32 1 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i32 2 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i32 4 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i32 8 }, %struct.anon { i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i32 1 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i32 0, i32 0), i32 2 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i32 4 }, %struct.anon { i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i32 0, i32 0), i32 8 }, %struct.anon { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i32 0, i32 0), i32 1 }, %struct.anon zeroinitializer]
@.str = [3 x i8] c"u8\00"
@.str.1 = [4 x i8] c"u16\00"
@.str.2 = [4 x i8] c"u32\00"
@.str.3 = [4 x i8] c"u64\00"
@.str.4 = [3 x i8] c"s8\00"
@.str.5 = [4 x i8] c"s16\00"
@.str.6 = [4 x i8] c"s32\00"
@.str.7 = [4 x i8] c"s64\00"
@.str.8 = [5 x i8] c"char\00"
define i32 @type_size(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %29, %26, %23, %20, %17, %14, %11, %8, %1
%5 = phi i64 [ 0, %1 ], [ 1, %8 ], [ 2, %11 ], [ 3, %14 ], [ 4, %17 ], [ 5, %20 ], [ 6, %23 ], [ 7, %26 ], [ 8, %29 ]
%6 = getelementptr inbounds [10 x %struct.anon], [10 x %struct.anon]* @type_size.table, i64 0, i64 %5, i32 1
%7 = load i32, i32* %6
br label %32
8: ; preds = %1
%9 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %0)
%10 = icmp eq i32 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %8
%12 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %4, label %14
14: ; preds = %11
%15 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(1) %0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %4, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(1) %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %4, label %20
20: ; preds = %17
%21 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* dereferenceable(1) %0)
%22 = icmp eq i32 %21, 0
br i1 %22, label %4, label %23
23: ; preds = %20
%24 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* dereferenceable(1) %0)
%25 = icmp eq i32 %24, 0
br i1 %25, label %4, label %26
26: ; preds = %23
%27 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* dereferenceable(1) %0)
%28 = icmp eq i32 %27, 0
br i1 %28, label %4, label %29
29: ; preds = %26
%30 = tail call i32 @strcmp(i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), i8* dereferenceable(1) %0)
%31 = icmp eq i32 %30, 0
br i1 %31, label %4, label %32
32: ; preds = %29, %4
%33 = phi i32 [ %7, %4 ], [ 0, %29 ]
ret i32 %33
}