#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*/ err_ret(char *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char **argv) {
  char *p;
  struct stat buf;
  while (--argc) {
    printf("%s: ", *++argv);
    if (lstat(*argv, &buf) < 0) {
      err_ret("lstat error");
      continue;
    }
    if (S_ISDIR(buf.st_mode)) {
      p = "directory";
    } else if (S_ISREG(buf.st_mode)) {
      p = "regular file";
    } else if (S_ISCHR(buf.st_mode)) {
      p = "character special";
    } else if (S_ISBLK(buf.st_mode)) {
      p = "block special";
    } else if (S_ISFIFO(buf.st_mode)) {
      p = "FIFO";
    } else if (S_ISSOCK(buf.st_mode)) {
      p = "socket";
    } else if (S_ISLNK(buf.st_mode)) {
      p = "symbolic link";
    } else {
      p = "unknown type";
    }
    printf("%s\n", p);
  }
  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)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     133e <main+0x19e>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rsi
lea    0xe1e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <lstat@plt>
cmp    $0x0,%rax
jge    1212 <main+0x72>
lea    0xdfd(%rip),%rdi
call   10c0 <err_ret@plt>
jmp    11b6 <main+0x16>
mov    -0x20(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1234 <main+0x94>
lea    0xde6(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1329 <main+0x189>
mov    -0x20(%rbp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%rax
je     1256 <main+0xb6>
lea    0xdce(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1324 <main+0x184>
mov    -0x20(%rbp),%edi
call   10a0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     1278 <main+0xd8>
lea    0xdb9(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    131f <main+0x17f>
mov    -0x20(%rbp),%edi
call   10b0 <S_ISBLK@plt>
cmp    $0x0,%rax
je     129a <main+0xfa>
lea    0xda9(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    131a <main+0x17a>
mov    -0x20(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     12bc <main+0x11c>
lea    0xd95(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1315 <main+0x175>
mov    -0x20(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     12de <main+0x13e>
lea    0xd78(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1310 <main+0x170>
mov    -0x20(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     1300 <main+0x160>
lea    0xd5d(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    130b <main+0x16b>
lea    0xd5b(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1310 <main+0x170>
jmp    1315 <main+0x175>
jmp    131a <main+0x17a>
jmp    131f <main+0x17f>
jmp    1324 <main+0x184>
jmp    1329 <main+0x189>
mov    -0x18(%rbp),%rsi
lea    0xd3b(%rip),%rdi
call   1060 <printf@plt>
jmp    11b6 <main+0x16>
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    $0x1,%edi
je     12c1 <main+0x121>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x1,%r13d
lea    0xe39(%rip),%r14
mov    %rsp,%r15
jmp    11e9 <main+0x49>
nopl   0x0(%rax)
lea    0xe98(%rip),%rdi
call   1060 <printf@plt>
add    $0x1,%r13
cmp    %r13d,%r12d
je     12c1 <main+0x121>
mov    (%rbx,%r13,8),%rsi
mov    %r14,%rdi
call   1060 <printf@plt>
mov    (%rbx,%r13,8),%rdi
mov    %r15,%rsi
call   1080 <lstat@plt>
test   %rax,%rax
js     12b0 <main+0x110>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   1070 <S_ISDIR@plt>
lea    0xdf6(%rip),%rsi
test   %rax,%rax
jne    11d0 <main+0x30>
mov    %ebp,%edi
call   1090 <S_ISREG@plt>
lea    0xded(%rip),%rsi
test   %rax,%rax
jne    11d0 <main+0x30>
mov    %ebp,%edi
call   10a0 <S_ISCHR@plt>
lea    0xde7(%rip),%rsi
test   %rax,%rax
jne    11d0 <main+0x30>
mov    %ebp,%edi
call   10b0 <S_ISBLK@plt>
lea    0xde6(%rip),%rsi
test   %rax,%rax
jne    11d0 <main+0x30>
mov    %ebp,%edi
call   1040 <S_ISFIFO@plt>
lea    0xddd(%rip),%rsi
test   %rax,%rax
jne    11d0 <main+0x30>
mov    %ebp,%edi
call   1050 <S_ISSOCK@plt>
lea    0xdcb(%rip),%rsi
test   %rax,%rax
jne    11d0 <main+0x30>
mov    %ebp,%edi
call   1030 <S_ISLNK@plt>
test   %rax,%rax
lea    0xdb8(%rip),%rsi
lea    0xdbf(%rip),%rax
cmove  %rax,%rsi
jmp    11d0 <main+0x30>
nopl   0x0(%rax)
lea    0xd4e(%rip),%rdi
call   10c0 <err_ret@plt>
jmp    11dc <main+0x3c>
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 = [12 x i8] c"lstat error\00"
@.str.2 = [10 x i8] c"directory\00"
@.str.3 = [13 x i8] c"regular file\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 = [7 x i8] c"socket\00"
@.str.8 = [14 x i8] c"symbolic link\00"
@.str.9 = [13 x i8] c"unknown type\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 i8*
%7 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %72, %21, %2
%9 = load i32, i32* %4
%10 = add nsw i32 %9, -1
store i32 %10, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %75
12: ; preds = %8
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i32 1
store i8** %14, i8*** %5
%15 = load i8*, i8** %14
%16 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i8**, i8*** %5
%18 = load i8*, i8** %17
%19 = call i64 @lstat(i8* %18, %struct.stat* %7)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = call i32 @err_ret(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
br label %8
23: ; preds = %12
%24 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%25 = load i32, i32* %24
%26 = call i64 @S_ISDIR(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %23
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %6
br label %72
29: ; preds = %23
%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 ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %6
br label %71
35: ; preds = %29
%36 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%37 = load i32, i32* %36
%38 = call i64 @S_ISCHR(i32 %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %35
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8** %6
br label %70
41: ; preds = %35
%42 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%43 = load i32, i32* %42
%44 = call i64 @S_ISBLK(i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %41
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %6
br label %69
47: ; preds = %41
%48 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%49 = load i32, i32* %48
%50 = call i64 @S_ISFIFO(i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %47
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %6
br label %68
53: ; preds = %47
%54 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%55 = load i32, i32* %54
%56 = call i64 @S_ISSOCK(i32 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %53
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i8** %6
br label %67
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.8, i64 0, i64 0), i8** %6
br label %66
65: ; preds = %59
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8** %6
br label %66
66: ; preds = %65, %64
br label %67
67: ; preds = %66, %58
br label %68
68: ; preds = %67, %52
br label %69
69: ; preds = %68, %46
br label %70
70: ; preds = %69, %40
br label %71
71: ; preds = %70, %34
br label %72
72: ; preds = %71, %28
%73 = load i8*, i8** %6
%74 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %73)
br label %8
75: ; preds = %8
ret i32 0
}

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