#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 *);
scalar_t__ getline(char **, unsigned int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, unsigned int, char *);
int main() {
  FILE *fp = fopen("README.txt", "r");
  if (!fp)
    return 1;
  char *p = NULL;
  unsigned int n = 0;
  while (getline(&p, &n, fp) > 0)
    printf("%d: %s", n, p);
  fclose(fp);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    117d <main+0x3d>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <main+0x88>
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <getline@plt>
cmp    $0x0,%rax
jle    11bf <main+0x7f>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%rdx
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
jmp    118c <main+0x4c>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@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
lea    0xeae(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d0 <main+0x90>
mov    %rax,%rbx
movq   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
mov    %rax,%rdx
call   1060 <getline@plt>
test   %rax,%rax
jle    11c4 <main+0x84>
lea    0xe78(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
nop
mov    0xc(%rsp),%esi
mov    0x10(%rsp),%rdx
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    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    11d5 <main+0x95>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"README.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"%d: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 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** %2
%6 = load i32*, i32** %2
%7 = icmp ne i32* %6, null
br i1 %7, label %9, label %8
8: ; preds = %0
store i32 1, i32* %1
br label %21
9: ; preds = %0
store i8* null, i8** %3
store i32 0, i32* %4
br label %10
10: ; preds = %14, %9
%11 = load i32*, i32** %2
%12 = call i64 @getline(i8** %3, i32* %4, i32* %11)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* %4
%16 = load i8*, i8** %3
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %15, i8* %16)
br label %10
18: ; preds = %10
%19 = load i32*, i32** %2
%20 = call i32 @fclose(i32* %19)
br label %21
21: ; preds = %18, %8
%22 = load i32, i32* %1
ret i32 %22
}

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