#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 st_uid;
  int st_gid;
  int /*<<< orphan*/ st_mode;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
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*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  struct stat buffer;
  int i;
  char *pt;
  if (argc < 2) {
    fprintf(stderr, "Uso: %s <pathname> ... <pathname N>\n", argv[0]);
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < argc; i++) {
    printf("%s: \n", argv[i]);
    if (lstat(argv[i], &buffer) < 0) {
      fprintf(stderr, "Err: stat\n");
      continue;
    }
    if (S_ISREG(buffer.st_mode))
      pt = "regular";
    else if (S_ISDIR(buffer.st_mode))
      pt = "directory";
    else if (S_ISCHR(buffer.st_mode))
      pt = "character special";
    else if (S_ISBLK(buffer.st_mode))
      pt = "block special";
    else if (S_ISFIFO(buffer.st_mode))
      pt = "FIFO";
    else if (S_ISLNK(buffer.st_mode))
      pt = "symbolic link";
    else if (S_ISSOCK(buffer.st_mode))
      pt = "socket";
    else
      pt = "** tipo di file sconosciuto **";
    printf("%-20s UID:%-5d GID:%-5d\n\n", pt, buffer.st_uid, buffer.st_gid);
  }
  return (EXIT_SUCCESS);
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    11fc <main+0x4c>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe19(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13a1 <main+0x1f1>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <lstat@plt>
cmp    $0x0,%rax
jge    1264 <main+0xb4>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xdd3(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
jmp    1393 <main+0x1e3>
mov    -0x18(%rbp),%edi
call   10a0 <S_ISREG@plt>
cmp    $0x0,%rax
je     1286 <main+0xd6>
lea    0xdb9(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    137b <main+0x1cb>
mov    -0x18(%rbp),%edi
call   1070 <S_ISDIR@plt>
cmp    $0x0,%rax
je     12a8 <main+0xf8>
lea    0xd9f(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1376 <main+0x1c6>
mov    -0x18(%rbp),%edi
call   10b0 <S_ISCHR@plt>
cmp    $0x0,%rax
je     12ca <main+0x11a>
lea    0xd87(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1371 <main+0x1c1>
mov    -0x18(%rbp),%edi
call   10c0 <S_ISBLK@plt>
cmp    $0x0,%rax
je     12ec <main+0x13c>
lea    0xd77(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    136c <main+0x1bc>
mov    -0x18(%rbp),%edi
call   1040 <S_ISFIFO@plt>
cmp    $0x0,%rax
je     130e <main+0x15e>
lea    0xd63(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1367 <main+0x1b7>
mov    -0x18(%rbp),%edi
call   1030 <S_ISLNK@plt>
cmp    $0x0,%rax
je     1330 <main+0x180>
lea    0xd46(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1362 <main+0x1b2>
mov    -0x18(%rbp),%edi
call   1050 <S_ISSOCK@plt>
cmp    $0x0,%rax
je     1352 <main+0x1a2>
lea    0xd32(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    135d <main+0x1ad>
lea    0xd29(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1362 <main+0x1b2>
jmp    1367 <main+0x1b7>
jmp    136c <main+0x1bc>
jmp    1371 <main+0x1c1>
jmp    1376 <main+0x1c6>
jmp    137b <main+0x1cb>
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1203 <main+0x53>
mov    0x2c28(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jl     1304 <main+0x154>
mov    %edi,%r12d
lea    0xe51(%rip),%r14
lea    0x8(%rsp),%r15
xor    %r13d,%r13d
jmp    1203 <main+0x53>
xchg   %ax,%ax
mov    0x8(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%r13
cmp    %r13,%r12
je     12ec <main+0x13c>
mov    (%rbx,%r13,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rbx,%r13,8),%rdi
mov    %r15,%rsi
call   1080 <lstat@plt>
test   %rax,%rax
js     12d0 <main+0x120>
mov    0x10(%rsp),%ebp
mov    %ebp,%edi
call   10a0 <S_ISREG@plt>
lea    0xdfe(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   1070 <S_ISDIR@plt>
lea    0xdf3(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   10b0 <S_ISCHR@plt>
lea    0xdea(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   10c0 <S_ISBLK@plt>
lea    0xde5(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   1040 <S_ISFIFO@plt>
lea    0xddc(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   1030 <S_ISLNK@plt>
lea    0xdca(%rip),%rsi
test   %rax,%rax
jne    11e0 <main+0x30>
mov    %ebp,%edi
call   1050 <S_ISSOCK@plt>
test   %rax,%rax
lea    0xdbe(%rip),%rsi
lea    0xdbe(%rip),%rax
cmove  %rax,%rsi
jmp    11e0 <main+0x30>
nopl   (%rax)
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
lea    0xd4b(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    11f6 <main+0x46>
mov    0x2cdd(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xce9(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2cb3(%rip),%rax
mov    (%rax),%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32, i32 }
@stderr = global i32 0
@.str = [37 x i8] c"Uso: %s <pathname> ... <pathname N>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [6 x i8] c"%s: \0A\00"
@.str.2 = [11 x i8] c"Err: stat\0A\00"
@.str.3 = [8 x i8] c"regular\00"
@.str.4 = [10 x i8] c"directory\00"
@.str.5 = [18 x i8] c"character special\00"
@.str.6 = [14 x i8] c"block special\00"
@.str.7 = [5 x i8] c"FIFO\00"
@.str.8 = [14 x i8] c"symbolic link\00"
@.str.9 = [7 x i8] c"socket\00"
@.str.10 = [31 x i8] c"** tipo di file sconosciuto **\00"
@.str.11 = [26 x i8] c"%-20s UID:%-5d GID:%-5d\0A\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i32
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 0
%15 = load i8*, i8** %14
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %2
store i32 0, i32* %7
br label %20
20: ; preds = %97, %19
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %100
24: ; preds = %20
%25 = load i8**, i8*** %5
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i8**, i8*** %5
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
%36 = call i64 @lstat(i8* %35, %struct.stat* %6)
%37 = icmp slt i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %24
%39 = load i32, i32* @stderr
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %97
41: ; preds = %24
%42 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%43 = load i32, i32* %42
%44 = call i64 @S_ISREG(i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %41
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %8
br label %90
47: ; preds = %41
%48 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%49 = load i32, i32* %48
%50 = call i64 @S_ISDIR(i32 %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %53
52: ; preds = %47
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %8
br label %89
53: ; preds = %47
%54 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%55 = load i32, i32* %54
%56 = call i64 @S_ISCHR(i32 %55)
%57 = icmp ne i64 %56, 0
br i1 %57, label %58, label %59
58: ; preds = %53
store i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8** %8
br label %88
59: ; preds = %53
%60 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%61 = load i32, i32* %60
%62 = call i64 @S_ISBLK(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.6, i64 0, i64 0), i8** %8
br label %87
65: ; preds = %59
%66 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%67 = load i32, i32* %66
%68 = call i64 @S_ISFIFO(i32 %67)
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %71
70: ; preds = %65
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i8** %8
br label %86
71: ; preds = %65
%72 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%73 = load i32, i32* %72
%74 = call i64 @S_ISLNK(i32 %73)
%75 = icmp ne i64 %74, 0
br i1 %75, label %76, label %77
76: ; preds = %71
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i8** %8
br label %85
77: ; preds = %71
%78 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 2
%79 = load i32, i32* %78
%80 = call i64 @S_ISSOCK(i32 %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %83
82: ; preds = %77
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0), i8** %8
br label %84
83: ; preds = %77
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8** %8
br label %84
84: ; preds = %83, %82
br label %85
85: ; preds = %84, %76
br label %86
86: ; preds = %85, %70
br label %87
87: ; preds = %86, %64
br label %88
88: ; preds = %87, %58
br label %89
89: ; preds = %88, %52
br label %90
90: ; preds = %89, %46
%91 = load i8*, i8** %8
%92 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%93 = load i32, i32* %92
%94 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 1
%95 = load i32, i32* %94
%96 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %91, i32 %93, i32 %95)
br label %97
97: ; preds = %90, %38
%98 = load i32, i32* %7
%99 = add nsw i32 %98, 1
store i32 %99, i32* %7
br label %20
100: ; preds = %20
%101 = load i32, i32* @EXIT_SUCCESS
ret i32 %101
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32 }
@stderr = global i32 0
@.str = [37 x i8] c"Uso: %s <pathname> ... <pathname N>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [6 x i8] c"%s: \0A\00"
@.str.2 = [11 x i8] c"Err: stat\0A\00"
@.str.3 = [8 x i8] c"regular\00"
@.str.4 = [10 x i8] c"directory\00"
@.str.5 = [18 x i8] c"character special\00"
@.str.6 = [14 x i8] c"block special\00"
@.str.7 = [5 x i8] c"FIFO\00"
@.str.8 = [14 x i8] c"symbolic link\00"
@.str.9 = [7 x i8] c"socket\00"
@.str.10 = [31 x i8] c"** tipo di file sconosciuto **\00"
@.str.11 = [26 x i8] c"%-20s UID:%-5d GID:%-5d\0A\0A\00"
@EXIT_SUCCESS = global i32 0
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 %11, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%8 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%9 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%10 = zext i32 %0 to i64
br label %17
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = load i32, i32* @EXIT_FAILURE
%16 = tail call i32 @exit(i32 %15)
unreachable
17: ; preds = %6, %56
%18 = phi i64 [ 0, %6 ], [ %57, %56 ]
%19 = getelementptr inbounds i8*, i8** %1, i64 %18
%20 = load i8*, i8** %19
%21 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i8*, i8** %19
%23 = call i64 @lstat(i8* %22, %struct.stat* %3)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %17
%26 = load i32, i32* @stderr
%27 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %56
28: ; preds = %17
%29 = load i32, i32* %7
%30 = tail call i64 @S_ISREG(i32 %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %51
32: ; preds = %28
%33 = tail call i64 @S_ISDIR(i32 %29)
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %51
35: ; preds = %32
%36 = tail call i64 @S_ISCHR(i32 %29)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %35
%39 = tail call i64 @S_ISBLK(i32 %29)
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %51
41: ; preds = %38
%42 = tail call i64 @S_ISFIFO(i32 %29)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %51
44: ; preds = %41
%45 = tail call i64 @S_ISLNK(i32 %29)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = tail call i64 @S_ISSOCK(i32 %29)
%49 = icmp eq i64 %48, 0
%50 = select i1 %49, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.9, i64 0, i64 0)
br label %51
51: ; preds = %47, %44, %41, %38, %35, %32, %28
%52 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %28 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), %32 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), %35 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), %38 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), %41 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), %44 ], [ %50, %47 ]
%53 = load i32, i32* %8
%54 = load i32, i32* %9
%55 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.11, i64 0, i64 0), i8* %52, i32 %53, i32 %54)
br label %56
56: ; preds = %51, %25
%57 = add nuw nsw i64 %18, 1
%58 = icmp eq i64 %57, %10
br i1 %58, label %59, label %17
59: ; preds = %56
%60 = load i32, i32* @EXIT_SUCCESS
ret i32 %60
}