#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_ino;
  int st_nlink;
  int st_size;
  int /*<<< orphan*/ st_mtim;
  int /*<<< orphan*/ st_gid;
  int /*<<< orphan*/ st_uid;
};
struct passwd {
  char *pw_gecos;
};
struct group {
  char *gr_name;
};
struct dirent {
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
scalar_t__ S_ISDIR(int);
int /*<<< orphan*/ chdir(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct group *getgrgid(int /*<<< orphan*/);
struct passwd *getpwuid(int /*<<< orphan*/);
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strftime(char *, int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Syntaxe incorrecte.\n");
    exit(EXIT_FAILURE);
  }
  DIR *repertoire;
  if ((repertoire = opendir(argv[1])) != NULL) {
    chdir(argv[1]);
    struct dirent *input = NULL;
    struct stat buffer;
    struct passwd *dataUser = NULL;
    struct group *dataGrp = NULL;
    char bufferDate[20];
    char c;
    while (input = readdir(repertoire)) {
      stat(input->d_name, &buffer);
      dataUser = getpwuid(buffer.st_uid);
      dataGrp = getgrgid(buffer.st_gid);
      strftime(bufferDate, 20, "%d/%m/%Y", localtime(&buffer.st_mtim));
      c = (S_ISDIR(buffer.st_mode) ? 'd' : 'f');
      printf("%d %c %6o %d %s %s %4d %s ", buffer.st_ino, c,
             buffer.st_mode & 0777, buffer.st_nlink, dataUser->pw_gecos,
             dataGrp->gr_name, buffer.st_size, bufferDate);
      printf("%s\n", input->d_name);
    }
  } else {
    fprintf(stderr, "Impossible d'acceder au repertoire specifie.\n");
    exit(EXIT_FAILURE);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1206 <main+0x46>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xe0d(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1335 <main+0x175>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <chdir@plt>
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
call   10c0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1330 <main+0x170>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
lea    -0x40(%rbp),%rsi
call   10b0 <stat@plt>
mov    -0x28(%rbp),%edi
call   1050 <getpwuid@plt>
mov    %rax,-0x48(%rbp)
mov    -0x2c(%rbp),%edi
call   1090 <getgrgid@plt>
mov    %rax,-0x50(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
lea    -0x40(%rbp),%rdi
add    $0x10,%rdi
call   1030 <localtime@plt>
mov    -0x80(%rbp),%rdi
mov    %eax,%ecx
mov    $0x14,%esi
lea    0xd69(%rip),%rdx
call   10d0 <strftime@plt>
mov    -0x40(%rbp),%edi
call   1080 <S_ISDIR@plt>
mov    %rax,%rdx
mov    $0x66,%eax
mov    $0x64,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
mov    %al,-0x71(%rbp)
mov    -0x3c(%rbp),%esi
movsbl -0x71(%rbp),%edx
mov    -0x40(%rbp),%ecx
and    $0x1ff,%ecx
mov    -0x38(%rbp),%r8d
mov    -0x48(%rbp),%rax
mov    (%rax),%r9
mov    -0x50(%rbp),%rax
mov    (%rax),%r11
mov    -0x34(%rbp),%r10d
lea    -0x70(%rbp),%rax
lea    0xd1d(%rip),%rdi
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1246 <main+0x86>
jmp    1358 <main+0x198>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
lea    0xcf8(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
cmp    $0x2,%edi
jne    1309 <main+0x129>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     131b <main+0x13b>
mov    %rax,%r13
mov    0x8(%rbx),%rdi
call   1080 <chdir@plt>
mov    %r13,%rdi
call   10e0 <readdir@plt>
test   %rax,%rax
je     12ee <main+0x10e>
mov    %rax,%rbp
lea    0x20(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%rdi
mov    %rsp,%rsi
call   10d0 <stat@plt>
mov    0x18(%rsp),%edi
call   1070 <getpwuid@plt>
mov    %rax,%r12
mov    0x14(%rsp),%edi
call   10b0 <getgrgid@plt>
mov    %rax,%r15
lea    0x10(%rsp),%rdi
call   1040 <localtime@plt>
mov    %r14,%rdi
mov    $0x14,%esi
lea    0xd98(%rip),%rdx
mov    %eax,%ecx
call   10f0 <strftime@plt>
mov    (%rsp),%edi
call   10a0 <S_ISDIR@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rcx,%rcx,1),%edx
add    $0x64,%edx
mov    (%rsp),%ecx
mov    $0x1ff,%eax
and    %eax,%ecx
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%r8d
mov    (%r12),%r9
mov    0xc(%rsp),%ebx
sub    $0x8,%rsp
lea    0xd5e(%rip),%rdi
xor    %eax,%eax
push   %r14
push   %rbx
push   (%r15)
call   1090 <printf@plt>
add    $0x20,%rsp
mov    0x0(%rbp),%rdi
call   1050 <puts@plt>
mov    %r13,%rdi
call   10e0 <readdir@plt>
mov    %rax,%rbp
test   %rax,%rax
jne    1240 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cd0(%rip),%rax
mov    (%rax),%edi
lea    0xce7(%rip),%rsi
jmp    132b <main+0x14b>
mov    0x2cbe(%rip),%rax
mov    (%rax),%edi
lea    0xd0e(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x2ca1(%rip),%rax
mov    (%rax),%edi
call   1100 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@stderr = global i32 0
@.str = [21 x i8] c"Syntaxe incorrecte.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%d/%m/%Y\00"
@.str.2 = [27 x i8] c"%d %c %6o %d %s %s %4d %s \00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [46 x i8] c"Impossible d'acceder au repertoire specifie.\0A\00"
@.str.5 = [2 x i8] c"\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
%9 = alloca %struct.passwd*
%10 = alloca %struct.group*
%11 = alloca [20 x i8]
%12 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @opendir(i8* %23)
store i32* %24, i32** %6
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %81
26: ; preds = %20
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @chdir(i8* %29)
store %struct.dirent* null, %struct.dirent** %7
store %struct.passwd* null, %struct.passwd** %9
store %struct.group* null, %struct.group** %10
br label %31
31: ; preds = %35, %26
%32 = load i32*, i32** %6
%33 = call %struct.dirent* @readdir(i32* %32)
store %struct.dirent* %33, %struct.dirent** %7
%34 = icmp ne %struct.dirent* %33, null
br i1 %34, label %35, label %80
35: ; preds = %31
%36 = load %struct.dirent*, %struct.dirent** %7
%37 = getelementptr inbounds %struct.dirent, %struct.dirent* %36, i32 0, i32 0
%38 = load i8*, i8** %37
%39 = call i32 @stat(i8* %38, %struct.stat* %8)
%40 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 6
%41 = load i32, i32* %40
%42 = call %struct.passwd* @getpwuid(i32 %41)
store %struct.passwd* %42, %struct.passwd** %9
%43 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 5
%44 = load i32, i32* %43
%45 = call %struct.group* @getgrgid(i32 %44)
store %struct.group* %45, %struct.group** %10
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%47 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 4
%48 = call i32 @localtime(i32* %47)
%49 = call i32 @strftime(i8* %46, i32 20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%51 = load i32, i32* %50
%52 = call i64 @S_ISDIR(i32 %51)
%53 = icmp ne i64 %52, 0
%54 = zext i1 %53 to i64
%55 = select i1 %53, i32 100, i32 102
%56 = trunc i32 %55 to i8
store i8 %56, i8* %12
%57 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%58 = load i32, i32* %57
%59 = load i8, i8* %12
%60 = sext i8 %59 to i32
%61 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%62 = load i32, i32* %61
%63 = and i32 %62, 511
%64 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 2
%65 = load i32, i32* %64
%66 = load %struct.passwd*, %struct.passwd** %9
%67 = getelementptr inbounds %struct.passwd, %struct.passwd* %66, i32 0, i32 0
%68 = load i8*, i8** %67
%69 = load %struct.group*, %struct.group** %10
%70 = getelementptr inbounds %struct.group, %struct.group* %69, i32 0, i32 0
%71 = load i8*, i8** %70
%72 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 3
%73 = load i32, i32* %72
%74 = getelementptr inbounds [20 x i8], [20 x i8]* %11, i64 0, i64 0
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %58, i32 %60, i32 %63, i32 %65, i8* %68, i8* %71, i32 %73, i8* %74)
%76 = load %struct.dirent*, %struct.dirent** %7
%77 = getelementptr inbounds %struct.dirent, %struct.dirent* %76, i32 0, i32 0
%78 = load i8*, i8** %77
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %78)
br label %31
80: ; preds = %31
br label %86
81: ; preds = %20
%82 = load i32, i32* @stderr
%83 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%84 = load i32, i32* @EXIT_FAILURE
%85 = call i32 @exit(i32 %84)
unreachable
86: ; preds = %80
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32, i32, i32, i32, i32, i32, i32 }
%struct.dirent = type { i8* }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@stderr = global i32 0
@.str = [21 x i8] c"Syntaxe incorrecte.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [9 x i8] c"%d/%m/%Y\00"
@.str.2 = [27 x i8] c"%d %c %6o %d %s %s %4d %s \00"
@.str.4 = [46 x i8] c"Impossible d'acceder au repertoire specifie.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca [20 x i8]
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = tail call i32 @exit(i32 %9)
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32* @opendir(i8* %13)
%15 = icmp eq i32* %14, null
br i1 %15, label %62, label %16
16: ; preds = %11
%17 = load i8*, i8** %12
%18 = tail call i32 @chdir(i8* %17)
%19 = bitcast %struct.stat* %3 to i8*
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%21 = call %struct.dirent* @readdir(i32* %14)
%22 = icmp eq %struct.dirent* %21, null
br i1 %22, label %60, label %23
23: ; preds = %16
%24 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 6
%25 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 5
%26 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 4
%27 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%28 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%29 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%30 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 3
br label %31
31: ; preds = %23, %31
%32 = phi %struct.dirent* [ %21, %23 ], [ %58, %31 ]
%33 = getelementptr inbounds %struct.dirent, %struct.dirent* %32, i64 0, i32 0
%34 = load i8*, i8** %33
%35 = call i32 @stat(i8* %34, %struct.stat* %3)
%36 = load i32, i32* %24
%37 = call %struct.passwd* @getpwuid(i32 %36)
%38 = load i32, i32* %25
%39 = call %struct.group* @getgrgid(i32 %38)
%40 = call i32 @localtime(i32* %26)
%41 = call i32 @strftime(i8* %20, i32 20, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %27
%43 = call i64 @S_ISDIR(i32 %42)
%44 = icmp eq i64 %43, 0
%45 = load i32, i32* %28
%46 = select i1 %44, i32 102, i32 100
%47 = load i32, i32* %27
%48 = and i32 %47, 511
%49 = load i32, i32* %29
%50 = getelementptr inbounds %struct.passwd, %struct.passwd* %37, i64 0, i32 0
%51 = load i8*, i8** %50
%52 = getelementptr inbounds %struct.group, %struct.group* %39, i64 0, i32 0
%53 = load i8*, i8** %52
%54 = load i32, i32* %30
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %45, i32 %46, i32 %48, i32 %49, i8* %51, i8* %53, i32 %54, i8* %20)
%56 = load i8*, i8** %33
%57 = call i32 @puts(i8* dereferenceable(1) %56)
%58 = call %struct.dirent* @readdir(i32* %14)
%59 = icmp eq %struct.dirent* %58, null
br i1 %59, label %60, label %31
60: ; preds = %31, %16
%61 = call i32 @putchar(i32 10)
ret i32 0
62: ; preds = %11
%63 = load i32, i32* @stderr
%64 = tail call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = tail call i32 @exit(i32 %65)
unreachable
}