// File: /workspace/github_c_makefile_star2_O1/Leeheng86[P]word2vec/word2vec.c
// Function: SortVocab()
void SortVocab() {
  int a, size;
  unsigned int hash;
  // Sort the vocabulary and keep 
 at the first position
  qsort(&vocab[1], vocab_size - 1, sizeof(struct vocab_word), VocabCompare);
  for (a = 0; a < vocab_hash_size; a++) vocab_hash[a] = -1;
  size = vocab_size;
  train_words = 0;
  for (a = 0; a < size; a++) {
    // Words occuring less than min_count times will be discarded from the vocab
    if ((vocab[a].cn < min_count) && (a != 0)) {
      vocab_size--;
      free(vocab[a].word);
    } else {
      // Hash will be re-computed, as after the sorting it is not actual
      hash=GetWordHash(vocab[a].word);
      while (vocab_hash[hash] != -1) hash = (hash + 1) % vocab_hash_size;
      vocab_hash[hash] = a;
      train_words += vocab[a].cn;
    }
  }
  vocab = (struct vocab_word *)realloc(vocab, (vocab_size + 1) * sizeof(struct vocab_word));
  // Allocate memory for the binary tree construction
  for (a = 0; a < vocab_size; a++) {
    vocab[a].code = (char *)calloc(MAX_CODE_LENGTH, sizeof(char));
    vocab[a].point = (int *)calloc(MAX_CODE_LENGTH, sizeof(int));
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq 0x898b(%rip), %rdi      # 0xb478
addq $0x28, %rdi
movq 0x8998(%rip), %rsi      # 0xb490
decq %rsi
leaq -0x2c(%rip), %rcx       # 0x2ad6
movl $0x28, %edx
callq 0x2450
movq 0x8975(%rip), %rdi      # 0xb488
movl $0x7270e00, %edx        # imm = 0x7270E00
movl $0xff, %esi
callq 0x2150
movq 0x8967(%rip), %r14      # 0xb490
movq $0x0, 0x8964(%rip) # 0xb498
testl %r14d, %r14d
jle 0x2c11
andl $0x7fffffff, %r14d      # imm = 0x7FFFFFFF
xorl %r15d, %r15d
movabsq $0x23ca98ce50e9b5d, %r12 # imm = 0x23CA98CE50E9B5D
xorl %r13d, %r13d
movq 0x891d(%rip), %rax      # 0xb478
leaq (,%r13,4), %rcx
addq %r13, %rcx
movq (%rax,%rcx,8), %rbp
testq %r13, %r13
je 0x2b8e
movslq 0x86ee(%rip), %rdx      # 0xb264
cmpq %rdx, %rbp
jge 0x2b8e
decq 0x890e(%rip)            # 0xb490
movq 0x10(%rax,%rcx,8), %rdi
callq 0x22b0
jmp 0x2c05
leaq (%rax,%rcx,8), %rax
movq 0x10(%rax), %rbx
movq %rbx, %rdi
callq 0x2110
xorl %ecx, %ecx
testq %rax, %rax
je 0x2bd7
xorl %edx, %edx
movq %rcx, %rsi
shlq $0x8, %rsi
addq %rcx, %rsi
movsbq (%rbx,%rdx), %rcx
addq %rsi, %rcx
incq %rdx
cmpq %rdx, %rax
jne 0x2ba7
movq %rcx, %rax
shrq $0x7, %rax
mulq %r12
shrq $0xb, %rdx
imull $0x1c9c380, %edx, %eax  # imm = 0x1C9C380
subl %eax, %ecx
movq 0x88aa(%rip), %rax      # 0xb488
movl %ecx, %edx
cmpl $-0x1, (%rax,%rdx,4)
je 0x2bfa
movl %ecx, %edx
incl %edx
cmpl $0x1c9c380, %edx        # imm = 0x1C9C380
cmovel %r15d, %edx
cmpl $-0x1, (%rax,%rdx,4)
jne 0x2be8
movl %r13d, (%rax,%rdx,4)
addq %rbp, 0x8893(%rip)      # 0xb498
incq %r13
cmpq %r14, %r13
jne 0x2b54
movq 0x8860(%rip), %rdi      # 0xb478
movq 0x8871(%rip), %rax      # 0xb490
leaq (%rax,%rax,4), %rax
leaq 0x28(,%rax,8), %rsi
callq 0x23c0
movq %rax, 0x8841(%rip)      # 0xb478
movq 0x8852(%rip), %rbx      # 0xb490
testq %rbx, %rbx
jle 0x2c85
xorl %r14d, %r14d
movl $0x28, %edi
movl $0x1, %esi
callq 0x2160
movq 0x881c(%rip), %rcx      # 0xb478
movq %rax, 0x18(%rcx,%r14)
movl $0x28, %edi
movl $0x4, %esi
callq 0x2160
movq 0x8801(%rip), %rcx      # 0xb478
movq %rax, 0x8(%rcx,%r14)
addq $0x28, %r14
decq %rbx
jne 0x2c46
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq