// File: /workspace/github_cpp_makefile_star2_O2/vianna274[P]dropbox/src/Client.cpp
// Function: Dropbox::Client::askUpdate()
void Client::askUpdate() {
	MessageData request = make_packet(TYPE_REQUEST_UPDATE, 1 , 1, -1, "type_request_update", this->username.c_str());
	socketMtx.lock();
	bool ass = this->socket->send(&request);
	socketMtx.unlock();
	if (ass == -1) {
		socketMtx.lock();
		this->socket = new WrapperSocket(this->payload1, this->payload2);
		socketMtx.unlock();
		ass = this->socket->send(&request);
	}
	else if (ass == 0)
		return;
	this->sendFileList(this->socket, this->fileRecords);
	while(1) {
		socketMtx.lock();
		MessageData * response = this->socket->receive(TIMEOUT_ON);
		socketMtx.unlock();
		FileRecord fileRecord;
		if (response == NULL) return;
		switch (response->type) {
			case TYPE_NOTHING_TO_SEND:
				break;
			case TYPE_REQUEST_UPDATE_DONE:
				return;
			case TYPE_DELETE:
				socketMtx.lock();
				this->deleteFile(this->getSyncDirPath() + string(response->payload));
				socketMtx.unlock();
				this->removeFileRecord(string(response->payload));
				break;
			case TYPE_SEND_FILE:
				fileRecord = *((FileRecord *)response->payload);
				socketMtx.lock();
				this->receiveFile(this->socket, string(fileRecord.filename), 
					this->getSyncDirPath());
				socketMtx.unlock();
				this->updateFileRecord(fileRecord);
				break;
			case TYPE_SEND_UPLOAD_ALL:
				socketMtx.lock();
				this->receiveUploadAll(this->socket, this->getSyncDirPath());
				socketMtx.unlock();
				break;
			case TYPE_DELETE_ALL:
				socketMtx.lock();
				this->deleteAll(this->getFileList(this->getSyncDirPath()), this->getSyncDirPath());
				socketMtx.unlock();
				break;
			default:
				cout << "Received " + to_string(response->type) << endl;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1318, %rsp           # imm = 0x1318
movq %rdi, %rbx
movq (%rdi), %rax
movq %rax, (%rsp)
leaq 0x79fe(%rip), %r9       # 0xc0a7
leaq -0x124c(%rbp), %r15
pushq $0xe
popq %rsi
pushq $0x1
popq %rcx
pushq $-0x1
popq %r8
movq %r15, %rdi
movl %ecx, %edx
callq 0x5844
leaq 0x98(%rbx), %r14
movq %r14, %rdi
callq 0x50d8
movq 0x40(%rbx), %rdi
movq %r15, %rsi
callq 0xb850
movl %eax, %r15d
movq %r14, %rdi
callq 0x3250
testl %r15d, %r15d
je 0x49d0
movq 0x40(%rbx), %r15
leaq 0xc0(%rbx), %rsi
leaq -0xb0(%rbp), %r12
movq %r12, %rdi
callq 0x514a
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x599e
leaq -0xb0(%rbp), %rdi
callq 0x5508
leaq 0x50(%rbx), %rax
movq %rax, -0x40(%rbp)
movq %rbx, -0x30(%rbp)
movq %r14, %rdi
callq 0x50d8
movq 0x40(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0xb9d4
movq %rax, %r12
movq %r14, %rdi
callq 0x3250
testq %r12, %r12
je 0x49d0
movl (%r12), %esi
leal -0x3(%rsi), %eax
cmpl $0xc, %eax
ja 0x4937
leaq 0x7892(%rip), %rcx      # 0xc004
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x14, %r12
movl $0xe8, %edx
leaq -0x278(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x3280
movq %r14, %rdi
callq 0x50d8
movq -0x30(%rbp), %rax
movq 0x40(%rax), %r12
leaq -0xf0(%rbp), %rdi
movq %r15, %rsi
leaq -0x60(%rbp), %rdx
callq 0x3130
leaq -0x150(%rbp), %r13
movq %r13, %rdi
movq -0x40(%rbp), %rsi
callq 0x33d0
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
leaq -0xf0(%rbp), %r15
movq %r15, %rdx
movq %r13, %rcx
callq 0x5a7a
movq %r13, %rdi
callq 0x3170
movq %r15, %rdi
callq 0x3170
movq %r14, %rdi
callq 0x3250
pushq $0x1d
popq %rcx
movq %rsp, %rdi
leaq -0x278(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
callq 0x4c1c
jmp 0x49c7
movq %r14, %rdi
callq 0x50d8
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
movq -0x40(%rbp), %r15
movq %r15, %rsi
callq 0x33d0
leaq -0x98(%rbp), %rdi
movq -0x30(%rbp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x58ba
leaq -0x110(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x33d0
movq %rbx, %rdi
leaq -0x98(%rbp), %rbx
movq %rbx, %rsi
movq %r12, %rdx
callq 0x6bd0
movq %r12, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x5508
leaq -0xd0(%rbp), %rdi
callq 0x3170
movq %r14, %rdi
jmp 0x49c2
movq %r14, %rdi
callq 0x50d8
leaq -0x60(%rbp), %r13
movq %r13, %rdi
movq -0x40(%rbp), %rsi
callq 0x33d0
addq $0x14, %r12
leaq -0x80(%rbp), %r15
movq %r15, %rdi
movq %r12, %rsi
leaq -0x31(%rbp), %rdx
callq 0x3130
leaq -0x190(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x51aa
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x6b96
movq %rbx, %rdi
callq 0x3170
leaq -0x80(%rbp), %rdi
callq 0x3170
leaq -0x60(%rbp), %r15
movq %r15, %rdi
callq 0x3170
movq %r14, %rdi
callq 0x3250
leaq -0x170(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x3130
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x4b98
movq %rbx, %rdi
jmp 0x497c
leaq -0x80(%rbp), %r12
movq %r12, %rdi
callq 0x5249
leaq -0x60(%rbp), %r15
movq %r15, %rdi
leaq 0x776a(%rip), %rsi      # 0xc0bb
movq %r12, %rdx
callq 0x521b
movq 0xc668(%rip), %rdi      # 0x10fc8
movq %r15, %rsi
callq 0x32b0
movq %rax, %rdi
callq 0x31c0
leaq -0x60(%rbp), %rdi
callq 0x3170
movq %r12, %rdi
callq 0x3170
jmp 0x49c7
movq %r14, %r13
movq %r14, %rdi
callq 0x50d8
movq -0x30(%rbp), %rbx
movq 0x40(%rbx), %r12
leaq -0x130(%rbp), %r15
movq %r15, %rdi
movq -0x40(%rbp), %rsi
callq 0x33d0
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x6838
movq %r15, %rdi
callq 0x3170
movq %r13, %rdi
callq 0x3250
movq -0x30(%rbp), %rbx
jmp 0x4733
addq $0x1318, %rsp           # imm = 0x1318
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xb0(%rbp), %rdi
callq 0x5508
jmp 0x4aa8
movq %rax, %rbx
jmp 0x4a9f
movq %rax, %rbx
leaq -0x150(%rbp), %rdi
callq 0x3170
jmp 0x4a12
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
jmp 0x4aa3
jmp 0x4a38
movq %rax, %rbx
leaq -0x130(%rbp), %rdi
jmp 0x4aa3
movq %rax, %rbx
leaq -0x170(%rbp), %rdi
jmp 0x4aa3
movq %rax, %rbx
jmp 0x4aa8
movq %rax, %rbx
leaq -0x190(%rbp), %rdi
callq 0x3170
jmp 0x4a51
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x3170
jmp 0x4a5f
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
jmp 0x4aa3
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x3170
jmp 0x4a79
movq %rax, %rbx
leaq -0x98(%rbp), %rdi
callq 0x5508
jmp 0x4a8a
movq %rax, %rbx
leaq -0xd0(%rbp), %rdi
jmp 0x4aa3
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3170
leaq -0x80(%rbp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3540