// File: /workspace/github_cpp_makefile_star2_O2/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, -0x30(%rbp)
movl (%rsi), %eax
leaq -0xa8(%rbp), %rdi
movl %eax, (%rdi)
movl $0x1, 0x4(%rdi)
pushq $0x1
popq %rsi
pushq $0x32
popq %rdx
callq 0x3460
testl %eax, %eax
js 0x456a
je 0x4594
movl (%r14), %edi
leaq -0x362d0(%rbp), %rsi
movl $0x36000, %edx          # imm = 0x36000
callq 0x3400
movq %rax, %r14
movq -0x30(%rbp), %rax
leaq 0x50(%rax), %r13
addq $0x98, %rax
movq %rax, -0x40(%rbp)
xorl %r15d, %r15d
movslq %r15d, %rax
leaq (%rax,%rbp), %r12
addq $-0x362d0, %r12         # imm = 0xFFFC9D30
cmpl %r14d, %r15d
jge 0x4594
cmpl $0x0, 0xc(%r12)
je 0x4292
leaq 0x10(%r12), %rsi
leaq -0x68(%rbp), %rbx
movq %rbx, %rdi
leaq -0x2d0(%rbp), %rdx
callq 0x3130
leaq -0x88(%rbp), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x5352
leaq -0x1e8(%rbp), %rbx
movq %rbx, %rdi
movq %r13, -0x48(%rbp)
movq %r13, %rsi
callq 0x33d0
leaq -0xa0(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
callq 0x58ba
movq %rbx, %rdi
callq 0x3170
movl 0x4(%r12), %eax
testb %al, %al
jns 0x439d
movq -0x40(%rbp), %rdi
callq 0x50d8
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rbx
movq -0x88(%rbp), %rsi
leaq -0x148(%rbp), %rdi
leaq -0x31(%rbp), %rdx
callq 0x3130
leaq -0x1c8(%rbp), %r13
movq %r13, %rdi
movq -0x30(%rbp), %rsi
callq 0x33d0
leaq -0x2d0(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
leaq -0x148(%rbp), %rbx
movq %rbx, %rcx
movq %r13, %r8
callq 0x63ae
movq %r13, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3170
movq -0x40(%rbp), %rdi
callq 0x3250
pushq $0x1d
popq %rcx
movq %rsp, %rdi
leaq -0x2d0(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x30(%rbp), %rdi
callq 0x4c1c
movl 0x4(%r12), %eax
testw $0x240, %ax             # imm = 0x240
je 0x4444
movq -0x40(%rbp), %rdi
callq 0x50d8
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rbx
movq -0x68(%rbp), %rsi
leaq -0x128(%rbp), %rdi
leaq -0x2d0(%rbp), %rdx
callq 0x3130
leaq -0x1a8(%rbp), %r13
movq %r13, %rdi
movq -0x30(%rbp), %rsi
callq 0x33d0
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
leaq -0x128(%rbp), %rbx
movq %rbx, %rdx
movq %r13, %rcx
callq 0x6afe
movq %r13, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3170
movq -0x40(%rbp), %rdi
callq 0x3250
leaq -0x108(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x33d0
movq -0x30(%rbp), %rdi
leaq -0x108(%rbp), %rbx
movq %rbx, %rsi
callq 0x4b98
movq %rbx, %rdi
callq 0x3170
movl 0x4(%r12), %eax
testb $0x8, %al
je 0x4534
movq -0x40(%rbp), %rdi
callq 0x50d8
movq -0x30(%rbp), %rax
movq 0x40(%rax), %r13
movq -0x68(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
leaq -0x2d0(%rbp), %rdx
callq 0x3130
leaq -0x188(%rbp), %rbx
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0x33d0
movq -0x30(%rbp), %rdi
movq %r13, %rsi
leaq -0xe8(%rbp), %r13
movq %r13, %rdx
movq %rbx, %rcx
callq 0x6afe
movq %rbx, %rdi
callq 0x3170
movq %r13, %rdi
callq 0x3170
movq -0x30(%rbp), %rax
movq 0x40(%rax), %rbx
movq -0x88(%rbp), %rsi
leaq -0xc8(%rbp), %rdi
leaq -0x31(%rbp), %rdx
callq 0x3130
leaq -0x168(%rbp), %r13
movq %r13, %rdi
movq -0x30(%rbp), %rsi
callq 0x33d0
leaq -0x2d0(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq %rbx, %rdx
leaq -0xc8(%rbp), %rbx
movq %rbx, %rcx
movq %r13, %r8
callq 0x63ae
movq %r13, %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3170
movq -0x40(%rbp), %rdi
callq 0x3250
pushq $0x1d
popq %rcx
movq %rsp, %rdi
leaq -0x2d0(%rbp), %rsi
rep  movsq (%rsi), %es:(%rdi)
movq -0x30(%rbp), %rdi
callq 0x4c1c
movl 0xc(%r12), %eax
addl %eax, %r15d
addl $0x10, %r15d
leaq -0xa0(%rbp), %rdi
callq 0x5508
leaq -0x88(%rbp), %rdi
callq 0x3170
leaq -0x68(%rbp), %rdi
callq 0x3170
movq -0x48(%rbp), %r13
jmp 0x4284
movq 0xca5f(%rip), %rax      # 0x10fd0
movq (%rax), %rbx
callq 0x3050
movl (%rax), %edi
callq 0x3100
leaq 0x7b3e(%rip), %rsi      # 0xc0c5
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x33f0
addq $0x36398, %rsp          # imm = 0x36398
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4658
movq %rax, %rbx
leaq -0x168(%rbp), %rdi
callq 0x3170
jmp 0x45bf
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0x4634
jmp 0x4658
movq %rax, %rbx
leaq -0x188(%rbp), %rdi
callq 0x3170
jmp 0x45e1
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0x4634
jmp 0x4658
jmp 0x4658
movq %rax, %rbx
leaq -0x1c8(%rbp), %rdi
callq 0x3170
jmp 0x4602
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
jmp 0x4634
jmp 0x4658
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0x4634
movq %rax, %rbx
leaq -0x1a8(%rbp), %rdi
callq 0x3170
jmp 0x462d
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x3170
jmp 0x465b
jmp 0x4658
movq %rax, %rbx
leaq -0x1e8(%rbp), %rdi
callq 0x3170
jmp 0x4667
movq %rax, %rbx
jmp 0x4667
movq %rax, %rbx
jmp 0x4673
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x5508
leaq -0x88(%rbp), %rdi
callq 0x3170
leaq -0x68(%rbp), %rdi
callq 0x3170
movq %rbx, %rdi
callq 0x3540