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

/* Variables and functions */
#define S_IFBLK 134
#define S_IFCHR 133
#define S_IFDIR 132
#define S_IFIFO 131
#define S_IFLNK 130
#define S_IFREG 129
#define S_IFSOCK 128
int /*<<< orphan*/ printf(char *);
void printtype(mode_t m, int align) {
  switch (m) {
  case S_IFSOCK:
    printf("socket");
    if (align)
      printf("           ");
    break;
  case S_IFLNK:
    printf("symlink");
    if (align)
      printf("          ");
    break;
  case S_IFREG:
    printf("file");
    if (align)
      printf("             ");
    break;
  case S_IFBLK:
    printf("block device");
    if (align)
      printf("     ");
    break;
  case S_IFDIR:
    printf("directory");
    if (align)
      printf("        ");
    break;
  case S_IFCHR:
    printf("character device");
    if (align)
      printf(" ");
    break;
  case S_IFIFO:
    printf("fifo");
    if (align)
      printf("             ");
    break;
  }
}


x86 assembly (clang, -O0):
<printtype>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x6,%eax
ja     1258 <printtype+0x148>
mov    -0x10(%rbp),%rax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1169 <printtype+0x59>
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <printtype+0x148>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1190 <printtype+0x80>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <printtype+0x148>
lea    0xe8f(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11b7 <printtype+0xa7>
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <printtype+0x148>
lea    0xe7b(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11de <printtype+0xce>
lea    0xe5f(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <printtype+0x148>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1205 <printtype+0xf5>
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <printtype+0x148>
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     122c <printtype+0x11c>
lea    0xe15(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <printtype+0x148>
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1253 <printtype+0x143>
lea    0xde2(%rip),%rdi
call   1030 <printf@plt>
jmp    1258 <printtype+0x148>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printtype>:
push   %rbx
add    $0xffffff80,%edi
cmp    $0x6,%edi
ja     11f8 <printtype+0xd8>
mov    %esi,%ebx
lea    0xeca(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xed6(%rip),%rdi
call   1040 <printf@plt>
test   %ebx,%ebx
je     11f8 <printtype+0xd8>
lea    0xed8(%rip),%rdi
pop    %rbx
jmp    1040 <printf@plt>
lea    0xec4(%rip),%rdi
jmp    118d <printtype+0x6d>
lea    0xeb3(%rip),%rdi
call   1040 <printf@plt>
test   %ebx,%ebx
je     11f8 <printtype+0xd8>
lea    0xeb3(%rip),%rdi
pop    %rbx
jmp    1040 <printf@plt>
lea    0xed9(%rip),%rdi
call   1040 <printf@plt>
test   %ebx,%ebx
je     11f8 <printtype+0xd8>
lea    0xe93(%rip),%rdi
pop    %rbx
jmp    1040 <printf@plt>
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
test   %ebx,%ebx
je     11f8 <printtype+0xd8>
lea    0xe7b(%rip),%rdi
pop    %rbx
jmp    1040 <printf@plt>
lea    0xe8e(%rip),%rdi
call   1040 <printf@plt>
test   %ebx,%ebx
je     11f8 <printtype+0xd8>
mov    $0x20,%edi
pop    %rbx
jmp    1030 <putchar@plt>
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
test   %ebx,%ebx
je     11f8 <printtype+0xd8>
lea    0xe46(%rip),%rdi
pop    %rbx
jmp    1040 <printf@plt>
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"socket\00"
@.str.1 = [12 x i8] c" \00"
@.str.2 = [8 x i8] c"symlink\00"
@.str.3 = [11 x i8] c" \00"
@.str.4 = [5 x i8] c"file\00"
@.str.5 = [14 x i8] c" \00"
@.str.6 = [13 x i8] c"block device\00"
@.str.7 = [6 x i8] c" \00"
@.str.8 = [10 x i8] c"directory\00"
@.str.9 = [9 x i8] c" \00"
@.str.10 = [17 x i8] c"character device\00"
@.str.11 = [2 x i8] c" \00"
@.str.12 = [5 x i8] c"fifo\00"
define void @printtype(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
switch i32 %5, label %55 [
i32 128, label %6
i32 130, label %13
i32 129, label %20
i32 134, label %27
i32 132, label %34
i32 133, label %41
i32 131, label %48
]
6: ; preds = %2
%7 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
br label %55
13: ; preds = %2
%14 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
br label %55
20: ; preds = %2
%21 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%22 = load i32, i32* %4
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %24, %20
br label %55
27: ; preds = %2
%28 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
br label %55
34: ; preds = %2
%35 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%36 = load i32, i32* %4
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
br label %55
41: ; preds = %2
%42 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%43 = load i32, i32* %4
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %47
47: ; preds = %45, %41
br label %55
48: ; preds = %2
%49 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%50 = load i32, i32* %4
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %54
54: ; preds = %52, %48
br label %55
55: ; preds = %2, %54, %47, %40, %33, %26, %19, %12
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"socket\00"
@.str.1 = [12 x i8] c" \00"
@.str.2 = [8 x i8] c"symlink\00"
@.str.3 = [11 x i8] c" \00"
@.str.4 = [5 x i8] c"file\00"
@.str.5 = [14 x i8] c" \00"
@.str.6 = [13 x i8] c"block device\00"
@.str.7 = [6 x i8] c" \00"
@.str.8 = [10 x i8] c"directory\00"
@.str.9 = [9 x i8] c" \00"
@.str.10 = [17 x i8] c"character device\00"
@.str.12 = [5 x i8] c"fifo\00"
define void @printtype(i32 %0, i32 %1) {
switch i32 %0, label %38 [
i32 128, label %3
i32 130, label %8
i32 129, label %13
i32 134, label %18
i32 132, label %23
i32 133, label %28
i32 131, label %33
]
3: ; preds = %2
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %1, 0
br i1 %5, label %38, label %6
6: ; preds = %3
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %38
8: ; preds = %2
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32 %1, 0
br i1 %10, label %38, label %11
11: ; preds = %8
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
br label %38
13: ; preds = %2
%14 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32 %1, 0
br i1 %15, label %38, label %16
16: ; preds = %13
%17 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %38
18: ; preds = %2
%19 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%20 = icmp eq i32 %1, 0
br i1 %20, label %38, label %21
21: ; preds = %18
%22 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %38
23: ; preds = %2
%24 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0))
%25 = icmp eq i32 %1, 0
br i1 %25, label %38, label %26
26: ; preds = %23
%27 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
br label %38
28: ; preds = %2
%29 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
%30 = icmp eq i32 %1, 0
br i1 %30, label %38, label %31
31: ; preds = %28
%32 = tail call i32 @putchar(i32 32)
br label %38
33: ; preds = %2
%34 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0))
%35 = icmp eq i32 %1, 0
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %38
38: ; preds = %33, %36, %28, %31, %23, %26, %18, %21, %13, %16, %8, %11, %3, %6, %2
ret void
}