#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*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
scalar_t__ getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int main() {
  char *line = NULL;
  size_t line_size = 0;
  FILE *fp;
  fp = fopen("stats.txt", "r");
  while (getline(&line, &line_size, fp) > 0) {
    printf("Line : %s", line);
  }
  free(line);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
lea    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <getline@plt>
cmp    $0x0,%rax
jle    11a6 <main+0x66>
mov    -0x10(%rbp),%rsi
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
jmp    1176 <main+0x36>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0xe9c(%rip),%rdi
lea    0xe9f(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %rax,%rdx
call   1060 <getline@plt>
test   %rax,%rax
jle    11c0 <main+0x80>
lea    0xe7b(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1060 <getline@plt>
test   %rax,%rax
jg     11a0 <main+0x60>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"stats.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"Line : %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32*
store i32 0, i32* %1
store i8* null, i8** %2
store i64 0, i64* %3
%5 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %4
br label %6
6: ; preds = %10, %0
%7 = load i32*, i32** %4
%8 = call i64 @getline(i8** %2, i64* %3, i32* %7)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %11)
br label %6
13: ; preds = %6
%14 = load i8*, i8** %2
%15 = call i32 @free(i8* %14)
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str = [10 x i8] c"stats.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [10 x i8] c"Line : %s\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i64
%3 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = call i64 @getline(i8** %1, i64* %2, i32* %5)
%7 = icmp sgt i64 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %0, %8
%9 = load i8*, i8** %1
%10 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = call i64 @getline(i8** %1, i64* %2, i32* %5)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %8, label %13
13: ; preds = %8, %0
%14 = load i8*, i8** %1
%15 = call i32 @free(i8* %14)
ret i32 0
}