#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 */
char *fgets(char *, int, int /*<<< orphan*/ *);
char *strchr(char *, char);
size_t strhash(char *);
size_t load_table(size_t *table, size_t slots, FILE *wordfile) {
  char buffer[4096];
  size_t max_count = 0;
  for (;;) {
    char *rc = fgets(buffer, sizeof buffer, wordfile);
    if (rc == NULL)
      break;
    char *nl = strchr(buffer, '\n');
    if (nl != NULL)
      *nl = '\0';
    size_t slot = strhash(buffer) % slots;
    ++table[slot];
    if (max_count < table[slot])
      max_count = table[slot];
  }
  return max_count;
}


x86 assembly (clang, -O0):
<load_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x1028(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x1000,%esi
call   1040 <fgets@plt>
mov    %rax,-0x1030(%rbp)
cmpq   $0x0,-0x1030(%rbp)
jne    1181 <load_table+0x51>
jmp    121a <load_table+0xea>
lea    -0x1020(%rbp),%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
mov    %rax,-0x1038(%rbp)
cmpq   $0x0,-0x1038(%rbp)
je     11b1 <load_table+0x81>
mov    -0x1038(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x1020(%rbp),%rdi
call   1050 <strhash@plt>
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x10(%rbp)
mov    %rdx,-0x1040(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x1040(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
add    $0x1,%rdx
mov    %rdx,(%rax,%rcx,8)
mov    -0x1028(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    -0x1040(%rbp),%rdx
cmp    (%rcx,%rdx,8),%rax
jae    1215 <load_table+0xe5>
mov    -0x8(%rbp),%rax
mov    -0x1040(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x1028(%rbp)
jmp    1152 <load_table+0x22>
mov    -0x1028(%rbp),%rax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_table>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1000,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    %rsp,%rdi
mov    $0x1000,%esi
call   1040 <fgets@plt>
xor    %ebx,%ebx
test   %rax,%rax
je     11cd <load_table+0x9d>
mov    %rsp,%r13
jmp    119d <load_table+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %edx,%edx
div    %r15
mov    (%r12,%rdx,8),%rax
add    $0x1,%rax
mov    %rax,(%r12,%rdx,8)
cmp    %rax,%rbx
cmovb  %rax,%rbx
mov    %r13,%rdi
mov    $0x1000,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11cd <load_table+0x9d>
mov    %r13,%rdi
mov    $0xa,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11b2 <load_table+0x82>
movb   $0x0,(%rax)
mov    %r13,%rdi
call   1050 <strhash@plt>
mov    %rax,%rcx
or     %r15,%rcx
shr    $0x20,%rcx
jne    1170 <load_table+0x40>
xor    %edx,%edx
div    %r15d
jmp    1175 <load_table+0x45>
mov    %rbx,%rax
add    $0x1000,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @load_table(i64* %0, i64 %1, i32* %2) {
%4 = alloca i64*
%5 = alloca i64
%6 = alloca i32*
%7 = alloca [4096 x i8]
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
store i64* %0, i64** %4
store i64 %1, i64* %5
store i32* %2, i32** %6
store i64 0, i64* %8
br label %12
12: ; preds = %47, %3
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%14 = load i32*, i32** %6
%15 = call i8* @fgets(i8* %13, i32 4096, i32* %14)
store i8* %15, i8** %9
%16 = load i8*, i8** %9
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %12
br label %48
19: ; preds = %12
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%21 = call i8* @strchr(i8* %20, i8 signext 10)
store i8* %21, i8** %10
%22 = load i8*, i8** %10
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %26
24: ; preds = %19
%25 = load i8*, i8** %10
store i8 0, i8* %25
br label %26
26: ; preds = %24, %19
%27 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%28 = call i64 @strhash(i8* %27)
%29 = load i64, i64* %5
%30 = urem i64 %28, %29
store i64 %30, i64* %11
%31 = load i64*, i64** %4
%32 = load i64, i64* %11
%33 = getelementptr inbounds i64, i64* %31, i64 %32
%34 = load i64, i64* %33
%35 = add i64 %34, 1
store i64 %35, i64* %33
%36 = load i64, i64* %8
%37 = load i64*, i64** %4
%38 = load i64, i64* %11
%39 = getelementptr inbounds i64, i64* %37, i64 %38
%40 = load i64, i64* %39
%41 = icmp ult i64 %36, %40
br i1 %41, label %42, label %47
42: ; preds = %26
%43 = load i64*, i64** %4
%44 = load i64, i64* %11
%45 = getelementptr inbounds i64, i64* %43, i64 %44
%46 = load i64, i64* %45
store i64 %46, i64* %8
br label %47
47: ; preds = %42, %26
br label %12
48: ; preds = %18
%49 = load i64, i64* %8
ret i64 %49
}

LLVM IR (-O2):
define i64 @load_table(i64* nocapture %0, i64 %1, i32* nocapture %2) {
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%6 = call i8* @fgets(i8* %5, i32 4096, i32* %2)
%7 = icmp eq i8* %6, null
br i1 %7, label %23, label %8
8: ; preds = %3, %13
%9 = phi i64 [ %20, %13 ], [ 0, %3 ]
%10 = call i8* @strchr(i8* %5, i8 signext 10)
%11 = icmp eq i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %8
store i8 0, i8* %10
br label %13
13: ; preds = %8, %12
%14 = call i64 @strhash(i8* %5)
%15 = urem i64 %14, %1
%16 = getelementptr inbounds i64, i64* %0, i64 %15
%17 = load i64, i64* %16
%18 = add i64 %17, 1
store i64 %18, i64* %16
%19 = icmp ult i64 %9, %18
%20 = select i1 %19, i64 %18, i64 %9
%21 = call i8* @fgets(i8* %5, i32 4096, i32* %2)
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %8
23: ; preds = %13, %3
%24 = phi i64 [ 0, %3 ], [ %20, %13 ]
ret i64 %24
}