// File: parth-shel[P]xpac/client.cpp
// Function: install_all_packages()
static bool install_all_packages(){

	std::stack<std::string> display_stack(dep_list);

	std::cout<<"The following packages will be installed: "<<std::endl;
	while(!display_stack.empty()){
		std::string next_pkg = display_stack.top();
		std::cout<<next_pkg.substr(0,next_pkg.find("/"))<<std::endl;
		display_stack.pop();
	}

	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);
	}

	while(!dep_list.empty()){
		std::string to_install = dep_list.top();
		std::string to_display = to_install.substr(0,to_install.find("/"));
		curr = metadata::get_package(to_display + "/.metadata");
		std::string curr_version = curr->get_pkg_ver();
		dep_list.pop();
		std::cout<<"Installing package: "<<to_display<<std::endl;
		if(user_installed_list.find(to_display) != user_installed_list.end()) {
			std::cout<<"Already installed "<<to_display<<"!"<<std::endl;
			cleanup_directory(to_display);
			if(dep_list.empty())	exit(1);
		} else {
			int rem = system(to_install.c_str());
			if(rem != 0){
				std::cout<<"Unable to install "<<to_display<<"!!"<<std::endl;
				std::cout<<"Please rectify the errors and try again!"<<std::endl;
				//Emptying the stack:
				while(!dep_list.empty()) {
					std::string to_install = dep_list.top();
					cleanup_directory(to_display);
					dep_list.pop();
				}
				exit(1);
			} else { //Successfully installed
				metadata::write_package(curr, metadata_dir.c_str());
				add_to_install_list(to_display, curr_version); //Adding to the list of successfully installed packages
				cleanup_directory(to_display);
			}
		}
	}

	//Successfully installed all of them:
	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
