// File: /workspace/github_c_makefile_star2_O0/Leeheng86[P]word2vec/word2phrase.c
// Function: TrainModel()
void TrainModel() {
  long long pa = 0, pb = 0, pab = 0, oov, i, li = -1, cn = 0;
  char word[MAX_STRING], last_word[MAX_STRING], bigram_word[MAX_STRING * 2];
  real score;
  FILE *fo, *fin;
  printf("Starting training using file %s\n", train_file);
  LearnVocabFromTrainFile();
  fin = fopen(train_file, "rb");
  fo = fopen(output_file, "wb");
  word[0] = 0;
  while (1) {
    strcpy(last_word, word);
    ReadWord(word, fin);
    if (feof(fin)) break;
    if (!strcmp(word, "
")) {
      fprintf(fo, "\n");
      continue;
    }
    cn++;
    if ((debug_mode > 1) && (cn % 100000 == 0)) {
      printf("Words written: %lldK%c", cn / 1000, 13);
      fflush(stdout);
    }
    oov = 0;
    i = SearchVocab(word);
    if (i == -1) oov = 1; else pb = vocab[i].cn;
    if (li == -1) oov = 1;
    li = i;
    sprintf(bigram_word, "%s_%s", last_word, word);
    bigram_word[MAX_STRING - 1] = 0;
    i = SearchVocab(bigram_word);
    if (i == -1) oov = 1; else pab = vocab[i].cn;
    if (pa < min_count) oov = 1;
    if (pb < min_count) oov = 1;
    if (oov) score = 0; else score = (pab - min_count) / (real)pa / (real)pb * (real)train_words;
    if (score > threshold) {
      fprintf(fo, "_%s", word);
      pb = 0;
    } else fprintf(fo, " %s", word);
    pa = pb;
  }
  fclose(fo);
  fclose(fin);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq $0x0, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $-0x1, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
leaq 0x146e(%rip), %rdi      # 0x30b8
leaq 0x34af(%rip), %rsi      # 0x5100
movb $0x0, %al
callq 0x1030
callq 0x1900
leaq 0x349c(%rip), %rdi      # 0x5100
leaq 0x13aa(%rip), %rsi      # 0x3015
callq 0x10b0
movq %rax, -0x158(%rbp)
leaq 0x34c2(%rip), %rdi      # 0x5140
leaq 0x1454(%rip), %rsi      # 0x30d9
callq 0x10b0
movq %rax, -0x150(%rbp)
movb $0x0, -0x80(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x1080
leaq -0x80(%rbp), %rdi
movq -0x158(%rbp), %rsi
callq 0x1260
movq -0x158(%rbp), %rdi
callq 0x1110
cmpl $0x0, %eax
je 0x1ccb
jmp 0x1ee8
leaq -0x80(%rbp), %rdi
leaq 0x133a(%rip), %rsi      # 0x3010
callq 0x10f0
cmpl $0x0, %eax
jne 0x1cf7
movq -0x150(%rbp), %rdi
leaq 0x167f(%rip), %rsi      # 0x336d
movb $0x0, %al
callq 0x1100
jmp 0x1c95
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
cmpl $0x1, 0x33b6(%rip)      # 0x50c0
jle 0x1d53
movq -0x38(%rbp), %rax
movl $0x186a0, %ecx          # imm = 0x186A0
cqto
idivq %rcx
cmpq $0x0, %rdx
jne 0x1d53
movq -0x38(%rbp), %rax
movl $0x3e8, %ecx            # imm = 0x3E8
cqto
idivq %rcx
movq %rax, %rsi
leaq 0x13a4(%rip), %rdi      # 0x30dc
movl $0xd, %edx
movb $0x0, %al
callq 0x1030
movq 0x3285(%rip), %rax      # 0x4fd0
movq (%rax), %rdi
callq 0x10a0
movq $0x0, -0x20(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x13b0
cltq
movq %rax, -0x28(%rbp)
cmpq $-0x1, -0x28(%rbp)
jne 0x1d7b
movq $0x1, -0x20(%rbp)
jmp 0x1d94
movq 0x33fe(%rip), %rax      # 0x5180
movq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $-0x1, -0x30(%rbp)
jne 0x1da3
movq $0x1, -0x20(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x140(%rbp), %rdi
leaq -0xc0(%rbp), %rdx
leaq -0x80(%rbp), %rcx
leaq 0x12ab(%rip), %rsi      # 0x306f
movb $0x0, %al
callq 0x1050
movb $0x0, -0x105(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x13b0
cltq
movq %rax, -0x28(%rbp)
cmpq $-0x1, -0x28(%rbp)
jne 0x1df5
movq $0x1, -0x20(%rbp)
jmp 0x1e0e
movq 0x3384(%rip), %rax      # 0x5180
movq -0x28(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movslq 0x32ab(%rip), %rcx      # 0x50c4
cmpq %rcx, %rax
jge 0x1e26
movq $0x1, -0x20(%rbp)
movq -0x10(%rbp), %rax
movslq 0x3293(%rip), %rcx      # 0x50c4
cmpq %rcx, %rax
jge 0x1e3e
movq $0x1, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1e52
xorps %xmm0, %xmm0
movss %xmm0, -0x144(%rbp)
jmp 0x1e8e
movq -0x18(%rbp), %rax
movslq 0x3267(%rip), %rcx      # 0x50c4
subq %rcx, %rax
cvtsi2ss %rax, %xmm0
cvtsi2ssq -0x8(%rbp), %xmm1
divss %xmm1, %xmm0
cvtsi2ssq -0x10(%rbp), %xmm1
divss %xmm1, %xmm0
cvtsi2ssq 0x3316(%rip), %xmm1 # 0x5198
mulss %xmm1, %xmm0
movss %xmm0, -0x144(%rbp)
movss -0x144(%rbp), %xmm0
ucomiss 0x323b(%rip), %xmm0     # 0x50d8
jbe 0x1ec2
movq -0x150(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x11c0(%rip), %rsi      # 0x3071
movb $0x0, %al
callq 0x1100
movq $0x0, -0x10(%rbp)
jmp 0x1edb
movq -0x150(%rbp), %rdi
leaq -0x80(%rbp), %rdx
leaq 0x121f(%rip), %rsi      # 0x30f3
movb $0x0, %al
callq 0x1100
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x1c95
movq -0x150(%rbp), %rdi
callq 0x1090
movq -0x158(%rbp), %rdi
callq 0x1090
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopl (%rax)