#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 */
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
void *malloc(int);
int nombreFichiers(char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char **chargeListeFichiers(char *fichierConfig) {
  int nombre = nombreFichiers(fichierConfig);
  char **listeFichiers = malloc(nombre * sizeof(char *));
  int fichier = open(fichierConfig, O_RDONLY);
  if (fichier == -1) {
    perror("fichier");
    exit(-1);
  }
  int indiceFichiers = 0;
  char buffer[1024];
  int lu = 0;
  lu = read(fichier, buffer, sizeof(buffer));
  char *fin;
  int i;
  char *precedent = buffer - 1;
  char *tmp = malloc(20 * sizeof(char));
  for (i = 0; i < lu; i++) {
    if (buffer[i] == '\n') {
      strncpy(tmp, precedent + 1, (int)(&buffer[i] - precedent));
      tmp[(int)(&buffer[i] - precedent) - 1] = '\0';
      listeFichiers[indiceFichiers] = malloc((strlen(tmp) + 1) * sizeof(char));
      strcpy(listeFichiers[indiceFichiers], tmp);
      indiceFichiers++;
      precedent = &buffer[i];
      fin = &buffer[i] + 1;
    }
  }
  buffer[lu] = '\0';
  strncpy(tmp, fin, (int)(&buffer[lu] - fin + 1));
  listeFichiers[indiceFichiers] = malloc((strlen(tmp) + 1) * sizeof(char));
  strcpy(listeFichiers[indiceFichiers], tmp);
  close(fichier);
  return listeFichiers;
}


x86 assembly (clang, -O0):
<chargeListeFichiers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <nombreFichiers@plt>
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e0f(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1203 <chargeListeFichiers+0x63>
lea    0xe0c(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x424(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x420(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %eax,-0x424(%rbp)
lea    -0x420(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x440(%rbp)
mov    $0x14,%edi
call   1090 <malloc@plt>
mov    %rax,-0x448(%rbp)
movl   $0x0,-0x434(%rbp)
mov    -0x434(%rbp),%eax
cmp    -0x424(%rbp),%eax
jge    137e <chargeListeFichiers+0x1de>
movslq -0x434(%rbp),%rax
movsbl -0x420(%rbp,%rax,1),%eax
ff
cmp    $0xa,%eax
jne    1365 <chargeListeFichiers+0x1c5>
mov    -0x448(%rbp),%rdi
mov    -0x440(%rbp),%rsi
add    $0x1,%rsi
movslq -0x434(%rbp),%rcx
lea    -0x420(%rbp),%rax
add    %rcx,%rax
mov    -0x440(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x448(%rbp),%rax
movslq -0x434(%rbp),%rdx
lea    -0x420(%rbp),%rcx
add    %rdx,%rcx
mov    -0x440(%rbp),%rdx
sub    %rdx,%rcx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x448(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x448(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movslq -0x434(%rbp),%rcx
lea    -0x420(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x440(%rbp)
movslq -0x434(%rbp),%rcx
lea    -0x420(%rbp),%rax
add    %rcx,%rax
add    $0x1,%rax
mov    %rax,-0x430(%rbp)
jmp    136a <chargeListeFichiers+0x1ca>
mov    -0x434(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x434(%rbp)
jmp    125b <chargeListeFichiers+0xbb>
movslq -0x424(%rbp),%rax
movb   $0x0,-0x420(%rbp,%rax,1)
mov    -0x448(%rbp),%rdi
mov    -0x430(%rbp),%rsi
movslq -0x424(%rbp),%rcx
lea    -0x420(%rbp),%rax
add    %rcx,%rax
mov    -0x430(%rbp),%rcx
sub    %rcx,%rax
add    $0x1,%rax
mov    %eax,%edx
call   1040 <strncpy@plt>
mov    -0x448(%rbp),%rdi
call   1060 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x448(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%rax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chargeListeFichiers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %rdi,%rbx
call   1030 <nombreFichiers@plt>
lea    0x0(,%rax,8),%edi
call   1090 <malloc@plt>
mov    %rax,0x20(%rsp)
mov    0x2e17(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10a0 <open@plt>
cmp    $0xffffffff,%eax
je     1357 <chargeListeFichiers+0x1b7>
movabs $0xffffffff00000000,%rbp
ff ff ff
lea    0x30(%rsp),%r14
mov    %eax,0x14(%rsp)
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %eax,%ebx
lea    0x2f(%rsp),%r13
mov    $0x14,%edi
call   1090 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    %ebx,%r15d
mov    %r14,%rbx
shl    $0x20,%rbx
add    %rbp,%rbx
xor    %eax,%eax
mov    %rax,0x8(%rsp)
movabs $0x100000000,%rax
mov    %r15,0x28(%rsp)
mov    %r14,%r12
jmp    1265 <chargeListeFichiers+0xc5>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r12
add    %rax,%rbx
add    $0x1,%r14d
add    $0xffffffffffffffff,%r15
je     12ec <chargeListeFichiers+0x14c>
cmpb   $0xa,(%r12)
jne    1250 <chargeListeFichiers+0xb0>
lea    0x1(%r13),%rsi
mov    %r14d,%edx
sub    %r13d,%edx
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strncpy@plt>
movabs $0xffffffff00000000,%rax
ff ff ff
imul   %rax,%r13
add    %rbx,%r13
sar    $0x20,%r13
movb   $0x0,0x0(%rbp,%r13,1)
mov    %rbp,%rdi
mov    %rbp,%r13
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   1090 <malloc@plt>
mov    0x8(%rsp),%rbp
movslq %ebp,%rbp
mov    0x20(%rsp),%rcx
mov    %rax,(%rcx,%rbp,8)
mov    %rax,%rdi
mov    %r13,%rsi
call   1050 <strcpy@plt>
movabs $0x100000000,%rax
add    $0x1,%ebp
mov    %rbp,0x8(%rsp)
lea    0x1(%r12),%rsi
mov    %r12,%r13
jmp    1250 <chargeListeFichiers+0xb0>
mov    0x28(%rsp),%rax
lea    (%rsp,%rax,1),%rdx
add    $0x30,%rdx
movb   $0x0,0x30(%rsp,%rax,1)
sub    %esi,%edx
add    $0x1,%edx
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strncpy@plt>
mov    %rbp,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%edi
call   1090 <malloc@plt>
movslq 0x8(%rsp),%rcx
mov    0x20(%rsp),%rbx
mov    %rax,(%rbx,%rcx,8)
mov    %rax,%rdi
mov    %rbp,%rsi
call   1050 <strcpy@plt>
mov    0x14(%rsp),%edi
call   1070 <close@plt>
mov    %rbx,%rax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xca2(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [8 x i8] c"fichier\00"
define i8** @chargeListeFichiers(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %2
%13 = load i8*, i8** %2
%14 = call i32 @nombreFichiers(i8* %13)
store i32 %14, i32* %3
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 8
%18 = trunc i64 %17 to i32
%19 = call i8* @malloc(i32 %18)
%20 = bitcast i8* %19 to i8**
store i8** %20, i8*** %4
%21 = load i8*, i8** %2
%22 = load i32, i32* @O_RDONLY
%23 = call i32 @open(i8* %21, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %29
26: ; preds = %1
%27 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @exit(i32 -1)
unreachable
29: ; preds = %1
store i32 0, i32* %6
store i32 0, i32* %8
%30 = load i32, i32* %5
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%32 = call i32 @read(i32 %30, i8* %31, i32 1024)
store i32 %32, i32* %8
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%34 = getelementptr inbounds i8, i8* %33, i64 -1
store i8* %34, i8** %11
%35 = call i8* @malloc(i32 20)
store i8* %35, i8** %12
store i32 0, i32* %10
br label %36
36: ; preds = %100, %29
%37 = load i32, i32* %10
%38 = load i32, i32* %8
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %103
40: ; preds = %36
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 10
br i1 %46, label %47, label %99
47: ; preds = %40
%48 = load i8*, i8** %12
%49 = load i8*, i8** %11
%50 = getelementptr inbounds i8, i8* %49, i64 1
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %52
%54 = load i8*, i8** %11
%55 = ptrtoint i8* %53 to i64
%56 = ptrtoint i8* %54 to i64
%57 = sub i64 %55, %56
%58 = trunc i64 %57 to i32
%59 = call i32 @strncpy(i8* %48, i8* %50, i32 %58)
%60 = load i8*, i8** %12
%61 = load i32, i32* %10
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %62
%64 = load i8*, i8** %11
%65 = ptrtoint i8* %63 to i64
%66 = ptrtoint i8* %64 to i64
%67 = sub i64 %65, %66
%68 = trunc i64 %67 to i32
%69 = sub nsw i32 %68, 1
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %60, i64 %70
store i8 0, i8* %71
%72 = load i8*, i8** %12
%73 = call i32 @strlen(i8* %72)
%74 = add nsw i32 %73, 1
%75 = sext i32 %74 to i64
%76 = mul i64 %75, 1
%77 = trunc i64 %76 to i32
%78 = call i8* @malloc(i32 %77)
%79 = load i8**, i8*** %4
%80 = load i32, i32* %6
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8*, i8** %79, i64 %81
store i8* %78, i8** %82
%83 = load i8**, i8*** %4
%84 = load i32, i32* %6
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8*, i8** %83, i64 %85
%87 = load i8*, i8** %86
%88 = load i8*, i8** %12
%89 = call i32 @strcpy(i8* %87, i8* %88)
%90 = load i32, i32* %6
%91 = add nsw i32 %90, 1
store i32 %91, i32* %6
%92 = load i32, i32* %10
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %93
store i8* %94, i8** %11
%95 = load i32, i32* %10
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %96
%98 = getelementptr inbounds i8, i8* %97, i64 1
store i8* %98, i8** %9
br label %99
99: ; preds = %47, %40
br label %100
100: ; preds = %99
%101 = load i32, i32* %10
%102 = add nsw i32 %101, 1
store i32 %102, i32* %10
br label %36
103: ; preds = %36
%104 = load i32, i32* %8
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %105
store i8 0, i8* %106
%107 = load i8*, i8** %12
%108 = load i8*, i8** %9
%109 = load i32, i32* %8
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %110
%112 = load i8*, i8** %9
%113 = ptrtoint i8* %111 to i64
%114 = ptrtoint i8* %112 to i64
%115 = sub i64 %113, %114
%116 = add nsw i64 %115, 1
%117 = trunc i64 %116 to i32
%118 = call i32 @strncpy(i8* %107, i8* %108, i32 %117)
%119 = load i8*, i8** %12
%120 = call i32 @strlen(i8* %119)
%121 = add nsw i32 %120, 1
%122 = sext i32 %121 to i64
%123 = mul i64 %122, 1
%124 = trunc i64 %123 to i32
%125 = call i8* @malloc(i32 %124)
%126 = load i8**, i8*** %4
%127 = load i32, i32* %6
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i8*, i8** %126, i64 %128
store i8* %125, i8** %129
%130 = load i8**, i8*** %4
%131 = load i32, i32* %6
%132 = sext i32 %131 to i64
%133 = getelementptr inbounds i8*, i8** %130, i64 %132
%134 = load i8*, i8** %133
%135 = load i8*, i8** %12
%136 = call i32 @strcpy(i8* %134, i8* %135)
%137 = load i32, i32* %5
%138 = call i32 @close(i32 %137)
%139 = load i8**, i8*** %4
ret i8** %139
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [8 x i8] c"fichier\00"
define noalias i8** @chargeListeFichiers(i8* %0) {
%2 = alloca [1024 x i8]
%3 = tail call i32 @nombreFichiers(i8* %0)
%4 = shl i32 %3, 3
%5 = tail call i8* @malloc(i32 %4)
%6 = bitcast i8* %5 to i8**
%7 = load i32, i32* @O_RDONLY
%8 = tail call i32 @open(i8* %0, i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @exit(i32 -1)
unreachable
13: ; preds = %1
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%15 = call i32 @read(i32 %8, i8* %14, i32 1024)
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 -1
%17 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%18 = icmp sgt i32 %15, 0
%19 = zext i32 %15 to i64
br label %20
20: ; preds = %13, %47
%21 = phi i64 [ 0, %13 ], [ %51, %47 ]
%22 = phi i32 [ 0, %13 ], [ %50, %47 ]
%23 = phi i8* [ %16, %13 ], [ %49, %47 ]
%24 = phi i8* [ undef, %13 ], [ %48, %47 ]
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %21
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 10
br i1 %27, label %28, label %47
28: ; preds = %20
%29 = getelementptr inbounds i8, i8* %23, i64 1
%30 = ptrtoint i8* %25 to i64
%31 = ptrtoint i8* %23 to i64
%32 = sub i64 %30, %31
%33 = trunc i64 %32 to i32
%34 = call i32 @strncpy(i8* %17, i8* %29, i32 %33)
%35 = shl i64 %32, 32
%36 = add i64 %35, -4294967296
%37 = ashr exact i64 %36, 32
%38 = getelementptr inbounds i8, i8* %17, i64 %37
store i8 0, i8* %38
%39 = call i32 @strlen(i8* %17)
%40 = add nsw i32 %39, 1
%41 = call i8* @malloc(i32 %40)
%42 = sext i32 %22 to i64
%43 = getelementptr inbounds i8*, i8** %6, i64 %42
store i8* %41, i8** %43
%44 = call i32 @strcpy(i8* %41, i8* %17)
%45 = add nsw i32 %22, 1
%46 = getelementptr inbounds i8, i8* %25, i64 1
br label %47
47: ; preds = %20, %28
%48 = phi i8* [ %46, %28 ], [ %24, %20 ]
%49 = phi i8* [ %25, %28 ], [ %23, %20 ]
%50 = phi i32 [ %45, %28 ], [ %22, %20 ]
%51 = add nuw nsw i64 %21, 1
%52 = icmp eq i64 %51, %19
br i1 %52, label %53, label %20
53: ; preds = %47
%54 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %19
store i8 0, i8* %54
%55 = ptrtoint i8* %54 to i64
%56 = ptrtoint i8* %48 to i64
%57 = sub i64 %55, %56
%58 = trunc i64 %57 to i32
%59 = add i32 %58, 1
%60 = call i32 @strncpy(i8* %17, i8* %48, i32 %59)
%61 = call i32 @strlen(i8* %17)
%62 = add nsw i32 %61, 1
%63 = call i8* @malloc(i32 %62)
%64 = sext i32 %50 to i64
%65 = getelementptr inbounds i8*, i8** %6, i64 %64
store i8* %63, i8** %65
%66 = call i32 @strcpy(i8* %63, i8* %17)
%67 = call i32 @close(i32 %8)
ret i8** %6
}