#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 vocab_word {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int ReadWord(char *, int /*<<< orphan*/ *);
int SearchVocab(char *, struct vocab_word const *, int const *);
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int ReadWordIndex(FILE *fin, const struct vocab_word *vocab,
                  const int *vocab_hash) {
  char word[1000];
  int word_len = ReadWord(word, fin);
  if (word_len >= 1000 - 2)
    printf("! long word: %s\n", word);
  if (feof(fin))
    return -1;
  return SearchVocab(word, vocab, vocab_hash);
}


x86 assembly (clang, -O0):
<ReadWordIndex>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <ReadWord@plt>
mov    %eax,-0x414(%rbp)
cmpl   $0x3e6,-0x414(%rbp)
jl     1190 <ReadWordIndex+0x50>
lea    -0x410(%rbp),%rsi
lea    0xe75(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
je     11af <ReadWordIndex+0x6f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c6 <ReadWordIndex+0x86>
lea    -0x410(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1060 <SearchVocab@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadWordIndex>:
push   %r15
push   %r14
push   %rbx
sub    $0x3f0,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    %rsp,%rdi
mov    %rbx,%rsi
call   1050 <ReadWord@plt>
cmp    $0x3e6,%eax
jl     1176 <ReadWordIndex+0x36>
lea    0xe92(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <feof@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1199 <ReadWordIndex+0x59>
mov    %rsp,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1060 <SearchVocab@plt>
add    $0x3f0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.vocab_word = type { i32 }
@.str = [17 x i8] c"! long word: %s\0A\00"
define i32 @ReadWordIndex(i32* %0, %struct.vocab_word* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca %struct.vocab_word*
%7 = alloca i32*
%8 = alloca [1000 x i8]
%9 = alloca i32
store i32* %0, i32** %5
store %struct.vocab_word* %1, %struct.vocab_word** %6
store i32* %2, i32** %7
%10 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%11 = load i32*, i32** %5
%12 = call i32 @ReadWord(i8* %10, i32* %11)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp sge i32 %13, 998
br i1 %14, label %15, label %18
15: ; preds = %3
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %3
%19 = load i32*, i32** %5
%20 = call i64 @feof(i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 -1, i32* %4
br label %28
23: ; preds = %18
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%25 = load %struct.vocab_word*, %struct.vocab_word** %6
%26 = load i32*, i32** %7
%27 = call i32 @SearchVocab(i8* %24, %struct.vocab_word* %25, i32* %26)
store i32 %27, i32* %4
br label %28
28: ; preds = %23, %22
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
%struct.vocab_word = type { i32 }
@.str = [17 x i8] c"! long word: %s\0A\00"
define i32 @ReadWordIndex(i32* %0, %struct.vocab_word* %1, i32* %2) {
%4 = alloca [1000 x i8]
%5 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%6 = call i32 @ReadWord(i8* %5, i32* %0)
%7 = icmp sgt i32 %6, 997
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %10
10: ; preds = %8, %3
%11 = call i64 @feof(i32* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @SearchVocab(i8* %5, %struct.vocab_word* %1, i32* %2)
br label %15
15: ; preds = %10, %13
%16 = phi i32 [ %14, %13 ], [ -1, %10 ]
ret i32 %16
}