// File: rtackx[P]ComSim/projection.cpp
// Function: compute_projection_thread(void*)
void* compute_projection_thread(void* struct_args)
{
	projection_thread_args* args = static_cast<projection_thread_args*>(struct_args);

	pair<unordered_map<unsigned int, set<pair<unsigned int, float>, comp_pair>>::iterator, bool> it_map;
	unordered_map<unsigned int, set<pair<unsigned int, float>, comp_pair>> map_neighbor;

	vector<Node*> list_distance_neighbors = args->p->get_neighbors(args->index, args->distance);
	float projection_weight;

	Node* node = new Node();
	node->id = args->p->in_graph->list_nodes[args->index]->id;
	node->main_index = args->p->in_graph->list_nodes[args->index]->main_index;

	it_map = map_neighbor.emplace(args->index, set<pair<unsigned int, float>, comp_pair>());

	for(auto& node_neighbor : list_distance_neighbors)
	{
		projection_weight = args->p->similarity_projection(args->p->in_graph->list_nodes[args->index], node_neighbor);

		if(projection_weight > 0.0)
			it_map.first->second.insert(make_pair(node_neighbor->index, projection_weight));
	}

	pthread_mutex_lock(&compute_projection_mutex);
	args->map_node->emplace(make_pair(args->index, node));
	args->map_neighbor->insert(map_neighbor.begin(), map_neighbor.end());
	pthread_mutex_unlock(&compute_projection_mutex);

	pthread_exit(NULL);
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1c0(%rsp)
movq 0x1c0(%rsp), %rax
movq %rax, 0x1b8(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x10360
leaq 0x170(%rsp), %rdi
callq 0x77b0
movq 0x1b8(%rsp), %rcx
movq (%rcx), %rsi
movq %rcx, %rdx
addq $0x8, %rdx
addq $0xc, %rcx
leaq 0x158(%rsp), %rdi
callq 0xe7f0
jmp 0xe3ae
movl $0x68, %edi
callq 0x3250
movq %rax, 0x80(%rsp)
jmp 0xe3c2
movq 0x80(%rsp), %rdi
callq 0x36a0
jmp 0xe3d1
movq 0x80(%rsp), %rax
movq %rax, 0x140(%rsp)
movq 0x1b8(%rsp), %rcx
movq (%rcx), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rcx), %ecx
movq (%rax,%rcx,8), %rsi
addq $0x8, %rsi
movq 0x140(%rsp), %rdi
addq $0x8, %rdi
callq 0x3050
jmp 0xe412
movq 0x1b8(%rsp), %rcx
movq (%rcx), %rax
movq 0x10(%rax), %rax
movq 0x8(%rax), %rax
movl 0x8(%rcx), %ecx
movq (%rax,%rcx,8), %rax
movl 0x4(%rax), %ecx
movq 0x140(%rsp), %rax
movl %ecx, 0x4(%rax)
movq 0x1b8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x120(%rsp)
movaps %xmm0, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
leaq 0x100(%rsp), %rdi
movq %rdi, 0x68(%rsp)
callq 0xbf70
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
leaq 0x170(%rsp), %rdi
callq 0x103a0
movb %dl, 0x77(%rsp)
movq %rax, 0x78(%rsp)
jmp 0xe49a
movb 0x77(%rsp), %al
movq 0x78(%rsp), %rcx
movq %rcx, 0xf0(%rsp)
movb %al, 0xf8(%rsp)
movq 0xf0(%rsp), %rax
movq %rax, 0x130(%rsp)
movb 0xf8(%rsp), %al
movb %al, 0x138(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0x103f0
leaq 0x100(%rsp), %rdi
callq 0x84a0
leaq 0x158(%rsp), %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x10420
movq %rax, 0xe0(%rsp)
movq 0xe8(%rsp), %rdi
callq 0x10450
movq %rax, 0xd8(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x10480
testb $0x1, %al
jne 0xe54a
jmp 0xe6c5
leaq 0xe0(%rsp), %rdi
callq 0x104c0
movq %rax, 0xd0(%rsp)
movq 0x1b8(%rsp), %rdx
movq (%rdx), %rdi
movq (%rdi), %rax
movq 0x10(%rdi), %rcx
movq 0x8(%rcx), %rcx
movl 0x8(%rdx), %edx
leaq (%rcx,%rdx,8), %rsi
movq 0xd0(%rsp), %rdx
movq (%rax), %rax
callq *%rax
movss %xmm0, 0x5c(%rsp)
jmp 0xe591
movss 0x5c(%rsp), %xmm0
movss %xmm0, 0x148(%rsp)
movss 0x148(%rsp), %xmm0
cvtss2sd %xmm0, %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xe6b1
leaq 0x1a8(%rsp), %rdi
callq 0xb820
addq $0x8, %rax
movq %rax, 0x48(%rsp)
movq 0xd0(%rsp), %rax
movq (%rax), %rdi
leaq 0x148(%rsp), %rsi
callq 0x104d0
movq %rax, 0x50(%rsp)
jmp 0xe5ef
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rax
movq %rax, 0xc8(%rsp)
leaq 0xc8(%rsp), %rsi
callq 0x7910
movb %dl, 0x3f(%rsp)
movq %rax, 0x40(%rsp)
jmp 0xe619
movb 0x3f(%rsp), %al
movq 0x40(%rsp), %rcx
movq %rcx, 0xb8(%rsp)
movb %al, 0xc0(%rsp)
jmp 0xe6b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0xe7c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0xe7bb
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
callq 0x3220
jmp 0xe7bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x84a0
jmp 0xe7bb
jmp 0xe6b3
leaq 0xe0(%rsp), %rdi
callq 0x10500
jmp 0xe52c
leaq 0x22bfc(%rip), %rdi     # 0x312c8
callq 0x3380
movq 0x1b8(%rsp), %rdi
movq 0x10(%rdi), %rax
movq %rax, 0x28(%rsp)
addq $0x8, %rdi
leaq 0x140(%rsp), %rsi
callq 0x10570
movq %rdx, 0x30(%rsp)
movl %eax, 0x38(%rsp)
jmp 0xe6fe
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rax
movl 0x38(%rsp), %ecx
movl %ecx, 0xa8(%rsp)
movq %rax, 0xb0(%rsp)
leaq 0xa8(%rsp), %rsi
callq 0x10520
movb %dl, 0x1f(%rsp)
movq %rax, 0x20(%rsp)
jmp 0xe733
movb 0x1f(%rsp), %al
movq 0x20(%rsp), %rcx
movq %rcx, 0x98(%rsp)
movb %al, 0xa0(%rsp)
movq 0x1b8(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x10(%rsp)
leaq 0x170(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7a10
movq 0x8(%rsp), %rdi
movq %rax, 0x90(%rsp)
callq 0x7a40
movq 0x10(%rsp), %rdi
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %rdx
callq 0x105a0
jmp 0xe7a4
leaq 0x22b1d(%rip), %rdi     # 0x312c8
callq 0x31b0
xorl %eax, %eax
movl %eax, %edi
callq 0x3410
jmp 0xe7bb
leaq 0x158(%rsp), %rdi
callq 0x105e0
leaq 0x170(%rsp), %rdi
callq 0x79d0
movq 0x150(%rsp), %rdi
callq 0x3400
nopw %cs:(%rax,%rax)