// File: /workspace/github_cpp_makefile_star2_O1/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, -0x58(%rbp)
movq %rsp, -0xb8(%rbp)
leaq -0xa0(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rdi, -0x40(%rbp)
movl 0x8(%rdi), %ebx
movq %rsp, %r14
leaq 0xf(,%rbx,8), %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
testq %rbx, %rbx
je 0x35c2
leaq (,%rbx,8), %rdx
movq %r14, %rdi
xorl %esi, %esi
callq 0x2130
movq %r14, -0x30(%rbp)
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
movq %rsp, %rdx
leaq 0xf(%rax), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, -0x60(%rbp)
movq %rdx, %rsp
testq %rax, %rax
je 0x3741
xorl %r12d, %r12d
leaq -0x70(%rbp), %r13
movq -0x88(%rbp), %rax
movb (%rax), %al
testb $0x1, %al
je 0x3741
movq -0x58(%rbp), %rdi
callq 0x2280
testl %eax, %eax
jne 0x39b6
cmpq %r15, (%r15)
je 0x372a
movl %r12d, %r14d
xorl %eax, %eax
movq -0x60(%rbp), %rcx
xchgb %al, (%rcx,%r14)
movq (%r15), %rsi
addq $0x10, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x2120
movq (%r15), %rsi
movq %r15, %rdi
callq 0x3caa
movq %r13, -0x80(%rbp)
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0x2d6a
movq $0x0, -0x50(%rbp)
movl $0x38, %edi
callq 0x21e0
movq -0x60(%rbp), %rcx
addq %r14, %rcx
leaq 0x36ba(%rip), %rdx      # 0x6d40
movq %rdx, (%rax)
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rcx
addq $0x28, %rcx
movq %rcx, 0x18(%rax)
movq -0x80(%rbp), %rdx
cmpq %r13, %rdx
je 0x36ba
movq %rdx, 0x18(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x28(%rax)
jmp 0x36c2
movups (%r13), %xmm0
movups %xmm0, (%rcx)
movq -0x78(%rbp), %rcx
movq %rcx, 0x20(%rax)
movq %r13, -0x80(%rbp)
movq $0x0, -0x78(%rbp)
movb $0x0, -0x70(%rbp)
movq %rax, -0x38(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x21b0
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x36fc
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x30(%rbp), %rdx
movq (%rdx,%r14,8), %rax
testq %rax, %rax
jne 0x3a9a
movq -0x50(%rbp), %rcx
movq %rcx, (%rdx,%r14,8)
movq %rax, -0x50(%rbp)
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x3727
callq 0x21c0
incl %r12d
movq -0x58(%rbp), %rdi
callq 0x2170
movq -0x40(%rbp), %rax
cmpl 0x8(%rax), %r12d
jb 0x35f2
movq %rbx, -0x48(%rbp)
movq %r15, -0x90(%rbp)
movq -0x88(%rbp), %rax
movb (%rax), %al
testb $0x1, %al
movq -0x30(%rbp), %r12
je 0x38eb
leaq -0x70(%rbp), %r13
movq -0x90(%rbp), %rbx
movq -0x40(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x38da
xorl %r14d, %r14d
movl %r14d, %r15d
movq -0x60(%rbp), %rax
movb (%rax,%r15), %al
testb $0x1, %al
je 0x38c9
movq -0x58(%rbp), %rdi
callq 0x2280
testl %eax, %eax
jne 0x39af
movq -0x90(%rbp), %rax
cmpq %rax, (%rax)
je 0x38c0
leaq (%r12,%r15,8), %r12
movq %r12, %rdi
callq 0x22c0
addq -0x60(%rbp), %r15
xorl %eax, %eax
xchgb %al, (%r15)
movq (%rbx), %rsi
addq $0x10, %rsi
leaq -0xb0(%rbp), %rdi
callq 0x2120
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x3caa
movq %r13, -0x80(%rbp)
movq -0xb0(%rbp), %rsi
movq -0xa8(%rbp), %rdx
addq %rsi, %rdx
leaq -0x80(%rbp), %rdi
callq 0x2d6a
movq $0x0, -0x50(%rbp)
movl $0x38, %edi
callq 0x21e0
leaq 0x3565(%rip), %rcx      # 0x6d80
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
movq -0x40(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x10(%rax)
movq %rax, %rcx
addq $0x28, %rcx
movq %rcx, 0x18(%rax)
movq -0x80(%rbp), %rdx
movq %r13, %rsi
cmpq %r13, %rdx
je 0x3852
movq %rdx, 0x18(%rax)
movq -0x70(%rbp), %rcx
movq %rcx, 0x28(%rax)
jmp 0x3858
movups (%rsi), %xmm0
movups %xmm0, (%rcx)
movq -0x78(%rbp), %rcx
movq %rcx, 0x20(%rax)
movq %rsi, -0x80(%rbp)
movq $0x0, -0x78(%rbp)
movb $0x0, -0x70(%rbp)
movq %rax, -0x38(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x38(%rbp), %rsi
xorl %edx, %edx
callq 0x21b0
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x3892
movq (%rdi), %rax
callq *0x8(%rax)
movq (%r12), %rax
testq %rax, %rax
jne 0x3a9a
movq -0x50(%rbp), %rcx
movq %rcx, (%r12)
movq %rax, -0x50(%rbp)
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x38b9
callq 0x21c0
incl %r14d
movq -0x30(%rbp), %r12
movq -0x58(%rbp), %rdi
callq 0x2170
incl %r14d
movq -0x40(%rbp), %rax
cmpl 0x8(%rax), %r14d
jb 0x377d
movq -0x88(%rbp), %rax
movb (%rax), %al
testb $0x1, %al
jne 0x376c
leaq 0xdb3(%rip), %rsi       # 0x46a5
movl $0x5, %edi
xorl %eax, %eax
callq 0x2050
leaq -0x80(%rbp), %r14
movq $0x2, (%r14)
movq $0x0, 0x8(%r14)
movq -0x48(%rbp), %rbx
movq %r14, %rdi
movq %r14, %rsi
callq 0x20a0
cmpl $-0x1, %eax
jne 0x392f
callq 0x2030
cmpl $0x4, (%rax)
je 0x3915
movq -0x40(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x3966
xorl %r15d, %r15d
movq %r12, %r14
movq -0x60(%rbp), %rax
movb (%rax,%r15), %al
testb $0x1, %al
je 0x3953
movq %r14, %rdi
callq 0x22c0
incq %r15
movq -0x40(%rbp), %rax
movl 0x8(%rax), %eax
addq $0x8, %r14
cmpq %rax, %r15
jb 0x393f
testq %rbx, %rbx
je 0x3981
shlq $0x3, %rbx
cmpq $0x0, -0x8(%r12,%rbx)
jne 0x3a9a
addq $-0x8, %rbx
jne 0x396f
movq -0xb8(%rbp), %rsp
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x39a0
callq 0x21c0
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x2140
movl %eax, %edi
callq 0x2140
jmp 0x3a46
movq %rax, %r15
jmp 0x39e8
jmp 0x39c9
movq %rax, %r15
jmp 0x39f6
movq %rax, %r15
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x39e0
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, -0x38(%rbp)
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x39f6
callq 0x21c0
movq -0x58(%rbp), %rdi
callq 0x2170
jmp 0x3a04
movq %rax, %r15
movq -0x30(%rbp), %r12
jmp 0x3a63
jmp 0x3a0c
movq %rax, %r15
jmp 0x3a63
movq %rax, %r15
jmp 0x3a32
jmp 0x3a4f
movq %rax, %r15
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x3a2a
movq (%rdi), %rax
callq *0x8(%rax)
movq $0x0, -0x38(%rbp)
movq -0x30(%rbp), %r12
movq -0x80(%rbp), %rdi
cmpq %r13, %rdi
je 0x3a56
callq 0x21c0
jmp 0x3a56
movq %rax, %r15
movq -0x48(%rbp), %rbx
jmp 0x3a63
movq %rax, %r15
movq -0x30(%rbp), %r12
movq -0x48(%rbp), %rbx
movq -0x58(%rbp), %rdi
callq 0x2170
testq %rbx, %rbx
je 0x3a7a
shlq $0x3, %rbx
cmpq $0x0, -0x8(%r12,%rbx)
jne 0x3a9a
addq $-0x8, %rbx
jne 0x3a6c
movq -0xb0(%rbp), %rdi
leaq -0xa0(%rbp), %rax
cmpq %rax, %rdi
je 0x3a92
callq 0x21c0
movq %r15, %rdi
callq 0x22e0
callq 0x2090
nop