leaq 0x16246(%rip), %rsi     # 0x1e508
leaq -0x50(%rbp), %rdi
callq 0xc070
movq 0x15cfe(%rip), %rdi     # 0x1dfd0
leaq 0xd207(%rip), %rsi      # 0x154e0
callq 0x4400
movq %rax, -0x230(%rbp)
jmp 0x82e7
movq -0x230(%rbp), %rdi
movq 0x15cc3(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x82fc
jmp 0x82fe
leaq -0x50(%rbp), %rdi
callq 0xc0a0
movb %al, -0x231(%rbp)
jmp 0x830f
movb -0x231(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x8320
jmp 0x8420
leaq -0x50(%rbp), %rdi
callq 0xc0c0
movq %rax, -0x240(%rbp)
jmp 0x8332
movq -0x240(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0x41d0
jmp 0x8344
leaq 0xccd3(%rip), %rsi      # 0x1501e
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x248(%rbp)
leaq -0x80(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x47c0
movq -0x250(%rbp), %rsi
movq -0x248(%rbp), %rdx
movq %rax, %rcx
leaq -0xa0(%rbp), %rdi
callq 0x4420
jmp 0x8385
movq 0x15c44(%rip), %rdi     # 0x1dfd0
leaq -0xa0(%rbp), %rsi
callq 0x43d0
movq %rax, -0x258(%rbp)
jmp 0x83a1
movq -0x258(%rbp), %rdi
movq 0x15c09(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x83b6
leaq -0xa0(%rbp), %rdi
callq 0x47e8
leaq -0x50(%rbp), %rdi
callq 0xc0e0
jmp 0x83cd
leaq -0x80(%rbp), %rdi
callq 0x47e8
jmp 0x82fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8b63
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8412
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x47e8
leaq -0x80(%rbp), %rdi
callq 0x47e8
jmp 0x8b63
jmp 0x8422
movq 0x15ba7(%rip), %rdi     # 0x1dfd0
leaq 0xcc70(%rip), %rsi      # 0x150a0
callq 0x4400
movq %rax, -0x260(%rbp)
jmp 0x843e
movq -0x260(%rbp), %rdi
movq 0x15b6c(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x8453
movq 0x15b86(%rip), %rdi     # 0x1dfe0
leaq -0xa1(%rbp), %rsi
callq 0x4530
jmp 0x8468
jmp 0x846a
movsbl -0xa1(%rbp), %ecx
xorl %eax, %eax
cmpl $0x59, %ecx
movb %al, -0x261(%rbp)
je 0x84b9
movsbl -0xa1(%rbp), %ecx
xorl %eax, %eax
cmpl $0x6e, %ecx
movb %al, -0x261(%rbp)
je 0x84b9
movsbl -0xa1(%rbp), %ecx
xorl %eax, %eax
cmpl $0x4e, %ecx
movb %al, -0x261(%rbp)
je 0x84b9
movsbl -0xa1(%rbp), %eax
cmpl $0x79, %eax
setne %al
movb %al, -0x261(%rbp)
movb -0x261(%rbp), %al
testb $0x1, %al
jne 0x8422
movsbl -0xa1(%rbp), %eax
cmpl $0x6e, %eax
je 0x84df
movsbl -0xa1(%rbp), %eax
cmpl $0x4e, %eax
jne 0x84e6
xorl %edi, %edi
callq 0x44c0
jmp 0x84e8
leaq 0x16019(%rip), %rdi     # 0x1e508
callq 0xc0a0
movb %al, -0x262(%rbp)
jmp 0x84fc
movb -0x262(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x850d
jmp 0x8b4d
leaq 0x15ff4(%rip), %rdi     # 0x1e508
callq 0xc0c0
movq %rax, -0x270(%rbp)
jmp 0x8522
movq -0x270(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
callq 0x41d0
jmp 0x8537
leaq 0xcae0(%rip), %rsi      # 0x1501e
xorl %eax, %eax
movl %eax, %edx
movq %rdx, -0x278(%rbp)
leaq -0xc8(%rbp), %rdi
movq %rdi, -0x280(%rbp)
callq 0x47c0
movq -0x280(%rbp), %rsi
movq -0x278(%rbp), %rdx
movq %rax, %rcx
leaq -0xe8(%rbp), %rdi
callq 0x4420
jmp 0x857b
leaq 0xcf08(%rip), %rdx      # 0x1548a
leaq -0x108(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x9170
jmp 0x8597
leaq -0x108(%rbp), %rdi
callq 0x11b80
movq %rax, -0x288(%rbp)
jmp 0x85ac
movq -0x288(%rbp), %rax
movq %rax, 0x15f06(%rip)     # 0x1e4c0
leaq -0x108(%rbp), %rdi
callq 0x47e8
movq 0x15ef3(%rip), %rsi     # 0x1e4c0
leaq -0x128(%rbp), %rdi
callq 0x9820
jmp 0x85db
leaq 0x15f26(%rip), %rdi     # 0x1e508
callq 0xc0e0
jmp 0x85e9
movq 0x159e0(%rip), %rdi     # 0x1dfd0
leaq 0xcf14(%rip), %rsi      # 0x1550b
callq 0x4400
movq %rax, -0x290(%rbp)
jmp 0x8605
movq -0x290(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x43d0
movq %rax, -0x298(%rbp)
jmp 0x8621
movq -0x298(%rbp), %rdi
movq 0x15989(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x8636
leaq 0x16033(%rip), %rdi     # 0x1e670
leaq -0xe8(%rbp), %rsi
callq 0x9440
movq %rax, -0x2a0(%rbp)
jmp 0x8652
movq -0x2a0(%rbp), %rax
movq %rax, -0x130(%rbp)
leaq 0x16009(%rip), %rdi     # 0x1e670
callq 0x93e0
movq %rax, -0x138(%rbp)
leaq -0x130(%rbp), %rdi
leaq -0x138(%rbp), %rsi
callq 0x93b0
testb $0x1, %al
jne 0x868f
jmp 0x87c3
movq 0x1593a(%rip), %rdi     # 0x1dfd0
leaq 0xcb11(%rip), %rsi      # 0x151ae
callq 0x4400
movq %rax, -0x2a8(%rbp)
jmp 0x86ab
movq -0x2a8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x43d0
movq %rax, -0x2b0(%rbp)
jmp 0x86c7
movq -0x2b0(%rbp), %rdi
leaq 0xcd9a(%rip), %rsi      # 0x1546f
callq 0x4400
movq %rax, -0x2b8(%rbp)
jmp 0x86e3
movq -0x2b8(%rbp), %rdi
movq 0x158c7(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x86f8
leaq -0x158(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x41d0
jmp 0x870d
leaq -0x158(%rbp), %rdi
callq 0x12c30
jmp 0x871b
leaq -0x158(%rbp), %rdi
callq 0x47e8
leaq 0x15dda(%rip), %rdi     # 0x1e508
callq 0xc0a0
movb %al, -0x2b9(%rbp)
jmp 0x873b
movb -0x2b9(%rbp), %al
testb $0x1, %al
jne 0x8747
jmp 0x87be
movl $0x1, %edi
callq 0x44c0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8b3f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8b33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x47e8
jmp 0x8b33
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8b27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x47e8
jmp 0x8b27
jmp 0x8afe
leaq -0xc8(%rbp), %rdi
callq 0x41c0
movq %rax, %rdi
callq 0x43a0
movl %eax, -0x2c0(%rbp)
jmp 0x87df
movl -0x2c0(%rbp), %eax
movl %eax, -0x15c(%rbp)
cmpl $0x0, -0x15c(%rbp)
je 0x8972
movq 0x157d1(%rip), %rdi     # 0x1dfd0
leaq 0xcd1a(%rip), %rsi      # 0x15520
callq 0x4400
movq %rax, -0x2c8(%rbp)
jmp 0x8814
movq -0x2c8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x43d0
movq %rax, -0x2d0(%rbp)
jmp 0x8830
movq -0x2d0(%rbp), %rdi
leaq 0xcc30(%rip), %rsi      # 0x1546e
callq 0x4400
movq %rax, -0x2d8(%rbp)
jmp 0x884c
movq -0x2d8(%rbp), %rdi
movq 0x1575e(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x8861
movq 0x15768(%rip), %rdi     # 0x1dfd0
leaq 0xccc4(%rip), %rsi      # 0x15533
callq 0x4400
movq %rax, -0x2e0(%rbp)
jmp 0x887d
movq -0x2e0(%rbp), %rdi
movq 0x1572d(%rip), %rsi     # 0x1dfb8
callq 0x4440
jmp 0x8892
jmp 0x8894
leaq 0x15c6d(%rip), %rdi     # 0x1e508
callq 0xc0a0
movb %al, -0x2e1(%rbp)
jmp 0x88a8
movb -0x2e1(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x88b9
jmp 0x8968
leaq 0x15c48(%rip), %rdi     # 0x1e508
callq 0xc0c0
movq %rax, -0x2f0(%rbp)
jmp 0x88ce
movq -0x2f0(%rbp), %rsi
leaq -0x180(%rbp), %rdi
callq 0x41d0
jmp 0x88e3
leaq -0x1a0(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x41d0
jmp 0x88f8
leaq -0x1a0(%rbp), %rdi
callq 0x12c30
jmp 0x8906
leaq -0x1a0(%rbp), %rdi
callq 0x47e8
leaq 0x15bef(%rip), %rdi     # 0x1e508
callq 0xc0e0
jmp 0x8920
leaq -0x180(%rbp), %rdi
callq 0x47e8
jmp 0x8894
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8957
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x47e8
leaq -0x180(%rbp), %rdi
callq 0x47e8
jmp 0x8b27
movl $0x1, %edi
callq 0x44c0
movq 0x15b47(%rip), %rax     # 0x1e4c0
movq %rax, -0x308(%rbp)
leaq 0x15ac9(%rip), %rdi     # 0x1e450
callq 0x41c0
movq %rax, -0x300(%rbp)
leaq -0x1c1(%rbp), %rdi
movq %rdi, -0x2f8(%rbp)
callq 0x46e0
movq -0x300(%rbp), %rsi
movq -0x2f8(%rbp), %rdx
leaq -0x1c0(%rbp), %rdi
callq 0x4560
jmp 0x89c2
movq -0x308(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x11830
jmp 0x89d7
leaq -0x1c0(%rbp), %rdi
callq 0x47e8
leaq -0x1c1(%rbp), %rdi
callq 0x4460
leaq -0x1e8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x41d0
jmp 0x8a04
leaq -0x208(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x41d0
jmp 0x8a19
leaq -0x1e8(%rbp), %rdi
leaq -0x208(%rbp), %rsi
callq 0x12980
jmp 0x8a2e
leaq -0x208(%rbp), %rdi
callq 0x47e8
leaq -0x1e8(%rbp), %rdi
callq 0x47e8
leaq -0x228(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x41d0
jmp 0x8a5b
leaq -0x228(%rbp), %rdi
callq 0x12c30
jmp 0x8a69
leaq -0x228(%rbp), %rdi
callq 0x47e8
jmp 0x8afc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8aa0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x47e8
leaq -0x1c1(%rbp), %rdi
callq 0x4460
jmp 0x8b27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x8ad4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x47e8
leaq -0x1e8(%rbp), %rdi
callq 0x47e8
jmp 0x8b27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x47e8
jmp 0x8b27
jmp 0x8afe
leaq -0x128(%rbp), %rdi
callq 0x47e8
leaq -0xe8(%rbp), %rdi
callq 0x47e8
leaq -0xc8(%rbp), %rdi
callq 0x47e8
jmp 0x84e8
leaq -0x128(%rbp), %rdi
callq 0x47e8
leaq -0xe8(%rbp), %rdi
callq 0x47e8
leaq -0xc8(%rbp), %rdi
callq 0x47e8
jmp 0x8b63
leaq -0x50(%rbp), %rdi
callq 0x9270
movb $0x1, %al
andb $0x1, %al
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x50(%rbp), %rdi
callq 0x9270
movq -0x58(%rbp), %rdi
callq 0x46d0
nopw %cs:(%rax,%rax)