// File: /workspace/github_c_makefile_star2_O1/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 $0xd8, %rsp
movq %rdi, %r14
leaq 0x30(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x6a16(%rip), %rbx      # 0xb2c0
movq %rbx, %rdi
callq 0x2110
leaq (%rax,%rbx), %rdx
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
callq 0x6910
leaq 0x2894(%rip), %rsi      # 0x715e
leaq 0x20(%rsp), %rdi
callq 0x2460
movq %rax, %rbp
movq %r14, %r15
negq %r15
cmovsq %r14, %r15
movl $0x1, %r12d
cmpq $0xa, %r15
jb 0x4941
movl $0x4, %r12d
movabsq $0x346dc5d63886594b, %rsi # imm = 0x346DC5D63886594B
movq %r15, %rcx
cmpq $0x63, %rcx
jbe 0x4938
cmpq $0x3e7, %rcx            # imm = 0x3E7
jbe 0x493e
cmpq $0x2710, %rcx           # imm = 0x2710
jb 0x4941
movq %rcx, %rax
mulq %rsi
shrq $0xb, %rdx
addl $0x4, %r12d
cmpq $0x1869f, %rcx          # imm = 0x1869F
movq %rdx, %rcx
ja 0x4900
addl $-0x3, %r12d
jmp 0x4941
addl $-0x2, %r12d
jmp 0x4941
decl %r12d
movq %r14, %r13
shrq $0x3f, %r13
leal (%r12,%r13), %esi
leaq 0x10(%rsp), %rax
movq %rax, -0x10(%rax)
movq %rsp, %rdi
movl $0x2d, %edx
callq 0x2280
addq (%rsp), %r13
movq %r13, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x5ee6
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rdi
callq 0x20d0
leaq 0xc8(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xb8(%rsp), %rdi
callq 0x5f62
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x49c3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2240
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x49df
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2240
movq 0xb8(%rsp), %rsi
leaq 0x2777(%rip), %rdi      # 0x7165
xorl %eax, %eax
callq 0x2050
movq 0xb8(%rsp), %rdi
leaq 0x26b9(%rip), %rsi      # 0x70bd
callq 0x22a0
movq %rax, 0x48(%rsp)
movq 0x6afb(%rip), %rbx      # 0xb510
shlq $0x20, %r14
je 0x4a27
sarq $0x20, %r14
movq (%rbx), %rbx
decq %r14
jne 0x4a1f
testq %rbx, %rbx
jne 0x4a3d
movq 0x48(%rsp), %rdi
callq 0x2220
xorl %edi, %edi
callq 0x2400
leaq 0x60(%rsp), %r15
leaq 0xa8(%rsp), %r13
movq %rsp, %r12
leaq 0x98(%rsp), %rbp
cmpl $0x0, 0x6840(%rip)      # 0xb29c
jle 0x4c2a
leaq 0x28(%rbx), %rax
movq %rax, 0x90(%rsp)
xorl %r14d, %r14d
movl %r14d, 0x44(%rsp)
leaq 0x30(%rsp), %rax
movq %rax, 0x20(%rsp)
xorl %eax, %eax
movq %rax, 0x28(%rsp)
movb $0x0, 0x30(%rsp)
movq %rax, 0x80(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
movq %r15, 0x50(%rsp)
movq 0x8(%rbx), %rsi
movq 0x10(%rbx), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0x5f62
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x47b1
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x4adc
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x2240
movq %r12, %rdi
movq 0x90(%rsp), %rsi
callq 0x473e
leaq 0x6a0d(%rip), %rdi      # 0xb500
movq %r12, %rsi
callq 0x69a0
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4b19
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2240
cmpl $0x0, 0x6778(%rip)      # 0xb298
js 0x4bbd
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
movq %r13, 0x98(%rsp)
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x5f62
leaq 0x70(%rsp), %rdi
movq %rbp, %rsi
callq 0x47b1
movq 0x98(%rsp), %rdi
cmpq %r13, %rdi
je 0x4b71
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x2240
addq $0x28, %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x473e
leaq 0x6979(%rip), %rdi      # 0xb500
movq %r12, %rsi
callq 0x69a0
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4bad
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2240
incl %r15d
cmpl 0x66e1(%rip), %r15d     # 0xb298
jl 0x4b2c
leaq 0x70(%rsp), %r14
movq %r14, %rdi
movl $0x20, %esi
leaq 0x20(%rsp), %rdx
callq 0x4823
leaq 0x60(%rsp), %r15
movq 0x20(%rsp), %rdx
movq 0x48(%rsp), %rdi
leaq 0x25da(%rip), %rsi      # 0x71c4
xorl %eax, %eax
callq 0x2330
movq %r14, %rdi
callq 0x5d04
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
movl 0x44(%rsp), %r14d
je 0x4c1a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2240
incl %r14d
cmpl 0x6678(%rip), %r14d     # 0xb29c
jl 0x4a71
movslq 0x6637(%rip), %rax      # 0xb268
testq %rax, %rax
setns %cl
js 0x4c4f
xorl %edx, %edx
movq %rbx, %rsi
cmpl %eax, %edx
setl %cl
jge 0x4c4f
movq (%rsi), %rsi
incl %edx
testq %rsi, %rsi
jne 0x4c3e
testb %cl, %cl
je 0x4c57
xorl %ebx, %ebx
jmp 0x4c63
testl %eax, %eax
je 0x4c63
movq (%rbx), %rbx
decq %rax
jne 0x4c5b
testq %rbx, %rbx
jne 0x4a55
jmp 0x4a2c
movq %rax, %r14
movq 0x50(%rsp), %rdi
cmpq %r15, %rdi
je 0x4cca
movq 0x60(%rsp), %rsi
jmp 0x4cbb
jmp 0x4cc7
jmp 0x4ca5
jmp 0x4cc7
movq %rax, %r14
movq 0x98(%rsp), %rdi
cmpq %r13, %rdi
je 0x4cca
movq 0xa8(%rsp), %rsi
jmp 0x4cbb
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4cca
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x4cca
jmp 0x4cc7
movq %rax, %r14
leaq 0x70(%rsp), %rdi
callq 0x5d04
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4cf5
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x4cf5
movq %rax, %r14
movq 0xb8(%rsp), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x4d5a
movq 0xc8(%rsp), %rsi
jmp 0x4d4d
movq %rax, %r14
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x4d39
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x4d39
jmp 0x4d36
movq %rax, %r14
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0x4d5a
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x4d5a
movq %rax, %r14
movq %r14, %rdi
callq 0x23f0