#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 */
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);
  }
  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   1070 <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   1050 <lineFileNext@plt>
cmp    $0x0,%rax
je     11b0 <readAllLines+0x60>
mov    -0x28(%rbp),%rdi
call   1060 <newSlName@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   1030 <slAddHead@plt>
jmp    1176 <readAllLines+0x26>
lea    -0x18(%rbp),%rdi
call   1040 <slReverse@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readAllLines>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    $0x1,%esi
call   1070 <lineFileOpen@plt>
mov    %rax,%rbx
movq   $0x0,(%rsp)
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
xor    %edx,%edx
call   1050 <lineFileNext@plt>
test   %rax,%rax
je     11b7 <readAllLines+0x67>
mov    %rsp,%r14
lea    0x8(%rsp),%r15
nopw   0x0(%rax,%rax,1)
mov    0x8(%rsp),%rdi
call   1060 <newSlName@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <slAddHead@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1050 <lineFileNext@plt>
test   %rax,%rax
jne    1190 <readAllLines+0x40>
mov    %rsp,%rdi
call   1040 <slReverse@plt>
mov    (%rsp),%rax
add    $0x10,%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 @slReverse(%struct.slName** %4)
%20 = load %struct.slName*, %struct.slName** %4
ret %struct.slName* %20
}

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