// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq $0x1, -0x120(%rbp)
movq $0x0, -0x110(%rbp)
cmpq $0x1dcd6500, -0x110(%rbp) # imm = 0x1DCD6500
jge 0x1957
movq 0x3853(%rip), %rax      # 0x5188
movq -0x110(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x110(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x110(%rbp)
jmp 0x1921
leaq 0x37a2(%rip), %rdi      # 0x5100
leaq 0x16b0(%rip), %rsi      # 0x3015
callq 0x10b0
movq %rax, -0x108(%rbp)
cmpq $0x0, -0x108(%rbp)
jne 0x1993
leaq 0x1696(%rip), %rdi      # 0x3018
movb $0x0, %al
callq 0x1030
movl $0x1, %edi
callq 0x10d0
movq $0x0, 0x37f2(%rip) # 0x5190
leaq 0x166b(%rip), %rdi      # 0x3010
callq 0x1490
leaq -0x40(%rbp), %rdi
movq -0x108(%rbp), %rsi
callq 0x1260
movq -0x108(%rbp), %rdi
callq 0x1110
cmpl $0x0, %eax
je 0x19d0
jmp 0x1bb6
leaq -0x40(%rbp), %rdi
leaq 0x1635(%rip), %rsi      # 0x3010
callq 0x10f0
cmpl $0x0, %eax
jne 0x19f2
movq $0x1, -0x120(%rbp)
jmp 0x19aa
movq $0x0, -0x120(%rbp)
movq 0x3794(%rip), %rax      # 0x5198
addq $0x1, %rax
movq %rax, 0x3789(%rip)      # 0x5198
cmpl $0x1, 0x36aa(%rip)      # 0x50c0
jle 0x1a79
movq 0x3779(%rip), %rax      # 0x5198
movl $0x186a0, %ecx          # imm = 0x186A0
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0x1a79
movq 0x3762(%rip), %rax      # 0x5198
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rsi
movq 0x3746(%rip), %rax      # 0x5190
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rdx
leaq 0x15e0(%rip), %rdi      # 0x303e
movl $0xd, %ecx
movb $0x0, %al
callq 0x1030
movq 0x355f(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
callq 0x10a0
leaq -0x40(%rbp), %rdi
callq 0x13b0
cltq
movq %rax, -0x118(%rbp)
cmpq $-0x1, -0x118(%rbp)
jne 0x1ac5
leaq -0x40(%rbp), %rdi
callq 0x1490
cltq
movq %rax, -0x110(%rbp)
movq 0x36d2(%rip), %rax      # 0x5180
movq -0x110(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x1, (%rax)
jmp 0x1ae4
movq 0x36b4(%rip), %rax      # 0x5180
movq -0x118(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
cmpq $0x0, -0x120(%rbp)
je 0x1af3
jmp 0x19aa
leaq -0x100(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq -0x40(%rbp), %rcx
leaq 0x1566(%rip), %rsi      # 0x306f
movb $0x0, %al
callq 0x1050
movb $0x0, -0xc5(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1080
leaq -0x100(%rbp), %rdi
callq 0x13b0
cltq
movq %rax, -0x118(%rbp)
cmpq $-0x1, -0x118(%rbp)
jne 0x1b76
leaq -0x100(%rbp), %rdi
callq 0x1490
cltq
movq %rax, -0x110(%rbp)
movq 0x3621(%rip), %rax      # 0x5180
movq -0x110(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq $0x1, (%rax)
jmp 0x1b95
movq 0x3603(%rip), %rax      # 0x5180
movq -0x118(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
addq $0x1, %rcx
movq %rcx, (%rax)
cvtsi2sdq 0x35f2(%rip), %xmm0 # 0x5190
movsd 0x1462(%rip), %xmm1     # 0x3008
ucomisd %xmm1, %xmm0
jbe 0x1bb1
callq 0x1750
jmp 0x19aa
callq 0x1600
cmpl $0x0, 0x34fe(%rip)      # 0x50c0
jle 0x1bee
movq 0x35c5(%rip), %rsi      # 0x5190
leaq 0x14a3(%rip), %rdi      # 0x3075
movb $0x0, %al
callq 0x1030
movq 0x35b8(%rip), %rsi      # 0x5198
leaq 0x14b6(%rip), %rdi      # 0x309d
movb $0x0, %al
callq 0x1030
movq -0x108(%rbp), %rdi
callq 0x1090
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw %cs:(%rax,%rax)