#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 S_IFBLK;
int S_IFCHR;
int S_IFDIR;
int S_IFIFO;
int S_IFREG;
int S_IFSOCK;
int ftype(const char *strtype) {
  switch (strtype[0]) {
  case 's':
    return S_IFSOCK;
  case 'f':
    return S_IFREG;
  case 'b':
    return S_IFBLK;
  case 'd':
    return S_IFDIR;
  case 'c':
    return S_IFCHR;
  case 'p':
    return S_IFIFO;
  }
  return -1;
}


x86 assembly (clang, -O0):
<ftype>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x11,%eax
ja     119b <ftype+0x9b>
mov    -0x18(%rbp),%rax
lea    0xed4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <ftype+0xa2>
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <ftype+0xa2>
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <ftype+0xa2>
mov    0x2e41(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <ftype+0xa2>
mov    0x2e48(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <ftype+0xa2>
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <ftype+0xa2>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<ftype>:
movsbl (%rdi),%ecx
mov    $0xffffffff,%eax
add    $0xffffff9e,%ecx
cmp    $0x11,%ecx
ja     1156 <ftype+0x56>
lea    0xee9(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
mov    0x2ea9(%rip),%rax
jmp    1154 <ftype+0x54>
mov    0x2e98(%rip),%rax
jmp    1154 <ftype+0x54>
mov    0x2e77(%rip),%rax
jmp    1154 <ftype+0x54>
mov    0x2ea6(%rip),%rax
jmp    1154 <ftype+0x54>
mov    0x2e75(%rip),%rax
jmp    1154 <ftype+0x54>
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
@S_IFSOCK = global i32 0
@S_IFREG = global i32 0
@S_IFBLK = global i32 0
@S_IFDIR = global i32 0
@S_IFCHR = global i32 0
@S_IFIFO = global i32 0
define i32 @ftype(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = getelementptr inbounds i8, i8* %4, i64 0
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %20 [
i32 115, label %8
i32 102, label %10
i32 98, label %12
i32 100, label %14
i32 99, label %16
i32 112, label %18
]
8: ; preds = %1
%9 = load i32, i32* @S_IFSOCK
store i32 %9, i32* %2
br label %21
10: ; preds = %1
%11 = load i32, i32* @S_IFREG
store i32 %11, i32* %2
br label %21
12: ; preds = %1
%13 = load i32, i32* @S_IFBLK
store i32 %13, i32* %2
br label %21
14: ; preds = %1
%15 = load i32, i32* @S_IFDIR
store i32 %15, i32* %2
br label %21
16: ; preds = %1
%17 = load i32, i32* @S_IFCHR
store i32 %17, i32* %2
br label %21
18: ; preds = %1
%19 = load i32, i32* @S_IFIFO
store i32 %19, i32* %2
br label %21
20: ; preds = %1
store i32 -1, i32* %2
br label %21
21: ; preds = %20, %18, %16, %14, %12, %10, %8
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@S_IFSOCK = global i32 0
@S_IFREG = global i32 0
@S_IFBLK = global i32 0
@S_IFDIR = global i32 0
@S_IFCHR = global i32 0
@S_IFIFO = global i32 0
define i32 @ftype(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = sext i8 %2 to i32
switch i32 %3, label %16 [
i32 115, label %4
i32 102, label %6
i32 98, label %8
i32 100, label %10
i32 99, label %12
i32 112, label %14
]
4: ; preds = %1
%5 = load i32, i32* @S_IFSOCK
br label %16
6: ; preds = %1
%7 = load i32, i32* @S_IFREG
br label %16
8: ; preds = %1
%9 = load i32, i32* @S_IFBLK
br label %16
10: ; preds = %1
%11 = load i32, i32* @S_IFDIR
br label %16
12: ; preds = %1
%13 = load i32, i32* @S_IFCHR
br label %16
14: ; preds = %1
%15 = load i32, i32* @S_IFIFO
br label %16
16: ; preds = %1, %14, %12, %10, %8, %6, %4
%17 = phi i32 [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ -1, %1 ]
ret i32 %17
}