// File: /workspace/github_cpp_makefile_star2_O1/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 $0x138, %rsp            # imm = 0x138
leaq 0xaffd(%rip), %rdi      # 0x10530
callq 0x8e16
leaq 0xb081(%rip), %r12      # 0x105c0
movq 0x18(%r12), %rbx
addq $0x8, %r12
cmpq %r12, %rbx
je 0x55b2
leaq -0xf0(%rbp), %r13
leaq -0x100(%rbp), %r14
leaq 0xafce(%rip), %r15      # 0x10530
movq %r13, -0x100(%rbp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x8092
movl $0x0, -0xe0(%rbp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x8e4e
movq -0x100(%rbp), %rdi
cmpq %r13, %rdi
je 0x55a2
callq 0x3360
movq %rbx, %rdi
callq 0x3290
movq %rax, %rbx
cmpq %r12, %rax
jne 0x5562
xorps %xmm0, %xmm0
leaq -0x100(%rbp), %rdi
movaps %xmm0, 0x40(%rdi)
movaps %xmm0, 0x30(%rdi)
movaps %xmm0, 0x20(%rdi)
movaps %xmm0, 0x10(%rdi)
movaps %xmm0, (%rdi)
xorl %esi, %esi
callq 0x7bde
leaq -0x128(%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 -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x6a9a(%rip), %rsi      # 0xc0a4
leaq 0x6a97(%rip), %rdx      # 0xc0a8
leaq -0x48(%rbp), %rdi
callq 0x7f00
leaq -0x100(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x85e8
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x563c
callq 0x3360
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x6a56(%rip), %rsi      # 0xc0a4
leaq 0x6a53(%rip), %rdx      # 0xc0a8
callq 0x7f00
leaq -0x158(%rbp), %rbx
leaq -0x88(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x81ca
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5689
callq 0x3360
movq -0xf0(%rbp), %rax
cmpq %rax, -0xd0(%rbp)
je 0x58ea
leaq -0x110(%rbp), %r15
leaq 0xae85(%rip), %r12      # 0x10530
leaq -0x38(%rbp), %rcx
movq %rcx, -0x48(%rbp)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x48(%rbp), %rdi
callq 0x8092
leaq -0x100(%rbp), %rdi
callq 0x874a
leaq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0xacb9(%rip), %rsi      # 0x103a0
movq 0xacba(%rip), %rdx      # 0x103a8
addq %rsi, %rdx
leaq -0xa8(%rbp), %r14
movq %r14, %rdi
callq 0x8092
movq %r14, %rdi
leaq 0x6997(%rip), %rsi      # 0xc0a1
callq 0x3650
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq %r14, %rdi
callq 0x3140
leaq -0x58(%rbp), %rsi
movq %rsi, -0x68(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x5743
movq %rdx, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0x5749
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x60(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x68(%rbp), %rdi
leaq 0x6d0c(%rip), %rsi      # 0xc477
callq 0x3650
leaq -0x78(%rbp), %rsi
movq %rsi, -0x88(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x579a
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0x57a0
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x80(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x57c9
callq 0x3360
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x57e1
callq 0x3360
movq %r15, -0x120(%rbp)
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
addq %rsi, %rdx
leaq -0x120(%rbp), %r14
movq %r14, %rdi
callq 0x8092
movq %r14, %rdi
callq 0xa12e
movq %rax, %r14
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0x5821
callq 0x3360
movq %r14, %rdi
callq 0x9de8
movq %rax, %r13
movq (%rax), %r15
cmpq 0x8(%r13), %r15
je 0x58a8
movq %r12, %rdi
movq %r15, %rsi
callq 0x9048
movq %rax, %r14
leaq 0xacee(%rip), %rax      # 0x10538
cmpq %rax, %r14
je 0x5870
leaq -0x48(%rbp), %rdi
leaq 0x684a(%rip), %rsi      # 0xc0a4
callq 0x3130
movl 0x40(%r14), %ecx
cmpl $0x1, %eax
sbbl $0x0, %ecx
addl $0x2, %ecx
movl %ecx, 0x40(%r14)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x87e2
testq %rax, %rax
jne 0x58a2
movq %rbx, -0x68(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x68(%rbp), %rdx
callq 0x8826
leaq -0x100(%rbp), %rdi
movq %r15, %rsi
callq 0x7838
addq $0x20, %r15
jmp 0x582f
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x58bd
callq 0x3360
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
leaq -0x110(%rbp), %r15
je 0x58d6
callq 0x3360
movq -0xf0(%rbp), %rax
cmpq %rax, -0xd0(%rbp)
jne 0x56ab
leaq -0x158(%rbp), %rdi
callq 0x7664
leaq -0x100(%rbp), %rdi
callq 0x74ea
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5924
jmp 0x591c
jmp 0x5924
jmp 0x591c
movq %rax, %rbx
jmp 0x59b1
movq %rax, %rbx
jmp 0x599f
jmp 0x592b
movq %rax, %rbx
jmp 0x5945
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x5945
callq 0x3360
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
jmp 0x5995
jmp 0x5987
movq %rax, %rbx
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0x598a
callq 0x3360
jmp 0x598a
jmp 0x5987
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r13, %rdi
je 0x59c9
callq 0x3360
jmp 0x59c9
jmp 0x5987
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x599f
callq 0x3360
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x59b1
callq 0x3360
leaq -0x158(%rbp), %rdi
callq 0x7664
leaq -0x100(%rbp), %rdi
callq 0x74ea
movq %rbx, %rdi
callq 0x35c0