// File: /workspace/github_cpp_makefile_star2_O1/mrGoncharuk[P]foldermonitor/src/main.cpp
// Function: main
int main(void)
{
	int	pidfilehandle;
	pidfilehandle = daemonize();

	std::list<std::string> filenames;
	std::atomic<bool> isRunning;
	std::mutex l_mutex;
	const std::string watching_folder = "/home/foldermonitor/monitorme/";
	const std::string database_folder = "/home/foldermonitor/database/foldermonitor.db";
	DirectoryMonitor dm(watching_folder);
	DBWriter *dbw = new DBWriter(database_folder);
	MigrationManager migManager(dbw, countThreadAmount());

	if (dm.initWatcher() == false)
		exit(EXIT_FAILURE);
	if (dbw->initDB() == false)
		exit(EXIT_FAILURE);
	isRunning = true;

	std::thread threadFWatcher
		( &DirectoryMonitor::startWatching
			, std::ref(dm)
			, std::ref(l_mutex)
			, std::ref(filenames)
			, std::ref(isRunning)
		);
	migManager.migrateData(l_mutex, filenames, isRunning);
	threadFWatcher.join();
	dbw->closeDB();
	delete dbw;
	syslog(LOG_NOTICE, "Stopping daemon-foldermonitor.");
	close(pidfilehandle);
	closelog();
	exit(EXIT_SUCCESS);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
callq 0x24ec
movl %eax, %ebx
leaq 0xa8(%rsp), %rbp
movq %rbp, 0x8(%rbp)
movq %rbp, (%rbp)
xorl %eax, %eax
movq %rax, 0x10(%rbp)
movq %rax, 0x40(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
leaq 0x98(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x19d4(%rip), %rsi      # 0x411e
leaq 0x19eb(%rip), %rdx      # 0x413c
leaq 0x88(%rsp), %rdi
callq 0x2aac
leaq 0x78(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x19cf(%rip), %rsi      # 0x413d
leaq 0x19f5(%rip), %rdx      # 0x416a
leaq 0x68(%rsp), %rdi
callq 0x2aac
leaq 0xc0(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x2e4e
movl $0x58, %edi
callq 0x21e0
movq %rax, %r14
leaq 0x68(%rsp), %rsi
movq %rax, %rdi
callq 0x2b7c
callq 0x2250
movl %eax, %r15d
leaq 0x19cd(%rip), %rsi      # 0x418a
movl $0x5, %edi
movl %eax, %edx
xorl %eax, %eax
callq 0x2050
leal -0x2(%r15), %eax
cmpl $0x4, %r15d
movl $0x1, %edx
cmovael %eax, %edx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x3418
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
callq 0x2eac
testb %al, %al
je 0x28c0
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
testb %al, %al
je 0x28c0
movb $0x1, %al
leaq 0x7(%rsp), %rdi
xchgb %al, (%rdi)
leaq 0x6f2(%rip), %rax       # 0x2f12
leaq 0xe8(%rsp), %rsi
movq %rax, (%rsi)
movq $0x0, 0x8(%rsi)
leaq 0x60(%rsp), %rdx
movq %r15, (%rdx)
leaq 0x20(%rsp), %rax
leaq 0x58(%rsp), %rcx
movq %rax, (%rcx)
leaq 0x50(%rsp), %r8
movq %rbp, (%r8)
leaq 0x48(%rsp), %r9
movq %rdi, (%r9)
leaq 0x8(%rsp), %rdi
callq 0x294c
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0xa8(%rsp), %rdx
leaq 0x7(%rsp), %rcx
callq 0x3aa0
leaq 0x8(%rsp), %rdi
callq 0x22c0
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
leaq 0x18ca(%rip), %rsi      # 0x416b
movl $0x5, %edi
xorl %eax, %eax
callq 0x2050
movl %ebx, %edi
callq 0x2360
callq 0x21d0
xorl %edi, %edi
callq 0x2210
movl $0x1, %edi
callq 0x2210
cmpq $0x0, 0x8(%rsp)
je 0x28d9
callq 0x2090
jmp 0x28d9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3432
jmp 0x28fa
jmp 0x28f7
movq %rax, %rbx
movq %r14, %rdi
callq 0x21c0
jmp 0x28fa
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0x2dfc
jmp 0x290c
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r13, %rdi
je 0x2920
callq 0x21c0
jmp 0x2920
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r12, %rdi
je 0x2937
callq 0x21c0
jmp 0x2937
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x2a70
movq %rbx, %rdi
callq 0x22e0