// File: /workspace/github_c_makefile_star2_O2/Leeheng86[P]word2vec/word2vec.c
// Function: RandomWalkThread(void*)
void *RandomWalkThread(void *id) {
  long long thread_id = (long long)id;

  std::string new_train_file = std::string(train_file).append("_walks").append(std::to_string(thread_id));
  printf("Loaded and preprocessed edge file, save walks to file %s\n", new_train_file.c_str());
  FILE *fin = fopen(new_train_file.c_str(), "wb");

  std::unordered_map<std::string, std::vector<std::string> >::iterator it = std::next(umap.begin(), (int)thread_id);
  while (it != umap.end()) {
    //printf("[%lld] process node %s\n", thread_id, (it->first).c_str());

    for (int i = 0; i < number_walks; i++) {
      std::unordered_map<std::string, std::vector<std::string> >::iterator itt = it;
      std::string str;
      std::vector<std::string> v;
      append(v, itt->first);
      itt = umap.find(WalkTo(itt->second));
      for (int j = 0; j <= walk_length; j++) {
        append(v, itt->first);
        itt = umap.find(WalkTo(itt->second));
      }
      join(v, ' ', str);
      fprintf(fin, "%s\n", str.c_str());
    }

    if (!IsNextIElementsEnd(it, num_threads)) {
      it = std::next(it, num_threads);
    } else {
      it = umap.end();
    }
  }
  fclose(fin);
  pthread_exit(NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rdi, %rbx
leaq 0x6d9b(%rip), %rsi      # 0xb2c0
leaq 0x20(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x5448
leaq 0x2c13(%rip), %rsi      # 0x714e
leaq 0x20(%rsp), %rdi
callq 0x2460
movq %rax, %r14
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x5483
leaq 0x50(%rsp), %rsi
movq %r14, %rdi
callq 0x2490
leaq 0x88(%rsp), %rdi
movq %rax, %rsi
callq 0x2300
leaq 0x50(%rsp), %rdi
callq 0x2110
leaq 0x20(%rsp), %rdi
callq 0x2110
movq 0x88(%rsp), %rsi
leaq 0x2bc0(%rip), %rdi      # 0x7155
xorl %eax, %eax
callq 0x2050
movq 0x88(%rsp), %rdi
leaq 0x2b02(%rip), %rsi      # 0x70ad
callq 0x2280
movq %rax, 0x10(%rsp)
movq 0x6f54(%rip), %rdi      # 0xb510
movslq %ebx, %rsi
callq 0x54e3
leaq 0xa8(%rsp), %r14
leaq 0x70(%rsp), %r15
leaq 0x50(%rsp), %r12
leaq 0x6f23(%rip), %r13      # 0xb500
leaq 0xc8(%rsp), %rbx
testq %rax, %rax
je 0x4758
leaq 0x8(%rax), %rcx
movq %rcx, 0x48(%rsp)
leaq 0x28(%rax), %rcx
movq %rcx, 0x40(%rsp)
xorl %ecx, %ecx
movq %rax, 0x18(%rsp)
cmpl 0x6c97(%rip), %ecx      # 0xb2a4
jge 0x4727
movl %ecx, 0xc(%rsp)
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
andq $0x0, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
andq $0x0, 0x80(%rsp)
movq %r14, %rdi
movq 0x48(%rsp), %rsi
callq 0x2300
movq %r15, %rdi
movq %r14, %rsi
callq 0x444c
movq %r14, %rdi
callq 0x2110
movq %r12, %rdi
movq 0x40(%rsp), %rsi
callq 0x43fa
movq %r13, %rdi
movq %r12, %rsi
callq 0x6102
movq %rax, %rbp
movq %r12, %rdi
callq 0x2110
xorl %r14d, %r14d
cmpl 0x6c16(%rip), %r14d     # 0xb2a0
jg 0x46d5
leaq 0x8(%rbp), %rsi
movq %rbx, %rdi
callq 0x2300
movq %r15, %rdi
movq %rbx, %rsi
callq 0x444c
movq %rbx, %rdi
callq 0x2110
addq $0x28, %rbp
movq %r12, %rdi
movq %rbp, %rsi
callq 0x43fa
movq %r13, %rdi
movq %r12, %rsi
callq 0x6102
movq %rax, %rbp
movq %r12, %rdi
callq 0x2110
incl %r14d
jmp 0x4683
movq %r15, %rdi
pushq $0x20
popq %rsi
leaq 0x20(%rsp), %rdx
callq 0x44b2
leaq 0xa8(%rsp), %r14
movq 0x20(%rsp), %rdx
movq 0x10(%rsp), %rdi
leaq 0x2ab6(%rip), %rsi      # 0x71b4
xorl %eax, %eax
callq 0x2330
movq %r15, %rdi
callq 0x53e0
leaq 0x20(%rsp), %rdi
callq 0x2110
movl 0xc(%rsp), %ecx
incl %ecx
movq 0x18(%rsp), %rax
jmp 0x4607
movl 0x6b43(%rip), %ebp      # 0xb270
movq %rax, %rdi
movl %ebp, %esi
callq 0x4434
movl %eax, %ecx
movl $0x0, %eax
testb %cl, %cl
jne 0x45e5
movslq %ebp, %rsi
movq 0x18(%rsp), %rdi
callq 0x54e3
jmp 0x45e5
movq 0x10(%rsp), %rdi
callq 0x2210
xorl %edi, %edi
callq 0x2400
jmp 0x47b5
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
jmp 0x479a
jmp 0x478d
jmp 0x4792
jmp 0x478d
jmp 0x478d
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
jmp 0x479a
movq %rax, %rbx
jmp 0x479f
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2110
leaq 0x70(%rsp), %rdi
callq 0x53e0
leaq 0x20(%rsp), %rdi
callq 0x2110
jmp 0x47b8
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
jmp 0x47db
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2110
jmp 0x47d6
jmp 0x47d3
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2110
jmp 0x47e5
movq %rax, %rbx
movq %rbx, %rdi
callq 0x23f0