#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 *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ stat(char *, struct stat *);
int main(int argc, char **argv) {
  char *p;
  struct stat buf;
  while (--argc) {
    printf("%s: ", *++argv);
    if (stat(*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 <stat@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     12d1 <main+0x131>
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r12d
lea    0xe3a(%rip),%r14
mov    %rsp,%r15
lea    0xe9f(%rip),%r13
jmp    11f5 <main+0x55>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
call   1060 <printf@plt>
add    $0x1,%r12
cmp    %r12d,%ebp
je     12d1 <main+0x131>
mov    (%rbx,%r12,8),%rsi
mov    %r14,%rdi
call   1060 <printf@plt>
mov    (%rbx,%r12,8),%rdi
mov    %r15,%rsi
call   1080 <stat@plt>
test   %rax,%rax
js     12c0 <main+0x120>
mov    (%rsp),%edi
call   1070 <S_ISDIR@plt>
lea    0xdec(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x40>
mov    (%rsp),%edi
call   1090 <S_ISREG@plt>
lea    0xde2(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x40>
mov    (%rsp),%edi
call   10a0 <S_ISCHR@plt>
lea    0xddb(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x40>
mov    (%rsp),%edi
call   10b0 <S_ISBLK@plt>
lea    0xdd9(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x40>
mov    (%rsp),%edi
call   1040 <S_ISFIFO@plt>
lea    0xdcf(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x40>
mov    (%rsp),%edi
call   1050 <S_ISSOCK@plt>
lea    0xdbc(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x40>
mov    (%rsp),%edi
call   1030 <S_ISLNK@plt>
test   %rax,%rax
lea    0xda8(%rip),%rsi
lea    0xdaf(%rip),%rax
cmove  %rax,%rsi
jmp    11e0 <main+0x40>
nopl   0x0(%rax)
lea    0xd3e(%rip),%rdi
call   10c0 <err_ret@plt>
jmp    11e8 <main+0x48>
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 @stat(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 %55, 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 = 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 @stat(i8* %15, %struct.stat* %3)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %9
%19 = 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, %52
%21 = add nsw i32 %10, -1
%22 = icmp eq i32 %21, 0
br i1 %22, label %55, label %9
23: ; preds = %9
%24 = load i32, i32* %8
%25 = call i64 @S_ISDIR(i32 %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %52
27: ; preds = %23
%28 = load i32, i32* %8
%29 = call i64 @S_ISREG(i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %52
31: ; preds = %27
%32 = load i32, i32* %8
%33 = call i64 @S_ISCHR(i32 %32)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %52
35: ; preds = %31
%36 = load i32, i32* %8
%37 = call i64 @S_ISBLK(i32 %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %52
39: ; preds = %35
%40 = load i32, i32* %8
%41 = call i64 @S_ISFIFO(i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %52
43: ; preds = %39
%44 = load i32, i32* %8
%45 = call i64 @S_ISSOCK(i32 %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i32, i32* %8
%49 = call i64 @S_ISLNK(i32 %48)
%50 = icmp eq i64 %49, 0
%51 = select i1 %50, 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 %52
52: ; preds = %47, %43, %39, %35, %31, %27, %23
%53 = 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), %31 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), %35 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), %39 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), %43 ], [ %51, %47 ]
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %53)
br label %20
55: ; preds = %20, %2
ret i32 0
}