// File: /workspace/github_c_makefile_star2_O3/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, %rbx
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x6767(%rip), %r14      # 0xb2c0
movq %r14, %rdi
callq 0x2110
leaq (%rax,%r14), %rdx
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x6bc0
leaq 0x2631(%rip), %rsi      # 0x71aa
leaq 0x28(%rsp), %rdi
callq 0x2460
movq %rax, %r14
movq %rbx, %r15
negq %r15
cmovsq %rbx, %r15
movl $0x1, %r12d
cmpq $0xa, %r15
jb 0x4bf0
movl $0x4, %r12d
movabsq $0x346dc5d63886594b, %rsi # imm = 0x346DC5D63886594B
movq %r15, %rcx
cmpq $0x63, %rcx
jbe 0x4be7
cmpq $0x3e7, %rcx            # imm = 0x3E7
jbe 0x4bed
cmpq $0x2710, %rcx           # imm = 0x2710
jb 0x4bf0
movq %rcx, %rax
mulq %rsi
shrq $0xb, %rdx
addl $0x4, %r12d
cmpq $0x1869f, %rcx          # imm = 0x1869F
movq %rdx, %rcx
ja 0x4baf
addl $-0x3, %r12d
jmp 0x4bf0
addl $-0x2, %r12d
jmp 0x4bf0
decl %r12d
movq %rbx, %r13
shrq $0x3f, %r13
leal (%r12,%r13), %esi
leaq 0x18(%rsp), %rax
movq %rax, -0x10(%rax)
leaq 0x8(%rsp), %rdi
movl $0x2d, %edx
callq 0x2280
addq 0x8(%rsp), %r13
movq %r13, %rdi
movl %r12d, %esi
movq %r15, %rdx
callq 0x61d2
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq %r14, %rdi
callq 0x20d0
leaq 0xb0(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0xa0(%rsp), %rdi
callq 0x624e
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4c77
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2240
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x4c93
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2240
movq 0xa0(%rsp), %rsi
leaq 0x250f(%rip), %rdi      # 0x71b1
xorl %eax, %eax
callq 0x2050
movq 0xa0(%rsp), %rdi
leaq 0x2451(%rip), %rsi      # 0x7109
callq 0x22a0
movq %rax, 0x50(%rsp)
movq 0x6847(%rip), %r13      # 0xb510
shlq $0x20, %rbx
je 0x4cdc
sarq $0x20, %rbx
movq (%r13), %r13
decq %rbx
jne 0x4cd3
testq %r13, %r13
jne 0x4cf2
movq 0x50(%rsp), %rdi
callq 0x2220
xorl %edi, %edi
callq 0x2400
leaq 0x88(%rsp), %r15
movl 0x659c(%rip), %eax      # 0xb29c
leaq 0xc0(%rsp), %rbx
leaq 0x8(%rsp), %r12
leaq 0x58(%rsp), %rbp
testl %eax, %eax
jle 0x4eea
leaq 0x28(%r13), %rax
movq %rax, 0x98(%rsp)
xorl %r14d, %r14d
movl %r14d, 0x4c(%rsp)
leaq 0x38(%rsp), %rax
movq %rax, 0x28(%rsp)
xorl %eax, %eax
movq %rax, 0x30(%rsp)
movb $0x0, 0x38(%rsp)
movq %rax, 0xd0(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0xc0(%rsp)
movq %r15, 0x78(%rsp)
movq 0x8(%r13), %rsi
movq 0x10(%r13), %rdx
addq %rsi, %rdx
leaq 0x78(%rsp), %rdi
callq 0x624e
movq %rbx, %rdi
leaq 0x78(%rsp), %rsi
callq 0x4a5b
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x4d98
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x2240
movq %r12, %rdi
movq 0x98(%rsp), %rsi
callq 0x49e8
leaq 0x6751(%rip), %rdi      # 0xb500
movq %r12, %rsi
callq 0x6c56
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4dd6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2240
cmpl $0x0, 0x64bb(%rip)      # 0xb298
js 0x4e7a
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
leaq 0x68(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x8(%r14), %rsi
movq 0x10(%r14), %rdx
addq %rsi, %rdx
movq %rbp, %rdi
callq 0x624e
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x4a5b
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x4e2d
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x2240
addq $0x28, %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x49e8
leaq 0x66bd(%rip), %rdi      # 0xb500
movq %r12, %rsi
callq 0x6c56
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4e6a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2240
incl %r15d
cmpl 0x6424(%rip), %r15d     # 0xb298
jl 0x4de9
movq %rbx, %r14
movq %rbx, %rdi
movl $0x20, %esi
leaq 0x28(%rsp), %rdx
callq 0x4acf
leaq 0x88(%rsp), %r15
movq 0x28(%rsp), %rdx
movq 0x50(%rsp), %rdi
leaq 0x2368(%rip), %rsi      # 0x7210
xorl %eax, %eax
callq 0x2330
movq %r14, %rdi
callq 0x5fee
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
movl 0x4c(%rsp), %r14d
je 0x4ed8
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2240
incl %r14d
movl 0x63bb(%rip), %eax      # 0xb29c
cmpl %eax, %r14d
jl 0x4d29
movslq 0x6377(%rip), %rcx      # 0xb268
testq %rcx, %rcx
js 0x4f18
xorl %edi, %edi
movq %r13, %rdx
movl %edi, %esi
cmpl %ecx, %edi
jge 0x4f0c
movq (%rdx), %rdx
leal 0x1(%rsi), %edi
testq %rdx, %rdx
jne 0x4efb
cmpl %ecx, %esi
jl 0x4ce1
testl %ecx, %ecx
je 0x4f21
movq (%r13), %r13
decq %rcx
jne 0x4f18
testq %r13, %r13
jne 0x4d12
jmp 0x4ce1
movq %rax, %r14
movq 0x78(%rsp), %rdi
cmpq %r15, %rdi
je 0x4f8b
movq 0x88(%rsp), %rsi
jmp 0x4f7c
jmp 0x4f88
jmp 0x4f65
jmp 0x4f88
movq %rax, %r14
movq 0x58(%rsp), %rdi
leaq 0x68(%rsp), %rax
cmpq %rax, %rdi
je 0x4f8b
movq 0x68(%rsp), %rsi
jmp 0x4f7c
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4f8b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x4f8b
jmp 0x4f88
movq %rax, %r14
leaq 0xc0(%rsp), %rdi
callq 0x5fee
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x4fb9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x4fb9
movq %rax, %r14
movq 0xa0(%rsp), %rdi
leaq 0xb0(%rsp), %rax
cmpq %rax, %rdi
je 0x501f
movq 0xb0(%rsp), %rsi
jmp 0x5012
movq %rax, %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x4ffe
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x4ffe
jmp 0x4ffb
movq %rax, %r14
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x501f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2240
jmp 0x501f
movq %rax, %r14
movq %r14, %rdi
callq 0x23f0