// File: /workspace/github_cpp_makefile_star2_O1/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 0x58a6
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 0x6244
movq (%r15), %rdi
callq 0x3490
movq %rax, %r14
movq (%r15), %rdi
cmpq %r12, %rdi
je 0x401a
callq 0x3320
testq %r14, %r14
je 0x41b7
movq %r14, %rdi
callq 0x34b0
testq %rax, %rax
je 0x41af
movq %rax, %r13
leaq -0x40(%rbp), %r15
movq %r14, -0x30(%rbp)
cmpb $0x8, 0x12(%r13)
jne 0x419b
movq %r15, %r14
movq %r12, -0x2148(%rbp)
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
addq %rsi, %rdx
leaq -0x2148(%rbp), %rdi
callq 0x6244
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 0x62de
movq -0x2148(%rbp), %rcx
movl $0xf, %esi
cmpq %r12, %rcx
je 0x40b4
movq -0x2138(%rbp), %rsi
movq -0x2140(%rbp), %r8
movq -0x1168(%rbp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
movq %r14, %r15
movq -0x30(%rbp), %r14
jbe 0x40f3
movl $0xf, %esi
leaq -0x1160(%rbp), %rdi
cmpq %rdi, -0x1170(%rbp)
je 0x40ee
movq -0x1160(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x4108
movq -0x1170(%rbp), %rsi
leaq -0x2148(%rbp), %rdi
callq 0x3100
jmp 0x4118
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 0x4135
movq %rdx, -0x50(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x40(%rbp)
jmp 0x413c
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 0x7ef8
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x4172
callq 0x3320
movq -0x1170(%rbp), %rdi
leaq -0x1160(%rbp), %rax
cmpq %rax, %rdi
je 0x418a
callq 0x3320
movq -0x2148(%rbp), %rdi
cmpq %r12, %rdi
je 0x419b
callq 0x3320
movq %r14, %rdi
callq 0x34b0
movq %rax, %r13
testq %rax, %rax
jne 0x403f
movq %r14, %rdi
callq 0x34f0
movq 0x10e12(%rip), %r14     # 0x14fd0
leaq 0xbf4c(%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 0xbf24(%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 0x657c
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0xeae4
movq 0x40(%rbx), %rdx
leaq -0x1170(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7802
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 0x4286
callq 0x3320
movq -0x1170(%rbp), %rdi
testq %rdi, %rdi
je 0x4297
callq 0x3320
movq 0xc0(%rbx), %r15
movq 0xc8(%rbx), %rax
movq %rax, -0x30(%rbp)
cmpq %rax, %r15
je 0x43aa
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 0x657c
movq 0x40(%rbx), %rdi
movq %r14, %rsi
callq 0xeae4
movq 0x40(%rbx), %rdi
xorl %esi, %esi
callq 0xed22
cmpl $0x3, (%rax)
jne 0x4399
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 0x62de
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 0x6244
movq %rbx, %rdi
movq %r14, %rsi
leaq -0x70(%rbp), %rdx
movq %r13, %rcx
callq 0x689a
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x4387
callq 0x3320
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x4399
callq 0x3320
addq $0xe8, %r15
cmpq -0x30(%rbp), %r15
jne 0x42b9
leaq 0xc0(%rbx), %rsi
leaq -0xa8(%rbp), %r14
movq %r14, %rdi
callq 0x60e0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x78ca
movq -0xa8(%rbp), %rdi
testq %rdi, %rdi
je 0x43dc
callq 0x3320
leaq 0xbd4d(%rip), %rsi      # 0x10130
movl $0x13, %edx
movq 0x10be1(%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 0x44b1
jmp 0x44b6
movq %rax, %rbx
jmp 0x445c
movq %rax, %rbx
jmp 0x4474
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r15, %rdi
je 0x445c
callq 0x3320
movq -0x1170(%rbp), %rdi
leaq -0x1160(%rbp), %rax
cmpq %rax, %rdi
je 0x4474
callq 0x3320
movq -0x2148(%rbp), %rdi
cmpq %r12, %rdi
jne 0x44b1
jmp 0x44b6
movq %rax, %rbx
jmp 0x44a4
movq %rax, %rbx
jmp 0x44b6
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x44a4
callq 0x3320
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x44b6
callq 0x3320
movq %rbx, %rdi
callq 0x3580