#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 slName {
  int dummy;
};
struct lineFile {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ lineFileClose(struct lineFile **);
scalar_t__ lineFileNext(struct lineFile *, char **, int /*<<< orphan*/ *);
struct lineFile *lineFileOpen(char *, int);
struct slName *newSlName(char *);
int /*<<< orphan*/ slAddHead(struct slName **, struct slName *);
int /*<<< orphan*/ slReverse(struct slName **);
struct slName *readAllLines(char *fileName) {
  struct lineFile *lf = lineFileOpen(fileName, 1);
  struct slName *list = NULL, *el;
  char *line;
  while (lineFileNext(lf, &line, NULL)) {
    el = newSlName(line);
    slAddHead(&list, el);
  }
  lineFileClose(&lf);
  slReverse(&list);
  return list;
}


x86 assembly (clang, -O0):
<readAllLines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1080 <lineFileOpen@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <lineFileNext@plt>
cmp    $0x0,%rax
je     11c0 <readAllLines+0x60>
mov    -0x28(%rbp),%rdi
call   1070 <newSlName@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   1040 <slAddHead@plt>
jmp    1186 <readAllLines+0x26>
lea    -0x10(%rbp),%rdi
call   1030 <lineFileClose@plt>
lea    -0x18(%rbp),%rdi
call   1050 <slReverse@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readAllLines>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x1,%esi
call   1080 <lineFileOpen@plt>
mov    %rax,%rbx
mov    %rax,0x18(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
xor    %edx,%edx
call   1060 <lineFileNext@plt>
test   %rax,%rax
je     11d7 <readAllLines+0x77>
lea    0x8(%rsp),%r14
lea    0x10(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x10(%rsp),%rdi
call   1070 <newSlName@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <slAddHead@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1060 <lineFileNext@plt>
test   %rax,%rax
jne    11b0 <readAllLines+0x50>
lea    0x18(%rsp),%rdi
call   1030 <lineFileClose@plt>
lea    0x8(%rsp),%rdi
call   1050 <slReverse@plt>
mov    0x8(%rsp),%rax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.slName = type { i32 }
%struct.lineFile = type { i32 }
define %struct.slName* @readAllLines(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.lineFile*
%4 = alloca %struct.slName*
%5 = alloca %struct.slName*
%6 = alloca i8*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call %struct.lineFile* @lineFileOpen(i8* %7, i32 1)
store %struct.lineFile* %8, %struct.lineFile** %3
store %struct.slName* null, %struct.slName** %4
br label %9
9: ; preds = %13, %1
%10 = load %struct.lineFile*, %struct.lineFile** %3
%11 = call i64 @lineFileNext(%struct.lineFile* %10, i8** %6, i32* null)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i8*, i8** %6
%15 = call %struct.slName* @newSlName(i8* %14)
store %struct.slName* %15, %struct.slName** %5
%16 = load %struct.slName*, %struct.slName** %5
%17 = call i32 @slAddHead(%struct.slName** %4, %struct.slName* %16)
br label %9
18: ; preds = %9
%19 = call i32 @lineFileClose(%struct.lineFile** %3)
%20 = call i32 @slReverse(%struct.slName** %4)
%21 = load %struct.slName*, %struct.slName** %4
ret %struct.slName* %21
}

LLVM IR (-O2):
%struct.slName = type { i32 }
%struct.lineFile = type { i32 }
define %struct.slName* @readAllLines(i8* %0) {
%2 = alloca %struct.lineFile*
%3 = alloca %struct.slName*
%4 = alloca i8*
%5 = bitcast %struct.lineFile** %2 to i8*
%6 = tail call %struct.lineFile* @lineFileOpen(i8* %0, i32 1)
store %struct.lineFile* %6, %struct.lineFile** %2
%7 = bitcast %struct.slName** %3 to i8*
store %struct.slName* null, %struct.slName** %3
%8 = bitcast i8** %4 to i8*
%9 = call i64 @lineFileNext(%struct.lineFile* %6, i8** %4, i32* null)
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %1, %11
%12 = load i8*, i8** %4
%13 = call %struct.slName* @newSlName(i8* %12)
%14 = call i32 @slAddHead(%struct.slName** %3, %struct.slName* %13)
%15 = call i64 @lineFileNext(%struct.lineFile* %6, i8** %4, i32* null)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %11
17: ; preds = %11, %1
%18 = call i32 @lineFileClose(%struct.lineFile** %2)
%19 = call i32 @slReverse(%struct.slName** %3)
%20 = load %struct.slName*, %struct.slName** %3
ret %struct.slName* %20
}