#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 */
scalar_t__ S_ISBLK(int /*<<< orphan*/);
scalar_t__ S_ISCHR(int /*<<< orphan*/);
scalar_t__ S_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISFIFO(int /*<<< orphan*/);
scalar_t__ S_ISLNK(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
scalar_t__ S_ISSOCK(int /*<<< orphan*/);
const char *inode_type(mode_t mode) {
  if (S_ISREG(mode))
    return ("file");
  if (S_ISLNK(mode))
    return ("symlink");
  if (S_ISDIR(mode))
    return ("dir");
  if (S_ISLNK(mode))
    return ("link");
  if (S_ISFIFO(mode))
    return ("fifo");
  if (S_ISSOCK(mode))
    return ("socket");
  if (S_ISCHR(mode))
    return ("char");
  if (S_ISBLK(mode))
    return ("block");
  return ("unknown");
}


x86 assembly (clang, -O0):
<inode_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <S_ISREG@plt>
cmp    $0x0,%rax
je     119d <inode_type+0x2d>
lea    0xe6c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1296 <inode_type+0x126>
mov    -0xc(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     11bf <inode_type+0x4f>
lea    0xe4f(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1296 <inode_type+0x126>
mov    -0xc(%rbp),%edi
call   1060 <S_ISDIR@plt>
cmp    $0x0,%rax
je     11e1 <inode_type+0x71>
lea    0xe35(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1296 <inode_type+0x126>
mov    -0xc(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     1203 <inode_type+0x93>
lea    0xe0e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1296 <inode_type+0x126>
mov    -0xc(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     1225 <inode_type+0xb5>
lea    0xdf5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1296 <inode_type+0x126>
mov    -0xc(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     1247 <inode_type+0xd7>
lea    0xdd8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1296 <inode_type+0x126>
mov    -0xc(%rbp),%edi
call   1080 <S_ISCHR@plt>
cmp    $0x0,%rax
je     1269 <inode_type+0xf9>
lea    0xdbd(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1296 <inode_type+0x126>
mov    -0xc(%rbp),%edi
call   1090 <S_ISBLK@plt>
cmp    $0x0,%rax
je     128b <inode_type+0x11b>
lea    0xda0(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1296 <inode_type+0x126>
lea    0xd96(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inode_type>:
push   %rbx
mov    %edi,%ebx
call   1070 <S_ISREG@plt>
test   %rax,%rax
je     1186 <inode_type+0x16>
lea    0xe7c(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1030 <S_ISLNK@plt>
test   %rax,%rax
je     119b <inode_type+0x2b>
lea    0xe6c(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1060 <S_ISDIR@plt>
test   %rax,%rax
je     11b0 <inode_type+0x40>
lea    0xe5f(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1030 <S_ISLNK@plt>
test   %rax,%rax
je     11c5 <inode_type+0x55>
lea    0xe45(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1040 <S_ISFIFO@plt>
test   %rax,%rax
je     11da <inode_type+0x6a>
lea    0xe39(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1050 <S_ISSOCK@plt>
test   %rax,%rax
je     11ef <inode_type+0x7f>
lea    0xe29(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1080 <S_ISCHR@plt>
test   %rax,%rax
je     1204 <inode_type+0x94>
lea    0xe1b(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1090 <S_ISBLK@plt>
test   %rax,%rax
lea    0xe13(%rip),%rcx
lea    0xe06(%rip),%rax
cmove  %rcx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"file\00"
@.str.1 = [8 x i8] c"symlink\00"
@.str.2 = [4 x i8] c"dir\00"
@.str.3 = [5 x i8] c"link\00"
@.str.4 = [5 x i8] c"fifo\00"
@.str.5 = [7 x i8] c"socket\00"
@.str.6 = [5 x i8] c"char\00"
@.str.7 = [6 x i8] c"block\00"
@.str.8 = [8 x i8] c"unknown\00"
define i8* @inode_type(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = call i64 @S_ISREG(i32 %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %2
br label %44
8: ; preds = %1
%9 = load i32, i32* %3
%10 = call i64 @S_ISLNK(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %44
13: ; preds = %8
%14 = load i32, i32* %3
%15 = call i64 @S_ISDIR(i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %44
18: ; preds = %13
%19 = load i32, i32* %3
%20 = call i64 @S_ISLNK(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %44
23: ; preds = %18
%24 = load i32, i32* %3
%25 = call i64 @S_ISFIFO(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %44
28: ; preds = %23
%29 = load i32, i32* %3
%30 = call i64 @S_ISSOCK(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %44
33: ; preds = %28
%34 = load i32, i32* %3
%35 = call i64 @S_ISCHR(i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %44
38: ; preds = %33
%39 = load i32, i32* %3
%40 = call i64 @S_ISBLK(i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %44
43: ; preds = %38
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8** %2
br label %44
44: ; preds = %43, %42, %37, %32, %27, %22, %17, %12, %7
%45 = load i8*, i8** %2
ret i8* %45
}

LLVM IR (-O2):
@.str = [5 x i8] c"file\00"
@.str.1 = [8 x i8] c"symlink\00"
@.str.2 = [4 x i8] c"dir\00"
@.str.3 = [5 x i8] c"link\00"
@.str.4 = [5 x i8] c"fifo\00"
@.str.5 = [7 x i8] c"socket\00"
@.str.6 = [5 x i8] c"char\00"
@.str.7 = [6 x i8] c"block\00"
@.str.8 = [8 x i8] c"unknown\00"
define i8* @inode_type(i32 %0) {
%2 = tail call i64 @S_ISREG(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %26
4: ; preds = %1
%5 = tail call i64 @S_ISLNK(i32 %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %26
7: ; preds = %4
%8 = tail call i64 @S_ISDIR(i32 %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %26
10: ; preds = %7
%11 = tail call i64 @S_ISLNK(i32 %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %26
13: ; preds = %10
%14 = tail call i64 @S_ISFIFO(i32 %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = tail call i64 @S_ISSOCK(i32 %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %16
%20 = tail call i64 @S_ISCHR(i32 %0)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = tail call i64 @S_ISBLK(i32 %0)
%24 = icmp eq i64 %23, 0
%25 = select i1 %24, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0)
br label %26
26: ; preds = %22, %19, %16, %13, %10, %7, %4, %1
%27 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %13 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %16 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %19 ], [ %25, %22 ]
ret i8* %27
}