// File: /workspace/github_cpp_makefile_star2_O2/parth-shel[P]xpac/client.cpp
// Function: calculate_indegrees()
void calculate_indegrees() {
	indegree_map.clear();
	//Adding all the installed packages to the map:
	for(auto itr = user_installed_list.begin(); itr!=user_installed_list.end(); itr++) {
		indegree_map.insert(std::make_pair(itr->first,0));
	}

	//Performing a breadth first search on the graph to see all reachable packages:
	std::queue<std::string> bfs_indegree_queue;
	std::unordered_set<std::string> indegree_visited;

	//Pushing the first element into the bfs_queue:
	bfs_indegree_queue.push("base");
	indegree_visited.insert("base");

	//Performing the bfs here:
	while(!bfs_indegree_queue.empty()){
		std::string next_pkg_name = bfs_indegree_queue.front();
		bfs_indegree_queue.pop();

		std::string next_pkg_filepath = metadata_dir + "/." + next_pkg_name + ".metadata";
		metadata * next_pkg = metadata::get_package(next_pkg_filepath);

		//Getting the dependency list of the next package:
		std::vector<std::string> * next_pkg_dep_list = next_pkg->get_dep_list();

		for(auto itr = next_pkg_dep_list->begin(); itr!=next_pkg_dep_list->end(); itr++) {
			
			//Updating indegree values in the map:
			auto indegree_find = indegree_map.find(*itr);
			if(indegree_find != indegree_map.end()) {
				if(next_pkg_name.compare("base") == 0) { //One degree depth
					indegree_find->second++;
				}
				else{
					indegree_find->second += 2;
				}
			}

			//Finding whether it has already been visited:
			auto found = indegree_visited.find(*itr);
			//If not found then:
			if(found == indegree_visited.end()) {
				indegree_visited.insert(*itr);
				bfs_indegree_queue.push(*itr);
			}
		}
	}

	//Testing calculating indegrees:
	/*for(auto itr=indegree_map.begin(); itr!=indegree_map.end(); itr++){
		std::cout<<"Node: "<<itr->first<<" "<<"Value: "<<itr->second<<std::endl;
	}*/
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
leaq 0xab12(%rip), %rbx      # 0xf540
movq %rbx, %rdi
callq 0x7970
leaq 0xab93(%rip), %r12      # 0xf5d0
movq 0x18(%r12), %r15
addq $0x8, %r12
leaq -0xb8(%rbp), %r14
cmpq %r12, %r15
je 0x4a85
leaq 0x20(%r15), %rsi
movq %r14, %rdi
callq 0x34a0
andl $0x0, -0x98(%rbp)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x79a8
movq %r14, %rdi
callq 0x36a8
movq %r15, %rdi
callq 0x32a0
movq %rax, %r15
jmp 0x4a4d
leaq -0xb8(%rbp), %rdi
callq 0x5eec
leaq -0xe0(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
leaq 0x55e7(%rip), %rsi      # 0xa0a4
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x3180
leaq -0xb8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x7262
leaq -0x48(%rbp), %rdi
callq 0x36a8
leaq 0x55ba(%rip), %rsi      # 0xa0a4
leaq -0x48(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x3180
leaq -0x110(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x6dfe
leaq -0x48(%rbp), %rdi
callq 0x36a8
leaq 0xaa29(%rip), %r15      # 0xf540
leaq -0x110(%rbp), %r12
movq -0xa8(%rbp), %rsi
cmpq %rsi, -0x88(%rbp)
je 0x4c5d
leaq -0x48(%rbp), %rdi
callq 0x34a0
leaq -0xb8(%rbp), %rdi
callq 0x7318
leaq -0xd8(%rbp), %rbx
movq %rbx, %rdi
leaq 0xa858(%rip), %rsi      # 0xf3b0
leaq 0x5542(%rip), %rdx      # 0xa0a1
callq 0x5e5c
leaq -0x150(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
leaq -0x48(%rbp), %rdx
callq 0x5f53
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x58ec(%rip), %rdx      # 0xa477
callq 0x5f2a
movq %r14, %rdi
callq 0x36a8
leaq -0xd8(%rbp), %rdi
callq 0x36a8
leaq -0x130(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x34a0
movq %r14, %rdi
callq 0x8728
movq %rax, %rbx
movq %r14, %rdi
callq 0x36a8
movq %rbx, %rdi
callq 0x856c
movq %rax, %r14
movq (%rax), %r13
cmpq 0x8(%r14), %r13
je 0x4c46
movq %r15, %rdi
movq %r13, %rsi
callq 0x7bb0
movq %rax, %rbx
leaq 0xa956(%rip), %rax      # 0xf548
cmpq %rax, %rbx
je 0x4c16
leaq -0x48(%rbp), %rdi
leaq 0x54a2(%rip), %rsi      # 0xa0a4
callq 0x3140
movl 0x40(%rbx), %ecx
cmpl $0x1, %eax
sbbl $0x0, %ecx
addl $0x2, %ecx
movl %ecx, 0x40(%rbx)
movq %r12, %rdi
movq %r13, %rsi
callq 0x7398
testq %rax, %rax
jne 0x4c40
movq %r12, %rdi
movq %r13, %rsi
callq 0x73c6
leaq -0xb8(%rbp), %rdi
movq %r13, %rsi
callq 0x640e
addq $0x20, %r13
jmp 0x4bd7
leaq -0x68(%rbp), %rdi
callq 0x36a8
leaq -0x48(%rbp), %rdi
callq 0x36a8
jmp 0x4b1e
leaq -0x110(%rbp), %rdi
callq 0x61c2
leaq -0xb8(%rbp), %rdi
callq 0x600e
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4c94
jmp 0x4c8f
jmp 0x4c94
jmp 0x4c8f
movq %rax, %rbx
jmp 0x4cf3
movq %rax, %rbx
jmp 0x4cea
movq %rax, %rbx
jmp 0x4cad
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x36a8
leaq -0xd8(%rbp), %rdi
jmp 0x4ce5
jmp 0x4cde
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
callq 0x36a8
jmp 0x4ce1
jmp 0x4cde
movq %rax, %rbx
leaq -0xb8(%rbp), %rdi
callq 0x36a8
jmp 0x4d0b
jmp 0x4cde
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x36a8
leaq -0x48(%rbp), %rdi
callq 0x36a8
leaq -0x110(%rbp), %rdi
callq 0x61c2
leaq -0xb8(%rbp), %rdi
callq 0x600e
movq %rbx, %rdi
callq 0x35c0