// File: /workspace/github_cpp_makefile_star2_O3/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 0xb000(%rip), %rdi      # 0x10530
callq 0x8dec
leaq 0xb084(%rip), %r12      # 0x105c0
movq 0x18(%r12), %rbx
addq $0x8, %r12
cmpq %r12, %rbx
je 0x55af
leaq -0xf0(%rbp), %r13
leaq -0x100(%rbp), %r14
leaq 0xafd1(%rip), %r15      # 0x10530
movq %r13, -0x100(%rbp)
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
addq %rsi, %rdx
movq %r14, %rdi
callq 0x80a2
movl $0x0, -0xe0(%rbp)
movq %r15, %rdi
movq %r14, %rsi
callq 0x8e24
movq -0x100(%rbp), %rdi
cmpq %r13, %rdi
je 0x559f
callq 0x3360
movq %rbx, %rdi
callq 0x3290
movq %rax, %rbx
cmpq %r12, %rax
jne 0x555f
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 0x7bee
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 0x6a9d(%rip), %rsi      # 0xc0a4
leaq 0x6a9a(%rip), %rdx      # 0xc0a8
leaq -0x48(%rbp), %rdi
callq 0x7f0c
leaq -0x100(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x85f8
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5639
callq 0x3360
leaq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
movq %rax, (%rdi)
leaq 0x6a59(%rip), %rsi      # 0xc0a4
leaq 0x6a56(%rip), %rdx      # 0xc0a8
callq 0x7f0c
leaq -0x158(%rbp), %rbx
leaq -0x88(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x48(%rbp), %rsi
movq %rbx, %rdi
callq 0x81de
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5686
callq 0x3360
movq -0xf0(%rbp), %rax
cmpq %rax, -0xd0(%rbp)
je 0x58e7
leaq -0x110(%rbp), %r15
leaq 0xae88(%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 0x80a2
leaq -0x100(%rbp), %rdi
callq 0x875a
leaq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq 0xacbc(%rip), %rsi      # 0x103a0
movq 0xacbd(%rip), %rdx      # 0x103a8
addq %rsi, %rdx
leaq -0xa8(%rbp), %r14
movq %r14, %rdi
callq 0x80a2
movq %r14, %rdi
leaq 0x699a(%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 0x5740
movq %rdx, -0x68(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x58(%rbp)
jmp 0x5746
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 0x6d0f(%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 0x5797
movq %rdx, -0x88(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x78(%rbp)
jmp 0x579d
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 0x57c6
callq 0x3360
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x57de
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 0x80a2
movq %r14, %rdi
callq 0xa11c
movq %rax, %r14
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0x581e
callq 0x3360
movq %r14, %rdi
callq 0x9dd8
movq %rax, %r13
movq (%rax), %r15
cmpq 0x8(%r13), %r15
je 0x58a5
movq %r12, %rdi
movq %r15, %rsi
callq 0x9014
movq %rax, %r14
leaq 0xacf1(%rip), %rax      # 0x10538
cmpq %rax, %r14
je 0x586d
leaq -0x48(%rbp), %rdi
leaq 0x684d(%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 0x87f8
testq %rax, %rax
jne 0x589f
movq %rbx, -0x68(%rbp)
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x68(%rbp), %rdx
callq 0x883c
leaq -0x100(%rbp), %rdi
movq %r15, %rsi
callq 0x7848
addq $0x20, %r15
jmp 0x582c
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x58ba
callq 0x3360
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
leaq -0x110(%rbp), %r15
je 0x58d3
callq 0x3360
movq -0xf0(%rbp), %rax
cmpq %rax, -0xd0(%rbp)
jne 0x56a8
leaq -0x158(%rbp), %rdi
callq 0x7674
leaq -0x100(%rbp), %rdi
callq 0x74e8
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5921
jmp 0x5919
jmp 0x5921
jmp 0x5919
movq %rax, %rbx
jmp 0x59ae
movq %rax, %rbx
jmp 0x599c
jmp 0x5928
movq %rax, %rbx
jmp 0x5942
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x5942
callq 0x3360
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
jmp 0x5992
jmp 0x5984
movq %rax, %rbx
movq -0x120(%rbp), %rdi
cmpq %r15, %rdi
je 0x5987
callq 0x3360
jmp 0x5987
jmp 0x5984
movq %rax, %rbx
movq -0x100(%rbp), %rdi
cmpq %r13, %rdi
je 0x59c6
callq 0x3360
jmp 0x59c6
jmp 0x5984
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x599c
callq 0x3360
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x59ae
callq 0x3360
leaq -0x158(%rbp), %rdi
callq 0x7674
leaq -0x100(%rbp), %rdi
callq 0x74e8
movq %rbx, %rdi
callq 0x35c0