#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 *, struct stat *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  struct stat stBuff;
  int i;
  if (argc < 2) {
    puts("Error :: no arguments ");
    return 0;
  }
  for (i = 1; i < argc; ++i) {
    if (lstat(argv[i], &stBuff)) {
      printf("Error stating file :%s", argv[i]);
      continue;
    }
    if (S_ISREG(stBuff.st_mode)) {
      printf("%s : Regular File\n", argv[i]);
    }
    if (S_ISDIR(stBuff.st_mode)) {
      printf("%s : Directory\n", argv[i]);
    }
    if (S_ISLNK(stBuff.st_mode)) {
      printf("%s : Link\n", argv[i]);
    }
    if (S_ISSOCK(stBuff.st_mode)) {
      printf("%s : Socket\n", argv[i]);
    }
    if (S_ISCHR(stBuff.st_mode)) {
      printf("%s : Character Device\n", argv[i]);
    }
    if (S_ISFIFO(stBuff.st_mode)) {
      printf("%s : FIFO pipe\n", argv[i]);
    }
    if (S_ISBLK(stBuff.st_mode)) {
      printf("%s : Block Device\n", argv[i]);
    }
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    11d8 <main+0x38>
lea    0xe39(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    1367 <main+0x1c7>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1360 <main+0x1c0>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <lstat@plt>
cmp    $0x0,%rax
je     1227 <main+0x87>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdfa(%rip),%rdi
call   1070 <printf@plt>
jmp    1352 <main+0x1b2>
mov    -0x18(%rbp),%edi
call   10a0 <S_ISREG@plt>
cmp    $0x0,%rax
je     1251 <main+0xb1>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xde2(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
call   1080 <S_ISDIR@plt>
cmp    $0x0,%rax
je     127b <main+0xdb>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdcb(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     12a5 <main+0x105>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdb1(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
call   1060 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     12cf <main+0x12f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd92(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
call   10b0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     12f9 <main+0x159>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd75(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
call   1050 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     1323 <main+0x183>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd62(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%edi
call   10c0 <S_ISBLK@plt>
cmp    $0x0,%rax
je     134d <main+0x1ad>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd48(%rip),%rdi
call   1070 <printf@plt>
jmp    1352 <main+0x1b2>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11df <main+0x3f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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
jge    11cd <main+0x2d>
lea    0xe49(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r15d
mov    %rsp,%r14
lea    0xe35(%rip),%r12
jmp    1202 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%rbx,%r15,8),%rsi
call   1070 <printf@plt>
add    $0x1,%r15
cmp    %r15,%rbp
je     11bc <main+0x1c>
mov    (%rbx,%r15,8),%rdi
mov    %r14,%rsi
call   1090 <lstat@plt>
mov    %r12,%rdi
test   %rax,%rax
jne    11f0 <main+0x50>
mov    (%rsp),%r13d
mov    %r13d,%edi
call   10a0 <S_ISREG@plt>
test   %rax,%rax
je     1237 <main+0x97>
mov    (%rbx,%r15,8),%rsi
lea    0xdfc(%rip),%rdi
call   1070 <printf@plt>
mov    %r13d,%edi
call   1080 <S_ISDIR@plt>
test   %rax,%rax
je     1254 <main+0xb4>
mov    (%rbx,%r15,8),%rsi
lea    0xdf2(%rip),%rdi
call   1070 <printf@plt>
mov    %r13d,%edi
call   1030 <S_ISLNK@plt>
test   %rax,%rax
je     1271 <main+0xd1>
mov    (%rbx,%r15,8),%rsi
lea    0xde5(%rip),%rdi
call   1070 <printf@plt>
mov    %r13d,%edi
call   1060 <S_ISSOCK@plt>
test   %rax,%rax
je     128e <main+0xee>
mov    (%rbx,%r15,8),%rsi
lea    0xdd3(%rip),%rdi
call   1070 <printf@plt>
mov    %r13d,%edi
call   10b0 <S_ISCHR@plt>
test   %rax,%rax
je     12ab <main+0x10b>
mov    (%rbx,%r15,8),%rsi
lea    0xdc3(%rip),%rdi
call   1070 <printf@plt>
mov    %r13d,%edi
call   1050 <S_ISFIFO@plt>
test   %rax,%rax
je     12c8 <main+0x128>
mov    (%rbx,%r15,8),%rsi
lea    0xdbd(%rip),%rdi
call   1070 <printf@plt>
mov    %r13d,%edi
call   10c0 <S_ISBLK@plt>
lea    0xdb9(%rip),%rdi
test   %rax,%rax
jne    11f0 <main+0x50>
jmp    11f9 <main+0x59>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [23 x i8] c"Error :: no arguments \00"
@.str.1 = [23 x i8] c"Error stating file :%s\00"
@.str.2 = [19 x i8] c"%s : Regular File\0A\00"
@.str.3 = [16 x i8] c"%s : Directory\0A\00"
@.str.4 = [11 x i8] c"%s : Link\0A\00"
@.str.5 = [13 x i8] c"%s : Socket\0A\00"
@.str.6 = [23 x i8] c"%s : Character Device\0A\00"
@.str.7 = [16 x i8] c"%s : FIFO pipe\0A\00"
@.str.8 = [19 x i8] c"%s : Block Device\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @puts(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %121
12: ; preds = %2
store i32 1, i32* %7
br label %13
13: ; preds = %117, %12
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %120
17: ; preds = %13
%18 = load i8**, i8*** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8*, i8** %18, i64 %20
%22 = load i8*, i8** %21
%23 = call i64 @lstat(i8* %22, %struct.stat* %6)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %17
%26 = load i8**, i8*** %5
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8*, i8** %26, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %30)
br label %117
32: ; preds = %17
%33 = getelementptr inbounds %struct.stat, %struct.stat* %6, 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 %44
37: ; preds = %32
%38 = load i8**, i8*** %5
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8*, i8** %38, i64 %40
%42 = load i8*, i8** %41
%43 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %37, %32
%45 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%46 = load i32, i32* %45
%47 = call i64 @S_ISDIR(i32 %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %44
%50 = load i8**, i8*** %5
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8*, i8** %50, i64 %52
%54 = load i8*, i8** %53
%55 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %49, %44
%57 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%58 = load i32, i32* %57
%59 = call i64 @S_ISLNK(i32 %58)
%60 = icmp ne i64 %59, 0
br i1 %60, label %61, label %68
61: ; preds = %56
%62 = load i8**, i8*** %5
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds i8*, i8** %62, i64 %64
%66 = load i8*, i8** %65
%67 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %66)
br label %68
68: ; preds = %61, %56
%69 = getelementptr inbounds %struct.stat, %struct.stat* %6, 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 %80
73: ; preds = %68
%74 = load i8**, i8*** %5
%75 = load i32, i32* %7
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds i8*, i8** %74, i64 %76
%78 = load i8*, i8** %77
%79 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %78)
br label %80
80: ; preds = %73, %68
%81 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%82 = load i32, i32* %81
%83 = call i64 @S_ISCHR(i32 %82)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %92
85: ; preds = %80
%86 = load i8**, i8*** %5
%87 = load i32, i32* %7
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8*, i8** %86, i64 %88
%90 = load i8*, i8** %89
%91 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %90)
br label %92
92: ; preds = %85, %80
%93 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%94 = load i32, i32* %93
%95 = call i64 @S_ISFIFO(i32 %94)
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %104
97: ; preds = %92
%98 = load i8**, i8*** %5
%99 = load i32, i32* %7
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8*, i8** %98, i64 %100
%102 = load i8*, i8** %101
%103 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %102)
br label %104
104: ; preds = %97, %92
%105 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%106 = load i32, i32* %105
%107 = call i64 @S_ISBLK(i32 %106)
%108 = icmp ne i64 %107, 0
br i1 %108, label %109, label %116
109: ; preds = %104
%110 = load i8**, i8*** %5
%111 = load i32, i32* %7
%112 = sext i32 %111 to i64
%113 = getelementptr inbounds i8*, i8** %110, i64 %112
%114 = load i8*, i8** %113
%115 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i8* %114)
br label %116
116: ; preds = %109, %104
br label %117
117: ; preds = %116, %25
%118 = load i32, i32* %7
%119 = add nsw i32 %118, 1
store i32 %119, i32* %7
br label %13
120: ; preds = %13
store i32 0, i32* %3
br label %121
121: ; preds = %120, %10
%122 = load i32, i32* %3
ret i32 %122
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [23 x i8] c"Error :: no arguments \00"
@.str.1 = [23 x i8] c"Error stating file :%s\00"
@.str.2 = [19 x i8] c"%s : Regular File\0A\00"
@.str.3 = [16 x i8] c"%s : Directory\0A\00"
@.str.4 = [11 x i8] c"%s : Link\0A\00"
@.str.5 = [13 x i8] c"%s : Socket\0A\00"
@.str.6 = [23 x i8] c"%s : Character Device\0A\00"
@.str.7 = [16 x i8] c"%s : FIFO pipe\0A\00"
@.str.8 = [19 x i8] c"%s : Block Device\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%8 = zext i32 %0 to i64
br label %11
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %64
11: ; preds = %6, %61
%12 = phi i64 [ 1, %6 ], [ %62, %61 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = call i64 @lstat(i8* %14, %struct.stat* %3)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %57
17: ; preds = %11
%18 = load i32, i32* %7
%19 = tail call i64 @S_ISREG(i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %17
%22 = load i8*, i8** %13
%23 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %24
24: ; preds = %21, %17
%25 = tail call i64 @S_ISDIR(i32 %18)
%26 = icmp eq i64 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i8*, i8** %13
%29 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %30
30: ; preds = %27, %24
%31 = tail call i64 @S_ISLNK(i32 %18)
%32 = icmp eq i64 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i8*, i8** %13
%35 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %33, %30
%37 = tail call i64 @S_ISSOCK(i32 %18)
%38 = icmp eq i64 %37, 0
br i1 %38, label %42, label %39
39: ; preds = %36
%40 = load i8*, i8** %13
%41 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %39, %36
%43 = tail call i64 @S_ISCHR(i32 %18)
%44 = icmp eq i64 %43, 0
br i1 %44, label %48, label %45
45: ; preds = %42
%46 = load i8*, i8** %13
%47 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %45, %42
%49 = tail call i64 @S_ISFIFO(i32 %18)
%50 = icmp eq i64 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = load i8*, i8** %13
%53 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %51, %48
%55 = tail call i64 @S_ISBLK(i32 %18)
%56 = icmp eq i64 %55, 0
br i1 %56, label %61, label %57
57: ; preds = %54, %11
%58 = phi i8* [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), %11 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), %54 ]
%59 = load i8*, i8** %13
%60 = tail call i32 @printf(i8* %58, i8* %59)
br label %61
61: ; preds = %57, %54
%62 = add nuw nsw i64 %12, 1
%63 = icmp eq i64 %62, %8
br i1 %63, label %64, label %11
64: ; preds = %61, %9
ret i32 0
}