// File: 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
subq $0x410, %rsp            # imm = 0x410
leaq -0x18(%rbp), %rdi
callq 0x9360
leaq -0x228(%rbp), %rdi
callq 0x44b0
jmp 0x5362
leaq 0x19127(%rip), %rsi     # 0x1e490
leaq -0x228(%rbp), %rdi
movl $0x8, %edx
callq 0x4570
jmp 0x537c
leaq -0x258(%rbp), %rdi
callq 0x4580
leaq -0x228(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x40e0
movq %rax, -0x3b0(%rbp)
jmp 0x53a4
movq -0x3b0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x4500
movb %al, -0x3b1(%rbp)
jmp 0x53c2
movb -0x3b1(%rbp), %al
testb $0x1, %al
jne 0x53ce
jmp 0x5427
leaq -0x18(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x9510
jmp 0x53e0
jmp 0x5388
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x594a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x593e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x5932
leaq -0x18(%rbp), %rdi
callq 0x9740
cmpq $0x0, %rax
jne 0x5476
movq 0x18b93(%rip), %rdi     # 0x1dfd0
leaq 0xfc1d(%rip), %rsi      # 0x15061
callq 0x4400
movq %rax, -0x3c0(%rbp)
jmp 0x5452
movq -0x3c0(%rbp), %rdi
movq 0x18b58(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x5467
movl $0x1, -0x25c(%rbp)
jmp 0x5908
movq 0x18b53(%rip), %rdi     # 0x1dfd0
leaq 0xfbf3(%rip), %rsi      # 0x15077
callq 0x4400
movq %rax, -0x3c8(%rbp)
jmp 0x5492
movq -0x3c8(%rbp), %rdi
movq 0x18b18(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x54a7
leaq -0x18(%rbp), %rdi
callq 0x95e0
movq %rax, -0x268(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x9650
movq %rax, -0x270(%rbp)
leaq -0x268(%rbp), %rdi
leaq -0x270(%rbp), %rsi
callq 0x9610
testb $0x1, %al
jne 0x54e0
jmp 0x5532
leaq -0x268(%rbp), %rdi
callq 0x9680
movq %rax, %rsi
movq 0x18ada(%rip), %rdi     # 0x1dfd0
callq 0x43d0
movq %rax, -0x3d0(%rbp)
jmp 0x5504
movq -0x3d0(%rbp), %rdi
movq 0x18aa6(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x5519
jmp 0x551b
leaq -0x268(%rbp), %rdi
xorl %esi, %esi
callq 0x96a0
movq %rax, -0x278(%rbp)
jmp 0x54b7
jmp 0x5534
movq 0x18a95(%rip), %rdi     # 0x1dfd0
leaq 0xfb5e(%rip), %rsi      # 0x150a0
callq 0x4400
movq %rax, -0x3d8(%rbp)
jmp 0x5550
movq -0x3d8(%rbp), %rdi
movq 0x18a5a(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x5565
movq 0x18a74(%rip), %rdi     # 0x1dfe0
leaq -0x279(%rbp), %rsi
callq 0x4530
jmp 0x557a
jmp 0x557c
movsbl -0x279(%rbp), %ecx
xorl %eax, %eax
cmpl $0x59, %ecx
movb %al, -0x3d9(%rbp)
je 0x55cb
movsbl -0x279(%rbp), %ecx
xorl %eax, %eax
cmpl $0x6e, %ecx
movb %al, -0x3d9(%rbp)
je 0x55cb
movsbl -0x279(%rbp), %ecx
xorl %eax, %eax
cmpl $0x4e, %ecx
movb %al, -0x3d9(%rbp)
je 0x55cb
movsbl -0x279(%rbp), %eax
cmpl $0x79, %eax
setne %al
movb %al, -0x3d9(%rbp)
movb -0x3d9(%rbp), %al
testb $0x1, %al
jne 0x5534
movsbl -0x279(%rbp), %eax
cmpl $0x6e, %eax
je 0x55f1
movsbl -0x279(%rbp), %eax
cmpl $0x4e, %eax
jne 0x55f8
xorl %edi, %edi
callq 0x44c0
leaq -0x18(%rbp), %rdi
callq 0x95e0
movq %rax, -0x288(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x9650
movq %rax, -0x290(%rbp)
leaq -0x288(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x9610
testb $0x1, %al
jne 0x5634
jmp 0x58fc
leaq -0x288(%rbp), %rdi
callq 0x9680
movq %rax, %rsi
leaq 0x19026(%rip), %rdi     # 0x1e670
callq 0x9440
movq %rax, -0x3e8(%rbp)
jmp 0x5658
movq -0x3e8(%rbp), %rax
movq %rax, -0x298(%rbp)
movq -0x298(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rsi
leaq 0x18fee(%rip), %rdi     # 0x1e670
callq 0x9760
movq %rax, -0x3f0(%rbp)
jmp 0x5690
movq -0x3f0(%rbp), %rax
movq %rax, -0x2a8(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x9680
movq %rax, %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x5960
jmp 0x56bc
leaq 0x18d8d(%rip), %rsi     # 0x1e450
leaq 0xf9eb(%rip), %rdx      # 0x150b5
leaq -0x308(%rbp), %rdi
callq 0x9170
jmp 0x56d8
leaq -0x288(%rbp), %rdi
callq 0x9680
movq %rax, %rdx
leaq -0x2e8(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x94c0
jmp 0x56fc
leaq 0xfd88(%rip), %rdx      # 0x1548b
leaq -0x2c8(%rbp), %rdi
leaq -0x2e8(%rbp), %rsi
callq 0x9470
jmp 0x5718
leaq -0x2e8(%rbp), %rdi
callq 0x47e8
leaq -0x308(%rbp), %rdi
callq 0x47e8
leaq -0x330(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x41d0
jmp 0x5745
leaq -0x330(%rbp), %rdi
callq 0x11b80
movq %rax, -0x3f8(%rbp)
jmp 0x575a
leaq -0x330(%rbp), %rdi
callq 0x47e8
movq -0x3f8(%rbp), %rax
movq %rax, -0x310(%rbp)
leaq -0x288(%rbp), %rdi
callq 0x9680
movq %rax, -0x400(%rbp)
movq -0x310(%rbp), %rsi
leaq -0x390(%rbp), %rdi
callq 0x9820
jmp 0x579c
movq -0x400(%rbp), %rsi
leaq -0x370(%rbp), %rdi
leaq -0x390(%rbp), %rdx
callq 0x97e0
jmp 0x57b8
leaq 0x18eb1(%rip), %rdi     # 0x1e670
leaq -0x370(%rbp), %rsi
callq 0x97a0
movb %dl, -0x409(%rbp)
movq %rax, -0x408(%rbp)
jmp 0x57da
movb -0x409(%rbp), %al
movq -0x408(%rbp), %rcx
movq %rcx, -0x3a0(%rbp)
movb %al, -0x398(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x9850
leaq -0x390(%rbp), %rdi
callq 0x47e8
callq 0x12aa0
jmp 0x5813
leaq -0x2c8(%rbp), %rdi
callq 0x47e8
leaq -0x288(%rbp), %rdi
xorl %esi, %esi
callq 0x96a0
movq %rax, -0x3a8(%rbp)
jmp 0x5608
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x586b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x47e8
leaq -0x308(%rbp), %rdi
callq 0x47e8
jmp 0x5932
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x58ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x330(%rbp), %rdi
callq 0x47e8
jmp 0x58ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
jmp 0x58e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x230(%rbp)
movl %eax, -0x234(%rbp)
leaq -0x370(%rbp), %rdi
callq 0x9850
leaq -0x390(%rbp), %rdi
callq 0x47e8
leaq -0x2c8(%rbp), %rdi
callq 0x47e8
jmp 0x5932
jmp 0x58fe
movl $0x0, -0x25c(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x47e8
leaq -0x228(%rbp), %rdi
callq 0x4110
leaq -0x18(%rbp), %rdi
callq 0x96e0
addq $0x410, %rsp            # imm = 0x410
popq %rbp
retq
leaq -0x258(%rbp), %rdi
callq 0x47e8
leaq -0x228(%rbp), %rdi
callq 0x4110
leaq -0x18(%rbp), %rdi
callq 0x96e0
movq -0x230(%rbp), %rdi
callq 0x46d0
nop