#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*/ mode_t;

/* Variables and functions */
int S_ISBLK(int /*<<< orphan*/);
int S_ISCHR(int /*<<< orphan*/);
int S_ISDIR(int /*<<< orphan*/);
int S_ISFIFO(int /*<<< orphan*/);
int S_ISLNK(int /*<<< orphan*/);
int S_ISREG(int /*<<< orphan*/);
int S_ISSOCK(int /*<<< orphan*/);
bool compare_type(mode_t mode, char type) {
  switch (type) {
  case '\0':
    return true;
  case 'f':
    return S_ISREG(mode);
  case 'd':
    return S_ISDIR(mode);
  case 'c':
    return S_ISCHR(mode);
  case 'b':
    return S_ISBLK(mode);
  case 'p':
    return S_ISFIFO(mode);
  case 'l':
    return S_ISLNK(mode);
  case 's':
    return S_ISSOCK(mode);
  default:
    return false;
  }
}


x86 assembly (clang, -O0):
<compare_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
mov    %eax,-0x10(%rbp)
test   %eax,%eax
je     120c <compare_type+0x9c>
jmp    1195 <compare_type+0x25>
mov    -0x10(%rbp),%eax
sub    $0x62,%eax
je     1248 <compare_type+0xd8>
jmp    11a6 <compare_type+0x36>
mov    -0x10(%rbp),%eax
sub    $0x63,%eax
je     1238 <compare_type+0xc8>
jmp    11b7 <compare_type+0x47>
mov    -0x10(%rbp),%eax
sub    $0x64,%eax
je     1228 <compare_type+0xb8>
jmp    11c8 <compare_type+0x58>
mov    -0x10(%rbp),%eax
sub    $0x66,%eax
je     1218 <compare_type+0xa8>
jmp    11d9 <compare_type+0x69>
mov    -0x10(%rbp),%eax
sub    $0x6c,%eax
je     1268 <compare_type+0xf8>
jmp    11ea <compare_type+0x7a>
mov    -0x10(%rbp),%eax
sub    $0x70,%eax
je     1258 <compare_type+0xe8>
jmp    11fb <compare_type+0x8b>
mov    -0x10(%rbp),%eax
sub    $0x73,%eax
je     1278 <compare_type+0x108>
jmp    1288 <compare_type+0x118>
movl   $0x1,-0x4(%rbp)
jmp    128f <compare_type+0x11f>
mov    -0x8(%rbp),%edi
call   1070 <S_ISREG@plt>
mov    %eax,-0x4(%rbp)
jmp    128f <compare_type+0x11f>
mov    -0x8(%rbp),%edi
call   1060 <S_ISDIR@plt>
mov    %eax,-0x4(%rbp)
jmp    128f <compare_type+0x11f>
mov    -0x8(%rbp),%edi
call   1080 <S_ISCHR@plt>
mov    %eax,-0x4(%rbp)
jmp    128f <compare_type+0x11f>
mov    -0x8(%rbp),%edi
call   1090 <S_ISBLK@plt>
mov    %eax,-0x4(%rbp)
jmp    128f <compare_type+0x11f>
mov    -0x8(%rbp),%edi
call   1040 <S_ISFIFO@plt>
mov    %eax,-0x4(%rbp)
jmp    128f <compare_type+0x11f>
mov    -0x8(%rbp),%edi
call   1030 <S_ISLNK@plt>
mov    %eax,-0x4(%rbp)
jmp    128f <compare_type+0x11f>
mov    -0x8(%rbp),%edi
call   1050 <S_ISSOCK@plt>
mov    %eax,-0x4(%rbp)
jmp    128f <compare_type+0x11f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compare_type>:
lea    -0x62(%rsi),%eax
cmp    $0x11,%eax
ja     118d <compare_type+0x1d>
lea    0xe81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    1090 <S_ISBLK@plt>
mov    $0x1,%eax
test   %esi,%esi
je     1198 <compare_type+0x28>
xor    %eax,%eax
ret
jmp    1080 <S_ISCHR@plt>
jmp    1060 <S_ISDIR@plt>
jmp    1070 <S_ISREG@plt>
jmp    1030 <S_ISLNK@plt>
jmp    1050 <S_ISSOCK@plt>
jmp    1040 <S_ISFIFO@plt>

LLVM IR (-O0):
define i32 @compare_type(i32 %0, i8 signext %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
store i32 %0, i32* %4
store i8 %1, i8* %5
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %30 [
i32 0, label %8
i32 102, label %9
i32 100, label %12
i32 99, label %15
i32 98, label %18
i32 112, label %21
i32 108, label %24
i32 115, label %27
]
8: ; preds = %2
store i32 1, i32* %3
br label %31
9: ; preds = %2
%10 = load i32, i32* %4
%11 = call i32 @S_ISREG(i32 %10)
store i32 %11, i32* %3
br label %31
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call i32 @S_ISDIR(i32 %13)
store i32 %14, i32* %3
br label %31
15: ; preds = %2
%16 = load i32, i32* %4
%17 = call i32 @S_ISCHR(i32 %16)
store i32 %17, i32* %3
br label %31
18: ; preds = %2
%19 = load i32, i32* %4
%20 = call i32 @S_ISBLK(i32 %19)
store i32 %20, i32* %3
br label %31
21: ; preds = %2
%22 = load i32, i32* %4
%23 = call i32 @S_ISFIFO(i32 %22)
store i32 %23, i32* %3
br label %31
24: ; preds = %2
%25 = load i32, i32* %4
%26 = call i32 @S_ISLNK(i32 %25)
store i32 %26, i32* %3
br label %31
27: ; preds = %2
%28 = load i32, i32* %4
%29 = call i32 @S_ISSOCK(i32 %28)
store i32 %29, i32* %3
br label %31
30: ; preds = %2
store i32 0, i32* %3
br label %31
31: ; preds = %30, %27, %24, %21, %18, %15, %12, %9, %8
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @compare_type(i32 %0, i8 signext %1) {
%3 = sext i8 %1 to i32
switch i32 %3, label %18 [
i32 0, label %19
i32 102, label %4
i32 100, label %6
i32 99, label %8
i32 98, label %10
i32 112, label %12
i32 108, label %14
i32 115, label %16
]
4: ; preds = %2
%5 = tail call i32 @S_ISREG(i32 %0)
br label %19
6: ; preds = %2
%7 = tail call i32 @S_ISDIR(i32 %0)
br label %19
8: ; preds = %2
%9 = tail call i32 @S_ISCHR(i32 %0)
br label %19
10: ; preds = %2
%11 = tail call i32 @S_ISBLK(i32 %0)
br label %19
12: ; preds = %2
%13 = tail call i32 @S_ISFIFO(i32 %0)
br label %19
14: ; preds = %2
%15 = tail call i32 @S_ISLNK(i32 %0)
br label %19
16: ; preds = %2
%17 = tail call i32 @S_ISSOCK(i32 %0)
br label %19
18: ; preds = %2
br label %19
19: ; preds = %2, %18, %16, %14, %12, %10, %8, %6, %4
%20 = phi i32 [ 0, %18 ], [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ], [ 1, %2 ]
ret i32 %20
}