// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xf8, %rsp
callq 0x251c
leaq 0x90(%rsp), %r12
movq %r12, 0x8(%r12)
movq %r12, (%r12)
andq $0x0, 0x10(%r12)
movl %eax, %ebx
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
andq $0x0, 0x40(%rsp)
leaq 0x1a65(%rip), %rsi      # 0x411e
leaq 0xc8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x20d0
leaq 0x1a6b(%rip), %rsi      # 0x413d
leaq 0xa8(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x20d0
leaq 0x68(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x2d00
pushq $0x58
popq %rdi
callq 0x21f0
movq %rax, %r14
leaq 0xa8(%rsp), %rsi
movq %rax, %rdi
callq 0x2af8
callq 0x2270
movl %eax, %r15d
leaq 0x1a6a(%rip), %rsi      # 0x418a
pushq $0x5
popq %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x2050
leal -0x2(%r15), %eax
cmpl $0x4, %r15d
pushq $0x1
popq %rdx
cmovael %eax, %edx
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x320c
leaq 0x68(%rsp), %r15
movq %r15, %rdi
callq 0x2d44
testb %al, %al
je 0x2817
movq (%r14), %rax
movq %r14, %rdi
callq *(%rax)
testb %al, %al
je 0x2817
movb $0x1, %al
leaq 0x7(%rsp), %rdi
xchgb %al, (%rdi)
leaq 0x62a(%rip), %rax       # 0x2da6
leaq 0xe8(%rsp), %rsi
movq %rax, (%rsi)
andq $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 %r12, (%r8)
leaq 0x48(%rsp), %r9
movq %rdi, (%r9)
leaq 0x8(%rsp), %rdi
callq 0x28f2
leaq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rsi
leaq 0x90(%rsp), %rdx
leaq 0x7(%rsp), %rcx
callq 0x3776
leaq 0x8(%rsp), %rdi
callq 0x22f0
movq (%r14), %rax
movq %r14, %rdi
callq *0x10(%rax)
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
leaq 0x1971(%rip), %rsi      # 0x416b
pushq $0x5
popq %rdi
xorl %eax, %eax
callq 0x2050
movl %ebx, %edi
callq 0x2390
callq 0x21e0
xorl %edi, %edi
callq 0x2220
pushq $0x1
popq %rdi
callq 0x2220
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2996
jmp 0x2833
jmp 0x2830
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3224
jmp 0x2851
jmp 0x284e
movq %rax, %rbx
movq %r14, %rdi
callq 0x21d0
jmp 0x2851
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x2cb8
jmp 0x2860
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x20f0
jmp 0x2872
movq %rax, %rbx
leaq 0xc8(%rsp), %rdi
callq 0x20f0
jmp 0x2884
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x2a3c
movq %rbx, %rdi
callq 0x2310