#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 */
struct sockaddr_storage {
  int dummy;
};
struct iovec {
  int dummy;
};

/* Variables and functions */
scalar_t__ strcmp(char const *, char *);
size_t size_of(const char *type) {
  do {
    if (0 == strcmp(type, "long")) {
      return sizeof(long);
    }
  } while (0);
  do {
    if (0 == strcmp(type, "sockaddr_storage")) {
      return sizeof(struct sockaddr_storage);
    }
  } while (0);
  do {
    if (0 == strcmp(type, "iovec")) {
      return sizeof(struct iovec);
    }
  } while (0);
  return 0;
}


x86 assembly (clang, -O0):
<size_of>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1147 <size_of+0x37>
movq   $0x8,-0x8(%rbp)
jmp    11be <size_of+0xae>
jmp    114c <size_of+0x3c>
jmp    1151 <size_of+0x41>
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    117c <size_of+0x6c>
movq   $0x4,-0x8(%rbp)
jmp    11be <size_of+0xae>
jmp    1181 <size_of+0x71>
jmp    1186 <size_of+0x76>
mov    -0x10(%rbp),%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11b1 <size_of+0xa1>
movq   $0x4,-0x8(%rbp)
jmp    11be <size_of+0xae>
jmp    11b6 <size_of+0xa6>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<size_of>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1159 <size_of+0x49>
lea    0xed9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1160 <size_of+0x50>
lea    0xed6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
shl    $0x2,%rax
pop    %rbx
ret
mov    $0x8,%eax
pop    %rbx
ret
mov    $0x4,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"long\00"
@.str.1 = [17 x i8] c"sockaddr_storage\00"
@.str.2 = [6 x i8] c"iovec\00"
define i64 @size_of(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
store i8* %0, i8** %3
br label %4
4: ; preds = %1
%5 = load i8*, i8** %3
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 0, %6
br i1 %7, label %8, label %9
8: ; preds = %4
store i64 8, i64* %2
br label %25
9: ; preds = %4
br label %10
10: ; preds = %9
br label %11
11: ; preds = %10
%12 = load i8*, i8** %3
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 0, %13
br i1 %14, label %15, label %16
15: ; preds = %11
store i64 4, i64* %2
br label %25
16: ; preds = %11
br label %17
17: ; preds = %16
br label %18
18: ; preds = %17
%19 = load i8*, i8** %3
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 0, %20
br i1 %21, label %22, label %23
22: ; preds = %18
store i64 4, i64* %2
br label %25
23: ; preds = %18
br label %24
24: ; preds = %23
store i64 0, i64* %2
br label %25
25: ; preds = %24, %22, %15, %8
%26 = load i64, i64* %2
ret i64 %26
}

LLVM IR (-O2):
@.str = [5 x i8] c"long\00"
@.str.1 = [17 x i8] c"sockaddr_storage\00"
@.str.2 = [6 x i8] c"iovec\00"
define i64 @size_of(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i64 4, i64 0
br label %11
11: ; preds = %7, %4, %1
%12 = phi i64 [ 8, %1 ], [ 4, %4 ], [ %10, %7 ]
ret i64 %12
}