// File: /workspace/github_cpp_makefile_star2_O2/mrGoncharuk[P]foldermonitor/src/MigrationManager.cpp
// Function: MigrationManager::migrateThreaded(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	MigrationManager::migrateThreaded(std::mutex &list_mutex, std::list<std::string> &filenames, std::atomic<bool> &isRunning)
{
	std::string currFileName;
	std::thread migrateThreads[threadAmount];
	std::atomic<bool> isThreadFinished[threadAmount];
	unsigned int i = 0;

	while (i < threadAmount && isRunning)
	{
		std::lock_guard<std::mutex> lock(list_mutex);
		if (!filenames.empty())
		{
			isThreadFinished[i] = false;
			currFileName = filenames.front();
			filenames.pop_front();
			migrateThreads[i] = std::thread(
				[currFileName](IDB *idb, std::atomic<bool> &isReady)
				{
					std::string query = FileReader::extractData(currFileName);
					idb->executeQuery(query);
					isReady = true;
				},
				this->dbwriter, std::ref(isThreadFinished[i]));
			i++;
		}
	}
	while (isRunning)
	{
		for (i = 0; i < threadAmount; i++)
		{
			if (isThreadFinished[i])
			{
				std::lock_guard<std::mutex> lock(list_mutex);
				if (!filenames.empty())
				{
					migrateThreads[i].join();
					isThreadFinished[i] = false;
					currFileName = filenames.front();
					filenames.pop_front();
					migrateThreads[i] = std::thread(
						[currFileName](IDB *idb, std::atomic<bool> &isReady)
						{
							std::string query = FileReader::extractData(currFileName);
							idb->executeQuery(query);
							isReady = true;
						},
						this->dbwriter, std::ref(isThreadFinished[i]));
					i++;
				}
			}
		}
	}
	syslog(LOG_NOTICE, "MM> Waiting for end of threads task.");
	std::this_thread::sleep_for(std::chrono::seconds(2));
	for (i = 0; i < threadAmount; i++)
	{
		if (isThreadFinished[i])
			migrateThreads[i].join();
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, -0x88(%rbp)
movq %rdx, %r15
movq %rsi, -0x40(%rbp)
leaq -0xa8(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movq %rsp, -0x90(%rbp)
movb $0x0, (%rax)
movq %rdi, -0x48(%rbp)
movl 0x8(%rdi), %r12d
movq %rsp, %r14
leaq 0xf(,%r12,8), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
testq %r12, %r12
je 0x3368
leaq (,%r12,8), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2150
movq -0x48(%rbp), %rax
movl 0x8(%rax), %eax
movq %rsp, %rdx
movq %rax, %rcx
addq $0xf, %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, -0x50(%rbp)
movq %rdx, %rsp
xorl %r13d, %r13d
leaq -0xb8(%rbp), %rbx
movq %r14, -0x30(%rbp)
cmpl %eax, %r13d
jae 0x34ce
movq -0x88(%rbp), %rax
movb (%rax), %al
testb $0x1, %al
je 0x34ce
movq -0x40(%rbp), %rdi
callq 0x2ca2
movq (%r15), %rsi
cmpq %r15, %rsi
je 0x3444
movl %r13d, %r14d
xorl %eax, %eax
movq -0x50(%rbp), %rcx
xchgb %al, (%rcx,%r14)
addq $0x10, %rsi
movq %rbx, %rdi
callq 0x2140
movq %r15, %rdi
callq 0x38fc
leaq -0x78(%rbp), %rdi
movq %rbx, %rsi
callq 0x2280
andq $0x0, -0x58(%rbp)
pushq $0x38
popq %rdi
callq 0x21f0
movq -0x50(%rbp), %rcx
addq %r14, %rcx
leaq 0x3934(%rip), %rdx      # 0x6d40
movq %rdx, (%rax)
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rcx
addq $0x28, %rcx
movq %rcx, 0x18(%rax)
movq -0x78(%rbp), %rdx
leaq -0x68(%rbp), %rsi
cmpq %rsi, %rdx
je 0x344a
movq %rdx, 0x18(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x28(%rax)
jmp 0x3450
movq -0x30(%rbp), %r14
jmp 0x34b9
movups (%rsi), %xmm0
movups %xmm0, (%rcx)
movq -0x70(%rbp), %rcx
movq %rsi, -0x78(%rbp)
andq $0x0, -0x70(%rbp)
movq %rcx, 0x20(%rax)
movb $0x0, -0x68(%rbp)
movq %rax, -0x38(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x21c0
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x3487
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x30(%rbp), %rax
leaq (%rax,%r14,8), %rdi
movq %rax, %r14
leaq -0x58(%rbp), %rbx
movq %rbx, %rsi
callq 0x3904
movq %rbx, %rdi
callq 0x2996
leaq -0x78(%rbp), %rdi
callq 0x20f0
incl %r13d
leaq -0xb8(%rbp), %rbx
movq -0x40(%rbp), %rdi
callq 0x2180
movq -0x48(%rbp), %rax
movl 0x8(%rax), %eax
jmp 0x3395
movq %r12, -0x80(%rbp)
movq -0x88(%rbp), %rax
movb (%rax), %al
testb $0x1, %al
je 0x3634
xorl %r13d, %r13d
movq -0x48(%rbp), %rax
cmpl 0x8(%rax), %r13d
jae 0x34d2
movq %r15, %rbx
movl %r13d, %r15d
movq -0x50(%rbp), %rax
movb (%rax,%r15), %al
testb $0x1, %al
je 0x35ae
movq -0x40(%rbp), %rdi
callq 0x2ca2
cmpq %rbx, (%rbx)
je 0x35b3
leaq (%r14,%r15,8), %rdi
movq %rdi, -0x98(%rbp)
callq 0x22f0
leaq -0xb8(%rbp), %r14
movq %rbx, %r12
addq -0x50(%rbp), %r15
xorl %eax, %eax
xchgb %al, (%r15)
movq (%rbx), %rsi
addq $0x10, %rsi
movq %r14, %rdi
callq 0x2140
movq %r12, %rdi
callq 0x38fc
leaq -0x78(%rbp), %rdi
movq %r14, %rsi
callq 0x2280
andq $0x0, -0x58(%rbp)
pushq $0x38
popq %rdi
movq -0x80(%rbp), %r12
callq 0x21f0
leaq 0x380a(%rip), %rcx      # 0x6d80
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rcx
addq $0x28, %rcx
movq %rcx, 0x18(%rax)
movq -0x78(%rbp), %rdx
leaq -0x68(%rbp), %rsi
cmpq %rsi, %rdx
je 0x35b8
movq %rdx, 0x18(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x28(%rax)
jmp 0x35be
movq %rbx, %r15
jmp 0x362c
movq %rbx, %r15
jmp 0x3623
movups (%rsi), %xmm0
movups %xmm0, (%rcx)
movq %rbx, %r15
movq -0x70(%rbp), %rcx
movq %rsi, -0x78(%rbp)
andq $0x0, -0x70(%rbp)
movq %rcx, 0x20(%rax)
movb $0x0, -0x68(%rbp)
movq %rax, -0x38(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x21c0
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x35f8
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x98(%rbp), %rdi
leaq -0x58(%rbp), %rbx
movq %rbx, %rsi
callq 0x3904
movq %rbx, %rdi
callq 0x2996
leaq -0x78(%rbp), %rdi
callq 0x20f0
incl %r13d
movq -0x30(%rbp), %r14
movq -0x40(%rbp), %rdi
callq 0x2180
incl %r13d
jmp 0x34e6
leaq 0x104a(%rip), %rsi      # 0x4685
pushq $0x5
popq %rdi
xorl %eax, %eax
callq 0x2050
leaq -0x78(%rbp), %rdi
movq $0x2, (%rdi)
callq 0x391e
xorl %r15d, %r15d
movq -0x48(%rbp), %rax
movl 0x8(%rax), %eax
cmpq %rax, %r15
jae 0x3681
movq -0x50(%rbp), %rax
movb (%rax,%r15), %al
testb $0x1, %al
je 0x3678
movq %r14, %rdi
callq 0x22f0
incq %r15
addq $0x8, %r14
jmp 0x3658
testq %r12, %r12
movq -0x30(%rbp), %r14
je 0x36a1
addq $-0x8, %r14
shlq $0x3, %r12
leaq (%r14,%r12), %rdi
callq 0x2996
addq $-0x8, %r12
jne 0x3692
movq -0x90(%rbp), %rsp
leaq -0xb8(%rbp), %rdi
callq 0x20f0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x372c
jmp 0x372c
movq %rax, %r15
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x36de
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x36de
movq %rax, %r15
leaq -0x78(%rbp), %rdi
callq 0x20f0
jmp 0x36ee
jmp 0x36eb
movq %rax, %r15
movq -0x40(%rbp), %rdi
callq 0x2180
jmp 0x36fe
jmp 0x36fb
movq %rax, %r15
movq -0x30(%rbp), %r14
jmp 0x3745
movq %rax, %r15
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x371b
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x371b
movq %rax, %r15
movq -0x30(%rbp), %r14
leaq -0x78(%rbp), %rdi
callq 0x20f0
jmp 0x373c
jmp 0x3731
movq %rax, %r15
jmp 0x3745
movq %rax, %r15
movq -0x30(%rbp), %r14
movq -0x80(%rbp), %r12
movq -0x40(%rbp), %rdi
callq 0x2180
testq %r12, %r12
je 0x3761
addq $-0x8, %r14
shlq $0x3, %r12
leaq (%r14,%r12), %rdi
callq 0x2996
addq $-0x8, %r12
jne 0x3752
leaq -0xb8(%rbp), %rdi
callq 0x20f0
movq %r15, %rdi
callq 0x2310
nop