#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*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fread(char *, int, long, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
void *malloc(int);
int /*<<< orphan*/ perror(char *);
char *strchr(char *, char);
int strlen(char *);
char **load_words(char *path, int *lines) {
  char **words = NULL;
  char *filecont;
  char *last;
  FILE *dict = fopen(path, "r");
  if (!dict) {
    perror("open");
    exit(1);
  }
  fseek(dict, 0L, SEEK_END);
  long len = ftell(dict);
  filecont = malloc(len);
  fseek(dict, 0L, SEEK_SET);
  if (!fread(filecont, 1, len, dict)) {
    perror("read");
    exit(1);
  }
  fclose(dict);
  *lines = 0;
  for (last = filecont; last; last = strchr(last, '\n')) {
    if (last != filecont)
      *last = 0;
    last++;
    (*lines)++;
  }
  words = malloc(*lines * sizeof(*words));
  for (*lines = 0, last = filecont; last < filecont + len;) {
    int l;
    if (!*last) {
      last++;
      continue;
    }
    l = strlen(last);
    words[(*lines)++] = last;
    last += l + 1;
  }
  return words;
}


x86 assembly (clang, -O0):
<load_words>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe3d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11ed <load_words+0x4d>
lea    0xe24(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rdi
mov    0x2df0(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   1070 <ftell@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x2dae(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   1090 <fseek@plt>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
cmp    $0x0,%eax
jne    126a <load_words+0xca>
lea    0xdac(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12d3 <load_words+0x133>
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     12a5 <load_words+0x105>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
mov    %rax,-0x28(%rbp)
jmp    1285 <load_words+0xe5>
mov    -0x10(%rbp),%rax
movslq (%rax),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x20(%rbp),%rcx
add    -0x38(%rbp),%rcx
cmp    %rcx,%rax
jae    136f <load_words+0x1cf>
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
jne    132e <load_words+0x18e>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    12fb <load_words+0x15b>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rsi
mov    (%rsi),%ecx
mov    %ecx,%edi
add    $0x1,%edi
mov    %edi,(%rsi)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x3c(%rbp),%ecx
add    $0x1,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    12fb <load_words+0x15b>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_words>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
lea    0xe4d(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12cb <load_words+0x12b>
mov    %rax,%r13
mov    0x2e1d(%rip),%rax
mov    (%rax),%edx
xor    %r12d,%r12d
mov    %r13,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r13,%rdi
call   1070 <ftell@plt>
mov    %rax,%r15
mov    %r15d,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    0x2de1(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
mov    %r13,%rcx
call   1030 <fread@plt>
test   %eax,%eax
je     12d4 <load_words+0x134>
mov    %r13,%rdi
call   1040 <fclose@plt>
movl   $0x0,(%r14)
test   %rbx,%rbx
je     126e <load_words+0xce>
xor    %r12d,%r12d
mov    %rbx,%rax
jmp    125d <load_words+0xbd>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
add    $0x1,%r12d
mov    %r12d,(%r14)
mov    %rax,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     126a <load_words+0xca>
cmp    %rbx,%rax
je     1240 <load_words+0xa0>
movb   $0x0,(%rax)
mov    (%r14),%r12d
jmp    1240 <load_words+0xa0>
shl    $0x3,%r12d
mov    %r12d,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
movl   $0x0,(%r14)
test   %r15,%r15
jle    12be <load_words+0x11e>
mov    %rbx,%r13
add    %r15,%r13
jmp    12b2 <load_words+0x112>
nopl   (%rax)
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq (%r14),%rcx
lea    0x1(%rcx),%edx
mov    %edx,(%r14)
mov    %rbx,(%r12,%rcx,8)
add    $0x1,%eax
cltq
add    %rax,%rbx
cmp    %r13,%rbx
jae    12be <load_words+0x11e>
cmpb   $0x0,(%rbx)
jne    1290 <load_words+0xf0>
mov    $0x1,%eax
jmp    12aa <load_words+0x10a>
mov    %r12,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xd30(%rip),%rdi
jmp    12db <load_words+0x13b>
lea    0xd2c(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"open\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [5 x i8] c"read\00"
define i8** @load_words(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i64
%10 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
store i8** null, i8*** %5
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %12, i32** %8
%13 = load i32*, i32** %8
%14 = icmp ne i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = load i32*, i32** %8
%20 = load i32, i32* @SEEK_END
%21 = call i32 @fseek(i32* %19, i64 0, i32 %20)
%22 = load i32*, i32** %8
%23 = call i64 @ftell(i32* %22)
store i64 %23, i64* %9
%24 = load i64, i64* %9
%25 = trunc i64 %24 to i32
%26 = call i8* @malloc(i32 %25)
store i8* %26, i8** %6
%27 = load i32*, i32** %8
%28 = load i32, i32* @SEEK_SET
%29 = call i32 @fseek(i32* %27, i64 0, i32 %28)
%30 = load i8*, i8** %6
%31 = load i64, i64* %9
%32 = load i32*, i32** %8
%33 = call i32 @fread(i8* %30, i32 1, i64 %31, i32* %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %18
%36 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %18
%39 = load i32*, i32** %8
%40 = call i32 @fclose(i32* %39)
%41 = load i32*, i32** %4
store i32 0, i32* %41
%42 = load i8*, i8** %6
store i8* %42, i8** %7
br label %43
43: ; preds = %58, %38
%44 = load i8*, i8** %7
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %61
46: ; preds = %43
%47 = load i8*, i8** %7
%48 = load i8*, i8** %6
%49 = icmp ne i8* %47, %48
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = load i8*, i8** %7
store i8 0, i8* %51
br label %52
52: ; preds = %50, %46
%53 = load i8*, i8** %7
%54 = getelementptr inbounds i8, i8* %53, i32 1
store i8* %54, i8** %7
%55 = load i32*, i32** %4
%56 = load i32, i32* %55
%57 = add nsw i32 %56, 1
store i32 %57, i32* %55
br label %58
58: ; preds = %52
%59 = load i8*, i8** %7
%60 = call i8* @strchr(i8* %59, i8 signext 10)
store i8* %60, i8** %7
br label %43
61: ; preds = %43
%62 = load i32*, i32** %4
%63 = load i32, i32* %62
%64 = sext i32 %63 to i64
%65 = mul i64 %64, 8
%66 = trunc i64 %65 to i32
%67 = call i8* @malloc(i32 %66)
%68 = bitcast i8* %67 to i8**
store i8** %68, i8*** %5
%69 = load i32*, i32** %4
store i32 0, i32* %69
%70 = load i8*, i8** %6
store i8* %70, i8** %7
br label %71
71: ; preds = %84, %81, %61
%72 = load i8*, i8** %7
%73 = load i8*, i8** %6
%74 = load i64, i64* %9
%75 = getelementptr inbounds i8, i8* %73, i64 %74
%76 = icmp ult i8* %72, %75
br i1 %76, label %77, label %99
77: ; preds = %71
%78 = load i8*, i8** %7
%79 = load i8, i8* %78
%80 = icmp ne i8 %79, 0
br i1 %80, label %84, label %81
81: ; preds = %77
%82 = load i8*, i8** %7
%83 = getelementptr inbounds i8, i8* %82, i32 1
store i8* %83, i8** %7
br label %71
84: ; preds = %77
%85 = load i8*, i8** %7
%86 = call i32 @strlen(i8* %85)
store i32 %86, i32* %10
%87 = load i8*, i8** %7
%88 = load i8**, i8*** %5
%89 = load i32*, i32** %4
%90 = load i32, i32* %89
%91 = add nsw i32 %90, 1
store i32 %91, i32* %89
%92 = sext i32 %90 to i64
%93 = getelementptr inbounds i8*, i8** %88, i64 %92
store i8* %87, i8** %93
%94 = load i32, i32* %10
%95 = add nsw i32 %94, 1
%96 = load i8*, i8** %7
%97 = sext i32 %95 to i64
%98 = getelementptr inbounds i8, i8* %96, i64 %97
store i8* %98, i8** %7
br label %71
99: ; preds = %71
%100 = load i8**, i8*** %5
ret i8** %100
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [5 x i8] c"open\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [5 x i8] c"read\00"
define noalias i8** @load_words(i8* nocapture %0, i32* nocapture %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = load i32, i32* @SEEK_END
%10 = tail call i32 @fseek(i32* %3, i64 0, i32 %9)
%11 = tail call i64 @ftell(i32* %3)
%12 = trunc i64 %11 to i32
%13 = tail call i8* @malloc(i32 %12)
%14 = load i32, i32* @SEEK_SET
%15 = tail call i32 @fseek(i32* %3, i64 0, i32 %14)
%16 = tail call i32 @fread(i8* %13, i32 1, i64 %11, i32* %3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %8
%19 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %8
%22 = tail call i32 @fclose(i32* %3)
store i32 0, i32* %1
%23 = icmp eq i8* %13, null
br i1 %23, label %38, label %24
24: ; preds = %21, %30
%25 = phi i32 [ %33, %30 ], [ 0, %21 ]
%26 = phi i8* [ %34, %30 ], [ %13, %21 ]
%27 = icmp eq i8* %26, %13
br i1 %27, label %30, label %28
28: ; preds = %24
store i8 0, i8* %26
%29 = load i32, i32* %1
br label %30
30: ; preds = %28, %24
%31 = phi i32 [ %29, %28 ], [ %25, %24 ]
%32 = getelementptr inbounds i8, i8* %26, i64 1
%33 = add nsw i32 %31, 1
store i32 %33, i32* %1
%34 = tail call i8* @strchr(i8* %32, i8 signext 10)
%35 = icmp eq i8* %34, null
br i1 %35, label %36, label %24
36: ; preds = %30
%37 = shl i32 %33, 3
br label %38
38: ; preds = %36, %21
%39 = phi i32 [ %37, %36 ], [ 0, %21 ]
%40 = tail call i8* @malloc(i32 %39)
%41 = bitcast i8* %40 to i8**
store i32 0, i32* %1
%42 = getelementptr inbounds i8, i8* %13, i64 %11
%43 = icmp sgt i64 %11, 0
br i1 %43, label %44, label %60
44: ; preds = %38, %56
%45 = phi i8* [ %58, %56 ], [ %13, %38 ]
%46 = load i8, i8* %45
%47 = icmp eq i8 %46, 0
br i1 %47, label %56, label %48
48: ; preds = %44
%49 = tail call i32 @strlen(i8* %45)
%50 = load i32, i32* %1
%51 = add nsw i32 %50, 1
store i32 %51, i32* %1
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8*, i8** %41, i64 %52
store i8* %45, i8** %53
%54 = add nsw i32 %49, 1
%55 = sext i32 %54 to i64
br label %56
56: ; preds = %44, %48
%57 = phi i64 [ %55, %48 ], [ 1, %44 ]
%58 = getelementptr inbounds i8, i8* %45, i64 %57
%59 = icmp ult i8* %58, %42
br i1 %59, label %44, label %60
60: ; preds = %56, %38
ret i8** %41
}