// File: mrGoncharuk[P]foldermonitor/src/DirectoryMonitor.cpp
// Function: DirectoryMonitor::startWatching(std::mutex&, std::__cxx11::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, std::atomic<bool>&)
void	DirectoryMonitor::startWatching(std::mutex &p_mutex, std::list<std::string> &filenames, std::atomic<bool> &isRunning)
{
	char buffer[BufferSize];
	int i;
	int total_read;
	while (isRunning)
	{
		i = 0;
		total_read = read(fileDescriptor, buffer, BufferSize);
		if (total_read < 0)
			syslog (LOG_ERR, "DM> Error while reading folder events.");
		while (i < total_read)
		{
			inotify_event *event = reinterpret_cast<inotify_event *>(buffer + i);
			if (event->len)
			{
				if (!(event->mask & IN_ISDIR))
				{
					std::lock_guard<std::mutex> lock(p_mutex);
					syslog (LOG_INFO, "DM> File created <%s>", event->name);

					filenames.push_back(fname + event->name);
				}
			}
			i += MonitorEventSize + event->len;
		}
	}
	syslog(LOG_NOTICE, "DM> Monitoring of <%s> stops.", fname.c_str());
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3080, %rsp           # imm = 0x3080
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x3070(%rbp)
movq -0x20(%rbp), %rdi
callq 0x5ae0
testb $0x1, %al
jne 0x5878
jmp 0x5a06
movq -0x3070(%rbp), %rax
movl $0x0, -0x3024(%rbp)
movl (%rax), %edi
leaq -0x3020(%rbp), %rsi
movl $0x3000, %edx           # imm = 0x3000
callq 0x32d0
movl %eax, -0x3028(%rbp)
cmpl $0x0, -0x3028(%rbp)
jge 0x58be
movl $0x3, %edi
leaq 0x2cb6(%rip), %rsi      # 0x856d
movb $0x0, %al
callq 0x3060
jmp 0x58c0
movl -0x3024(%rbp), %eax
cmpl -0x3028(%rbp), %eax
jge 0x5a01
leaq -0x3020(%rbp), %rax
movslq -0x3024(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x3030(%rbp)
movq -0x3030(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x59e3
movq -0x3030(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x40000000, %eax       # imm = 0x40000000
cmpl $0x0, %eax
jne 0x59e1
movq -0x10(%rbp), %rsi
leaq -0x3038(%rbp), %rdi
callq 0x55c0
movq -0x3030(%rbp), %rdx
addq $0x10, %rdx
leaq 0x2c5f(%rip), %rsi      # 0x8594
xorl %eax, %eax
movl $0x6, %edi
callq 0x3060
jmp 0x5943
movq -0x3070(%rbp), %rsi
movq -0x18(%rbp), %rax
movq %rax, -0x3078(%rbp)
addq $0x8, %rsi
movq -0x3030(%rbp), %rdx
addq $0x10, %rdx
leaq -0x3068(%rbp), %rdi
callq 0x5bb0
jmp 0x5972
movq -0x3078(%rbp), %rdi
leaq -0x3068(%rbp), %rsi
callq 0x5b70
jmp 0x5987
leaq -0x3068(%rbp), %rdi
callq 0x3170
leaq -0x3038(%rbp), %rdi
callq 0x55f0
jmp 0x59e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x3040(%rbp)
movl %eax, -0x3044(%rbp)
jmp 0x59d3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x3040(%rbp)
movl %eax, -0x3044(%rbp)
leaq -0x3068(%rbp), %rdi
callq 0x3170
leaq -0x3038(%rbp), %rdi
callq 0x55f0
jmp 0x5a35
jmp 0x59e3
movq -0x3030(%rbp), %rax
movl 0xc(%rax), %eax
addl $0x10, %eax
addl -0x3024(%rbp), %eax
movl %eax, -0x3024(%rbp)
jmp 0x58c0
jmp 0x5866
movq -0x3070(%rbp), %rdi
addq $0x8, %rdi
callq 0x30f0
movq %rax, %rdx
movl $0x5, %edi
leaq 0x2b85(%rip), %rsi      # 0x85aa
movb $0x0, %al
callq 0x3060
addq $0x3080, %rsp           # imm = 0x3080
popq %rbp
retq
movq -0x3040(%rbp), %rdi
callq 0x3360
nopw %cs:(%rax,%rax)