#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*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int i;
  struct stat st;
  char *ptr;
  for (i = 1; i < argc; ++i) {
    fprintf(stdout, "%s: ", argv[i]);
    if (lstat(argv[i], &st) < 0) {
      fprintf(stderr, "lstat error\n");
      continue;
    }
    if (S_ISREG(st.st_mode))
      ptr = "regular";
    else if (S_ISDIR(st.st_mode))
      ptr = "directory";
    else if (S_ISCHR(st.st_mode))
      ptr = "character special";
    else if (S_ISBLK(st.st_mode))
      ptr = "block special";
    else if (S_ISFIFO(st.st_mode))
      ptr = "fifo";
    else if (S_ISLNK(st.st_mode))
      ptr = "symbolic link";
    else if (S_ISSOCK(st.st_mode))
      ptr = "socket";
    else
      ptr = "** unknown mode **";
    fprintf(stdout, "%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    1357 <main+0x1c7>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <lstat@plt>
cmp    $0x0,%rax
jge    1217 <main+0x87>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
lea    0xdfa(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1349 <main+0x1b9>
mov    -0x18(%rbp),%edi
call   1090 <S_ISREG@plt>
cmp    $0x0,%rax
je     1239 <main+0xa9>
lea    0xde2(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    132e <main+0x19e>
mov    -0x18(%rbp),%edi
call   1060 <S_ISDIR@plt>
cmp    $0x0,%rax
je     125b <main+0xcb>
lea    0xdc8(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1329 <main+0x199>
mov    -0x18(%rbp),%edi
call   10a0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     127d <main+0xed>
lea    0xdb0(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1324 <main+0x194>
mov    -0x18(%rbp),%edi
call   10b0 <S_ISBLK@plt>
cmp    $0x0,%rax
je     129f <main+0x10f>
lea    0xda0(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    131f <main+0x18f>
mov    -0x18(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     12c1 <main+0x131>
lea    0xd8c(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    131a <main+0x18a>
mov    -0x18(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     12e3 <main+0x153>
lea    0xd6f(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1315 <main+0x185>
mov    -0x18(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     1305 <main+0x175>
lea    0xd5b(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1310 <main+0x180>
lea    0xd52(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1315 <main+0x185>
jmp    131a <main+0x18a>
jmp    131f <main+0x18f>
jmp    1324 <main+0x194>
jmp    1329 <main+0x199>
jmp    132e <main+0x19e>
mov    0x2ca3(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd2f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11ad <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     12cc <main+0x13c>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x1,%r13d
mov    0x2e21(%rip),%r14
mov    %rsp,%r15
jmp    11de <main+0x4e>
nopl   0x0(%rax)
mov    (%r14),%edi
lea    0xea7(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
add    $0x1,%r13
cmp    %r13,%r12
je     12cc <main+0x13c>
mov    (%r14),%edi
mov    (%rbx,%r13,8),%rdx
lea    0xe14(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx,%r13,8),%rdi
mov    %r15,%rsi
call   1070 <lstat@plt>
test   %rax,%rax
js     12b0 <main+0x120>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   1090 <S_ISREG@plt>
lea    0xdf9(%rip),%rdx
test   %rax,%rax
jne    11c0 <main+0x30>
mov    %ebp,%edi
call   1060 <S_ISDIR@plt>
lea    0xdee(%rip),%rdx
test   %rax,%rax
jne    11c0 <main+0x30>
mov    %ebp,%edi
call   10a0 <S_ISCHR@plt>
lea    0xde5(%rip),%rdx
test   %rax,%rax
jne    11c0 <main+0x30>
mov    %ebp,%edi
call   10b0 <S_ISBLK@plt>
lea    0xde0(%rip),%rdx
test   %rax,%rax
jne    11c0 <main+0x30>
mov    %ebp,%edi
call   1040 <S_ISFIFO@plt>
lea    0xdd7(%rip),%rdx
test   %rax,%rax
jne    11c0 <main+0x30>
mov    %ebp,%edi
call   1030 <S_ISLNK@plt>
lea    0xdc5(%rip),%rdx
test   %rax,%rax
jne    11c0 <main+0x30>
mov    %ebp,%edi
call   1050 <S_ISSOCK@plt>
test   %rax,%rax
lea    0xdb9(%rip),%rdx
lea    0xdb9(%rip),%rax
cmove  %rax,%rdx
jmp    11c0 <main+0x30>
xchg   %ax,%ax
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
lea    0xd45(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    11d1 <main+0x41>
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 }
@stdout = global i32 0
@.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 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 = %84, %2
%10 = load i32, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %87
13: ; preds = %9
%14 = load i32, i32* @stdout
%15 = load i8**, i8*** %5
%16 = load i32, i32* %6
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8*, i8** %15, i64 %17
%19 = load i8*, i8** %18
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i8**, i8*** %5
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = call i64 @lstat(i8* %25, %struct.stat* %7)
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %13
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %84
31: ; preds = %13
%32 = getelementptr inbounds %struct.stat, %struct.stat* %7, 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** %8
br label %80
37: ; preds = %31
%38 = getelementptr inbounds %struct.stat, %struct.stat* %7, 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** %8
br label %79
43: ; preds = %37
%44 = getelementptr inbounds %struct.stat, %struct.stat* %7, 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** %8
br label %78
49: ; preds = %43
%50 = getelementptr inbounds %struct.stat, %struct.stat* %7, 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** %8
br label %77
55: ; preds = %49
%56 = getelementptr inbounds %struct.stat, %struct.stat* %7, 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** %8
br label %76
61: ; preds = %55
%62 = getelementptr inbounds %struct.stat, %struct.stat* %7, 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** %8
br label %75
67: ; preds = %61
%68 = getelementptr inbounds %struct.stat, %struct.stat* %7, 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** %8
br label %74
73: ; preds = %67
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8** %8
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 i32, i32* @stdout
%82 = load i8*, i8** %8
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %82)
br label %84
84: ; preds = %80, %28
%85 = load i32, i32* %6
%86 = add nsw i32 %85, 1
store i32 %86, i32* %6
br label %9
87: ; preds = %9
ret i32 0
}

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