#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 dev_type_enum(char const *, char const *);
const char *dev_type_string(const char *dev, const char *dev_type) {
  switch (dev_type_enum(dev, dev_type)) {
  case 2:
    return "tun";
  case 3:
    return "tap";
  case 1:
    return "null";
  default:
    return "[unknown-dev-type]";
  }
}


x86 assembly (clang, -O0):
<dev_type_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <dev_type_enum@plt>
mov    %eax,%ecx
mov    %ecx,-0x1c(%rbp)
sub    $0x1,%eax
je     1182 <dev_type_string+0x72>
jmp    1140 <dev_type_string+0x30>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     1162 <dev_type_string+0x52>
jmp    1151 <dev_type_string+0x41>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
je     1172 <dev_type_string+0x62>
jmp    1192 <dev_type_string+0x82>
lea    0xe97(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <dev_type_string+0x8d>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <dev_type_string+0x8d>
lea    0xe7f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119d <dev_type_string+0x8d>
lea    0xe74(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dev_type_string>:
push   %rax
call   1030 <dev_type_enum@plt>
add    $0xffffffff,%eax
cmp    $0x2,%eax
ja     1130 <dev_type_string+0x20>
cltq
lea    0xef9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
lea    0xed6(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"tun\00"
@.str.1 = [4 x i8] c"tap\00"
@.str.2 = [5 x i8] c"null\00"
@.str.3 = [19 x i8] c"[unknown-dev-type]\00"
define i8* @dev_type_string(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %4
%7 = load i8*, i8** %5
%8 = call i32 @dev_type_enum(i8* %6, i8* %7)
switch i32 %8, label %12 [
i32 2, label %9
i32 3, label %10
i32 1, label %11
]
9: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
br label %13
10: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %13
11: ; preds = %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %13
12: ; preds = %2
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8** %3
br label %13
13: ; preds = %12, %11, %10, %9
%14 = load i8*, i8** %3
ret i8* %14
}

LLVM IR (-O2):
@.str = [4 x i8] c"tun\00"
@.str.1 = [4 x i8] c"tap\00"
@.str.2 = [5 x i8] c"null\00"
@.str.3 = [19 x i8] c"[unknown-dev-type]\00"
@reltable.dev_type_string = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.dev_type_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.dev_type_string to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.dev_type_string to i64)) to i32)]
define i8* @dev_type_string(i8* %0, i8* %1) {
%3 = tail call i32 @dev_type_enum(i8* %0, i8* %1)
%4 = add i32 %3, -1
%5 = icmp ult i32 %4, 3
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.dev_type_string to i8*), i64 %8)
br label %10
10: ; preds = %2, %6
%11 = phi i8* [ %9, %6 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), %2 ]
ret i8* %11
}