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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
struct dirent *readdir(int /*<<< orphan*/ *);
void lireDossier(char *s, DIR *rep) {
  struct dirent *ent = NULL;
  printf(" -- Lecture du dossier '%s' -- \n", s);
  while ((ent = readdir(rep)) != NULL)
    printf("%s\n", ent->d_name);
  printf("\n\n -- Que voulez-vous ouvrir -- ?\n");
}


x86 assembly (clang, -O0):
<lireDossier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <readdir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     117b <lireDossier+0x5b>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114a <lireDossier+0x2a>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lireDossier>:
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
call   1050 <readdir@plt>
test   %rax,%rax
je     1167 <lireDossier+0x37>
mov    (%rax),%rdi
call   1030 <puts@plt>
jmp    1150 <lireDossier+0x20>
lea    0xeb3(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [33 x i8] c" -- Lecture du dossier '%s' -- \0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [35 x i8] c"\0A\0A -- Que voulez-vous ouvrir -- ?\0A\00"
define void @lireDossier(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.dirent*
store i8* %0, i8** %3
store i32* %1, i32** %4
store %struct.dirent* null, %struct.dirent** %5
%6 = load i8*, i8** %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %8
8: ; preds = %12, %2
%9 = load i32*, i32** %4
%10 = call %struct.dirent* @readdir(i32* %9)
store %struct.dirent* %10, %struct.dirent** %5
%11 = icmp ne %struct.dirent* %10, null
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load %struct.dirent*, %struct.dirent** %5
%14 = getelementptr inbounds %struct.dirent, %struct.dirent* %13, i32 0, i32 0
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %8
17: ; preds = %8
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [33 x i8] c" -- Lecture du dossier '%s' -- \0A\00"
@str = [34 x i8] c"\0A\0A -- Que voulez-vous ouvrir -- ?\00"
define void @lireDossier(i8* %0, i32* %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0)
%4 = tail call %struct.dirent* @readdir(i32* %1)
%5 = icmp eq %struct.dirent* %4, null
br i1 %5, label %13, label %6
6: ; preds = %2, %6
%7 = phi %struct.dirent* [ %11, %6 ], [ %4, %2 ]
%8 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = tail call i32 @puts(i8* dereferenceable(1) %9)
%11 = tail call %struct.dirent* @readdir(i32* %1)
%12 = icmp eq %struct.dirent* %11, null
br i1 %12, label %13, label %6
13: ; preds = %6, %2
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
ret void
}