#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 */
struct stat {
  int /*<<< orphan*/ st_mode;
};

/* 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*/);
char *byMacro(struct stat buf) {
  char *fileType;
  if (S_ISREG(buf.st_mode)) {
    fileType = "regular";
  } else if (S_ISDIR(buf.st_mode)) {
    fileType = "directory";
  } else if (S_ISCHR(buf.st_mode)) {
    fileType = "character special";
  } else if (S_ISBLK(buf.st_mode)) {
    fileType = "block special";
  } else if (S_ISFIFO(buf.st_mode)) {
    fileType = "fifo";
  } else if (S_ISLNK(buf.st_mode)) {
    fileType = "symbolic link";
  } else if (S_ISSOCK(buf.st_mode)) {
    fileType = "socket";
  }
  return fileType;
}


x86 assembly (clang, -O0):
<byMacro>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <S_ISREG@plt>
cmp    $0x0,%rax
je     119d <byMacro+0x2d>
lea    0xe6c(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1282 <byMacro+0x112>
mov    -0x8(%rbp),%edi
call   1060 <S_ISDIR@plt>
cmp    $0x0,%rax
je     11bf <byMacro+0x4f>
lea    0xe52(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    127d <byMacro+0x10d>
mov    -0x8(%rbp),%edi
call   1080 <S_ISCHR@plt>
cmp    $0x0,%rax
je     11e1 <byMacro+0x71>
lea    0xe3a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1278 <byMacro+0x108>
mov    -0x8(%rbp),%edi
call   1090 <S_ISBLK@plt>
cmp    $0x0,%rax
je     1203 <byMacro+0x93>
lea    0xe2a(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1273 <byMacro+0x103>
mov    -0x8(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     1225 <byMacro+0xb5>
lea    0xe16(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    126e <byMacro+0xfe>
mov    -0x8(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     1247 <byMacro+0xd7>
lea    0xdf9(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1269 <byMacro+0xf9>
mov    -0x8(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     1264 <byMacro+0xf4>
lea    0xde5(%rip),%rax
mov    %rax,-0x10(%rbp)
jmp    1269 <byMacro+0xf9>
jmp    126e <byMacro+0xfe>
jmp    1273 <byMacro+0x103>
jmp    1278 <byMacro+0x108>
jmp    127d <byMacro+0x10d>
jmp    1282 <byMacro+0x112>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<byMacro>:
push   %rbx
mov    %edi,%ebx
call   1070 <S_ISREG@plt>
test   %rax,%rax
je     1186 <byMacro+0x16>
lea    0xe7c(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1060 <S_ISDIR@plt>
test   %rax,%rax
je     119b <byMacro+0x2b>
lea    0xe6f(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1080 <S_ISCHR@plt>
test   %rax,%rax
je     11b0 <byMacro+0x40>
lea    0xe64(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1090 <S_ISBLK@plt>
test   %rax,%rax
je     11c5 <byMacro+0x55>
lea    0xe61(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1040 <S_ISFIFO@plt>
test   %rax,%rax
je     11da <byMacro+0x6a>
lea    0xe5a(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1030 <S_ISLNK@plt>
test   %rax,%rax
je     11ef <byMacro+0x7f>
lea    0xe4a(%rip),%rax
pop    %rbx
ret
mov    %ebx,%edi
call   1050 <S_ISSOCK@plt>
lea    0xe48(%rip),%rax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [8 x i8] c"regular\00"
@.str.1 = [10 x i8] c"directory\00"
@.str.2 = [18 x i8] c"character special\00"
@.str.3 = [14 x i8] c"block special\00"
@.str.4 = [5 x i8] c"fifo\00"
@.str.5 = [14 x i8] c"symbolic link\00"
@.str.6 = [7 x i8] c"socket\00"
define i8* @byMacro(i32 %0) {
%2 = tail call i64 @S_ISREG(i32 %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %21
4: ; preds = %1
%5 = tail call i64 @S_ISDIR(i32 %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %21
7: ; preds = %4
%8 = tail call i64 @S_ISCHR(i32 %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = tail call i64 @S_ISBLK(i32 %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %10
%14 = tail call i64 @S_ISFIFO(i32 %0)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = tail call i64 @S_ISLNK(i32 %0)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i64 @S_ISSOCK(i32 %0)
br label %21
21: ; preds = %19, %16, %13, %10, %7, %4, %1
%22 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([14 x i8], [14 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 ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %16 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), %19 ]
ret i8* %22
}