// File: /workspace/github_c_makefile_star2_O0/Leeheng86[P]word2vec/word2vec.c
// Function: TrainModel()
void TrainModel() {
  long a, b, c, d;
  FILE *fo;
  pthread_t *pt = (pthread_t *)malloc(num_threads * sizeof(pthread_t));
  printf("Starting training using file %s\n", train_file);
  starting_alpha = alpha;
  if (read_vocab_file[0] != 0) ReadVocab(); else LearnVocabFromTrainFile();
  if (save_vocab_file[0] != 0) SaveVocab();
  if (output_file[0] == 0) return;
  InitNet();
  if (negative > 0) InitUnigramTable();
  start = clock();
  for (a = 0; a < num_threads; a++) pthread_create(&pt[a], NULL, TrainModelThread, (void *)a);
  for (a = 0; a < num_threads; a++) pthread_join(pt[a], NULL);
  fo = fopen(output_file, "wb");
  if (classes == 0) {
    // Save the word vectors
    fprintf(fo, "%lld %lld\n", vocab_size, layer1_size);
    for (a = 0; a < vocab_size; a++) {
      fprintf(fo, "%s ", vocab[a].word);
      if (binary) for (b = 0; b < layer1_size; b++) fwrite(&syn0[a * layer1_size + b], sizeof(real), 1, fo);
      else for (b = 0; b < layer1_size; b++) fprintf(fo, "%lf ", syn0[a * layer1_size + b]);
      fprintf(fo, "\n");
    }
  } else {
    // Run K-means on the word vectors
    int clcn = classes, iter = 10, closeid;
    int *centcn = (int *)malloc(classes * sizeof(int));
    int *cl = (int *)calloc(vocab_size, sizeof(int));
    real closev, x;
    real *cent = (real *)calloc(classes * layer1_size, sizeof(real));
    for (a = 0; a < vocab_size; a++) cl[a] = a % clcn;
    for (a = 0; a < iter; a++) {
      for (b = 0; b < clcn * layer1_size; b++) cent[b] = 0;
      for (b = 0; b < clcn; b++) centcn[b] = 1;
      for (c = 0; c < vocab_size; c++) {
        for (d = 0; d < layer1_size; d++) cent[layer1_size * cl[c] + d] += syn0[c * layer1_size + d];
        centcn[cl[c]]++;
      }
      for (b = 0; b < clcn; b++) {
        closev = 0;
        for (c = 0; c < layer1_size; c++) {
          cent[layer1_size * b + c] /= centcn[b];
          closev += cent[layer1_size * b + c] * cent[layer1_size * b + c];
        }
        closev = sqrt(closev);
        for (c = 0; c < layer1_size; c++) cent[layer1_size * b + c] /= closev;
      }
      for (c = 0; c < vocab_size; c++) {
        closev = -10;
        closeid = 0;
        for (d = 0; d < clcn; d++) {
          x = 0;
          for (b = 0; b < layer1_size; b++) x += cent[layer1_size * d + b] * syn0[c * layer1_size + b];
          if (x > closev) {
            closev = x;
            closeid = d;
          }
        }
        cl[c] = closeid;
      }
    }
    // Save the K-means classes
    for (a = 0; a < vocab_size; a++) fprintf(fo, "%s %d\n", vocab[a].word, cl[a]);
    free(centcn);
    free(cent);
    free(cl);
  }
  fclose(fo);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movslq 0xe301(%rip), %rdi      # 0x142f0
shlq $0x3, %rdi
callq 0x33c0
movq %rax, -0x30(%rbp)
leaq 0x813d(%rip), %rdi      # 0xe140
leaq 0xe336(%rip), %rsi      # 0x14340
movb $0x0, %al
callq 0x3060
movss 0xe2f7(%rip), %xmm0     # 0x14310
movss %xmm0, 0xe517(%rip)     # 0x14538
movsbl 0xe468(%rip), %eax      # 0x14490
cmpl $0x0, %eax
je 0x6034
callq 0x4670
jmp 0x6039
callq 0x43f0
movsbl 0xe3e0(%rip), %eax      # 0x14420
cmpl $0x0, %eax
je 0x604a
callq 0x45e0
movsbl 0xe35f(%rip), %eax      # 0x143b0
cmpl $0x0, %eax
jne 0x605b
jmp 0x66dc
callq 0x4820
cmpl $0x0, 0xe2b1(%rip)      # 0x14318
jle 0x606e
callq 0x3750
callq 0x31c0
movq %rax, 0xe4e6(%rip)      # 0x14560
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
movslq 0xe263(%rip), %rcx      # 0x142f0
cmpq %rcx, %rax
jge 0x60c3
movq -0x30(%rbp), %rdi
movq -0x8(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x8(%rbp), %rcx
xorl %eax, %eax
movl %eax, %esi
leaq -0x15e0(%rip), %rdx     # 0x4ad0
callq 0x3510
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x6082
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
movslq 0xe21a(%rip), %rcx      # 0x142f0
cmpq %rcx, %rax
jge 0x60fe
movq -0x30(%rbp), %rax
movq -0x8(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3240
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x60cb
leaq 0xe2ab(%rip), %rdi      # 0x143b0
leaq 0x7fb3(%rip), %rsi      # 0xe0bf
callq 0x3330
movq %rax, -0x28(%rbp)
cmpq $0x0, 0xe413(%rip)      # 0x14530
jne 0x625f
movq -0x28(%rbp), %rdi
movq 0xe3e2(%rip), %rdx      # 0x14510
movq 0xe1cb(%rip), %rcx      # 0x14300
leaq 0x8025(%rip), %rsi      # 0xe161
movb $0x0, %al
callq 0x33f0
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq 0xe3ba(%rip), %rax      # 0x14510
jge 0x625a
movq -0x28(%rbp), %rdi
movq 0xe391(%rip), %rax      # 0x144f8
imulq $0x28, -0x8(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
leaq 0x7ff2(%rip), %rsi      # 0xe16c
movb $0x0, %al
callq 0x33f0
cmpl $0x0, 0xe378(%rip)      # 0x14500
je 0x61e0
movq $0x0, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq 0xe163(%rip), %rax      # 0x14300
jge 0x61de
movq 0xe39a(%rip), %rdi      # 0x14540
movq -0x8(%rbp), %rax
imulq 0xe14e(%rip), %rax      # 0x14300
addq -0x10(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x28(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x3560
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x6192
jmp 0x6237
movq $0x0, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq 0xe10d(%rip), %rax      # 0x14300
jge 0x6235
movq -0x28(%rbp), %rdi
movq 0xe340(%rip), %rax      # 0x14540
movq -0x8(%rbp), %rcx
imulq 0xe0f4(%rip), %rcx      # 0x14300
addq -0x10(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
cvtss2sd %xmm0, %xmm0
leaq 0x7f50(%rip), %rsi      # 0xe170
movb $0x1, %al
callq 0x33f0
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x61e8
jmp 0x6237
movq -0x28(%rbp), %rdi
leaq 0x880a(%rip), %rsi      # 0xea4c
movb $0x0, %al
callq 0x33f0
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x614b
jmp 0x66d3
movq 0xe2ca(%rip), %rax      # 0x14530
movl %eax, -0x34(%rbp)
movl $0xa, -0x38(%rbp)
movq 0xe2b9(%rip), %rdi      # 0x14530
shlq $0x2, %rdi
callq 0x33c0
movq %rax, -0x48(%rbp)
movq 0xe285(%rip), %rdi      # 0x14510
movl $0x4, %esi
callq 0x31b0
movq %rax, -0x50(%rbp)
movq 0xe290(%rip), %rdi      # 0x14530
imulq 0xe058(%rip), %rdi      # 0x14300
movl $0x4, %esi
callq 0x31b0
movq %rax, -0x60(%rbp)
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq 0xe247(%rip), %rax      # 0x14510
jge 0x62f1
movq -0x8(%rbp), %rax
movslq -0x34(%rbp), %rcx
cqto
idivq %rcx
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x62be
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
movslq -0x38(%rbp), %rcx
cmpq %rcx, %rax
jge 0x6665
movq $0x0, -0x10(%rbp)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq 0xdfde(%rip), %rcx      # 0x14300
cmpq %rcx, %rax
jge 0x6345
movq -0x60(%rbp), %rax
movq -0x10(%rbp), %rcx
xorps %xmm0, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x6312
movq $0x0, -0x10(%rbp)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpq %rcx, %rax
jge 0x6377
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
movl $0x1, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x634d
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq 0xe186(%rip), %rax      # 0x14510
jge 0x6422
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpq 0xdf5d(%rip), %rax      # 0x14300
jge 0x63f8
movq 0xe194(%rip), %rax      # 0x14540
movq -0x18(%rbp), %rcx
imulq 0xdf48(%rip), %rcx      # 0x14300
addq -0x20(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x60(%rbp), %rax
movq 0xdf34(%rip), %rcx      # 0x14300
movq -0x50(%rbp), %rdx
movq -0x18(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
imulq %rdx, %rcx
addq -0x20(%rbp), %rcx
addss (%rax,%rcx,4), %xmm0
movss %xmm0, (%rax,%rcx,4)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x6398
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movq -0x18(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x637f
movq $0x0, -0x10(%rbp)
movq -0x10(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpq %rcx, %rax
jge 0x654c
xorps %xmm0, %xmm0
movss %xmm0, -0x54(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq 0xdeaa(%rip), %rax      # 0x14300
jge 0x64e0
movq -0x48(%rbp), %rax
movq -0x10(%rbp), %rcx
cvtsi2ssl (%rax,%rcx,4), %xmm1
movq -0x60(%rbp), %rax
movq 0xde8c(%rip), %rcx      # 0x14300
imulq -0x10(%rbp), %rcx
addq -0x18(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq -0x60(%rbp), %rax
movq 0xde6a(%rip), %rcx      # 0x14300
imulq -0x10(%rbp), %rcx
addq -0x18(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq -0x60(%rbp), %rax
movq 0xde51(%rip), %rcx      # 0x14300
imulq -0x10(%rbp), %rcx
addq -0x18(%rbp), %rcx
movss (%rax,%rcx,4), %xmm2
movss -0x54(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x54(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x644b
movss -0x54(%rbp), %xmm0
callq 0x8110
movss %xmm0, -0x54(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq 0xddfe(%rip), %rax      # 0x14300
jge 0x6539
movss -0x54(%rbp), %xmm1
movq -0x60(%rbp), %rax
movq 0xddec(%rip), %rcx      # 0x14300
imulq -0x10(%rbp), %rcx
addq -0x18(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x64f7
jmp 0x653b
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x642a
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpq 0xdfb1(%rip), %rax      # 0x14510
jge 0x6652
movss 0x7ae3(%rip), %xmm0     # 0xe050
movss %xmm0, -0x54(%rbp)
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
cmpq %rcx, %rax
jge 0x6633
xorps %xmm0, %xmm0
movss %xmm0, -0x58(%rbp)
movq $0x0, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq 0xdd53(%rip), %rax      # 0x14300
jge 0x6604
movq -0x60(%rbp), %rax
movq 0xdd46(%rip), %rcx      # 0x14300
imulq -0x20(%rbp), %rcx
addq -0x10(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movq 0xdf71(%rip), %rax      # 0x14540
movq -0x18(%rbp), %rcx
imulq 0xdd25(%rip), %rcx      # 0x14300
addq -0x10(%rbp), %rcx
movss (%rax,%rcx,4), %xmm2
movss -0x58(%rbp), %xmm1
mulss %xmm2, %xmm0
addss %xmm1, %xmm0
movss %xmm0, -0x58(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
jmp 0x65a2
movss -0x58(%rbp), %xmm0
ucomiss -0x54(%rbp), %xmm0
jbe 0x6620
movss -0x58(%rbp), %xmm0
movss %xmm0, -0x54(%rbp)
movq -0x20(%rbp), %rax
movl %eax, -0x3c(%rbp)
jmp 0x6622
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x6581
movl -0x3c(%rbp), %edx
movq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x6554
jmp 0x6654
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x62f9
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq 0xde98(%rip), %rax      # 0x14510
jge 0x66b8
movq -0x28(%rbp), %rdi
movq 0xde73(%rip), %rax      # 0x144f8
imulq $0x28, -0x8(%rbp), %rcx
addq %rcx, %rax
movq 0x10(%rax), %rdx
movq -0x50(%rbp), %rax
movq -0x8(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x7ad2(%rip), %rsi      # 0xe175
movb $0x0, %al
callq 0x33f0
movq -0x8(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x8(%rbp)
jmp 0x666d
movq -0x48(%rbp), %rdi
callq 0x3340
movq -0x60(%rbp), %rdi
callq 0x3340
movq -0x50(%rbp), %rdi
callq 0x3340
movq -0x28(%rbp), %rdi
callq 0x3280
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)