#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getLine(char **, int /*<<< orphan*/ *);
int /*<<< orphan*/ libererSimple(void **);
int /*<<< orphan*/ printf(char *, ...);
int getLine_test(char *fileName) {
  int lastLine = 0;
  char *ch = NULL;
  FILE *fichier = NULL;
  fichier = fopen(fileName, "r");
  if (fichier != NULL) {
    printf("### BOF ###\n");
    while (lastLine != 1) {
      lastLine = getLine(&ch, fichier);
      printf("%s\n", ch);
      libererSimple((void **)&ch);
    }
    printf("### EOF ###\n");
    fclose(fichier);
  } else {
    printf("Fichier inexistant : %s", fileName);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<getLine_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f6 <getLine_test+0xa6>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x1,-0x14(%rbp)
je     11da <getLine_test+0x8a>
mov    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdi
call   1070 <getLine@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <libererSimple@plt>
jmp    11a0 <getLine_test+0x50>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    1214 <getLine_test+0xc4>
mov    -0x10(%rbp),%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    121b <getLine_test+0xcb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLine_test>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movq   $0x0,0x8(%rsp)
lea    0xe85(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11dc <getLine_test+0x7c>
mov    %rax,%r14
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rbx
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <getLine@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <libererSimple@plt>
cmp    $0x1,%ebp
jne    11a0 <getLine_test+0x40>
lea    0xe5b(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
jmp    11f2 <getLine_test+0x92>
lea    0xe1f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [13 x i8] c"### BOF ###\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [13 x i8] c"### EOF ###\0A\00"
@.str.4 = [24 x i8] c"Fichier inexistant : %s\00"
define i32 @getLine_test(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
store i8* %0, i8** %3
store i32 0, i32* %4
store i8* null, i8** %5
store i32* null, i32** %6
%7 = load i8*, i8** %3
%8 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp ne i32* %9, null
br i1 %10, label %11, label %26
11: ; preds = %1
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %16, %11
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i32*, i32** %6
%18 = call i32 @getLine(i8** %5, i32* %17)
store i32 %18, i32* %4
%19 = load i8*, i8** %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = call i32 @libererSimple(i8** %5)
br label %13
22: ; preds = %13
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%24 = load i32*, i32** %6
%25 = call i32 @fclose(i32* %24)
br label %29
26: ; preds = %1
%27 = load i8*, i8** %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %27)
store i32 1, i32* %2
br label %30
29: ; preds = %22
store i32 0, i32* %2
br label %30
30: ; preds = %29, %26
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.4 = [24 x i8] c"Fichier inexistant : %s\00"
@str = [12 x i8] c"### BOF ###\00"
@str.5 = [12 x i8] c"### EOF ###\00"
define i32 @getLine_test(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%4 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %17, label %6
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %8
8: ; preds = %6, %8
%9 = call i32 @getLine(i8** %2, i32* %4)
%10 = load i8*, i8** %2
%11 = call i32 @puts(i8* dereferenceable(1) %10)
%12 = call i32 @libererSimple(i8** %2)
%13 = icmp eq i32 %9, 1
br i1 %13, label %14, label %8
14: ; preds = %8
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.5, i64 0, i64 0))
%16 = call i32 @fclose(i32* %4)
br label %19
17: ; preds = %1
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %14, %17
%20 = phi i32 [ 0, %14 ], [ 1, %17 ]
ret i32 %20
}