#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*/);
scalar_t__ lstat(char const *, struct stat *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char const *);
int main(int argc, const char *argv[]) {
  int i;
  struct stat buf;
  char *ptr;
  for (i = 1; i < argc; i++) {
    printf("%s: ", argv[i]);
    if (lstat(argv[i], &buf) < 0) {
      perror("lstat");
      continue;
    }
    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 = "sockte";
    } else {
      ptr = "** unknow mode **";
    }
    printf("%s\n", ptr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1346 <main+0x1a6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe24(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <lstat@plt>
cmp    $0x0,%rax
jge    1211 <main+0x71>
lea    0xdfe(%rip),%rdi
call   10c0 <perror@plt>
jmp    1338 <main+0x198>
mov    -0x18(%rbp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%rax
je     1233 <main+0x93>
lea    0xde1(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1328 <main+0x188>
mov    -0x18(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1255 <main+0xb5>
lea    0xdc7(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1323 <main+0x183>
mov    -0x18(%rbp),%edi
call   10a0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     1277 <main+0xd7>
lea    0xdaf(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    131e <main+0x17e>
mov    -0x18(%rbp),%edi
call   10b0 <S_ISBLK@plt>
cmp    $0x0,%rax
je     1299 <main+0xf9>
lea    0xd9f(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1319 <main+0x179>
mov    -0x18(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     12bb <main+0x11b>
lea    0xd8b(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1314 <main+0x174>
mov    -0x18(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     12dd <main+0x13d>
lea    0xd6e(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    130f <main+0x16f>
mov    -0x18(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     12ff <main+0x15f>
lea    0xd5a(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    130a <main+0x16a>
lea    0xd51(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    130f <main+0x16f>
jmp    1314 <main+0x174>
jmp    1319 <main+0x179>
jmp    131e <main+0x17e>
jmp    1323 <main+0x183>
jmp    1328 <main+0x188>
mov    -0x20(%rbp),%rsi
lea    0xd36(%rip),%rdi
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11bd <main+0x1d>
xor    %eax,%eax
add    $0x20,%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     12b5 <main+0x115>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x1,%r14d
mov    %rsp,%r15
lea    0xe9f(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    (%rbx,%r14,8),%rsi
lea    0xe25(%rip),%rdi
call   1060 <printf@plt>
mov    (%rbx,%r14,8),%rdi
mov    %r15,%rsi
call   1080 <lstat@plt>
test   %rax,%rax
js     12a7 <main+0x107>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   1090 <S_ISREG@plt>
lea    0xe05(%rip),%rsi
test   %rax,%rax
jne    1290 <main+0xf0>
mov    %ebp,%edi
call   1070 <S_ISDIR@plt>
lea    0xdf6(%rip),%rsi
test   %rax,%rax
jne    1290 <main+0xf0>
mov    %ebp,%edi
call   10a0 <S_ISCHR@plt>
lea    0xded(%rip),%rsi
test   %rax,%rax
jne    1290 <main+0xf0>
mov    %ebp,%edi
call   10b0 <S_ISBLK@plt>
lea    0xdec(%rip),%rsi
test   %rax,%rax
jne    1290 <main+0xf0>
mov    %ebp,%edi
call   1040 <S_ISFIFO@plt>
lea    0xde7(%rip),%rsi
test   %rax,%rax
jne    1290 <main+0xf0>
mov    %ebp,%edi
call   1030 <S_ISLNK@plt>
lea    0xdd9(%rip),%rsi
test   %rax,%rax
jne    1290 <main+0xf0>
mov    %ebp,%edi
call   1050 <S_ISSOCK@plt>
test   %rax,%rax
lea    0xdd1(%rip),%rsi
lea    0xdd1(%rip),%rax
cmove  %rax,%rsi
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1060 <printf@plt>
add    $0x1,%r14
cmp    %r14,%r12
jne    11d0 <main+0x30>
jmp    12b5 <main+0x115>
lea    0xd57(%rip),%rdi
call   10c0 <perror@plt>
jmp    1298 <main+0xf8>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [5 x i8] c"%s: \00"
@.str.1 = [6 x i8] c"lstat\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"sockte\00"
@.str.9 = [18 x i8] c"** unknow 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 i32
%7 = alloca %struct.stat
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
br label %9
9: ; preds = %81, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %84
13: ; preds = %9
%14 = load i8**, i8*** %5
%15 = load i32, i32* %6
%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* %6
%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* %7)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %13
%28 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %81
29: ; preds = %13
%30 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%31 = load i32, i32* %30
%32 = call i64 @S_ISREG(i32 %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %29
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %8
br label %78
35: ; preds = %29
%36 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%37 = load i32, i32* %36
%38 = call i64 @S_ISDIR(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %35
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %8
br label %77
41: ; preds = %35
%42 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%43 = load i32, i32* %42
%44 = call i64 @S_ISCHR(i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %41
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8** %8
br label %76
47: ; preds = %41
%48 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%49 = load i32, i32* %48
%50 = call i64 @S_ISBLK(i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %47
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %8
br label %75
53: ; preds = %47
%54 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%55 = load i32, i32* %54
%56 = call i64 @S_ISFIFO(i32 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %53
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %8
br label %74
59: ; preds = %53
%60 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%61 = load i32, i32* %60
%62 = call i64 @S_ISLNK(i32 %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %59
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8** %8
br label %73
65: ; preds = %59
%66 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%67 = load i32, i32* %66
%68 = call i64 @S_ISSOCK(i32 %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %65
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8** %8
br label %72
71: ; preds = %65
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), i8** %8
br label %72
72: ; preds = %71, %70
br label %73
73: ; preds = %72, %64
br label %74
74: ; preds = %73, %58
br label %75
75: ; preds = %74, %52
br label %76
76: ; preds = %75, %46
br label %77
77: ; preds = %76, %40
br label %78
78: ; preds = %77, %34
%79 = load i8*, i8** %8
%80 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %79)
br label %81
81: ; preds = %78, %27
%82 = load i32, i32* %6
%83 = add nsw i32 %82, 1
store i32 %83, i32* %6
br label %9
84: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [5 x i8] c"%s: \00"
@.str.1 = [6 x i8] c"lstat\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"sockte\00"
@.str.9 = [18 x i8] c"** unknow 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 %48
6: ; preds = %2
%7 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %6, %45
%10 = phi i64 [ 1, %6 ], [ %46, %45 ]
%11 = getelementptr inbounds i8*, i8** %1, i64 %10
%12 = load i8*, i8** %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8*, i8** %11
%15 = call i64 @lstat(i8* %14, %struct.stat* %3)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %9
%18 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %45
19: ; preds = %9
%20 = load i32, i32* %7
%21 = tail call i64 @S_ISREG(i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %42
23: ; preds = %19
%24 = tail call i64 @S_ISDIR(i32 %20)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %42
26: ; preds = %23
%27 = tail call i64 @S_ISCHR(i32 %20)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %42
29: ; preds = %26
%30 = tail call i64 @S_ISBLK(i32 %20)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = tail call i64 @S_ISFIFO(i32 %20)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %42
35: ; preds = %32
%36 = tail call i64 @S_ISLNK(i32 %20)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %42
38: ; preds = %35
%39 = tail call i64 @S_ISSOCK(i32 %20)
%40 = icmp eq i64 %39, 0
%41 = select i1 %40, i8* getelementptr inbounds ([18 x i8], [18 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 %42
42: ; preds = %38, %35, %32, %29, %26, %23, %19
%43 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), %19 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), %23 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), %26 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %29 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %32 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), %35 ], [ %41, %38 ]
%44 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %43)
br label %45
45: ; preds = %42, %17
%46 = add nuw nsw i64 %10, 1
%47 = icmp eq i64 %46, %8
br i1 %47, label %48, label %9
48: ; preds = %45, %2
ret i32 0
}