// File: /workspace/github_cpp_makefile_star2_O3/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 0x65b0
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0xea3c
leaq -0x1090(%rbp), %rdi
movl $0x1000, %esi           # imm = 0x1000
callq 0x31e0
testq %rax, %rax
jne 0x5ce8
movq 0xf323(%rip), %r14      # 0x14fd0
leaq 0xa422(%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 0x630e
leaq 0xa6cb(%rip), %rsi      # 0x103f3
movq %r15, %rdi
callq 0x35c0
movq 0x40(%rbx), %rdi
xorl %esi, %esi
callq 0xec2e
movq %rax, %r15
movl (%rax), %eax
cmpl $0x7, %eax
je 0x5dd8
cmpl $0x3, %eax
jne 0x5e1e
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 0x630e
leaq -0x78(%rbp), %r15
movq %r15, -0x10(%r15)
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %rdi
callq 0x6270
leaq -0x48(%rbp), %rdx
leaq -0x88(%rbp), %rcx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x68ce
movq -0x88(%rbp), %rdi
cmpq %r15, %rdi
je 0x5dc4
callq 0x3320
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5e1e
callq 0x3320
jmp 0x5e1e
movq 0xf1f1(%rip), %rbx      # 0x14fd0
leaq 0xa316(%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 0xf1bf(%rip), %rdi      # 0x14fd0
callq 0x3040
movq %rax, %rdi
callq 0x3260
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x5e2c
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 0x5e57
callq 0x3320
jmp 0x5e57
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x5e72
callq 0x3320
jmp 0x5e72
jmp 0x5e6f
jmp 0x5e6f
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x5e80
callq 0x3320
movq %rbx, %rdi
callq 0x3580