#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_ISDIR(int /*<<< orphan*/);
scalar_t__ S_ISREG(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  struct stat buff;
  char *s;
  s = malloc(25 * sizeof(char));
  if (stat(argv[1], &buff) < 0) {
    fprintf(stdout, "stat error\n");
  }
  if (S_ISREG(buff.st_mode))
    strcpy(s, "un file");
  else if (S_ISDIR(buff.st_mode))
    strcpy(s, "una directory");
  printf("\n\n**********\nL'oggetto \"%s\" e': %s\n**********\n\n", argv[1], s);
  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    $0x19,%edi
call   1090 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <stat@plt>
cmp    $0x0,%rax
jge    11c4 <main+0x54>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%edi
call   1080 <S_ISREG@plt>
cmp    $0x0,%rax
je     11eb <main+0x7b>
mov    -0x20(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1212 <main+0xa2>
mov    -0x18(%rbp),%edi
call   1050 <S_ISDIR@plt>
cmp    $0x0,%rax
je     120d <main+0x9d>
mov    -0x20(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1212 <main+0xa2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%rdx
lea    0xdfd(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    $0x19,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
mov    %rsp,%rsi
call   1070 <stat@plt>
test   %rax,%rax
jns    11aa <main+0x3a>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xe5b(%rip),%rsi
call   1060 <fprintf@plt>
mov    (%rsp),%edi
call   1080 <S_ISREG@plt>
test   %rax,%rax
je     11c0 <main+0x50>
lea    0xe4e(%rip),%rsi
jmp    11d4 <main+0x64>
mov    (%rsp),%edi
call   1050 <S_ISDIR@plt>
test   %rax,%rax
je     11dc <main+0x6c>
lea    0xe40(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    0x8(%rbx),%rsi
lea    0xe3b(%rip),%rdi
mov    %r14,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@stdout = global i32 0
@.str = [12 x i8] c"stat error\0A\00"
@.str.1 = [8 x i8] c"un file\00"
@.str.2 = [14 x i8] c"una directory\00"
@.str.3 = [48 x i8] c"\0A\0A**********\0AL'oggetto \22%s\22 e': %s\0A**********\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.stat
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* @malloc(i32 25)
store i8* %8, i8** %7
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @stat(i8* %11, %struct.stat* %6)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @stdout
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %14, %2
%18 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%19 = load i32, i32* %18
%20 = call i64 @S_ISREG(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = call i32 @strcpy(i8* %23, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %34
25: ; preds = %17
%26 = getelementptr inbounds %struct.stat, %struct.stat* %6, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i64 @S_ISDIR(i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i8*, i8** %7
%32 = call i32 @strcpy(i8* %31, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %30, %25
br label %34
34: ; preds = %33, %22
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = load i8*, i8** %7
%39 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %37, i8* %38)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stdout = global i32 0
@.str = [12 x i8] c"stat error\0A\00"
@.str.1 = [8 x i8] c"un file\00"
@.str.2 = [14 x i8] c"una directory\00"
@.str.3 = [48 x i8] c"\0A\0A**********\0AL'oggetto \22%s\22 e': %s\0A**********\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = tail call dereferenceable_or_null(25) i8* @malloc(i32 25)
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = call i64 @stat(i8* %7, %struct.stat* %3)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stdout
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %10, %2
%14 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%15 = load i32, i32* %14
%16 = call i64 @S_ISREG(i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i32, i32* %14
%20 = call i64 @S_ISDIR(i32 %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18, %13
%23 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %13 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), %18 ]
%24 = call i32 @strcpy(i8* %5, i8* %23)
br label %25
25: ; preds = %22, %18
%26 = load i8*, i8** %6
%27 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.3, i64 0, i64 0), i8* %26, i8* %5)
ret i32 0
}