// File: /workspace/github_cpp_makefile_star2_O1/vianna274[P]dropbox/src/Client.cpp
// Function: Dropbox::Client::download(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Client::download(string filename){
	MessageData request = make_packet(TYPE_REQUEST_DOWNLOAD, 1 , 1, -1, filename.c_str());
	this->socket->send(&request);

	char cCurrentPath[FILENAME_MAX];
	if (!getcwd(cCurrentPath, sizeof(cCurrentPath))) 
		cout << "ERROR GETTING THE CURRENT DIRECTORY!!" << endl;
	cCurrentPath[sizeof(cCurrentPath) - 1] = '\0';
	string currentPath(cCurrentPath);
	currentPath += "/";

	MessageData *data = this->socket->receive(TIMEOUT_OFF);
	if(data->type == TYPE_SEND_FILE) {
		FileRecord * fileRecord = (FileRecord *)(data->payload);
		this->receiveFile(this->socket, string(fileRecord->filename), currentPath);
	}
	else if(data->type == TYPE_NOTHING_TO_SEND)
		cout << "File does not exist." << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2048, %rsp           # imm = 0x2048
movq %rdi, %rbx
movq (%rsi), %r9
leaq -0x2064(%rbp), %r14
movq %r14, %rdi
movl $0x8, %esi
movl $0x1, %edx
movl $0x1, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x657c
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0xeae4
leaq -0x1090(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x31e0
testq %rax, %rax
jne 0x5cac
movq 0xf35f(%rip), %r14      # 0x14fd0
leaq 0xa45e(%rip), %rsi      # 0x100d6
movl $0x25, %edx
movq %r14, %rdi
callq 0x33a0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x3330
movsbl %al, %esi
movq %r14, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3260
leaq -0x1090(%rbp), %r14
movb $0x0, 0xfff(%r14)
leaq -0x58(%rbp), %r13
movq %r13, -0x10(%r13)
movq %r14, %rdi
callq 0x3170
leaq (%rax,%rbp), %rdx
addq $-0x1090, %rdx          # imm = 0xEF70
leaq -0x68(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x62de
leaq 0xa707(%rip), %rsi      # 0x103f3
movq %r15, %rdi
callq 0x35c0
movq 0x40(%rbx), %rdi
xorl %esi, %esi
callq 0xed22
movq %rax, %r15
movl (%rax), %eax
cmpl $0x7, %eax
je 0x5d9c
cmpl $0x3, %eax
jne 0x5de2
leaq 0x14(%r15), %r12
movq 0x40(%rbx), %r14
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq %r12, %rdi
callq 0x3170
leaq (%r15,%rax), %rdx
addq $0x14, %rdx
leaq -0x48(%rbp), %rdi
movq %r12, %rsi
callq 0x62de
leaq -0x78(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x6244
leaq -0x48(%rbp), %rdx
leaq -0x88(%rbp), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x689a
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x5d88
callq 0x3320
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5de2
callq 0x3320
jmp 0x5de2
movq 0xf22d(%rip), %rbx      # 0x14fd0
leaq 0xa352(%rip), %rsi      # 0x100fc
movl $0x14, %edx
movq %rbx, %rdi
callq 0x33a0
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x3330
movsbl %al, %esi
movq 0xf1fb(%rip), %rdi      # 0x14fd0
callq 0x3040
movq %rax, %rdi
callq 0x3260
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x5df0
callq 0x3320
addq $0x2048, %rsp           # imm = 0x2048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x5e1b
callq 0x3320
jmp 0x5e1b
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5e36
callq 0x3320
jmp 0x5e36
jmp 0x5e33
jmp 0x5e33
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x5e44
callq 0x3320
movq %rbx, %rdi
callq 0x3580