#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*/ words;

/* Variables and functions */
int chopByWhite(char *, char **, int);
char **needMem(int);
int /*<<< orphan*/ readInGulp(char *, char **, size_t *);
void readAllWords(char *fileName, char ***retWords, int *retWordCount,
                  char **retBuf) {
  int wordCount;
  char *buf = NULL;
  char **words = NULL;
  size_t bufSize;
  readInGulp(fileName, &buf, &bufSize);
  wordCount = chopByWhite(buf, NULL, 0);
  if (wordCount != 0) {
    words = needMem(wordCount * sizeof(words[0]));
    chopByWhite(buf, words, wordCount);
  }
  *retWords = words;
  *retWordCount = wordCount;
  *retBuf = buf;
}


x86 assembly (clang, -O0):
<readAllWords>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1030 <readInGulp@plt>
mov    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1050 <chopByWhite@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11a8 <readAllWords+0x78>
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1040 <needMem@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <chopByWhite@plt>
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readAllWords>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
movq   $0x0,(%rsp)
mov    %rsp,%rsi
lea    0x8(%rsp),%rdx
call   1030 <readInGulp@plt>
mov    (%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
xor    %edx,%edx
call   1050 <chopByWhite@plt>
mov    %eax,%ebp
test   %eax,%eax
je     118a <readAllWords+0x5a>
mov    %ebp,%edi
shl    $0x3,%edi
call   1040 <needMem@plt>
mov    %rax,%rbx
mov    (%rsp),%rdi
mov    %rax,%rsi
mov    %ebp,%edx
call   1050 <chopByWhite@plt>
mov    %rbx,(%r12)
mov    %ebp,(%r15)
mov    (%rsp),%rax
mov    %rax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @readAllWords(i8* %0, i8*** %1, i32* %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i8***
%7 = alloca i32*
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8**
%12 = alloca i64
store i8* %0, i8** %5
store i8*** %1, i8**** %6
store i32* %2, i32** %7
store i8** %3, i8*** %8
store i8* null, i8** %10
store i8** null, i8*** %11
%13 = load i8*, i8** %5
%14 = call i32 @readInGulp(i8* %13, i8** %10, i64* %12)
%15 = load i8*, i8** %10
%16 = call i32 @chopByWhite(i8* %15, i8** null, i32 0)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %4
%20 = load i32, i32* %9
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 8
%23 = trunc i64 %22 to i32
%24 = call i8** @needMem(i32 %23)
store i8** %24, i8*** %11
%25 = load i8*, i8** %10
%26 = load i8**, i8*** %11
%27 = load i32, i32* %9
%28 = call i32 @chopByWhite(i8* %25, i8** %26, i32 %27)
br label %29
29: ; preds = %19, %4
%30 = load i8**, i8*** %11
%31 = load i8***, i8**** %6
store i8** %30, i8*** %31
%32 = load i32, i32* %9
%33 = load i32*, i32** %7
store i32 %32, i32* %33
%34 = load i8*, i8** %10
%35 = load i8**, i8*** %8
store i8* %34, i8** %35
ret void
}

LLVM IR (-O2):
define void @readAllWords(i8* %0, i8*** nocapture writeonly %1, i32* nocapture writeonly %2, i8** nocapture writeonly %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%8 = bitcast i64* %6 to i8*
%9 = call i32 @readInGulp(i8* %0, i8** %5, i64* %6)
%10 = load i8*, i8** %5
%11 = call i32 @chopByWhite(i8* %10, i8** null, i32 0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %4
%14 = shl i32 %11, 3
%15 = call i8** @needMem(i32 %14)
%16 = load i8*, i8** %5
%17 = call i32 @chopByWhite(i8* %16, i8** %15, i32 %11)
br label %18
18: ; preds = %13, %4
%19 = phi i8** [ %15, %13 ], [ null, %4 ]
store i8** %19, i8*** %1
store i32 %11, i32* %2
%20 = load i8*, i8** %5
store i8* %20, i8** %3
ret void
}