// File: /workspace/github_cpp_makefile_star2_O1/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 0x4f7d
je 0x4f6b
movl (%r14), %edi
leaq -0x362d0(%rbp), %rsi
movl $0x36000, %edx          # imm = 0x36000
callq 0x3440
movq %rax, -0x60(%rbp)
testl %eax, %eax
jle 0x4f6b
leaq 0x50(%rbx), %rax
movq %rax, -0x58(%rbp)
leaq 0x98(%rbx), %r12
xorl %ecx, %ecx
movslq %ecx, %rax
cmpl $0x0, -0x362c4(%rbp,%rax)
je 0x4f62
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 0x62de
leaq -0x148(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq %r12, %rdx
callq 0x6174
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 0x6244
leaq -0x1e0(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x664e
movq %r13, %r12
movq -0x128(%rbp), %rdi
leaq -0x118(%rbp), %rax
cmpq %rax, %rdi
je 0x4c08
callq 0x3320
testb $-0x80, 0x4(%r14)
je 0x4cd3
movq %r12, %rdi
callq 0x3470
testl %eax, %eax
jne 0x4f84
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 0x6244
leaq -0x2d0(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
leaq -0x1c8(%rbp), %rcx
movq %r13, %r8
callq 0x7448
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0x4c99
callq 0x3320
movq -0x1c8(%rbp), %rdi
leaq -0x1b8(%rbp), %rax
cmpq %rax, %rdi
je 0x4cb1
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 0x5acc
movzwl 0x4(%r14), %eax
testl $0x240, %eax            # imm = 0x240
je 0x4dcd
movq %r12, %rdi
callq 0x3470
testl %eax, %eax
jne 0x4f84
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 0x6244
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x1a8(%rbp), %rdx
movq %r13, %rcx
callq 0x7e4e
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x4d62
callq 0x3320
movq -0x1a8(%rbp), %rdi
leaq -0x198(%rbp), %rax
cmpq %rax, %rdi
je 0x4d7a
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 0x6244
movq %rbx, %rdi
movq %r15, %rsi
callq 0x59f6
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
cmpq %rax, %rdi
je 0x4dcd
callq 0x3320
testb $0x8, 0x4(%r14)
je 0x4f19
movq %r12, %rdi
callq 0x3470
testl %eax, %eax
jne 0x4f84
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 0x6244
movq %rbx, %rdi
movq %r15, %rsi
leaq -0x188(%rbp), %rdx
movq %r13, %rcx
callq 0x7e4e
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x4e57
callq 0x3320
movq -0x188(%rbp), %rdi
leaq -0x178(%rbp), %rax
cmpq %rax, %rdi
je 0x4e6f
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 0x6244
leaq -0x2d0(%rbp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
leaq -0x168(%rbp), %rcx
movq %r13, %r8
callq 0x7448
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x4edf
callq 0x3320
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0x4ef7
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 0x5acc
movl 0xc(%r14), %r14d
movq -0x1e0(%rbp), %rdi
testq %rdi, %rdi
je 0x4f2e
callq 0x3320
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0x4f46
callq 0x3320
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x4f58
callq 0x3320
movq -0x68(%rbp), %rcx
addl %r14d, %ecx
addl $0x10, %ecx
cmpl -0x60(%rbp), %ecx
jl 0x4b52
addq $0x36398, %rsp          # imm = 0x36398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3610
jmp 0x4f6b
movl %eax, %edi
callq 0x3250
jmp 0x50aa
movq %rax, %rbx
jmp 0x5027
movq %rax, %rbx
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x4fbd
callq 0x3320
jmp 0x4fbd
jmp 0x50aa
movq %rax, %rbx
movq -0x188(%rbp), %rdi
leaq -0x178(%rbp), %rax
jmp 0x507c
jmp 0x50aa
jmp 0x50aa
movq %rax, %rbx
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x4ffc
callq 0x3320
jmp 0x4ffc
jmp 0x50aa
movq %rax, %rbx
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
jmp 0x507c
movq %rax, %rbx
movq -0x108(%rbp), %rdi
leaq -0xf8(%rbp), %rax
cmpq %rax, %rdi
je 0x5027
callq 0x3320
movq -0x1c8(%rbp), %rdi
leaq -0x1b8(%rbp), %rax
jmp 0x507c
movq %rax, %rbx
jmp 0x506e
movq %rax, %rbx
movq -0xc8(%rbp), %rdi
leaq -0xb8(%rbp), %rax
jmp 0x507c
jmp 0x50aa
jmp 0x50aa
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
leaq -0xd8(%rbp), %rax
cmpq %rax, %rdi
je 0x506e
callq 0x3320
movq -0x1a8(%rbp), %rdi
leaq -0x198(%rbp), %rax
cmpq %rax, %rdi
je 0x50ad
callq 0x3320
jmp 0x50ad
movq %rax, %rbx
jmp 0x50d6
movq %rax, %rbx
jmp 0x50be
movq %rax, %rbx
movq -0x128(%rbp), %rdi
leaq -0x118(%rbp), %rax
cmpq %rax, %rdi
jne 0x50b9
jmp 0x50be
movq %rax, %rbx
movq -0x1e0(%rbp), %rdi
testq %rdi, %rdi
je 0x50be
callq 0x3320
movq -0x148(%rbp), %rdi
leaq -0x138(%rbp), %rax
cmpq %rax, %rdi
je 0x50d6
callq 0x3320
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x50e8
callq 0x3320
movq %rbx, %rdi
callq 0x3580