// File: /workspace/github_cpp_makefile_star2_O2/parth-shel[P]xpac/client.cpp
// Function: upgrade_all_packages()
void upgrade_all_packages() {
	std::vector<std::string> updates;

	std::fstream file;
	file.open(update_file, std::ios::in);

	std::string next_line;
	while(getline(file,next_line)) {
		updates.push_back(next_line);
	}

	if(updates.size() == 0)	{
		std::cout<<"No updates available!"<<std::endl;
		return;
	}

	std::cout<<"The following packages will be updated: "<<std::endl;
	for(auto itr = updates.begin(); itr!=updates.end(); itr++){
		std::cout<<*itr<<std::endl;
	}
	char confirm;
	do {
		std::cout<<"Do you confirm?[Y/n]"<<std::endl;
		std::cin>>confirm;
	} while(confirm != 'Y' && confirm != 'n' && confirm != 'N' && confirm != 'y');

	if(confirm == 'n' || confirm == 'N') {
		exit(0);
	}
	else { //Updating all packages:
		for(auto itr = updates.begin(); itr!=updates.end(); itr++) {
			auto find_itr = user_installed_list.find(*itr);
			user_installed_list.erase(find_itr);
			install_package((*itr).c_str());
			std::string next_pkg_filepath = metadata_dir + "/." + *itr + ".metadata";
			metadata * new_pkg = metadata::get_package(next_pkg_filepath);
			//Adding the package back to the user installed list:
			user_installed_list.insert(std::make_pair(*itr,new_pkg->get_pkg_ver()));
			//Rewriting the user installed packages list:
			rewrite_installed_packages();
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2f8, %rsp            # imm = 0x2F8
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
leaq -0x320(%rbp), %rdi
callq 0x3400
leaq 0xb4eb(%rip), %rsi      # 0xf3f0
leaq -0x320(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x3490
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x320(%rbp), %rbx
leaq -0x70(%rbp), %r14
leaq -0x50(%rbp), %r15
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x3f59
movq %r15, %rdi
movq %r14, %rsi
callq 0x5f7c
jmp 0x3f33
movq -0x48(%rbp), %rax
cmpq -0x50(%rbp), %rax
je 0x4113
movq 0xb062(%rip), %rdi      # 0xefd0
leaq 0x60ee(%rip), %rsi      # 0xa063
callq 0x3370
movq %rax, %rdi
callq 0x31f0
movq -0x50(%rbp), %rbx
movq 0xb043(%rip), %r14      # 0xefd0
cmpq -0x48(%rbp), %rbx
je 0x3fac
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3340
movq %rax, %rdi
callq 0x31f0
addq $0x20, %rbx
jmp 0x3f8d
movq 0xb01d(%rip), %rbx      # 0xefd0
leaq 0x60d2(%rip), %r14      # 0xa08c
movq 0xb01f(%rip), %r15      # 0xefe0
leaq -0x29(%rbp), %r12
movabsq $0x80100000801, %r13    # imm = 0x80100000801
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3370
movq %rax, %rdi
callq 0x31f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x3460
movzbl -0x29(%rbp), %eax
leal -0x4e(%rax), %ecx
cmpl $0x2b, %ecx
ja 0x3fcf
btq %rcx, %r13
jae 0x3fcf
andb $0x5f, %al
cmpb $0x4e, %al
je 0x415e
movq -0x50(%rbp), %rbx
leaq -0x90(%rbp), %r13
leaq -0x110(%rbp), %r15
leaq -0xd0(%rbp), %r14
cmpq -0x48(%rbp), %rbx
je 0x412e
leaq 0xb59d(%rip), %rdi      # 0xf5d0
movq %rbx, %rsi
callq 0x6d4a
leaq 0xb58e(%rip), %rdi      # 0xf5d0
movq %rax, %rsi
callq 0x76ba
movq (%rbx), %rdi
callq 0x4203
movq %r13, %rdi
leaq 0xb354(%rip), %rsi      # 0xf3b0
leaq 0x603e(%rip), %rdx      # 0xa0a1
callq 0x5e5c
movq %r15, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x5f53
leaq -0xb0(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
leaq 0x63ed(%rip), %rdx      # 0xa477
callq 0x5f2a
movq %r15, %rdi
callq 0x36a8
movq %r13, %rdi
callq 0x36a8
movq %r14, %rdi
movq %r12, %rsi
callq 0x34a0
movq %r14, %rdi
callq 0x8728
movq %rax, %r12
movq %r14, %rdi
callq 0x36a8
addq $0x40, %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x34a0
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x6cb6
leaq 0xb4ef(%rip), %rdi      # 0xf5d0
movq %r15, %rsi
callq 0x775c
movq %r15, %rdi
callq 0x5fe4
movq %r13, %rdi
callq 0x36a8
callq 0x8f5c
leaq -0xb0(%rbp), %rdi
callq 0x36a8
addq $0x20, %rbx
jmp 0x4022
movq 0xaeb6(%rip), %rdi      # 0xefd0
leaq 0x5f2c(%rip), %rsi      # 0xa04d
callq 0x3370
movq %rax, %rdi
callq 0x31f0
leaq -0x70(%rbp), %rdi
callq 0x36a8
leaq -0x320(%rbp), %rdi
callq 0x30d0
leaq -0x50(%rbp), %rdi
callq 0x5fb8
addq $0x2f8, %rsp            # imm = 0x2F8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x3410
movq %rax, %rbx
jmp 0x41e6
movq %rax, %rbx
jmp 0x41f2
jmp 0x41da
jmp 0x41da
movq %rax, %rbx
jmp 0x418a
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x5fe4
leaq -0x90(%rbp), %rdi
jmp 0x41bc
jmp 0x41da
movq %rax, %rbx
jmp 0x41a9
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x36a8
leaq -0x90(%rbp), %rdi
jmp 0x41cf
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
callq 0x36a8
jmp 0x41c8
jmp 0x41c5
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x36a8
jmp 0x41dd
jmp 0x41da
jmp 0x41da
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x36a8
leaq -0x320(%rbp), %rdi
callq 0x30d0
leaq -0x50(%rbp), %rdi
callq 0x5fb8
movq %rbx, %rdi
callq 0x35c0