#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_mode;
  int st_nlink;
  int st_uid;
  int st_gid;
  int st_size;
  int st_ino;
  int /*<<< orphan*/ st_mtime;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
scalar_t__ S_ISDIR(int);
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
char *asctime(int /*<<< orphan*/);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
scalar_t__ stat(char *, struct stat *);
int main(int argc, char **argv) {
  printf("Ejecutando comando ls -l con stat\n");
  DIR *dir;
  struct dirent *entry;
  struct stat archivo;
  if ((dir = opendir(argv[1])) == NULL)
    perror("opendir() error");
  else {
    printf("Contenido de %s: \n", argv[1]);
    printf("Permisos Ligas* Usuario Grupo Tamaño Fecha Nombre Inodo\n");
    while ((entry = readdir(dir)) != NULL) {
      if (stat(entry->d_name, &archivo)) {
        perror("Error leyendo archivo");
      } else {
        printf((S_ISDIR(archivo.st_mode)) ? "d" : "-");
        printf((archivo.st_mode & S_IRUSR) ? "r" : "-");
        printf((archivo.st_mode & S_IWUSR) ? "w" : "-");
        printf((archivo.st_mode & S_IXUSR) ? "x" : "-");
        printf((archivo.st_mode & S_IRGRP) ? "r" : "-");
        printf((archivo.st_mode & S_IWGRP) ? "w" : "-");
        printf((archivo.st_mode & S_IXGRP) ? "x" : "-");
        printf((archivo.st_mode & S_IROTH) ? "r" : "-");
        printf((archivo.st_mode & S_IWOTH) ? "w" : "-");
        printf((archivo.st_mode & S_IXOTH) ? "x" : "-");
        printf("\t");
        printf("%d ", archivo.st_nlink);
        printf("%d ", archivo.st_uid);
        printf("%d ", archivo.st_gid);
        printf("%d ", archivo.st_size);
        printf("%s ", asctime(localtime(&archivo.st_mtime)));
        printf("%s ", entry->d_name);
        printf("%d\n ", archivo.st_ino);
      }
    }
    printf("* Solo para archivos que no sean directorios\n");
    closedir(dir);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11e0 <main+0x50>
lea    0xe4d(%rip),%rdi
call   10b0 <perror@plt>
jmp    148f <main+0x2ff>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1478 <main+0x2e8>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
call   1090 <stat@plt>
cmp    $0x0,%rax
je     1246 <main+0xb6>
lea    0xe44(%rip),%rdi
call   10b0 <perror@plt>
jmp    1473 <main+0x2e3>
mov    -0x40(%rbp),%edi
call   1070 <S_ISDIR@plt>
mov    %rax,%rcx
lea    0xe40(%rip),%rdi
lea    0xe37(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%ecx
mov    0x2d30(%rip),%rax
and    (%rax),%ecx
lea    0xe17(%rip),%rdi
lea    0xda9(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%ecx
mov    0x2d30(%rip),%rax
and    (%rax),%ecx
lea    0xdef(%rip),%rdi
lea    0xdea(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%ecx
mov    0x2d18(%rip),%rax
and    (%rax),%ecx
lea    0xdc7(%rip),%rdi
lea    0xdc4(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%ecx
mov    0x2cc8(%rip),%rax
and    (%rax),%ecx
lea    0xd9f(%rip),%rdi
lea    0xd31(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%ecx
mov    0x2cc0(%rip),%rax
and    (%rax),%ecx
lea    0xd77(%rip),%rdi
lea    0xd72(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%ecx
mov    0x2c88(%rip),%rax
and    (%rax),%ecx
lea    0xd4f(%rip),%rdi
lea    0xd4c(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%ecx
mov    0x2c48(%rip),%rax
and    (%rax),%ecx
lea    0xd27(%rip),%rdi
lea    0xcb9(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%ecx
mov    0x2c08(%rip),%rax
and    (%rax),%ecx
lea    0xcff(%rip),%rdi
lea    0xcfa(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%ecx
mov    0x2c30(%rip),%rax
and    (%rax),%ecx
lea    0xcd7(%rip),%rdi
lea    0xcd4(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcc1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%esi
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%esi
lea    0xc90(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xc7f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x40(%rbp),%rdi
add    $0x18,%rdi
call   1030 <localtime@plt>
mov    %eax,%edi
call   1050 <asctime@plt>
mov    %rax,%rsi
lea    0xc5e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xc49(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x2c(%rbp),%esi
lea    0xc3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1204 <main+0x74>
lea    0xc2e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <closedir@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
lea    0xe86(%rip),%rdi
call   1050 <puts@plt>
mov    0x8(%rbx),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     142e <main+0x27e>
mov    %rax,%rbp
mov    0x8(%rbx),%rsi
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xe75(%rip),%rdi
call   1050 <puts@plt>
mov    %rbp,0x20(%rsp)
mov    %rbp,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     1407 <main+0x257>
mov    %rax,%rbp
lea    0xe1b(%rip),%r15
lea    0xe18(%rip),%r12
lea    0xe13(%rip),%r13
xchg   %ax,%ax
mov    0x0(%rbp),%rdi
mov    %rsp,%rsi
call   10b0 <stat@plt>
test   %rax,%rax
jne    13f9 <main+0x249>
mov    (%rsp),%edi
call   1090 <S_ISDIR@plt>
test   %rax,%rax
lea    0xde2(%rip),%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d3f(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
lea    0xd99(%rip),%rbx
mov    %rbx,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d46(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
lea    0xda7(%rip),%r14
mov    %r14,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2cf3(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
mov    %rbx,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2cf9(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
mov    %r14,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2ccf(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2c9d(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
mov    %rbx,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2c6b(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
mov    %r14,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2ca1(%rip),%rax
mov    (%rax),%eax
and    (%rsp),%eax
mov    %r12,%rdi
cmove  %r15,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x9,%edi
call   1030 <putchar@plt>
mov    0x4(%rsp),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rsp),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0xc(%rsp),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x10(%rsp),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0x18(%rsp),%rdi
call   1040 <localtime@plt>
mov    %eax,%edi
call   1070 <asctime@plt>
lea    0xc91(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x0(%rbp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x14(%rsp),%esi
lea    0xc6f(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x20(%rsp),%rdi
call   10c0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1230 <main+0x80>
jmp    1407 <main+0x257>
lea    0xc23(%rip),%rdi
call   10d0 <perror@plt>
jmp    13e1 <main+0x231>
lea    0xc9b(%rip),%rdi
call   1050 <puts@plt>
mov    0x20(%rsp),%rdi
call   10a0 <closedir@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xbcb(%rip),%rdi
call   10d0 <perror@plt>
jmp    141d <main+0x26d>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32 }
@.str = [35 x i8] c"Ejecutando comando ls -l con stat\0A\00"
@.str.1 = [16 x i8] c"opendir() error\00"
@.str.2 = [19 x i8] c"Contenido de %s: \0A\00"
@.str.3 = [58 x i8] c"Permisos Ligas* Usuario Grupo Tama\C3\B1o Fecha Nombre Inodo\0A\00"
@.str.4 = [22 x i8] c"Error leyendo archivo\00"
@.str.5 = [2 x i8] c"d\00"
@.str.6 = [2 x i8] c"-\00"
@S_IRUSR = global i32 0
@.str.7 = [2 x i8] c"r\00"
@S_IWUSR = global i32 0
@.str.8 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.9 = [2 x i8] c"x\00"
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@.str.10 = [2 x i8] c"\09\00"
@.str.11 = [4 x i8] c"%d \00"
@.str.12 = [4 x i8] c"%s \00"
@.str.13 = [5 x i8] c"%d\0A \00"
@.str.14 = [46 x i8] c"* Solo para archivos que no sean directorios\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.dirent*
%8 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = call i32* @opendir(i8* %12)
store i32* %13, i32** %6
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %144
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0))
br label %23
23: ; preds = %139, %17
%24 = load i32*, i32** %6
%25 = call %struct.dirent* @readdir(i32* %24)
store %struct.dirent* %25, %struct.dirent** %7
%26 = icmp ne %struct.dirent* %25, null
br i1 %26, label %27, label %140
27: ; preds = %23
%28 = load %struct.dirent*, %struct.dirent** %7
%29 = getelementptr inbounds %struct.dirent, %struct.dirent* %28, i32 0, i32 0
%30 = load i8*, i8** %29
%31 = call i64 @stat(i8* %30, %struct.stat* %8)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %139
35: ; preds = %27
%36 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%37 = load i32, i32* %36
%38 = call i64 @S_ISDIR(i32 %37)
%39 = icmp ne i64 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%42 = call i32 (i8*, ...) @printf(i8* %41)
%43 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%44 = load i32, i32* %43
%45 = load i32, i32* @S_IRUSR
%46 = and i32 %44, %45
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%50 = call i32 (i8*, ...) @printf(i8* %49)
%51 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%52 = load i32, i32* %51
%53 = load i32, i32* @S_IWUSR
%54 = and i32 %52, %53
%55 = icmp ne i32 %54, 0
%56 = zext i1 %55 to i64
%57 = select i1 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%58 = call i32 (i8*, ...) @printf(i8* %57)
%59 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%60 = load i32, i32* %59
%61 = load i32, i32* @S_IXUSR
%62 = and i32 %60, %61
%63 = icmp ne i32 %62, 0
%64 = zext i1 %63 to i64
%65 = select i1 %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%66 = call i32 (i8*, ...) @printf(i8* %65)
%67 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%68 = load i32, i32* %67
%69 = load i32, i32* @S_IRGRP
%70 = and i32 %68, %69
%71 = icmp ne i32 %70, 0
%72 = zext i1 %71 to i64
%73 = select i1 %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%74 = call i32 (i8*, ...) @printf(i8* %73)
%75 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%76 = load i32, i32* %75
%77 = load i32, i32* @S_IWGRP
%78 = and i32 %76, %77
%79 = icmp ne i32 %78, 0
%80 = zext i1 %79 to i64
%81 = select i1 %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%82 = call i32 (i8*, ...) @printf(i8* %81)
%83 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%84 = load i32, i32* %83
%85 = load i32, i32* @S_IXGRP
%86 = and i32 %84, %85
%87 = icmp ne i32 %86, 0
%88 = zext i1 %87 to i64
%89 = select i1 %87, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%90 = call i32 (i8*, ...) @printf(i8* %89)
%91 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%92 = load i32, i32* %91
%93 = load i32, i32* @S_IROTH
%94 = and i32 %92, %93
%95 = icmp ne i32 %94, 0
%96 = zext i1 %95 to i64
%97 = select i1 %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%98 = call i32 (i8*, ...) @printf(i8* %97)
%99 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%100 = load i32, i32* %99
%101 = load i32, i32* @S_IWOTH
%102 = and i32 %100, %101
%103 = icmp ne i32 %102, 0
%104 = zext i1 %103 to i64
%105 = select i1 %103, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%106 = call i32 (i8*, ...) @printf(i8* %105)
%107 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%108 = load i32, i32* %107
%109 = load i32, i32* @S_IXOTH
%110 = and i32 %108, %109
%111 = icmp ne i32 %110, 0
%112 = zext i1 %111 to i64
%113 = select i1 %111, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%114 = call i32 (i8*, ...) @printf(i8* %113)
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%116 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%117 = load i32, i32* %116
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %117)
%119 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 2
%120 = load i32, i32* %119
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %120)
%122 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 3
%123 = load i32, i32* %122
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %123)
%125 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 4
%126 = load i32, i32* %125
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %126)
%128 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 6
%129 = call i32 @localtime(i32* %128)
%130 = call i8* @asctime(i32 %129)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %130)
%132 = load %struct.dirent*, %struct.dirent** %7
%133 = getelementptr inbounds %struct.dirent, %struct.dirent* %132, i32 0, i32 0
%134 = load i8*, i8** %133
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %134)
%136 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 5
%137 = load i32, i32* %136
%138 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %137)
br label %139
139: ; preds = %35, %33
br label %23
140: ; preds = %23
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.14, i64 0, i64 0))
%142 = load i32*, i32** %6
%143 = call i32 @closedir(i32* %142)
br label %144
144: ; preds = %140, %15
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.dirent = type { i8* }
@.str.1 = [16 x i8] c"opendir() error\00"
@.str.2 = [19 x i8] c"Contenido de %s: \0A\00"
@.str.4 = [22 x i8] c"Error leyendo archivo\00"
@.str.5 = [2 x i8] c"d\00"
@.str.6 = [2 x i8] c"-\00"
@S_IRUSR = global i32 0
@.str.7 = [2 x i8] c"r\00"
@S_IWUSR = global i32 0
@.str.8 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.9 = [2 x i8] c"x\00"
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@S_IXGRP = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IXOTH = global i32 0
@.str.11 = [4 x i8] c"%d \00"
@.str.12 = [4 x i8] c"%s \00"
@.str.13 = [5 x i8] c"%d\0A \00"
@str = [34 x i8] c"Ejecutando comando ls -l con stat\00"
@str.15 = [57 x i8] c"Permisos Ligas* Usuario Grupo Tama\C3\B1o Fecha Nombre Inodo\00"
@str.16 = [45 x i8] c"* Solo para archivos que no sean directorios\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%5 = bitcast %struct.stat* %3 to i8*
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32* @opendir(i8* %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %116
12: ; preds = %2
%13 = load i8*, i8** %6
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.15, i64 0, i64 0))
%16 = call %struct.dirent* @readdir(i32* %8)
%17 = icmp eq %struct.dirent* %16, null
br i1 %17, label %113, label %18
18: ; preds = %12
%19 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%20 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%21 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%22 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 3
%23 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 4
%24 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 6
%25 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 5
br label %26
26: ; preds = %18, %110
%27 = phi %struct.dirent* [ %16, %18 ], [ %111, %110 ]
%28 = getelementptr inbounds %struct.dirent, %struct.dirent* %27, i64 0, i32 0
%29 = load i8*, i8** %28
%30 = call i64 @stat(i8* %29, %struct.stat* %3)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %26
%33 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %110
34: ; preds = %26
%35 = load i32, i32* %19
%36 = call i64 @S_ISDIR(i32 %35)
%37 = icmp eq i64 %36, 0
%38 = select i1 %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %38)
%40 = load i32, i32* %19
%41 = load i32, i32* @S_IRUSR
%42 = and i32 %41, %40
%43 = icmp eq i32 %42, 0
%44 = select i1 %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0)
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %44)
%46 = load i32, i32* %19
%47 = load i32, i32* @S_IWUSR
%48 = and i32 %47, %46
%49 = icmp eq i32 %48, 0
%50 = select i1 %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0)
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %50)
%52 = load i32, i32* %19
%53 = load i32, i32* @S_IXUSR
%54 = and i32 %53, %52
%55 = icmp eq i32 %54, 0
%56 = select i1 %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %56)
%58 = load i32, i32* %19
%59 = load i32, i32* @S_IRGRP
%60 = and i32 %59, %58
%61 = icmp eq i32 %60, 0
%62 = select i1 %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0)
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %62)
%64 = load i32, i32* %19
%65 = load i32, i32* @S_IWGRP
%66 = and i32 %65, %64
%67 = icmp eq i32 %66, 0
%68 = select i1 %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0)
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %68)
%70 = load i32, i32* %19
%71 = load i32, i32* @S_IXGRP
%72 = and i32 %71, %70
%73 = icmp eq i32 %72, 0
%74 = select i1 %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %74)
%76 = load i32, i32* %19
%77 = load i32, i32* @S_IROTH
%78 = and i32 %77, %76
%79 = icmp eq i32 %78, 0
%80 = select i1 %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0)
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %80)
%82 = load i32, i32* %19
%83 = load i32, i32* @S_IWOTH
%84 = and i32 %83, %82
%85 = icmp eq i32 %84, 0
%86 = select i1 %85, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0)
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %86)
%88 = load i32, i32* %19
%89 = load i32, i32* @S_IXOTH
%90 = and i32 %89, %88
%91 = icmp eq i32 %90, 0
%92 = select i1 %91, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0)
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %92)
%94 = call i32 @putchar(i32 9)
%95 = load i32, i32* %20
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %95)
%97 = load i32, i32* %21
%98 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %97)
%99 = load i32, i32* %22
%100 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %99)
%101 = load i32, i32* %23
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 %101)
%103 = call i32 @localtime(i32* %24)
%104 = call i8* @asctime(i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %104)
%106 = load i8*, i8** %28
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i8* %106)
%108 = load i32, i32* %25
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.13, i64 0, i64 0), i32 %108)
br label %110
110: ; preds = %34, %32
%111 = call %struct.dirent* @readdir(i32* %8)
%112 = icmp eq %struct.dirent* %111, null
br i1 %112, label %113, label %26
113: ; preds = %110, %12
%114 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.16, i64 0, i64 0))
%115 = call i32 @closedir(i32* %8)
br label %116
116: ; preds = %113, %10
ret i32 0
}