#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 */
scalar_t__ S_ISBLK(int);
scalar_t__ S_ISCHR(int);
scalar_t__ S_ISDIR(int);
scalar_t__ S_ISFIFO(int);
scalar_t__ S_ISLNK(int);
scalar_t__ S_ISREG(int);
scalar_t__ S_ISSOCK(int);
char get_filetype_letter(int mode) {
  char letter;
  if (S_ISREG(mode)) {
    letter = '-';
  } else if (S_ISDIR(mode)) {
    letter = 'd';
  } else if (S_ISBLK(mode)) {
    letter = 'b';
  } else if (S_ISCHR(mode)) {
    letter = 'c';
  } else if (S_ISFIFO(mode)) {
    letter = 'p';
  } else if (S_ISLNK(mode)) {
    letter = 'l';
  } else if (S_ISSOCK(mode)) {
    letter = 's';
  } else {
    letter = '?';
  }
  return letter;
}


x86 assembly (clang, -O0):
<get_filetype_letter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1070 <S_ISREG@plt>
cmp    $0x0,%rax
je     1196 <get_filetype_letter+0x26>
movb   $0x2d,-0x5(%rbp)
jmp    125a <get_filetype_letter+0xea>
mov    -0x4(%rbp),%edi
call   1060 <S_ISDIR@plt>
cmp    $0x0,%rax
je     11b1 <get_filetype_letter+0x41>
movb   $0x64,-0x5(%rbp)
jmp    1255 <get_filetype_letter+0xe5>
mov    -0x4(%rbp),%edi
call   1090 <S_ISBLK@plt>
cmp    $0x0,%rax
je     11cc <get_filetype_letter+0x5c>
movb   $0x62,-0x5(%rbp)
jmp    1250 <get_filetype_letter+0xe0>
mov    -0x4(%rbp),%edi
call   1080 <S_ISCHR@plt>
cmp    $0x0,%rax
je     11e7 <get_filetype_letter+0x77>
movb   $0x63,-0x5(%rbp)
jmp    124b <get_filetype_letter+0xdb>
mov    -0x4(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     1202 <get_filetype_letter+0x92>
movb   $0x70,-0x5(%rbp)
jmp    1246 <get_filetype_letter+0xd6>
mov    -0x4(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     121d <get_filetype_letter+0xad>
movb   $0x6c,-0x5(%rbp)
jmp    1241 <get_filetype_letter+0xd1>
mov    -0x4(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     1238 <get_filetype_letter+0xc8>
movb   $0x73,-0x5(%rbp)
jmp    123c <get_filetype_letter+0xcc>
movb   $0x3f,-0x5(%rbp)
jmp    1241 <get_filetype_letter+0xd1>
jmp    1246 <get_filetype_letter+0xd6>
jmp    124b <get_filetype_letter+0xdb>
jmp    1250 <get_filetype_letter+0xe0>
jmp    1255 <get_filetype_letter+0xe5>
jmp    125a <get_filetype_letter+0xea>
movsbl -0x5(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_filetype_letter>:
push   %rbx
mov    %edi,%ebx
call   1070 <S_ISREG@plt>
mov    %rax,%rcx
mov    $0x2d,%al
test   %rcx,%rcx
je     1184 <get_filetype_letter+0x14>
pop    %rbx
ret
mov    %ebx,%edi
call   1060 <S_ISDIR@plt>
mov    %rax,%rcx
mov    $0x64,%al
test   %rcx,%rcx
jne    1182 <get_filetype_letter+0x12>
mov    %ebx,%edi
call   1090 <S_ISBLK@plt>
mov    %rax,%rcx
mov    $0x62,%al
test   %rcx,%rcx
jne    1182 <get_filetype_letter+0x12>
mov    %ebx,%edi
call   1080 <S_ISCHR@plt>
mov    %rax,%rcx
mov    $0x63,%al
test   %rcx,%rcx
jne    1182 <get_filetype_letter+0x12>
mov    %ebx,%edi
call   1040 <S_ISFIFO@plt>
mov    %rax,%rcx
mov    $0x70,%al
test   %rcx,%rcx
jne    1182 <get_filetype_letter+0x12>
mov    %ebx,%edi
call   1030 <S_ISLNK@plt>
mov    %rax,%rcx
mov    $0x6c,%al
test   %rcx,%rcx
jne    1182 <get_filetype_letter+0x12>
mov    %ebx,%edi
call   1050 <S_ISSOCK@plt>
test   %rax,%rax
mov    $0x3f,%ecx
mov    $0x73,%eax
cmove  %ecx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define signext i8 @get_filetype_letter(i32 %0) {
%2 = alloca i32
%3 = alloca i8
store i32 %0, i32* %2
%4 = load i32, i32* %2
%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 45, i8* %3
br label %45
8: ; preds = %1
%9 = load i32, i32* %2
%10 = call i64 @S_ISDIR(i32 %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i8 100, i8* %3
br label %44
13: ; preds = %8
%14 = load i32, i32* %2
%15 = call i64 @S_ISBLK(i32 %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8 98, i8* %3
br label %43
18: ; preds = %13
%19 = load i32, i32* %2
%20 = call i64 @S_ISCHR(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8 99, i8* %3
br label %42
23: ; preds = %18
%24 = load i32, i32* %2
%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 112, i8* %3
br label %41
28: ; preds = %23
%29 = load i32, i32* %2
%30 = call i64 @S_ISLNK(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i8 108, i8* %3
br label %40
33: ; preds = %28
%34 = load i32, i32* %2
%35 = call i64 @S_ISSOCK(i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i8 115, i8* %3
br label %39
38: ; preds = %33
store i8 63, i8* %3
br label %39
39: ; preds = %38, %37
br label %40
40: ; preds = %39, %32
br label %41
41: ; preds = %40, %27
br label %42
42: ; preds = %41, %22
br label %43
43: ; preds = %42, %17
br label %44
44: ; preds = %43, %12
br label %45
45: ; preds = %44, %7
%46 = load i8, i8* %3
ret i8 %46
}

LLVM IR (-O2):
define signext i8 @get_filetype_letter(i32 %0) {
%2 = tail call i64 @S_ISREG(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %23
4: ; preds = %1
%5 = tail call i64 @S_ISDIR(i32 %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = tail call i64 @S_ISBLK(i32 %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = tail call i64 @S_ISCHR(i32 %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = tail call i64 @S_ISFIFO(i32 %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = tail call i64 @S_ISLNK(i32 %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = tail call i64 @S_ISSOCK(i32 %0)
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8 63, i8 115
br label %23
23: ; preds = %19, %16, %13, %10, %7, %4, %1
%24 = phi i8 [ 45, %1 ], [ 100, %4 ], [ 98, %7 ], [ 99, %10 ], [ 112, %13 ], [ 108, %16 ], [ %22, %19 ]
ret i8 %24
}