// File: /workspace/github_c_makefile_star2_O1/Leeheng86[P]word2vec/word2phrase.c
// Function: LearnVocabFromTrainFile()
void LearnVocabFromTrainFile() {
  char word[MAX_STRING], last_word[MAX_STRING], bigram_word[MAX_STRING * 2];
  FILE *fin;
  long long a, i, start = 1;
  for (a = 0; a < vocab_hash_size; a++) vocab_hash[a] = -1;
  fin = fopen(train_file, "rb");
  if (fin == NULL) {
    printf("ERROR: training data file not found!\n");
    exit(1);
  }
  vocab_size = 0;
  AddWordToVocab((char *)"
");
  while (1) {
    ReadWord(word, fin);
    if (feof(fin)) break;
    if (!strcmp(word, "
")) {
      start = 1;
      continue;
    } else start = 0;
    train_words++;
    if ((debug_mode > 1) && (train_words % 100000 == 0)) {
      printf("Words processed: %lldK     Vocab size: %lldK  %c", train_words / 1000, vocab_size / 1000, 13);
      fflush(stdout);
    }
    i = SearchVocab(word);
    if (i == -1) {
      a = AddWordToVocab(word);
      vocab[a].cn = 1;
    } else vocab[i].cn++;
    if (start) continue;
    sprintf(bigram_word, "%s_%s", last_word, word);
    bigram_word[MAX_STRING - 1] = 0;
    strcpy(last_word, word);
    i = SearchVocab(bigram_word);
    if (i == -1) {
      a = AddWordToVocab(bigram_word);
      vocab[a].cn = 1;
    } else vocab[i].cn++;
    if (vocab_size > vocab_hash_size * 0.7) ReduceVocab();
  }
  SortVocab();
  if (debug_mode > 0) {
    printf("\nVocab size (unigrams + bigrams): %lld\n", vocab_size);
    printf("Words in train file: %lld\n", train_words);
  }
  fclose(fin);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq 0x3931(%rip), %rdi      # 0x5198
movl $0x77359400, %edx       # imm = 0x77359400
movl $0xff, %esi
callq 0x1070
leaq 0x3893(%rip), %rdi      # 0x5110
leaq 0x1785(%rip), %rsi      # 0x3009
callq 0x10c0
testq %rax, %rax
je 0x1ab9
movq %rax, %rbx
movq $0x0, 0x3900(%rip) # 0x51a0
leaq 0x175d(%rip), %rdi      # 0x3004
callq 0x1476
movq %rsp, %rdi
movq %rbx, %rsi
callq 0x128c
movq %rbx, %rdi
callq 0x1140
testl %eax, %eax
jne 0x1a67
movl $0x3e732f3c, %r15d      # imm = 0x3E732F3C
movq %rsp, %r14
leaq 0x1766(%rip), %r13      # 0x303d
leaq 0x40(%rsp), %rbp
leaq 0xc0(%rsp), %r12
movl (%rsp), %eax
xorl %r15d, %eax
movzbl 0x4(%rsp), %ecx
orl %eax, %ecx
je 0x1a4c
movq 0x38aa(%rip), %rsi      # 0x51a8
leaq 0x1(%rsi), %rcx
movq %rcx, %rax
movabsq $0x29f16b11c6d1e109, %rdx # imm = 0x29F16B11C6D1E109
imulq %rdx
movq %rcx, 0x388f(%rip)      # 0x51a8
cmpl $0x2, 0x37b8(%rip)      # 0x50d8
jl 0x199d
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xe, %rdx
addq %rax, %rdx
imulq $0x186a0, %rdx, %rax    # imm = 0x186A0
negq %rax
addq %rsi, %rax
incq %rax
testq %rax, %rax
jne 0x199d
movq %rcx, %rax
movabsq $0x20c49ba5e353f7cf, %rcx # imm = 0x20C49BA5E353F7CF
imulq %rcx
movq %rdx, %rsi
shrq $0x3f, %rsi
sarq $0x7, %rdx
addq %rdx, %rsi
movq %rcx, %rax
imulq 0x3833(%rip)            # 0x51a0
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0x7, %rdx
addq %rax, %rdx
leaq 0x168a(%rip), %rdi      # 0x300c
movl $0xd, %ecx
xorl %eax, %eax
callq 0x1030
movq 0x363b(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
callq 0x10b0
movq %r14, %rdi
callq 0x137d
cmpl $-0x1, %eax
je 0x19bd
cltq
movq 0x37dd(%rip), %rcx      # 0x5190
shlq $0x4, %rax
incq (%rcx,%rax)
jmp 0x19da
movq %r14, %rdi
callq 0x1476
cltq
movq 0x37c2(%rip), %rcx      # 0x5190
shlq $0x4, %rax
movq $0x1, (%rcx,%rax)
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1050
movb $0x0, 0x7b(%rsp)
movq %r12, %rdi
movq %r14, %rsi
callq 0x1090
movq %rbp, %rdi
callq 0x137d
cmpl $-0x1, %eax
je 0x1a1d
cltq
movq 0x377d(%rip), %rcx      # 0x5190
shlq $0x4, %rax
incq (%rcx,%rax)
jmp 0x1a3a
movq %rbp, %rdi
callq 0x1476
cltq
movq 0x3762(%rip), %rcx      # 0x5190
shlq $0x4, %rax
movq $0x1, (%rcx,%rax)
cmpq $0x14dc9381, 0x375b(%rip) # imm = 0x14DC9381
jl 0x1a4c
callq 0x16ee
movq %r14, %rdi
movq %rbx, %rsi
callq 0x128c
movq %rbx, %rdi
callq 0x1140
testl %eax, %eax
je 0x18e4
callq 0x15a6
cmpl $0x0, 0x3665(%rip)      # 0x50d8
jle 0x1a9f
movq 0x3724(%rip), %rsi      # 0x51a0
leaq 0x15c0(%rip), %rdi      # 0x3043
xorl %eax, %eax
callq 0x1030
movq 0x3717(%rip), %rsi      # 0x51a8
leaq 0x15d3(%rip), %rdi      # 0x306b
xorl %eax, %eax
callq 0x1030
movq %rbx, %rdi
callq 0x10a0
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x164a(%rip), %rdi      # 0x310a
callq 0x1130
movl $0x1, %edi
callq 0x10e0