// File: /workspace/github_cpp_makefile_star2_O3/vianna274[P]dropbox/src/Client.cpp
// Function: Dropbox::Client::get_sync_dir()
void Client::get_sync_dir(){

	this->createSyncDir();
	
	DIR * dir;
    struct dirent *ent;
    if ((dir = opendir (this->getSyncDirPath().c_str())) != NULL) {
        while ((ent = readdir (dir)) != NULL) {
            if(ent->d_type == 0x8) {
                deleteFile(this->getSyncDirPath()+string(ent->d_name));
            }
        }
        closedir(dir);
    } 
	cout << "Deleted all files." << endl;
	MessageData packet = make_packet(TYPE_LIST_SERVER, 1, 1, -1, "list_server");
	socket->send(&packet);
	this->fileRecords = this->receiveFileList(this->getSocket());
	for(FileRecord record : this->fileRecords){
		MessageData request = make_packet(TYPE_REQUEST_DOWNLOAD, 1 , 1, -1, record.filename);
		this->socket->send(&request);
		MessageData *data = this->socket->receive(TIMEOUT_OFF);
		if(data->type == TYPE_SEND_FILE) {
			this->receiveFile(this->socket, record.filename, this->getSyncDirPath());
		}
	}
	this->printFileList(this->fileRecords);
	cout << "Received all files." << endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2128, %rsp           # imm = 0x2128
movq %rdi, %rbx
callq 0x58c6
leaq -0x2138(%rbp), %r12
movq %r12, -0x10(%r12)
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
addq %rsi, %rdx
leaq -0x2148(%rbp), %r15
movq %r15, %rdi
callq 0x6270
movq (%r15), %rdi
callq 0x3490
movq %rax, %r14
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x401a
callq 0x3320
testq %r14, %r14
je 0x41b3
movq %r14, %rdi
callq 0x34b0
testq %rax, %rax
je 0x41ab
movq %rax, %r13
leaq -0x40(%rbp), %r15
movq %r14, -0x30(%rbp)
cmpb $0x8, 0x12(%r13)
jne 0x4197
movq %r15, %r14
movq %r12, -0x2148(%rbp)
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
addq %rsi, %rdx
leaq -0x2148(%rbp), %rdi
callq 0x6270
leaq 0x13(%r13), %r15
leaq -0x1160(%rbp), %rax
movq %rax, -0x1170(%rbp)
movq %r15, %rdi
callq 0x3170
leaq (%rax,%r13), %rdx
addq $0x13, %rdx
leaq -0x1170(%rbp), %rdi
movq %r15, %rsi
callq 0x630e
movq -0x2148(%rbp), %rcx
movl $0xf, %edi
cmpq %r12, %rcx
je 0x40b4
movq -0x2138(%rbp), %rdi
movq -0x2140(%rbp), %r8
movq -0x1170(%rbp), %rsi
movq -0x1168(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
movq %r14, %r15
movq -0x30(%rbp), %r14
jbe 0x40f6
movl $0xf, %edi
leaq -0x1160(%rbp), %r9
cmpq %r9, %rsi
je 0x40f1
movq -0x1160(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x4104
leaq -0x2148(%rbp), %rdi
callq 0x3100
jmp 0x4114
leaq -0x1170(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x3370
movq %r15, -0x50(%rbp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x4131
movq %rdx, -0x50(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x40(%rbp)
jmp 0x4138
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x48(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq %rbx, %rdi
leaq -0x50(%rbp), %rsi
callq 0x7f36
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x416e
callq 0x3320
movq -0x1170(%rbp), %rdi
leaq -0x1160(%rbp), %rax
cmpq %rax, %rdi
je 0x4186
callq 0x3320
movq -0x2148(%rbp), %rdi
cmpq %r12, %rdi
je 0x4197
callq 0x3320
movq %r14, %rdi
callq 0x34b0
movq %rax, %r13
testq %rax, %rax
jne 0x403f
movq %r14, %rdi
callq 0x34f0
movq 0x10e16(%rip), %r14     # 0x14fd0
leaq 0xbf50(%rip), %rsi      # 0x10111
movl $0x12, %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 0xbf28(%rip), %r9       # 0x10124
leaq -0x2148(%rbp), %r14
movq %r14, %rdi
movl $0x6, %esi
movl $0x1, %edx
movl $0x1, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x65b0
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0xea3c
movq 0x40(%rbx), %rdx
leaq -0x1170(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7840
movq 0xc0(%rbx), %rdi
movq (%r14), %rax
movq %rax, 0xc0(%rbx)
movq 0x8(%r14), %rax
movq %rax, 0xc8(%rbx)
movq 0x10(%r14), %rax
movq %rax, 0xd0(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
testq %rdi, %rdi
je 0x4293
callq 0x3320
movq -0x1170(%rbp), %rdi
testq %rdi, %rdi
je 0x4293
callq 0x3320
movq 0xc0(%rbx), %r15
movq 0xc8(%rbx), %rax
movq %rax, -0x30(%rbp)
cmpq %rax, %r15
je 0x43a6
leaq -0x190(%rbp), %r12
movl $0xe8, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x32b0
leaq -0x1170(%rbp), %r14
movq %r14, %rdi
movl $0x8, %esi
movl $0x1, %edx
movl $0x1, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
movq %r12, %r9
callq 0x65b0
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0xea3c
movq 0x40(%rbx), %rdi
xorl %esi, %esi
callq 0xec2e
cmpl $0x3, (%rax)
jne 0x4395
movq 0x40(%rbx), %r14
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
movq %r12, %rdi
callq 0x3170
leaq (%rax,%rbp), %rdx
addq $-0x190, %rdx           # imm = 0xFE70
leaq -0x70(%rbp), %rdi
movq %r12, %rsi
callq 0x630e
leaq -0x80(%rbp), %rax
movq %rax, -0x90(%rbp)
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
addq %rsi, %rdx
leaq -0x90(%rbp), %r13
movq %r13, %rdi
callq 0x6270
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
movq %r13, %rcx
callq 0x68ce
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x4383
callq 0x3320
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x4395
callq 0x3320
addq $0xe8, %r15
cmpq -0x30(%rbp), %r15
jne 0x42b5
leaq 0xc0(%rbx), %rsi
leaq -0xa8(%rbp), %r14
movq %r14, %rdi
callq 0x610c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x7908
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x43d8
callq 0x3320
leaq 0xbd51(%rip), %rsi      # 0x10130
movl $0x13, %edx
movq 0x10be5(%rip), %rbx     # 0x14fd0
movq %rbx, %rdi
callq 0x33a0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3330
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3040
movq %rax, %rdi
callq 0x3260
addq $0x2128, %rsp           # imm = 0x2128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
jne 0x44ad
jmp 0x44b2
movq %rax, %rbx
jmp 0x4458
movq %rax, %rbx
jmp 0x4470
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x4458
callq 0x3320
movq -0x1170(%rbp), %rdi
leaq -0x1160(%rbp), %rax
cmpq %rax, %rdi
je 0x4470
callq 0x3320
movq -0x2148(%rbp), %rdi
cmpq %r12, %rdi
jne 0x44ad
jmp 0x44b2
movq %rax, %rbx
jmp 0x44a0
movq %rax, %rbx
jmp 0x44b2
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x44a0
callq 0x3320
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x44b2
callq 0x3320
movq %rbx, %rdi
callq 0x3580