// File: /workspace/github_cpp_makefile_star2_O3/vianna274[P]dropbox/src/Client.cpp
// Function: Dropbox::Client::eventsInotify(int*)
void Client::eventsInotify(int* fd){
	int length, i = 0;
	char buffer[BUF_LEN];
	struct pollfd pfd = { *fd, POLLIN, 0 };
	int ret = poll(&pfd, 1, 50);  // timeout of 50ms
	if (ret < 0) {
		fprintf(stderr, "poll failed: %s\n", strerror(errno));
	} else if (ret == 0) {
		// Timeout with no events, move on.
	} else {
		// Process the new event.
		length = read(*fd, buffer, BUF_LEN);  
		while (i < length) {
			struct inotify_event *event = ( struct inotify_event * ) &buffer[ i ];
			if (event->len ) {
				string filename(event->name);
				string path = syncDirPath + filename;
				vector<FileRecord> tempFiles = this->getFileList(this->getSyncDirPath());
				if(event->mask & IN_MOVED_TO){
					socketMtx.lock();
					FileRecord newRecord = this->sendFileClient(this->socket, path.c_str(), this->username);
					socketMtx.unlock();
					this->updateFileRecord(newRecord);
				}
			
				if(event->mask & IN_MOVED_FROM || event->mask & IN_DELETE){
					socketMtx.lock();
					this->sendDeleteFile(this->socket, filename.c_str(), this->username);
					socketMtx.unlock();
					this->removeFileRecord(filename);
				}  
		
				if(event->mask & IN_CLOSE_WRITE){
					socketMtx.lock();
					this->sendDeleteFile(this->socket, filename.c_str(), this->username);
					FileRecord newRecord = this->sendFileClient(this->socket, path.c_str(), this->username);
					socketMtx.unlock();
					this->updateFileRecord(newRecord);
				} 
	
			i += EVENT_SIZE + event->len;
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x36398, %rsp          # imm = 0x36398
movq %rsi, %r14
movq %rdi, %rbx
movl (%rsi), %eax
leaq -0x1e8(%rbp), %rdi
movl %eax, (%rdi)
movl $0x1, 0x4(%rdi)
movl $0x1, %esi
movl $0x32, %edx
callq 0x34a0
testl %eax, %eax
js 0x4f7b
je 0x4f69
movl (%r14), %edi
leaq -0x362d0(%rbp), %rsi
movl $0x36000, %edx          # imm = 0x36000
callq 0x3440
movq %rax, -0x60(%rbp)
testl %eax, %eax
jle 0x4f69
leaq 0x50(%rbx), %rax
movq %rax, -0x58(%rbp)
leaq 0x98(%rbx), %r12
xorl %ecx, %ecx
movslq %ecx, %rax
cmpl $0x0, -0x362c4(%rbp,%rax)
je 0x4f60
movq %rcx, -0x68(%rbp)
movq %r12, %r13
leaq (%rax,%rbp), %r14
addq $-0x362d0, %r14         # imm = 0xFFFC9D30
leaq 0x10(%r14), %r15
leaq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq %r15, %rdi
callq 0x3170
leaq (%r14,%rax), %rdx
addq $0x10, %rdx
leaq -0x50(%rbp), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x630e
leaq -0x148(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %r12, %rdx
callq 0x61a0
leaq -0x118(%rbp), %rax
movq %rax, -0x128(%rbp)
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rdx
addq %rsi, %rdx
leaq -0x128(%rbp), %r15
movq %r15, %rdi
callq 0x6270
leaq -0x1e0(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x6682
movq %r13, %r12
movq -0x128(%rbp), %rdi
leaq -0x118(%rbp), %rax
cmpq %rax, %rdi
je 0x4c06
callq 0x3320
movl 0x4(%r14), %eax
testb %al, %al
jns 0x4cd6
movq %r12, %rdi
callq 0x3470
testl %eax, %eax
jne 0x4f82
movq 0x40(%rbx), %r15
movq -0x148(%rbp), %rsi
leaq -0x1c8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3150
leaq -0xf8(%rbp), %rax
movq %rax, -0x108(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x108(%rbp), %r13
movq %r13, %rdi
callq 0x6270
leaq -0x2d0(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
leaq -0x1c8(%rbp), %rcx
movq %r13, %r8
callq 0x7486
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0x4c98
callq 0x3320
movq -0x1c8(%rbp), %rdi
leaq -0x1b8(%rbp), %rax
cmpq %rax, %rdi
je 0x4cb0
callq 0x3320
movq %r12, %rdi
callq 0x3280
movl $0x1d, %ecx
movq %rsp, %rdi
leaq -0x2d0(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
callq 0x5b02
movl 0x4(%r14), %eax
testl $0x240, %eax            # imm = 0x240
je 0x4dcb
movq %r12, %rdi
callq 0x3470
testl %eax, %eax
jne 0x4f82
movq 0x40(%rbx), %r15
movq -0x50(%rbp), %rsi
leaq -0x1a8(%rbp), %rdi
leaq -0x2d0(%rbp), %rdx
callq 0x3150
leaq -0xd8(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xe8(%rbp), %r13
movq %r13, %rdi
callq 0x6270
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x1a8(%rbp), %rdx
movq %r13, %rcx
callq 0x7e8c
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x4d60
callq 0x3320
movq -0x1a8(%rbp), %rdi
leaq -0x198(%rbp), %rax
cmpq %rax, %rdi
je 0x4d78
callq 0x3320
movq %r12, %rdi
callq 0x3280
leaq -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0xc8(%rbp), %r15
movq %r15, %rdi
callq 0x6270
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5a16
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x4dcb
callq 0x3320
testb $0x8, 0x4(%r14)
je 0x4f17
movq %r12, %rdi
callq 0x3470
testl %eax, %eax
jne 0x4f82
movq 0x40(%rbx), %r15
movq -0x50(%rbp), %rsi
leaq -0x188(%rbp), %rdi
leaq -0x2d0(%rbp), %rdx
callq 0x3150
leaq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0xa8(%rbp), %r13
movq %r13, %rdi
callq 0x6270
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x188(%rbp), %rdx
movq %r13, %rcx
callq 0x7e8c
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x4e55
callq 0x3320
movq -0x188(%rbp), %rdi
leaq -0x178(%rbp), %rax
cmpq %rax, %rdi
je 0x4e6d
callq 0x3320
movq 0x40(%rbx), %r15
movq -0x148(%rbp), %rsi
leaq -0x168(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x3150
leaq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %r13
movq %r13, %rdi
callq 0x6270
leaq -0x2d0(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
leaq -0x168(%rbp), %rcx
movq %r13, %r8
callq 0x7486
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x4edd
callq 0x3320
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0x4ef5
callq 0x3320
movq %r12, %rdi
callq 0x3280
movl $0x1d, %ecx
movq %rsp, %rdi
leaq -0x2d0(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq %rbx, %rdi
callq 0x5b02
movl 0xc(%r14), %r14d
movq -0x1e0(%rbp), %rdi
testq %rdi, %rdi
je 0x4f2c
callq 0x3320
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0x4f44
callq 0x3320
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x4f56
callq 0x3320
movq -0x68(%rbp), %rcx
addl %r14d, %ecx
addl $0x10, %ecx
cmpl -0x60(%rbp), %ecx
jl 0x4b50
addq $0x36398, %rsp          # imm = 0x36398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3610
jmp 0x4f69
movl %eax, %edi
callq 0x3250
jmp 0x50a8
movq %rax, %rbx
jmp 0x5025
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x4fbb
callq 0x3320
jmp 0x4fbb
jmp 0x50a8
movq %rax, %rbx
movq -0x188(%rbp), %rdi
leaq -0x178(%rbp), %rax
jmp 0x507a
jmp 0x50a8
jmp 0x50a8
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x4ffa
callq 0x3320
jmp 0x4ffa
jmp 0x50a8
movq %rax, %rbx
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
jmp 0x507a
movq %rax, %rbx
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0x5025
callq 0x3320
movq -0x1c8(%rbp), %rdi
leaq -0x1b8(%rbp), %rax
jmp 0x507a
movq %rax, %rbx
jmp 0x506c
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
jmp 0x507a
jmp 0x50a8
jmp 0x50a8
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x506c
callq 0x3320
movq -0x1a8(%rbp), %rdi
leaq -0x198(%rbp), %rax
cmpq %rax, %rdi
je 0x50ab
callq 0x3320
jmp 0x50ab
movq %rax, %rbx
jmp 0x50d4
movq %rax, %rbx
jmp 0x50bc
movq %rax, %rbx
movq -0x128(%rbp), %rdi
leaq -0x118(%rbp), %rax
cmpq %rax, %rdi
jne 0x50b7
jmp 0x50bc
movq %rax, %rbx
movq -0x1e0(%rbp), %rdi
testq %rdi, %rdi
je 0x50bc
callq 0x3320
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0x50d4
callq 0x3320
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x50e6
callq 0x3320
movq %rbx, %rdi
callq 0x3580