// File: migueeelvargas[P]Auto-Complete/util.cpp
// Function: Utils::load_dict(DictionaryTrie&, std::istream&, unsigned int)
void Utils::load_dict(DictionaryTrie& dict, istream& words, unsigned int num_words)
{
  unsigned int freq;
  string data = "";
  string temp_word = "";
  string word = "";
  vector<string> word_string;
  unsigned int i = 0;
  unsigned int j = 0;
  for(; j < num_words; j++)
    {
      getline(words, data);
      if(words.eof()) break;
      temp_word = "";
      word = "";
      data = data + " .";
      istringstream iss(data);
      iss >> freq;
      while(1)
        {
          iss >> temp_word;
          if(temp_word == ".") break;
          if(temp_word.length() > 0) word_string.push_back(temp_word);
        }
      for(i = 0; i < word_string.size(); i++)
        {
          if(i > 0) word = word + " ";
          word = word + word_string[i];
        }
      dict.insert(word, freq);
      word_string.clear();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq -0x39(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x33d0
movq -0x2c8(%rbp), %rdx
leaq 0x5d54(%rip), %rsi      # 0xe098
leaq -0x38(%rbp), %rdi
callq 0x4c60
jmp 0x834f
leaq -0x39(%rbp), %rdi
callq 0x3280
leaq -0x71(%rbp), %rdi
movq %rdi, -0x2d0(%rbp)
callq 0x33d0
movq -0x2d0(%rbp), %rdx
leaq 0x5d22(%rip), %rsi      # 0xe098
leaq -0x70(%rbp), %rdi
callq 0x4c60
jmp 0x8381
leaq -0x71(%rbp), %rdi
callq 0x3280
leaq -0x99(%rbp), %rdi
movq %rdi, -0x2d8(%rbp)
callq 0x33d0
movq -0x2d8(%rbp), %rdx
leaq 0x5ced(%rip), %rsi      # 0xe098
leaq -0x98(%rbp), %rdi
callq 0x4c60
jmp 0x83b9
leaq -0x99(%rbp), %rdi
callq 0x3280
leaq -0xb8(%rbp), %rdi
callq 0x4b30
movl $0x0, -0xbc(%rbp)
movl $0x0, -0xc0(%rbp)
movl -0xc0(%rbp), %eax
cmpl -0x14(%rbp), %eax
jae 0x8708
movq -0x10(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x3080
jmp 0x8403
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x33f0
movb %al, -0x2d9(%rbp)
jmp 0x841e
movb -0x2d9(%rbp), %al
testb $0x1, %al
jne 0x842a
jmp 0x8491
jmp 0x8708
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x39(%rbp), %rdi
callq 0x3280
jmp 0x8765
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x3280
jmp 0x875c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x99(%rbp), %rdi
callq 0x3280
jmp 0x8753
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x873b
leaq 0x5c00(%rip), %rsi      # 0xe098
leaq -0x70(%rbp), %rdi
callq 0x3330
jmp 0x84a3
leaq 0x5bee(%rip), %rsi      # 0xe098
leaq -0x98(%rbp), %rdi
callq 0x3330
jmp 0x84b8
leaq 0x5c42(%rip), %rdx      # 0xe101
leaq -0xe0(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x8840
jmp 0x84d1
leaq -0x38(%rbp), %rdi
movq %rdi, -0x2e8(%rbp)
leaq -0xe0(%rbp), %rsi
movq %rsi, -0x2f0(%rbp)
callq 0x32c0
movq -0x2f0(%rbp), %rdi
callq 0x3170
movq -0x2e8(%rbp), %rsi
leaq -0x260(%rbp), %rdi
movl $0x8, %edx
callq 0x33b0
jmp 0x8515
leaq -0x260(%rbp), %rdi
leaq -0x18(%rbp), %rsi
callq 0x3050
jmp 0x8527
jmp 0x8529
jmp 0x852b
leaq -0x260(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x32f0
jmp 0x853d
leaq 0x5bbe(%rip), %rsi      # 0xe102
leaq -0x70(%rbp), %rdi
callq 0x88c0
movb %al, -0x2f1(%rbp)
jmp 0x8555
movb -0x2f1(%rbp), %al
testb $0x1, %al
jne 0x8561
jmp 0x8574
jmp 0x8599
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x86fa
leaq -0x70(%rbp), %rdi
callq 0x3360
cmpq $0x0, %rax
jbe 0x8597
leaq -0xb8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x88f0
jmp 0x8595
jmp 0x8597
jmp 0x8529
movl $0x0, -0xbc(%rbp)
movl -0xbc(%rbp), %eax
movq %rax, -0x300(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x59a0
movq %rax, %rcx
movq -0x300(%rbp), %rax
cmpq %rcx, %rax
jae 0x8672
cmpl $0x0, -0xbc(%rbp)
jbe 0x8613
leaq 0x5b25(%rip), %rdx      # 0xe104
leaq -0x280(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x8840
jmp 0x85f4
leaq -0x98(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x32c0
leaq -0x280(%rbp), %rdi
callq 0x3170
movl -0xbc(%rbp), %eax
movl %eax, %esi
leaq -0xb8(%rbp), %rdi
callq 0x89e0
movq %rax, %rdx
leaq -0x2a0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x8960
jmp 0x863f
leaq -0x98(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x32c0
leaq -0x2a0(%rbp), %rdi
callq 0x3170
movl -0xbc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xbc(%rbp)
jmp 0x85a3
movq -0x8(%rbp), %rax
movq %rax, -0x308(%rbp)
leaq -0x2c0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x30f0
jmp 0x8692
movq -0x308(%rbp), %rdi
movl -0x18(%rbp), %edx
leaq -0x2c0(%rbp), %rsi
callq 0x8f40
jmp 0x86aa
leaq -0x2c0(%rbp), %rdi
callq 0x3170
leaq -0xb8(%rbp), %rdi
callq 0x8a00
leaq -0x260(%rbp), %rdi
callq 0x3120
movl -0xc0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc0(%rbp)
jmp 0x83e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x3170
leaq -0x260(%rbp), %rdi
callq 0x3120
jmp 0x873b
leaq -0xb8(%rbp), %rdi
callq 0x4b50
leaq -0x98(%rbp), %rdi
callq 0x3170
leaq -0x70(%rbp), %rdi
callq 0x3170
leaq -0x38(%rbp), %rdi
callq 0x3170
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0xb8(%rbp), %rdi
callq 0x4b50
leaq -0x98(%rbp), %rdi
callq 0x3170
leaq -0x70(%rbp), %rdi
callq 0x3170
leaq -0x38(%rbp), %rdi
callq 0x3170
movq -0x48(%rbp), %rdi
callq 0x33c0
nop