#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*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ lstat(char const *, struct stat *);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ stderr;
int main(int argc, char const *argv[]) {
  struct stat buf;
  char *ptr;
  for (int i = 1; i < argc; i++) {
    printf("%s: ", argv[i]);
    if (lstat(argv[i], &buf) < 0) {
      fprintf(stderr, "lstat error\n");
      exit(1);
    }
    if (S_ISREG(buf.st_mode)) {
      ptr = "regular";
    } else if (S_ISDIR(buf.st_mode)) {
      ptr = "directory";
    } else if (S_ISCHR(buf.st_mode)) {
      ptr = "character special";
    } else if (S_ISBLK(buf.st_mode)) {
      ptr = "block special";
    } else if (S_ISFIFO(buf.st_mode)) {
      ptr = "fifo";
    } else if (S_ISLNK(buf.st_mode)) {
      ptr = "symbolic link";
    } else if (S_ISSOCK(buf.st_mode)) {
      ptr = "socket";
    } else {
      ptr = "** unknown mode **";
    }
    printf("%s\n", ptr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1364 <main+0x1b4>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe14(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <lstat@plt>
cmp    $0x0,%rax
jge    122f <main+0x7f>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
lea    0xde5(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%edi
call   10a0 <S_ISREG@plt>
cmp    $0x0,%rax
je     1251 <main+0xa1>
lea    0xdca(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1346 <main+0x196>
mov    -0x18(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1273 <main+0xc3>
lea    0xdb0(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1341 <main+0x191>
mov    -0x18(%rbp),%edi
call   10b0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     1295 <main+0xe5>
lea    0xd98(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    133c <main+0x18c>
mov    -0x18(%rbp),%edi
call   10c0 <S_ISBLK@plt>
cmp    $0x0,%rax
je     12b7 <main+0x107>
lea    0xd88(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1337 <main+0x187>
mov    -0x18(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     12d9 <main+0x129>
lea    0xd74(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1332 <main+0x182>
mov    -0x18(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     12fb <main+0x14b>
lea    0xd57(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    132d <main+0x17d>
mov    -0x18(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     131d <main+0x16d>
lea    0xd43(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1328 <main+0x178>
lea    0xd3a(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    132d <main+0x17d>
jmp    1332 <main+0x182>
jmp    1337 <main+0x187>
jmp    133c <main+0x18c>
jmp    1341 <main+0x191>
jmp    1346 <main+0x196>
mov    -0x20(%rbp),%rsi
lea    0xd20(%rip),%rdi
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11cd <main+0x1d>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     12b8 <main+0x108>
mov    %rsi,%rbx
mov    %edi,%r13d
mov    $0x1,%r14d
lea    0xe3b(%rip),%r15
lea    0xe93(%rip),%r12
jmp    11f5 <main+0x45>
mov    %r12,%rdi
call   1060 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r13
je     12b8 <main+0x108>
mov    (%rbx,%r14,8),%rsi
lea    0xe00(%rip),%rdi
call   1060 <printf@plt>
mov    (%rbx,%r14,8),%rdi
mov    %rsp,%rsi
call   1080 <lstat@plt>
test   %rax,%rax
js     12c9 <main+0x119>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   10a0 <S_ISREG@plt>
mov    %r15,%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   1070 <S_ISDIR@plt>
lea    0xde0(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   10b0 <S_ISCHR@plt>
lea    0xdd7(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   10c0 <S_ISBLK@plt>
lea    0xdd6(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   1040 <S_ISFIFO@plt>
lea    0xdcd(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   1030 <S_ISLNK@plt>
lea    0xdbb(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   1050 <S_ISSOCK@plt>
test   %rax,%rax
lea    0xdaf(%rip),%rsi
lea    0xdaf(%rip),%rax
cmove  %rax,%rsi
jmp    11e0 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
lea    0xd2c(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [5 x i8] c"%s: \00"
@stderr = global i32 0
@.str.1 = [13 x i8] c"lstat error\0A\00"
@.str.2 = [8 x i8] c"regular\00"
@.str.3 = [10 x i8] c"directory\00"
@.str.4 = [18 x i8] c"character special\00"
@.str.5 = [14 x i8] c"block special\00"
@.str.6 = [5 x i8] c"fifo\00"
@.str.7 = [14 x i8] c"symbolic link\00"
@.str.8 = [7 x i8] c"socket\00"
@.str.9 = [19 x i8] c"** unknown mode **\00"
@.str.10 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %8
br label %9
9: ; preds = %83, %2
%10 = load i32, i32* %8
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %86
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i8**, i8*** %5
%21 = load i32, i32* %8
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
%24 = load i8*, i8** %23
%25 = call i64 @lstat(i8* %24, %struct.stat* %6)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %13
%28 = load i32, i32* @stderr
%29 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %13
%32 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%33 = load i32, i32* %32
%34 = call i64 @S_ISREG(i32 %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %31
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %7
br label %80
37: ; preds = %31
%38 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%39 = load i32, i32* %38
%40 = call i64 @S_ISDIR(i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %37
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %7
br label %79
43: ; preds = %37
%44 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%45 = load i32, i32* %44
%46 = call i64 @S_ISCHR(i32 %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %43
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8** %7
br label %78
49: ; preds = %43
%50 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i64 @S_ISBLK(i32 %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %49
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %7
br label %77
55: ; preds = %49
%56 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%57 = load i32, i32* %56
%58 = call i64 @S_ISFIFO(i32 %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %55
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %7
br label %76
61: ; preds = %55
%62 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%63 = load i32, i32* %62
%64 = call i64 @S_ISLNK(i32 %63)
%65 = icmp ne i64 %64, 0
br i1 %65, label %66, label %67
66: ; preds = %61
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8** %7
br label %75
67: ; preds = %61
%68 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%69 = load i32, i32* %68
%70 = call i64 @S_ISSOCK(i32 %69)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %73
72: ; preds = %67
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8** %7
br label %74
73: ; preds = %67
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8** %7
br label %74
74: ; preds = %73, %72
br label %75
75: ; preds = %74, %66
br label %76
76: ; preds = %75, %60
br label %77
77: ; preds = %76, %54
br label %78
78: ; preds = %77, %48
br label %79
79: ; preds = %78, %42
br label %80
80: ; preds = %79, %36
%81 = load i8*, i8** %7
%82 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %81)
br label %83
83: ; preds = %80
%84 = load i32, i32* %8
%85 = add nsw i32 %84, 1
store i32 %85, i32* %8
br label %9
86: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [5 x i8] c"%s: \00"
@stderr = global i32 0
@.str.1 = [13 x i8] c"lstat error\0A\00"
@.str.2 = [8 x i8] c"regular\00"
@.str.3 = [10 x i8] c"directory\00"
@.str.4 = [18 x i8] c"character special\00"
@.str.5 = [14 x i8] c"block special\00"
@.str.6 = [5 x i8] c"fifo\00"
@.str.7 = [14 x i8] c"symbolic link\00"
@.str.8 = [7 x i8] c"socket\00"
@.str.9 = [19 x i8] c"** unknown mode **\00"
@.str.10 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%8 = zext i32 %0 to i64
br label %10
9: ; preds = %45, %2
ret i32 0
10: ; preds = %6, %45
%11 = phi i64 [ 1, %6 ], [ %48, %45 ]
%12 = getelementptr inbounds i8*, i8** %1, i64 %11
%13 = load i8*, i8** %12
%14 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %12
%16 = call i64 @lstat(i8* %15, %struct.stat* %3)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %10
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %10
%23 = load i32, i32* %7
%24 = tail call i64 @S_ISREG(i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %45
26: ; preds = %22
%27 = tail call i64 @S_ISDIR(i32 %23)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %45
29: ; preds = %26
%30 = tail call i64 @S_ISCHR(i32 %23)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %45
32: ; preds = %29
%33 = tail call i64 @S_ISBLK(i32 %23)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %45
35: ; preds = %32
%36 = tail call i64 @S_ISFIFO(i32 %23)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = tail call i64 @S_ISLNK(i32 %23)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = tail call i64 @S_ISSOCK(i32 %23)
%43 = icmp eq i64 %42, 0
%44 = select i1 %43, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0)
br label %45
45: ; preds = %41, %38, %35, %32, %29, %26, %22
%46 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %22 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %26 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), %29 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %32 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %35 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), %38 ], [ %44, %41 ]
%47 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %46)
%48 = add nuw nsw i64 %11, 1
%49 = icmp eq i64 %48, %8
br i1 %49, label %9, label %10
}