#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;
};
struct dirent {
  char *d_ino;
  char *d_name;
};
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int S_IFDIR;
int S_IFMT;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
scalar_t__ S_ISLNK(int);
scalar_t__ S_ISREG(int);
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int S_IXGRP;
int S_IXOTH;
int S_IXUSR;
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ lstat(char *, struct stat *);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "utilisation: %s chemin\n", argv[0]);
    exit(1);
  }
  DIR *rep = opendir(argv[1]);
  if (rep == NULL) {
    fprintf(stderr, "Impossible d'ouvrir le répertoire : %s\n", argv[1]);
    exit(2);
  } else {
    struct dirent *entree;
    char chemin[512];
    struct stat etat;
    while ((entree = readdir(rep)) != NULL) {
      printf("%ld ", entree->d_ino);
      strcat(strcat(strcpy(chemin, argv[1]), "/"), entree->d_name);
      if (lstat(chemin, &etat) < 0) {
        fprintf(stderr, "Impossible d'ouvrir le fichier : %s\n", chemin);
        exit(3);
      }
      if ((etat.st_mode & S_IFMT) == S_IFDIR) {
        printf("d");
      } else if (S_ISREG(etat.st_mode)) {
        printf("-");
      } else if (S_ISLNK(etat.st_mode)) {
        printf("l");
      } else {
        printf("?");
      }
      if (etat.st_mode & S_IRUSR)
        printf("r");
      else
        printf("-");
      if (etat.st_mode & S_IWUSR)
        printf("w");
      else
        printf("-");
      if (etat.st_mode & S_IXUSR)
        printf("x");
      else
        printf("-");
      if (etat.st_mode & S_IRGRP)
        printf("r");
      else
        printf("-");
      if (etat.st_mode & S_IWGRP)
        printf("w");
      else
        printf("-");
      if (etat.st_mode & S_IXGRP)
        printf("x");
      else
        printf("-");
      if (etat.st_mode & S_IROTH)
        printf("r");
      else
        printf("-");
      if (etat.st_mode & S_IWOTH)
        printf("w");
      else
        printf("-");
      if (etat.st_mode & S_IXOTH)
        printf("x");
      else
        printf("-");
      printf(" %s\n", entree->d_name);
    }
    closedir(rep);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11f9 <main+0x49>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe16(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <opendir@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    123c <main+0x8c>
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xdeb(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
jmp    1241 <main+0x91>
mov    -0x18(%rbp),%rdi
call   10b0 <readdir@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1596 <main+0x3e6>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x220(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   1030 <strcpy@plt>
mov    %eax,%edi
lea    0xdbc(%rip),%rsi
call   10c0 <strcat@plt>
mov    %eax,%edi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
call   10c0 <strcat@plt>
lea    -0x220(%rbp),%rdi
lea    -0x228(%rbp),%rsi
call   1080 <lstat@plt>
cmp    $0x0,%rax
jge    12e1 <main+0x131>
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
lea    -0x220(%rbp),%rdx
lea    0xd76(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x3,%edi
call   10d0 <exit@plt>
mov    -0x228(%rbp),%eax
mov    0x2cca(%rip),%rcx
and    (%rcx),%eax
mov    0x2c89(%rip),%rcx
cmp    (%rcx),%eax
jne    1312 <main+0x162>
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    137a <main+0x1ca>
mov    -0x228(%rbp),%edi
call   10a0 <S_ISREG@plt>
cmp    $0x0,%rax
je     133a <main+0x18a>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1375 <main+0x1c5>
mov    -0x228(%rbp),%edi
call   1040 <S_ISLNK@plt>
cmp    $0x0,%rax
je     1362 <main+0x1b2>
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1370 <main+0x1c0>
lea    0xd0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1375 <main+0x1c5>
jmp    137a <main+0x1ca>
mov    -0x228(%rbp),%eax
mov    0x2c11(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13a5 <main+0x1f5>
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13b3 <main+0x203>
lea    0xcc3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x228(%rbp),%eax
mov    0x2c10(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     13de <main+0x22e>
lea    0xca5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13ec <main+0x23c>
lea    0xc8a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x228(%rbp),%eax
mov    0x2be7(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1417 <main+0x267>
lea    0xc6e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1425 <main+0x275>
lea    0xc51(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x228(%rbp),%eax
mov    0x2b76(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1450 <main+0x2a0>
lea    0xc31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    145e <main+0x2ae>
lea    0xc18(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x228(%rbp),%eax
mov    0x2b6d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1489 <main+0x2d9>
lea    0xbfa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1497 <main+0x2e7>
lea    0xbdf(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x228(%rbp),%eax
mov    0x2b24(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14c2 <main+0x312>
lea    0xbc3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14d0 <main+0x320>
lea    0xba6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x228(%rbp),%eax
mov    0x2ac3(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14fb <main+0x34b>
lea    0xb86(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1509 <main+0x359>
lea    0xb6d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x228(%rbp),%eax
mov    0x2a72(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1534 <main+0x384>
lea    0xb4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1542 <main+0x392>
lea    0xb34(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x228(%rbp),%eax
mov    0x2a99(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     156d <main+0x3bd>
lea    0xb18(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    157b <main+0x3cb>
lea    0xafb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xab2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1241 <main+0x91>
mov    -0x18(%rbp),%rdi
call   1070 <closedir@plt>
xor    %eax,%eax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jne    1406 <main+0x246>
mov    0x8(%r14),%rdi
call   1060 <opendir@plt>
test   %rax,%rax
je     1428 <main+0x268>
mov    %rax,%rbx
mov    %rax,%rdi
call   10c0 <readdir@plt>
test   %rax,%rax
je     13c6 <main+0x206>
mov    %rax,%r15
lea    0x10(%rsp),%r12
mov    $0x2d,%r13d
jmp    132a <main+0x16a>
cs nopw 0x0(%rax,%rax,1)
call   1030 <putchar@plt>
mov    0x2d6c(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x72,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x77,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x78,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x72,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
mov    0x2d48(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x77,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
mov    0x2d1f(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x78,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
mov    0x2cde(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x72,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
mov    0x2cad(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x77,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
mov    0x2cf4(%rip),%rax
and    (%rax),%ebp
mov    $0x78,%edi
cmove  %r13d,%edi
call   1030 <putchar@plt>
mov    0x8(%r15),%rsi
lea    0xd2d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   10c0 <readdir@plt>
mov    %rax,%r15
test   %rax,%rax
je     13c6 <main+0x206>
mov    (%r15),%rsi
lea    0xd0d(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%r14),%rsi
mov    %r12,%rdi
call   1040 <strcpy@plt>
mov    %eax,%edi
lea    0xcf6(%rip),%rsi
call   10d0 <strcat@plt>
mov    0x8(%r15),%rsi
mov    %eax,%edi
call   10d0 <strcat@plt>
mov    %r12,%rdi
lea    0x8(%rsp),%rsi
call   1090 <lstat@plt>
test   %rax,%rax
js     13e2 <main+0x222>
mov    0x8(%rsp),%ebp
mov    0x2c3b(%rip),%rax
mov    (%rax),%eax
and    %ebp,%eax
mov    $0x64,%edi
mov    0x2bf3(%rip),%rcx
cmp    (%rcx),%eax
je     1220 <main+0x60>
mov    %ebp,%edi
call   10b0 <S_ISREG@plt>
mov    $0x2d,%edi
test   %rax,%rax
jne    1220 <main+0x60>
mov    %ebp,%edi
call   1050 <S_ISLNK@plt>
test   %rax,%rax
mov    $0x6c,%edi
mov    $0x3f,%eax
cmove  %eax,%edi
jmp    1220 <main+0x60>
mov    %rbx,%rdi
call   1080 <closedir@plt>
xor    %eax,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bc7(%rip),%rax
mov    (%rax),%edi
lea    0xc56(%rip),%rsi
lea    0x10(%rsp),%rdx
call   10a0 <fprintf@plt>
mov    $0x3,%edi
call   10e0 <exit@plt>
mov    0x2ba3(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xbe7(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2b81(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xbdc(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.dirent = type { i8*, i8* }
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"utilisation: %s chemin\0A\00"
@.str.1 = [41 x i8] c"Impossible d'ouvrir le r\C3\A9pertoire : %s\0A\00"
@.str.2 = [5 x i8] c"%ld \00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [37 x i8] c"Impossible d'ouvrir le fichier : %s\0A\00"
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
@.str.5 = [2 x i8] c"d\00"
@.str.6 = [2 x i8] c"-\00"
@.str.7 = [2 x i8] c"l\00"
@.str.8 = [2 x i8] c"?\00"
@S_IRUSR = global i32 0
@.str.9 = [2 x i8] c"r\00"
@S_IWUSR = global i32 0
@.str.10 = [2 x i8] c"w\00"
@S_IXUSR = global i32 0
@.str.11 = [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.12 = [5 x i8] c" %s\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 [512 x i8]
%9 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32* @opendir(i8* %22)
store i32* %23, i32** %6
%24 = load i32*, i32** %6
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %33
26: ; preds = %19
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = call i32 @exit(i32 2)
unreachable
33: ; preds = %19
br label %34
34: ; preds = %178, %33
%35 = load i32*, i32** %6
%36 = call %struct.dirent* @readdir(i32* %35)
store %struct.dirent* %36, %struct.dirent** %7
%37 = icmp ne %struct.dirent* %36, null
br i1 %37, label %38, label %183
38: ; preds = %34
%39 = load %struct.dirent*, %struct.dirent** %7
%40 = getelementptr inbounds %struct.dirent, %struct.dirent* %39, i32 0, i32 0
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i32 @strcpy(i8* %43, i8* %46)
%48 = call i32 @strcat(i32 %47, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%49 = load %struct.dirent*, %struct.dirent** %7
%50 = getelementptr inbounds %struct.dirent, %struct.dirent* %49, i32 0, i32 1
%51 = load i8*, i8** %50
%52 = call i32 @strcat(i32 %48, i8* %51)
%53 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%54 = call i64 @lstat(i8* %53, %struct.stat* %9)
%55 = icmp slt i64 %54, 0
br i1 %55, label %56, label %61
56: ; preds = %38
%57 = load i32, i32* @stderr
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %8, i64 0, i64 0
%59 = call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %58)
%60 = call i32 @exit(i32 3)
unreachable
61: ; preds = %38
%62 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%63 = load i32, i32* %62
%64 = load i32, i32* @S_IFMT
%65 = and i32 %63, %64
%66 = load i32, i32* @S_IFDIR
%67 = icmp eq i32 %65, %66
br i1 %67, label %68, label %70
68: ; preds = %61
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %88
70: ; preds = %61
%71 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%72 = load i32, i32* %71
%73 = call i64 @S_ISREG(i32 %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %70
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %87
77: ; preds = %70
%78 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%79 = load i32, i32* %78
%80 = call i64 @S_ISLNK(i32 %79)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
br label %86
84: ; preds = %77
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %86
86: ; preds = %84, %82
br label %87
87: ; preds = %86, %75
br label %88
88: ; preds = %87, %68
%89 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%90 = load i32, i32* %89
%91 = load i32, i32* @S_IRUSR
%92 = and i32 %90, %91
%93 = icmp ne i32 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %88
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %98
96: ; preds = %88
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %98
98: ; preds = %96, %94
%99 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%100 = load i32, i32* %99
%101 = load i32, i32* @S_IWUSR
%102 = and i32 %100, %101
%103 = icmp ne i32 %102, 0
br i1 %103, label %104, label %106
104: ; preds = %98
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %108
106: ; preds = %98
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %108
108: ; preds = %106, %104
%109 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%110 = load i32, i32* %109
%111 = load i32, i32* @S_IXUSR
%112 = and i32 %110, %111
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %116
114: ; preds = %108
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %118
116: ; preds = %108
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %118
118: ; preds = %116, %114
%119 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%120 = load i32, i32* %119
%121 = load i32, i32* @S_IRGRP
%122 = and i32 %120, %121
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %126
124: ; preds = %118
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %128
126: ; preds = %118
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %128
128: ; preds = %126, %124
%129 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%130 = load i32, i32* %129
%131 = load i32, i32* @S_IWGRP
%132 = and i32 %130, %131
%133 = icmp ne i32 %132, 0
br i1 %133, label %134, label %136
134: ; preds = %128
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %138
136: ; preds = %128
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %138
138: ; preds = %136, %134
%139 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%140 = load i32, i32* %139
%141 = load i32, i32* @S_IXGRP
%142 = and i32 %140, %141
%143 = icmp ne i32 %142, 0
br i1 %143, label %144, label %146
144: ; preds = %138
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %148
146: ; preds = %138
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %148
148: ; preds = %146, %144
%149 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%150 = load i32, i32* %149
%151 = load i32, i32* @S_IROTH
%152 = and i32 %150, %151
%153 = icmp ne i32 %152, 0
br i1 %153, label %154, label %156
154: ; preds = %148
%155 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %158
156: ; preds = %148
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %158
158: ; preds = %156, %154
%159 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%160 = load i32, i32* %159
%161 = load i32, i32* @S_IWOTH
%162 = and i32 %160, %161
%163 = icmp ne i32 %162, 0
br i1 %163, label %164, label %166
164: ; preds = %158
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %168
166: ; preds = %158
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %168
168: ; preds = %166, %164
%169 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%170 = load i32, i32* %169
%171 = load i32, i32* @S_IXOTH
%172 = and i32 %170, %171
%173 = icmp ne i32 %172, 0
br i1 %173, label %174, label %176
174: ; preds = %168
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %178
176: ; preds = %168
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %178
178: ; preds = %176, %174
%179 = load %struct.dirent*, %struct.dirent** %7
%180 = getelementptr inbounds %struct.dirent, %struct.dirent* %179, i32 0, i32 1
%181 = load i8*, i8** %180
%182 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %181)
br label %34
183: ; preds = %34
%184 = load i32*, i32** %6
%185 = call i32 @closedir(i32* %184)
br label %186
186: ; preds = %183
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i8*, i8* }
@stderr = global i32 0
@.str = [24 x i8] c"utilisation: %s chemin\0A\00"
@.str.1 = [41 x i8] c"Impossible d'ouvrir le r\C3\A9pertoire : %s\0A\00"
@.str.2 = [5 x i8] c"%ld \00"
@.str.3 = [2 x i8] c"/\00"
@.str.4 = [37 x i8] c"Impossible d'ouvrir le fichier : %s\0A\00"
@S_IFMT = global i32 0
@S_IFDIR = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IXUSR = global i32 0
@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.12 = [5 x i8] c" %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca %struct.stat
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
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 %16, label %21
16: ; preds = %11
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %12
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 2)
unreachable
21: ; preds = %11
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%23 = bitcast %struct.stat* %4 to i8*
%24 = call %struct.dirent* @readdir(i32* %14)
%25 = icmp eq %struct.dirent* %24, null
br i1 %25, label %110, label %26
26: ; preds = %21
%27 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
br label %28
28: ; preds = %26, %58
%29 = phi %struct.dirent* [ %24, %26 ], [ %108, %58 ]
%30 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i64 0, i32 0
%31 = load i8*, i8** %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %12
%34 = call i32 @strcpy(i8* %22, i8* %33)
%35 = call i32 @strcat(i32 %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%36 = getelementptr inbounds %struct.dirent, %struct.dirent* %29, i64 0, i32 1
%37 = load i8*, i8** %36
%38 = call i32 @strcat(i32 %35, i8* %37)
%39 = call i64 @lstat(i8* %22, %struct.stat* %4)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %45
41: ; preds = %28
%42 = load i32, i32* @stderr
%43 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %22)
%44 = call i32 @exit(i32 3)
unreachable
45: ; preds = %28
%46 = load i32, i32* %27
%47 = load i32, i32* @S_IFMT
%48 = and i32 %47, %46
%49 = load i32, i32* @S_IFDIR
%50 = icmp eq i32 %48, %49
br i1 %50, label %58, label %51
51: ; preds = %45
%52 = call i64 @S_ISREG(i32 %46)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = call i64 @S_ISLNK(i32 %46)
%56 = icmp eq i64 %55, 0
%57 = select i1 %56, i32 63, i32 108
br label %58
58: ; preds = %54, %51, %45
%59 = phi i32 [ 100, %45 ], [ 45, %51 ], [ %57, %54 ]
%60 = call i32 @putchar(i32 %59)
%61 = load i32, i32* @S_IRUSR
%62 = and i32 %61, %46
%63 = icmp eq i32 %62, 0
%64 = select i1 %63, i32 45, i32 114
%65 = call i32 @putchar(i32 %64)
%66 = load i32, i32* @S_IWUSR
%67 = and i32 %66, %46
%68 = icmp eq i32 %67, 0
%69 = select i1 %68, i32 45, i32 119
%70 = call i32 @putchar(i32 %69)
%71 = load i32, i32* @S_IXUSR
%72 = and i32 %71, %46
%73 = icmp eq i32 %72, 0
%74 = select i1 %73, i32 45, i32 120
%75 = call i32 @putchar(i32 %74)
%76 = load i32, i32* @S_IRGRP
%77 = and i32 %76, %46
%78 = icmp eq i32 %77, 0
%79 = select i1 %78, i32 45, i32 114
%80 = call i32 @putchar(i32 %79)
%81 = load i32, i32* @S_IWGRP
%82 = and i32 %81, %46
%83 = icmp eq i32 %82, 0
%84 = select i1 %83, i32 45, i32 119
%85 = call i32 @putchar(i32 %84)
%86 = load i32, i32* @S_IXGRP
%87 = and i32 %86, %46
%88 = icmp eq i32 %87, 0
%89 = select i1 %88, i32 45, i32 120
%90 = call i32 @putchar(i32 %89)
%91 = load i32, i32* @S_IROTH
%92 = and i32 %91, %46
%93 = icmp eq i32 %92, 0
%94 = select i1 %93, i32 45, i32 114
%95 = call i32 @putchar(i32 %94)
%96 = load i32, i32* @S_IWOTH
%97 = and i32 %96, %46
%98 = icmp eq i32 %97, 0
%99 = select i1 %98, i32 45, i32 119
%100 = call i32 @putchar(i32 %99)
%101 = load i32, i32* @S_IXOTH
%102 = and i32 %101, %46
%103 = icmp eq i32 %102, 0
%104 = select i1 %103, i32 45, i32 120
%105 = call i32 @putchar(i32 %104)
%106 = load i8*, i8** %36
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.12, i64 0, i64 0), i8* %106)
%108 = call %struct.dirent* @readdir(i32* %14)
%109 = icmp eq %struct.dirent* %108, null
br i1 %109, label %110, label %28
110: ; preds = %58, %21
%111 = call i32 @closedir(i32* %14)
ret i32 0
}