// File: /workspace/github_cpp_makefile_star2_O2/vianna274[P]dropbox/src/Server.cpp
// Function: Dropbox::Server::listenToClient(Dropbox::WrapperSocket*, Dropbox::User*)
void Server::listenToClient(WrapperSocket *socket, User *user)
{   
    bool exit = false;
    FileRecord * temp = NULL;
    FileRecord fileTemp;
    vector<FileRecord> tempFiles = user->getFileRecords();
	while(!exit){
		MessageData *data = socket->receive(TIMEOUT_OFF);
        user->lockDevices();
        switch(data->type){
            case TYPE_REQUEST_DOWNLOAD:
                tempFiles = user->getFileRecords();
                fileTemp = this->getRecord(tempFiles, string(data->payload));
                sendFile(socket, user->getDirPath() + string(data->payload), fileTemp, string(data->username));
                break;
            case TYPE_DELETE: 
                deleteFile(user->getDirPath() + string(data->payload));
                user->removeFileRecord(string(data->payload));
                propagateDelete(string(data->payload), string(data->username));
                break;
            case TYPE_LIST_SERVER:
                sendFileList(socket, user->getFileRecords());
                break;
            case TYPE_SEND_FILE_NO_RECORD:
                receiveFile(socket, string(data->payload), user->getDirPath());
                user->updateFileRecord(this->getRecord(this->getFileList(user->getDirPath()), string(data->payload)));
                sendFileRecord(socket, string(data->payload), user);
                this->propagateFile(string(data->payload), string(data->username));
                break;
            case TYPE_REQUEST_UPLOAD_ALL:
                sendUploadAll(socket, user->getDirPath(), getFileList(user->getDirPath()), user->getUsername());
                break;
            case TYPE_REQUEST_UPDATE:
                receiveAskUpdate(socket, user);
                break;
            case EXIT:
                exitUser(socket, user);
                exit = true;
                break;
        }
        user->unlockDevices();
	}

    delete socket;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x768, %rsp            # imm = 0x768
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, -0x38(%rbp)
leaq -0xa0(%rbp), %rdi
movq %rdx, %rsi
callq 0xb1f6
movq %r14, -0x40(%rbp)
leaq 0x70(%r14), %rax
movq %rax, -0x50(%rbp)
movq %rbx, %r14
movq %rbx, %rdi
xorl %esi, %esi
callq 0xb9d4
movq %rax, %r13
movq -0x50(%rbp), %rdi
callq 0x50d8
movl (%r13), %eax
leal -0x4(%rax), %ecx
cmpl $0xa, %ecx
ja 0x938b
leaq 0x3489(%rip), %rdx      # 0xc37c
movslq (%rdx,%rcx,4), %rax
addq %rdx, %rax
jmpq *%rax
leaq 0x14(%r13), %rbx
leaq -0x1c8(%rbp), %rdi
movq %rbx, %rsi
leaq -0x3f0(%rbp), %rdx
callq 0x3130
leaq -0x288(%rbp), %r15
movq %r15, %rdi
movq -0x40(%rbp), %rsi
callq 0xb362
movq -0x38(%rbp), %rdi
movq %r14, %rsi
leaq -0x1c8(%rbp), %r12
movq %r12, %rdx
movq %r15, %rcx
callq 0x5a7a
movq %r15, %rdi
callq 0x3170
movq %r12, %rdi
callq 0x3170
leaq -0xd8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xb362
leaq -0x88(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0xd8(%rbp), %rdx
callq 0x58ba
leaq -0x1a8(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
leaq -0x3f0(%rbp), %rdx
callq 0x3130
leaq -0x5c0(%rbp), %r12
movq %r12, %rdi
movq -0x38(%rbp), %rsi
leaq -0x88(%rbp), %rdx
movq %r15, %rcx
callq 0x5b56
pushq $0x1d
popq %rcx
movq %rsp, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x40(%rbp), %rdi
callq 0xb28c
leaq -0x1a8(%rbp), %rdi
callq 0x3170
leaq -0x88(%rbp), %rdi
callq 0x5508
leaq -0xd8(%rbp), %rdi
callq 0x3170
leaq -0x268(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
leaq -0x3f0(%rbp), %rdx
callq 0x3130
movq -0x38(%rbp), %rdi
movq %r14, %rsi
movq %r15, %rdx
movq -0x40(%rbp), %rcx
callq 0x98d8
movq %r15, %rdi
callq 0x3170
leaq -0x188(%rbp), %rdi
movq %rbx, %rsi
leaq -0x3f0(%rbp), %rdx
callq 0x3130
addq $0xfb4, %r13            # imm = 0xFB4
leaq -0x248(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
leaq -0x70(%rbp), %rdx
callq 0x3130
movq -0x38(%rbp), %rdi
leaq -0x188(%rbp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x96e6
jmp 0x936a
leaq -0x3f0(%rbp), %r12
movq %r12, %rdi
movq -0x40(%rbp), %rsi
callq 0xb1f6
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x5732
movq %r12, %rdi
callq 0x5508
leaq -0x128(%rbp), %rdi
movq %rbx, %rsi
callq 0x514a
leaq 0x14(%r13), %rbx
leaq -0x110(%rbp), %rdi
movq %rbx, %rsi
leaq -0x70(%rbp), %rdx
callq 0x3130
movq %r12, %rdi
movq -0x38(%rbp), %rsi
leaq -0x128(%rbp), %r15
movq %r15, %rdx
leaq -0x110(%rbp), %rcx
callq 0x5b56
movl $0xe8, %edx
leaq -0x4d8(%rbp), %rdi
movq %r12, %rsi
callq 0x3280
leaq -0x110(%rbp), %rdi
callq 0x3170
movq %r15, %rdi
callq 0x5508
movq %r12, %rdi
movq -0x40(%rbp), %rsi
callq 0xb362
leaq -0x70(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
leaq -0x29(%rbp), %rdx
callq 0x3130
leaq -0x208(%rbp), %rdi
leaq -0x3f0(%rbp), %rsi
movq %r15, %rdx
callq 0x51aa
movl $0xe8, %edx
leaq -0x6a8(%rbp), %rbx
movq %rbx, %rdi
leaq -0x4d8(%rbp), %rsi
callq 0x3280
addq $0xfb4, %r13            # imm = 0xFB4
leaq -0x308(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
leaq -0x41(%rbp), %rdx
callq 0x3130
pushq $0x1d
popq %rcx
movq %rsp, %rdi
movq %rbx, %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x38(%rbp), %rdi
movq %r14, %rsi
leaq -0x208(%rbp), %rbx
movq %rbx, %rdx
movq %r15, %rcx
callq 0x5bd2
movq %r15, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3170
leaq -0x70(%rbp), %rdi
callq 0x3170
leaq -0x3f0(%rbp), %rdi
jmp 0x9375
leaq -0xf0(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xb1f6
movq -0x38(%rbp), %rdi
movq %r14, %rsi
leaq -0xf0(%rbp), %rbx
movq %rbx, %rdx
callq 0x599e
movq %rbx, %rdi
callq 0x5508
jmp 0x937a
movq -0x38(%rbp), %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rdx
callq 0x9990
jmp 0x937a
leaq -0x168(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xb362
leaq -0x148(%rbp), %rbx
movq %rbx, %rdi
movq -0x40(%rbp), %rsi
callq 0xb362
leaq -0xb8(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq %rbx, %rdx
callq 0x58ba
movq %r14, %rbx
leaq -0x228(%rbp), %r12
movq %r12, %rdi
movq -0x40(%rbp), %rsi
callq 0xb34a
movq -0x38(%rbp), %rdi
movq %rbx, %rsi
leaq -0x168(%rbp), %rbx
movq %rbx, %rdx
leaq -0xb8(%rbp), %r15
movq %r15, %rcx
movq %r12, %r8
callq 0x68e0
movq %r12, %rdi
callq 0x3170
movq %r15, %rdi
callq 0x5508
leaq -0x148(%rbp), %rdi
jmp 0x936d
leaq -0x3f0(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xb362
leaq 0x14(%r13), %rbx
leaq -0x70(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
leaq -0x29(%rbp), %rdx
callq 0x3130
leaq -0x2e8(%rbp), %r12
movq %r12, %rdi
leaq -0x3f0(%rbp), %rsi
movq %r15, %rdx
callq 0x51aa
movq -0x38(%rbp), %rdi
movq %r12, %rsi
callq 0x6b96
movq %r12, %rdi
callq 0x3170
leaq -0x70(%rbp), %rdi
callq 0x3170
leaq -0x3f0(%rbp), %r12
movq %r12, %rdi
callq 0x3170
leaq -0x2c8(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x3130
movq -0x40(%rbp), %rdi
movq %r15, %rsi
callq 0xb212
movq %r15, %rdi
callq 0x3170
leaq -0x1e8(%rbp), %rdi
movq %rbx, %rsi
leaq -0x3f0(%rbp), %rdx
callq 0x3130
addq $0xfb4, %r13            # imm = 0xFB4
leaq -0x2a8(%rbp), %r15
movq %r15, %rdi
movq %r13, %rsi
leaq -0x70(%rbp), %rdx
callq 0x3130
movq -0x38(%rbp), %rdi
leaq -0x1e8(%rbp), %rbx
movq %rbx, %rsi
movq %r15, %rdx
callq 0x9596
movq %r15, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3170
movq -0x50(%rbp), %rdi
callq 0x3250
movq %r14, %rbx
jmp 0x8ec3
cmpl $0x21, %eax
jne 0x937a
movq -0x38(%rbp), %rdi
movq %r14, %rsi
movq -0x40(%rbp), %rdx
callq 0x9a98
movq -0x50(%rbp), %rdi
callq 0x3250
movq %r14, %rdi
callq 0xb4c4
movq %r14, %rdi
callq 0x32f0
leaq -0xa0(%rbp), %rdi
callq 0x5508
addq $0x768, %rsp            # imm = 0x768
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x957f
movq %rax, %rbx
leaq -0x248(%rbp), %rdi
callq 0x3170
jmp 0x9410
movq %rax, %rbx
leaq -0x308(%rbp), %rdi
callq 0x3170
jmp 0x9401
movq %rax, %rbx
leaq -0x208(%rbp), %rdi
jmp 0x94a5
movq %rax, %rbx
leaq -0x188(%rbp), %rdi
jmp 0x9578
jmp 0x94ac
jmp 0x957f
movq %rax, %rbx
leaq -0x268(%rbp), %rdi
jmp 0x9578
jmp 0x957f
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
callq 0x3170
jmp 0x944e
movq %rax, %rbx
leaq -0x1e8(%rbp), %rdi
jmp 0x9578
jmp 0x957f
movq %rax, %rbx
jmp 0x9535
movq %rax, %rbx
jmp 0x9541
movq %rax, %rbx
jmp 0x954d
movq %rax, %rbx
jmp 0x9565
movq %rax, %rbx
jmp 0x9571
movq %rax, %rbx
leaq -0x2c8(%rbp), %rdi
jmp 0x9578
jmp 0x957f
movq %rax, %rbx
leaq -0x2e8(%rbp), %rdi
callq 0x3170
jmp 0x94af
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x3170
jmp 0x94f5
jmp 0x94f2
jmp 0x957f
movq %rax, %rbx
leaq -0x288(%rbp), %rdi
callq 0x3170
jmp 0x94d5
movq %rax, %rbx
leaq -0x1c8(%rbp), %rdi
jmp 0x9578
jmp 0x957f
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
jmp 0x951b
movq %rax, %rbx
leaq -0x3f0(%rbp), %rdi
jmp 0x9578
jmp 0x957f
movq %rax, %rbx
leaq -0x110(%rbp), %rdi
callq 0x3170
jmp 0x9514
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x5508
jmp 0x9582
jmp 0x957f
jmp 0x957f
movq %rax, %rbx
leaq -0x228(%rbp), %rdi
callq 0x3170
leaq -0xb8(%rbp), %rdi
callq 0x5508
leaq -0x148(%rbp), %rdi
callq 0x3170
leaq -0x168(%rbp), %rdi
jmp 0x9578
movq %rax, %rbx
leaq -0x1a8(%rbp), %rdi
callq 0x3170
leaq -0x88(%rbp), %rdi
callq 0x5508
leaq -0xd8(%rbp), %rdi
callq 0x3170
jmp 0x9582
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x5508
movq %rbx, %rdi
callq 0x3540