#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 hashMap {
  int dummy;
};
typedef int /*<<< orphan*/ line;
typedef double clock_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
double clock();
int containsKey(struct hashMap *, char *);
struct hashMap *createHashMap(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ insertMap(struct hashMap *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *stdin;
char *strchr(char *, char);
scalar_t__ strlen(char *);
double tableLoad(struct hashMap *);
int main() {
  FILE *dictionaryFile;
  char line[100];
  char *nlptr;
  struct hashMap *dictionaryMap;
  clock_t begin, end;
  int count = 0;
  int size = 1000;
  dictionaryMap = createHashMap(size);
  dictionaryFile = fopen("dictionary.txt", "r");
  assert(dictionaryFile != NULL);
  begin = clock();
  while (fgets(line, sizeof(line), dictionaryFile)) {
    nlptr = strchr(line, '\n');
    if (nlptr) {
      *nlptr = '\0';
    }
    if (!containsKey(dictionaryMap, line)) {
      insertMap(dictionaryMap, line, 1);
    }
    count++;
  }
  end = clock();
  printf("It took %0.3f second(s) to build our hashmap.\n",
         (end - begin) / (double)CLOCKS_PER_SEC);
  printf("With %d words in %d buckets, the hashmap's load is %0.3f\n", count,
         size, tableLoad(dictionaryMap));
  fclose(dictionaryFile);
  printf("Enter a word (or press 'Return' to exit): ");
  while (fgets(line, sizeof(line), stdin)) {
    nlptr = strchr(line, '\n');
    if (nlptr) {
      *nlptr = '\0';
    }
    if (strlen(line) == 0) {
      printf("Goodbye!\n");
      break;
    }
    if (containsKey(dictionaryMap, line) == 1)
      printf("The word is spelled correctly.\n");
    else
      printf("The word is misspelled.\n");
    printf("Enter a word (or press 'Return' to exit): ");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xa4(%rbp)
movl   $0x3e8,-0xa8(%rbp)
mov    -0xa8(%rbp),%edi
call   1030 <createHashMap@plt>
mov    %rax,-0x90(%rbp)
lea    0xe01(%rip),%rdi
lea    0xe09(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    $0x0,%al
call   1040 <clock@plt>
movsd  %xmm0,-0x98(%rbp)
ff
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     12bb <main+0xfb>
lea    -0x80(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     1279 <main+0xb9>
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x90(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   10c0 <containsKey@plt>
cmp    $0x0,%eax
jne    12a7 <main+0xe7>
mov    -0x90(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    $0x1,%edx
call   10e0 <insertMap@plt>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
jmp    1230 <main+0x70>
mov    $0x0,%al
call   1040 <clock@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0xa0(%rbp),%xmm0
ff
subsd  -0x98(%rbp),%xmm0
ff
mov    0x2cff(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xd20(%rip),%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    -0xa4(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    -0xa8(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x90(%rbp),%rdi
call   10b0 <tableLoad@plt>
mov    -0xb0(%rbp),%esi
mov    -0xac(%rbp),%edx
lea    0xd11(%rip),%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    0x2c90(%rip),%rax
mov    (%rax),%rdx
mov    $0x64,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     140f <main+0x24f>
lea    -0x80(%rbp),%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
mov    %rax,-0x88(%rbp)
cmpq   $0x0,-0x88(%rbp)
je     139c <main+0x1dc>
mov    -0x88(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x80(%rbp),%rdi
call   1060 <strlen@plt>
cmp    $0x0,%rax
jne    13c2 <main+0x202>
lea    0xcef(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    140f <main+0x24f>
mov    -0x90(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   10c0 <containsKey@plt>
cmp    $0x1,%eax
jne    13ee <main+0x22e>
lea    0xccd(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    13fc <main+0x23c>
lea    0xcda(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
lea    0xc77(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
jmp    134d <main+0x18d>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    $0x3e8,%edi
call   1040 <createHashMap@plt>
mov    %rax,%r15
lea    0xe1e(%rip),%rdi
lea    0xe26(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,%r14
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   10a0 <assert@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <clock@plt>
movsd  %xmm0,0x8(%rsp)
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     127e <main+0xbe>
xor    %ebp,%ebp
lea    0x10(%rsp),%rbx
jmp    1248 <main+0x88>
xchg   %ax,%ax
add    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     127e <main+0xbe>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     125d <main+0x9d>
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   10c0 <containsKey@plt>
test   %eax,%eax
jne    1230 <main+0x70>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   10e0 <insertMap@plt>
jmp    1230 <main+0x70>
xor    %eax,%eax
call   1050 <clock@plt>
subsd  0x8(%rsp),%xmm0
mov    0x2d4e(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
lea    0xd6f(%rip),%rdi
mov    $0x1,%al
call   1080 <printf@plt>
mov    %r15,%rdi
call   10b0 <tableLoad@plt>
lea    0xd88(%rip),%rdi
mov    %ebp,%esi
mov    $0x3e8,%edx
mov    $0x1,%al
call   1080 <printf@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
lea    0xda5(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2d05(%rip),%r14
mov    (%r14),%rdx
lea    0x10(%rsp),%rdi
mov    $0x64,%esi
call   1090 <fgets@plt>
test   %rax,%rax
je     1383 <main+0x1c3>
lea    0x10(%rsp),%rbp
lea    0xdb3(%rip),%r12
lea    0xd94(%rip),%r13
lea    0xd62(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    $0xa,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1335 <main+0x175>
movb   $0x0,(%rax)
cmpb   $0x0,0x10(%rsp)
je     1377 <main+0x1b7>
mov    %r15,%rdi
mov    %rbp,%rsi
call   10c0 <containsKey@plt>
cmp    $0x1,%eax
mov    %r13,%rdi
cmove  %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%r14),%rdx
mov    %rbp,%rdi
mov    $0x64,%esi
call   1090 <fgets@plt>
test   %rax,%rax
jne    1320 <main+0x160>
jmp    1383 <main+0x1c3>
lea    0xd5e(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hashMap = type { i32 }
@.str = [15 x i8] c"dictionary.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [47 x i8] c"It took %0.3f second(s) to build our hashmap.\0A\00"
@CLOCKS_PER_SEC = global i64 0
@.str.3 = [58 x i8] c"With %d words in %d buckets, the hashmap's load is %0.3f\0A\00"
@.str.4 = [43 x i8] c"Enter a word (or press 'Return' to exit): \00"
@stdin = global i32* null
@.str.5 = [10 x i8] c"Goodbye!\0A\00"
@.str.6 = [32 x i8] c"The word is spelled correctly.\0A\00"
@.str.7 = [25 x i8] c"The word is misspelled.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca [100 x i8]
%4 = alloca i8*
%5 = alloca %struct.hashMap*
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %8
store i32 1000, i32* %9
%10 = load i32, i32* %9
%11 = call %struct.hashMap* @createHashMap(i32 %10)
store %struct.hashMap* %11, %struct.hashMap** %5
%12 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %2
%13 = load i32*, i32** %2
%14 = icmp ne i32* %13, null
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = call double (...) @clock()
store double %17, double* %6
br label %18
18: ; preds = %39, %0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%20 = load i32*, i32** %2
%21 = call i64 @fgets(i8* %19, i32 100, i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %42
23: ; preds = %18
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%25 = call i8* @strchr(i8* %24, i8 signext 10)
store i8* %25, i8** %4
%26 = load i8*, i8** %4
%27 = icmp ne i8* %26, null
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = load i8*, i8** %4
store i8 0, i8* %29
br label %30
30: ; preds = %28, %23
%31 = load %struct.hashMap*, %struct.hashMap** %5
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%33 = call i32 @containsKey(%struct.hashMap* %31, i8* %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %39, label %35
35: ; preds = %30
%36 = load %struct.hashMap*, %struct.hashMap** %5
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%38 = call i32 @insertMap(%struct.hashMap* %36, i8* %37, i32 1)
br label %39
39: ; preds = %35, %30
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %18
42: ; preds = %18
%43 = call double (...) @clock()
store double %43, double* %7
%44 = load double, double* %7
%45 = load double, double* %6
%46 = fsub double %44, %45
%47 = load i64, i64* @CLOCKS_PER_SEC
%48 = sitofp i64 %47 to double
%49 = fdiv double %46, %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), double %49)
%51 = load i32, i32* %8
%52 = load i32, i32* %9
%53 = load %struct.hashMap*, %struct.hashMap** %5
%54 = call double @tableLoad(%struct.hashMap* %53)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %51, i32 %52, double %54)
%56 = load i32*, i32** %2
%57 = call i32 @fclose(i32* %56)
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
br label %59
59: ; preds = %86, %42
%60 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%61 = load i32*, i32** @stdin
%62 = call i64 @fgets(i8* %60, i32 100, i32* %61)
%63 = icmp ne i64 %62, 0
br i1 %63, label %64, label %88
64: ; preds = %59
%65 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%66 = call i8* @strchr(i8* %65, i8 signext 10)
store i8* %66, i8** %4
%67 = load i8*, i8** %4
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %71
69: ; preds = %64
%70 = load i8*, i8** %4
store i8 0, i8* %70
br label %71
71: ; preds = %69, %64
%72 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%73 = call i64 @strlen(i8* %72)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
br label %88
77: ; preds = %71
%78 = load %struct.hashMap*, %struct.hashMap** %5
%79 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%80 = call i32 @containsKey(%struct.hashMap* %78, i8* %79)
%81 = icmp eq i32 %80, 1
br i1 %81, label %82, label %84
82: ; preds = %77
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
br label %86
84: ; preds = %77
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
br label %86
86: ; preds = %84, %82
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
br label %59
88: ; preds = %75, %59
ret i32 0
}

LLVM IR (-O2):
%struct.hashMap = type { i32 }
@.str = [15 x i8] c"dictionary.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [47 x i8] c"It took %0.3f second(s) to build our hashmap.\0A\00"
@CLOCKS_PER_SEC = global i64 0
@.str.3 = [58 x i8] c"With %d words in %d buckets, the hashmap's load is %0.3f\0A\00"
@.str.4 = [43 x i8] c"Enter a word (or press 'Return' to exit): \00"
@stdin = global i32* null
@str = [24 x i8] c"The word is misspelled.\00"
@str.8 = [31 x i8] c"The word is spelled correctly.\00"
@str.9 = [9 x i8] c"Goodbye!\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call %struct.hashMap* @createHashMap(i32 1000)
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp ne i32* %4, null
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call double (...) @clock()
%9 = call i64 @fgets(i8* %2, i32 100, i32* %4)
%10 = icmp eq i64 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %0, %21
%12 = phi i32 [ %22, %21 ], [ 0, %0 ]
%13 = call i8* @strchr(i8* %2, i8 signext 10)
%14 = icmp eq i8* %13, null
br i1 %14, label %16, label %15
15: ; preds = %11
store i8 0, i8* %13
br label %16
16: ; preds = %15, %11
%17 = call i32 @containsKey(%struct.hashMap* %3, i8* %2)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @insertMap(%struct.hashMap* %3, i8* %2, i32 1)
br label %21
21: ; preds = %19, %16
%22 = add nuw nsw i32 %12, 1
%23 = call i64 @fgets(i8* %2, i32 100, i32* %4)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %11
25: ; preds = %21, %0
%26 = phi i32 [ 0, %0 ], [ %22, %21 ]
%27 = call double (...) @clock()
%28 = fsub double %27, %8
%29 = load i64, i64* @CLOCKS_PER_SEC
%30 = sitofp i64 %29 to double
%31 = fdiv double %28, %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), double %31)
%33 = call double @tableLoad(%struct.hashMap* %3)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 1000, double %33)
%35 = call i32 @fclose(i32* %4)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%37 = load i32*, i32** @stdin
%38 = call i64 @fgets(i8* %2, i32 100, i32* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %58, label %40
40: ; preds = %25, %49
%41 = call i8* @strchr(i8* %2, i8 signext 10)
%42 = icmp eq i8* %41, null
br i1 %42, label %44, label %43
43: ; preds = %40
store i8 0, i8* %41
br label %44
44: ; preds = %43, %40
%45 = load i8, i8* %2
%46 = icmp eq i8 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.9, i64 0, i64 0))
br label %58
49: ; preds = %44
%50 = call i32 @containsKey(%struct.hashMap* %3, i8* %2)
%51 = icmp eq i32 %50, 1
%52 = select i1 %51, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0)
%53 = call i32 @puts(i8* dereferenceable(1) %52)
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0))
%55 = load i32*, i32** @stdin
%56 = call i64 @fgets(i8* %2, i32 100, i32* %55)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %40
58: ; preds = %49, %25, %47
ret i32 0
}