#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*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int main(int argc, 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) {
      fprintf(stderr, "Can't stat: %s\n", strerror(errno));
      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 = "socket";
    else
      ptr = "** unknown mode **";
    printf("%s\n", ptr);
  }
  exit(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,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1386 <main+0x1c6>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe04(%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    1251 <main+0x91>
mov    0x2db9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xdbe(%rip),%rsi
call   1090 <fprintf@plt>
jmp    1378 <main+0x1b8>
mov    -0x18(%rbp),%edi
call   10a0 <S_ISREG@plt>
cmp    $0x0,%rax
je     1273 <main+0xb3>
lea    0xdab(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1368 <main+0x1a8>
mov    -0x18(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     1295 <main+0xd5>
lea    0xd91(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1363 <main+0x1a3>
mov    -0x18(%rbp),%edi
call   10b0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     12b7 <main+0xf7>
lea    0xd79(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    135e <main+0x19e>
mov    -0x18(%rbp),%edi
call   10c0 <S_ISBLK@plt>
cmp    $0x0,%rax
je     12d9 <main+0x119>
lea    0xd69(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1359 <main+0x199>
mov    -0x18(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     12fb <main+0x13b>
lea    0xd55(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    1354 <main+0x194>
mov    -0x18(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     131d <main+0x15d>
lea    0xd38(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    134f <main+0x18f>
mov    -0x18(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     133f <main+0x17f>
lea    0xd24(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    134a <main+0x18a>
lea    0xd1b(%rip),%rax
mov    %rax,-0x20(%rbp)
jmp    134f <main+0x18f>
jmp    1354 <main+0x194>
jmp    1359 <main+0x199>
jmp    135e <main+0x19e>
jmp    1363 <main+0x1a3>
jmp    1368 <main+0x1a8>
mov    -0x20(%rbp),%rsi
lea    0xc9e(%rip),%rdi
call   1060 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11dd <main+0x1d>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jl     12fd <main+0x13d>
mov    %rsi,%rbx
mov    %edi,%r12d
mov    $0x1,%r13d
lea    0xe19(%rip),%r14
mov    %rsp,%r15
jmp    1209 <main+0x49>
nopl   0x0(%rax)
lea    0xe1a(%rip),%rdi
call   1060 <printf@plt>
add    $0x1,%r13
cmp    %r13,%r12
je     12fd <main+0x13d>
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     12d0 <main+0x110>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   10a0 <S_ISREG@plt>
lea    0xdda(%rip),%rsi
test   %rax,%rax
jne    11f0 <main+0x30>
mov    %ebp,%edi
call   1070 <S_ISDIR@plt>
lea    0xdcf(%rip),%rsi
test   %rax,%rax
jne    11f0 <main+0x30>
mov    %ebp,%edi
call   10b0 <S_ISCHR@plt>
lea    0xdc6(%rip),%rsi
test   %rax,%rax
jne    11f0 <main+0x30>
mov    %ebp,%edi
call   10c0 <S_ISBLK@plt>
lea    0xdc5(%rip),%rsi
test   %rax,%rax
jne    11f0 <main+0x30>
mov    %ebp,%edi
call   1040 <S_ISFIFO@plt>
lea    0xdbc(%rip),%rsi
test   %rax,%rax
jne    11f0 <main+0x30>
mov    %ebp,%edi
call   1030 <S_ISLNK@plt>
lea    0xdaa(%rip),%rsi
test   %rax,%rax
jne    11f0 <main+0x30>
mov    %ebp,%edi
call   1050 <S_ISSOCK@plt>
test   %rax,%rax
lea    0xd9e(%rip),%rsi
lea    0xd9e(%rip),%rax
cmove  %rax,%rsi
jmp    11f0 <main+0x30>
nopl   0x0(%rax)
mov    0x2d09(%rip),%rax
mov    (%rax),%ebp
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
call   10e0 <strerror@plt>
mov    %ebp,%edi
lea    0xd15(%rip),%rsi
mov    %rax,%rdx
call   1090 <fprintf@plt>
jmp    11fc <main+0x3c>
xor    %edi,%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 = [16 x i8] c"Can't stat: %s\0A\00"
@errno = global i32 0
@.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 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 %32
27: ; preds = %13
%28 = load i32, i32* @stderr
%29 = load i32, i32* @errno
%30 = call i8* @strerror(i32 %29)
%31 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %84
32: ; preds = %13
%33 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%34 = load i32, i32* %33
%35 = call i64 @S_ISREG(i32 %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %32
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %8
br label %81
38: ; preds = %32
%39 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%40 = load i32, i32* %39
%41 = call i64 @S_ISDIR(i32 %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %38
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %8
br label %80
44: ; preds = %38
%45 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%46 = load i32, i32* %45
%47 = call i64 @S_ISCHR(i32 %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %44
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8** %8
br label %79
50: ; preds = %44
%51 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%52 = load i32, i32* %51
%53 = call i64 @S_ISBLK(i32 %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %50
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8** %8
br label %78
56: ; preds = %50
%57 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%58 = load i32, i32* %57
%59 = call i64 @S_ISFIFO(i32 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %56
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %8
br label %77
62: ; preds = %56
%63 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%64 = load i32, i32* %63
%65 = call i64 @S_ISLNK(i32 %64)
%66 = icmp ne i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %62
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8** %8
br label %76
68: ; preds = %62
%69 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%70 = load i32, i32* %69
%71 = call i64 @S_ISSOCK(i32 %70)
%72 = icmp ne i64 %71, 0
br i1 %72, label %73, label %74
73: ; preds = %68
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i8** %8
br label %75
74: ; preds = %68
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), i8** %8
br label %75
75: ; preds = %74, %73
br label %76
76: ; preds = %75, %67
br label %77
77: ; preds = %76, %61
br label %78
78: ; preds = %77, %55
br label %79
79: ; preds = %78, %49
br label %80
80: ; preds = %79, %43
br label %81
81: ; preds = %80, %37
%82 = load i8*, i8** %8
%83 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* %82)
br label %84
84: ; preds = %81, %27
%85 = load i32, i32* %6
%86 = add nsw i32 %85, 1
store i32 %86, i32* %6
br label %9
87: ; preds = %9
%88 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [5 x i8] c"%s: \00"
@stderr = global i32 0
@.str.1 = [16 x i8] c"Can't stat: %s\0A\00"
@errno = global i32 0
@.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 = 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 %22
17: ; preds = %9
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = tail call i8* @strerror(i32 %19)
%21 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %48
22: ; preds = %9
%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)
br label %48
48: ; preds = %45, %17
%49 = add nuw nsw i64 %10, 1
%50 = icmp eq i64 %49, %8
br i1 %50, label %51, label %9
51: ; preds = %48, %2
%52 = tail call i32 @exit(i32 0)
unreachable
}