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

/* Variables and functions */
int /*<<< orphan*/ hashAdd(struct hash *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ lineFileClose(struct lineFile **);
scalar_t__ lineFileNext(struct lineFile *, char **, int /*<<< orphan*/ *);
struct lineFile *lineFileOpen(char *, int);
struct hash *newHashExt(int, int);
char *nextWord(char **);
struct hash *hashWordsInFile(char *fileName, int hashSize) {
  struct hash *hash = newHashExt(hashSize, 1);
  struct lineFile *lf = lineFileOpen(fileName, 1);
  char *line, *word;
  while (lineFileNext(lf, &line, NULL)) {
    while ((word = nextWord(&line)) != NULL)
      hashAdd(hash, word, NULL);
  }
  lineFileClose(&lf);
  return hash;
}


x86 assembly (clang, -O0):
<hashWordsInFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
mov    $0x1,%esi
call   1040 <newHashExt@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1080 <lineFileOpen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1050 <lineFileNext@plt>
cmp    $0x0,%rax
je     11e4 <hashWordsInFile+0x84>
jmp    11b2 <hashWordsInFile+0x52>
lea    -0x28(%rbp),%rdi
call   1060 <nextWord@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     11df <hashWordsInFile+0x7f>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <hashAdd@plt>
jmp    11b2 <hashWordsInFile+0x52>
jmp    1192 <hashWordsInFile+0x32>
lea    -0x20(%rbp),%rdi
call   1030 <lineFileClose@plt>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashWordsInFile>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    %esi,%edi
mov    $0x1,%esi
call   1040 <newHashExt@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x1,%esi
call   1080 <lineFileOpen@plt>
mov    %rax,%r14
mov    %rax,0x8(%rsp)
mov    %rsp,%rsi
mov    %rax,%rdi
xor    %edx,%edx
call   1050 <lineFileNext@plt>
test   %rax,%rax
je     11dc <hashWordsInFile+0x7c>
mov    %rsp,%r15
jmp    11bd <hashWordsInFile+0x5d>
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1070 <hashAdd@plt>
mov    %r15,%rdi
call   1060 <nextWord@plt>
test   %rax,%rax
jne    11b0 <hashWordsInFile+0x50>
mov    %r14,%rdi
mov    %r15,%rsi
xor    %edx,%edx
call   1050 <lineFileNext@plt>
test   %rax,%rax
jne    11bd <hashWordsInFile+0x5d>
lea    0x8(%rsp),%rdi
call   1030 <lineFileClose@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.hash = type { i32 }
%struct.lineFile = type { i32 }
define %struct.hash* @hashWordsInFile(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.hash*
%6 = alloca %struct.lineFile*
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = call %struct.hash* @newHashExt(i32 %9, i32 1)
store %struct.hash* %10, %struct.hash** %5
%11 = load i8*, i8** %3
%12 = call %struct.lineFile* @lineFileOpen(i8* %11, i32 1)
store %struct.lineFile* %12, %struct.lineFile** %6
br label %13
13: ; preds = %25, %2
%14 = load %struct.lineFile*, %struct.lineFile** %6
%15 = call i64 @lineFileNext(%struct.lineFile* %14, i8** %7, i32* null)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %26
17: ; preds = %13
br label %18
18: ; preds = %21, %17
%19 = call i8* @nextWord(i8** %7)
store i8* %19, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load %struct.hash*, %struct.hash** %5
%23 = load i8*, i8** %8
%24 = call i32 @hashAdd(%struct.hash* %22, i8* %23, i32* null)
br label %18
25: ; preds = %18
br label %13
26: ; preds = %13
%27 = call i32 @lineFileClose(%struct.lineFile** %6)
%28 = load %struct.hash*, %struct.hash** %5
ret %struct.hash* %28
}

LLVM IR (-O2):
%struct.hash = type { i32 }
%struct.lineFile = type { i32 }
define %struct.hash* @hashWordsInFile(i8* %0, i32 %1) {
%3 = alloca %struct.lineFile*
%4 = alloca i8*
%5 = tail call %struct.hash* @newHashExt(i32 %1, i32 1)
%6 = bitcast %struct.lineFile** %3 to i8*
%7 = tail call %struct.lineFile* @lineFileOpen(i8* %0, i32 1)
store %struct.lineFile* %7, %struct.lineFile** %3
%8 = bitcast i8** %4 to i8*
%9 = call i64 @lineFileNext(%struct.lineFile* %7, i8** %4, i32* null)
%10 = icmp eq i64 %9, 0
br i1 %10, label %22, label %14
11: ; preds = %17, %14
%12 = call i64 @lineFileNext(%struct.lineFile* %7, i8** %4, i32* null)
%13 = icmp eq i64 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %2, %11
%15 = call i8* @nextWord(i8** %4)
%16 = icmp eq i8* %15, null
br i1 %16, label %11, label %17
17: ; preds = %14, %17
%18 = phi i8* [ %20, %17 ], [ %15, %14 ]
%19 = call i32 @hashAdd(%struct.hash* %5, i8* %18, i32* null)
%20 = call i8* @nextWord(i8** %4)
%21 = icmp eq i8* %20, null
br i1 %21, label %11, label %17
22: ; preds = %11, %2
%23 = call i32 @lineFileClose(%struct.lineFile** %3)
ret %struct.hash* %5
}