#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 scalar_t__ clock_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
scalar_t__ clock();
scalar_t__ containsKey(struct hashMap *, char *);
struct hashMap *createMap(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ loadDictionary(int /*<<< orphan*/ *, struct hashMap *);
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, const char *argv[]) {
  clock_t timer;
  struct hashMap *hashTable;
  int tableSize = 1000;
  timer = clock();
  hashTable = createMap(tableSize);
  FILE *dictionary;
  dictionary = fopen("dictionary.txt", "r");
  if (dictionary == NULL) {
    perror("dictionary.txt");
    return 1;
  }
  loadDictionary(dictionary, hashTable);
  timer = clock() - timer;
  printf("Dictionary loaded in %f seconds\n",
         (float)timer / (float)CLOCKS_PER_SEC);
  fclose(dictionary);
  char *word = (char *)malloc(256 * sizeof(char));
  int quit = 0;
  while (!quit) {
    printf("Enter a word: ");
    scanf("%s", word);
    if (containsKey(hashTable, word))
      printf("\"%s\" is spelled correctly\n", word);
    else
      printf("Did not find \"%s\" in the dictionary\n", word);
    if (strcmp(word, "quit") == 0)
      quit = !quit;
  }
  free(word);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x3e8,-0x24(%rbp)
mov    $0x0,%al
call   1050 <clock@plt>
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
call   10a0 <createMap@plt>
mov    %rax,-0x20(%rbp)
lea    0xe05(%rip),%rdi
lea    0xe0d(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    122e <main+0x6e>
lea    0xde3(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1344 <main+0x184>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <loadDictionary@plt>
mov    $0x0,%al
call   1050 <clock@plt>
sub    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
cvtsi2ssq -0x18(%rbp),%xmm0
mov    0x2d91(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xda6(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1060 <fclose@plt>
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    12a6 <main+0xe6>
jmp    1334 <main+0x174>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xd82(%rip),%rdi
call   10c0 <scanf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10b0 <containsKey@plt>
cmp    $0x0,%rax
je     12f2 <main+0x132>
mov    -0x38(%rbp),%rsi
lea    0xd5e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1304 <main+0x144>
mov    -0x38(%rbp),%rsi
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    0xd75(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    132f <main+0x16f>
cmpl   $0x0,-0x3c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x3c(%rbp)
jmp    1290 <main+0xd0>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <clock@plt>
mov    %rax,%r15
mov    $0x3e8,%edi
call   10a0 <createMap@plt>
mov    %rax,%r14
lea    0xe17(%rip),%rdi
lea    0xe1f(%rip),%rsi
call   10d0 <fopen@plt>
test   %rax,%rax
je     12d1 <main+0x111>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <loadDictionary@plt>
xor    %eax,%eax
call   1050 <clock@plt>
sub    %r15,%rax
cvtsi2ss %rax,%xmm0
mov    0x2dc6(%rip),%rax
cvtsi2ssq (%rax),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xddb(%rip),%rdi
mov    $0x1,%al
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
lea    0xde8(%rip),%r12
lea    0xdff(%rip),%rbp
lea    0xddd(%rip),%r15
lea    0xe16(%rip),%r13
xchg   %ax,%ax
lea    0xdbb(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10c0 <scanf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   10b0 <containsKey@plt>
test   %rax,%rax
mov    %r15,%rdi
cmove  %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    1270 <main+0xb0>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd28(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%eax
jmp    12c2 <main+0x102>

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 = [33 x i8] c"Dictionary loaded in %f seconds\0A\00"
@CLOCKS_PER_SEC = global i64 0
@.str.3 = [15 x i8] c"Enter a word: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [27 x i8] c"\22%s\22 is spelled correctly\0A\00"
@.str.6 = [37 x i8] c"Did not find \22%s\22 in the dictionary\0A\00"
@.str.7 = [5 x i8] c"quit\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca %struct.hashMap*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1000, i32* %8
%12 = call i64 (...) @clock()
store i64 %12, i64* %6
%13 = load i32, i32* %8
%14 = call %struct.hashMap* @createMap(i32 %13)
store %struct.hashMap* %14, %struct.hashMap** %7
%15 = 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* %15, i32** %9
%16 = load i32*, i32** %9
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %69
20: ; preds = %2
%21 = load i32*, i32** %9
%22 = load %struct.hashMap*, %struct.hashMap** %7
%23 = call i32 @loadDictionary(i32* %21, %struct.hashMap* %22)
%24 = call i64 (...) @clock()
%25 = load i64, i64* %6
%26 = sub nsw i64 %24, %25
store i64 %26, i64* %6
%27 = load i64, i64* %6
%28 = sitofp i64 %27 to float
%29 = load i64, i64* @CLOCKS_PER_SEC
%30 = sitofp i64 %29 to float
%31 = fdiv float %28, %30
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), double %32)
%34 = load i32*, i32** %9
%35 = call i32 @fclose(i32* %34)
%36 = call i64 @malloc(i32 256)
%37 = inttoptr i64 %36 to i8*
store i8* %37, i8** %10
store i32 0, i32* %11
br label %38
38: ; preds = %65, %20
%39 = load i32, i32* %11
%40 = icmp ne i32 %39, 0
%41 = xor i1 %40, true
br i1 %41, label %42, label %66
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%44 = load i8*, i8** %10
%45 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %44)
%46 = load %struct.hashMap*, %struct.hashMap** %7
%47 = load i8*, i8** %10
%48 = call i64 @containsKey(%struct.hashMap* %46, i8* %47)
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %42
%51 = load i8*, i8** %10
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i8* %51)
br label %56
53: ; preds = %42
%54 = load i8*, i8** %10
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* %54)
br label %56
56: ; preds = %53, %50
%57 = load i8*, i8** %10
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %56
%61 = load i32, i32* %11
%62 = icmp ne i32 %61, 0
%63 = xor i1 %62, true
%64 = zext i1 %63 to i32
store i32 %64, i32* %11
br label %65
65: ; preds = %60, %56
br label %38
66: ; preds = %38
%67 = load i8*, i8** %10
%68 = call i32 @free(i8* %67)
store i32 0, i32* %3
br label %69
69: ; preds = %66, %18
%70 = load i32, i32* %3
ret i32 %70
}

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 = [33 x i8] c"Dictionary loaded in %f seconds\0A\00"
@CLOCKS_PER_SEC = global i64 0
@.str.3 = [15 x i8] c"Enter a word: \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [27 x i8] c"\22%s\22 is spelled correctly\0A\00"
@.str.6 = [37 x i8] c"Did not find \22%s\22 in the dictionary\0A\00"
@.str.7 = [5 x i8] c"quit\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i64 (...) @clock()
%4 = tail call %struct.hashMap* @createMap(i32 1000)
%5 = 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))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %33
9: ; preds = %2
%10 = tail call i32 @loadDictionary(i32* %5, %struct.hashMap* %4)
%11 = tail call i64 (...) @clock()
%12 = sub nsw i64 %11, %3
%13 = sitofp i64 %12 to float
%14 = load i64, i64* @CLOCKS_PER_SEC
%15 = sitofp i64 %14 to float
%16 = fdiv float %13, %15
%17 = fpext float %16 to double
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = tail call i32 @fclose(i32* %5)
%20 = tail call i64 @malloc(i32 256)
%21 = inttoptr i64 %20 to i8*
br label %22
22: ; preds = %9, %22
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%25 = tail call i64 @containsKey(%struct.hashMap* %4, i8* %21)
%26 = icmp eq i64 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %27, i8* %21)
%29 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %22
31: ; preds = %22
%32 = tail call i32 @free(i8* %21)
br label %33
33: ; preds = %31, %7
%34 = phi i32 [ 1, %7 ], [ 0, %31 ]
ret i32 %34
}