#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*/ S_ISBLK(int);
int /*<<< orphan*/ S_ISCHR(int);
int S_ISDIR(int);
int /*<<< orphan*/ S_ISFIFO(int);
int S_ISLNK(int);
int S_ISREG(int);
int /*<<< orphan*/ S_ISSOCK(int);
int file_type_match(int st_mode, int type) {
  switch (type) {
  case 1:
    return S_ISDIR(st_mode);
  case 2:
    return S_ISREG(st_mode);
  case 4:
    return S_ISREG(st_mode) || S_ISDIR(st_mode) || S_ISCHR(st_mode) ||
           S_ISBLK(st_mode) || S_ISFIFO(st_mode) || S_ISSOCK(st_mode);
  case 5:
    return S_ISLNK(st_mode);
  case 3:
  default:
    return 1;
  }
}


x86 assembly (clang, -O0):
<file_type_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x4,%eax
ja     1275 <file_type_match+0x105>
mov    -0x18(%rbp),%rax
lea    0xe62(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
call   1060 <S_ISDIR@plt>
mov    %eax,-0x4(%rbp)
jmp    127c <file_type_match+0x10c>
mov    -0x8(%rbp),%edi
call   1070 <S_ISREG@plt>
mov    %eax,-0x4(%rbp)
jmp    127c <file_type_match+0x10c>
mov    -0x8(%rbp),%edi
call   1070 <S_ISREG@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    1250 <file_type_match+0xe0>
mov    -0x8(%rbp),%edi
call   1060 <S_ISDIR@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    1250 <file_type_match+0xe0>
mov    -0x8(%rbp),%edi
call   1080 <S_ISCHR@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    1250 <file_type_match+0xe0>
mov    -0x8(%rbp),%edi
call   1090 <S_ISBLK@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    1250 <file_type_match+0xe0>
mov    -0x8(%rbp),%edi
call   1040 <S_ISFIFO@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
jne    1250 <file_type_match+0xe0>
mov    -0x8(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    127c <file_type_match+0x10c>
mov    -0x8(%rbp),%edi
call   1030 <S_ISLNK@plt>
mov    %eax,-0x4(%rbp)
jmp    127c <file_type_match+0x10c>
jmp    1275 <file_type_match+0x105>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_type_match>:
push   %rbp
push   %rbx
push   %rax
mov    $0x1,%ebx
add    $0xffffffff,%esi
cmp    $0x4,%esi
ja     11f1 <file_type_match+0x81>
mov    %edi,%ebp
lea    0xe77(%rip),%rax
movslq (%rax,%rsi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1060 <S_ISDIR@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <S_ISREG@plt>
mov    %ebp,%edi
call   1070 <S_ISREG@plt>
test   %eax,%eax
jne    11f1 <file_type_match+0x81>
mov    %ebp,%edi
call   1060 <S_ISDIR@plt>
test   %eax,%eax
jne    11f1 <file_type_match+0x81>
mov    %ebp,%edi
call   1080 <S_ISCHR@plt>
test   %eax,%eax
jne    11f1 <file_type_match+0x81>
mov    %ebp,%edi
call   1090 <S_ISBLK@plt>
test   %eax,%eax
jne    11f1 <file_type_match+0x81>
mov    %ebp,%edi
call   1040 <S_ISFIFO@plt>
test   %eax,%eax
jne    11f1 <file_type_match+0x81>
mov    %ebp,%edi
call   1050 <S_ISSOCK@plt>
xor    %ebx,%ebx
test   %eax,%eax
setne  %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <S_ISLNK@plt>

LLVM IR (-O0):
define i32 @file_type_match(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %44 [
i32 1, label %7
i32 2, label %10
i32 4, label %13
i32 5, label %40
i32 3, label %43
]
7: ; preds = %2
%8 = load i32, i32* %4
%9 = call i32 @S_ISDIR(i32 %8)
store i32 %9, i32* %3
br label %45
10: ; preds = %2
%11 = load i32, i32* %4
%12 = call i32 @S_ISREG(i32 %11)
store i32 %12, i32* %3
br label %45
13: ; preds = %2
%14 = load i32, i32* %4
%15 = call i32 @S_ISREG(i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %37, label %17
17: ; preds = %13
%18 = load i32, i32* %4
%19 = call i32 @S_ISDIR(i32 %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %37, label %21
21: ; preds = %17
%22 = load i32, i32* %4
%23 = call i32 @S_ISCHR(i32 %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %37, label %25
25: ; preds = %21
%26 = load i32, i32* %4
%27 = call i32 @S_ISBLK(i32 %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %37, label %29
29: ; preds = %25
%30 = load i32, i32* %4
%31 = call i32 @S_ISFIFO(i32 %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %29
%34 = load i32, i32* %4
%35 = call i32 @S_ISSOCK(i32 %34)
%36 = icmp ne i32 %35, 0
br label %37
37: ; preds = %33, %29, %25, %21, %17, %13
%38 = phi i1 [ true, %29 ], [ true, %25 ], [ true, %21 ], [ true, %17 ], [ true, %13 ], [ %36, %33 ]
%39 = zext i1 %38 to i32
store i32 %39, i32* %3
br label %45
40: ; preds = %2
%41 = load i32, i32* %4
%42 = call i32 @S_ISLNK(i32 %41)
store i32 %42, i32* %3
br label %45
43: ; preds = %2
br label %44
44: ; preds = %2, %43
store i32 1, i32* %3
br label %45
45: ; preds = %44, %40, %37, %10, %7
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
define i32 @file_type_match(i32 %0, i32 %1) {
switch i32 %1, label %28 [
i32 1, label %3
i32 2, label %5
i32 4, label %7
i32 5, label %26
]
3: ; preds = %2
%4 = tail call i32 @S_ISDIR(i32 %0)
br label %28
5: ; preds = %2
%6 = tail call i32 @S_ISREG(i32 %0)
br label %28
7: ; preds = %2
%8 = tail call i32 @S_ISREG(i32 %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %28
10: ; preds = %7
%11 = tail call i32 @S_ISDIR(i32 %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %10
%14 = tail call i32 @S_ISCHR(i32 %0)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = tail call i32 @S_ISBLK(i32 %0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = tail call i32 @S_ISFIFO(i32 %0)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = tail call i32 @S_ISSOCK(i32 %0)
%24 = icmp ne i32 %23, 0
%25 = zext i1 %24 to i32
br label %28
26: ; preds = %2
%27 = tail call i32 @S_ISLNK(i32 %0)
br label %28
28: ; preds = %2, %7, %10, %13, %16, %19, %22, %26, %5, %3
%29 = phi i32 [ %27, %26 ], [ %6, %5 ], [ %4, %3 ], [ 1, %19 ], [ 1, %16 ], [ 1, %13 ], [ 1, %10 ], [ 1, %7 ], [ %25, %22 ], [ 1, %2 ]
ret i32 %29
}