// File: /workspace/github_cpp_makefile_star2_O3/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 $0x88, %rsp
movq %rcx, -0x80(%rbp)
movq %rdx, -0x78(%rbp)
movq %rsi, -0x68(%rbp)
movq %rsp, -0xb0(%rbp)
leaq -0x98(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq %rdi, -0x88(%rbp)
movl 0x8(%rdi), %ebx
movq %rsp, %r13
leaq 0xf(,%rbx,8), %rax
andq $-0x10, %rax
subq %rax, %r13
movq %r13, %rsp
testq %rbx, %rbx
je 0x35cb
leaq (,%rbx,8), %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x2130
movq %rbx, -0x30(%rbp)
movq -0x88(%rbp), %rbx
movl 0x8(%rbx), %eax
movq %rsp, %rdx
leaq 0xf(%rax), %rcx
andq $-0x10, %rcx
subq %rcx, %rdx
movq %rdx, -0x70(%rbp)
movq %rdx, %rsp
testq %rax, %rax
je 0x38db
xorl %r12d, %r12d
movq -0x80(%rbp), %rax
movb (%rax), %al
testb $0x1, %al
je 0x38db
movq -0x68(%rbp), %rdi
callq 0x2280
testl %eax, %eax
jne 0x39ac
movq -0x78(%rbp), %rax
movq (%rax), %rsi
cmpq %rax, %rsi
je 0x373a
movl %r12d, %r14d
xorl %eax, %eax
movq -0x70(%rbp), %rcx
xchgb %al, (%rcx,%r14)
addq $0x10, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x2120
movq -0x78(%rbp), %rdi
movq (%rdi), %rsi
callq 0x3c8c
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %rdi
callq 0x2d5e
movq (%rbx), %r15
movq $0x0, -0x38(%rbp)
movl $0x38, %edi
callq 0x21e0
movq -0x70(%rbp), %rcx
addq %r14, %rcx
leaq 0x36a9(%rip), %rdx      # 0x6d40
movq %rdx, (%rax)
movq %rcx, 0x8(%rax)
movq %r15, 0x10(%rax)
movq %rax, %rcx
addq $0x28, %rcx
movq %rcx, 0x18(%rax)
movq -0x60(%rbp), %rdx
leaq -0x50(%rbp), %rsi
cmpq %rsi, %rdx
je 0x36c8
movq %rdx, 0x18(%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x28(%rax)
jmp 0x36ce
movups (%rsi), %xmm0
movups %xmm0, (%rcx)
movq -0x58(%rbp), %rcx
movq %rcx, 0x20(%rax)
movq %rsi, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movb $0x0, -0x50(%rbp)
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0x21b0
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x3708
movq (%rdi), %rax
callq *0x8(%rax)
cmpq $0x0, (%r13,%r14,8)
jne 0x3a7d
movq -0x38(%rbp), %rax
movq %rax, (%r13,%r14,8)
movq $0x0, -0x38(%rbp)
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x3737
callq 0x21c0
incl %r12d
movq -0x68(%rbp), %rdi
callq 0x2170
cmpl 0x8(%rbx), %r12d
jb 0x35fa
jmp 0x38db
cmpl $0x0, 0x8(%rbx)
je 0x38db
xorl %r14d, %r14d
movl %r14d, %r15d
movq -0x70(%rbp), %rax
movb (%rax,%r15), %al
testb $0x1, %al
je 0x38ce
movq -0x68(%rbp), %rdi
callq 0x2280
testl %eax, %eax
movq -0x30(%rbp), %r12
jne 0x39a5
movq -0x78(%rbp), %rax
cmpq %rax, (%rax)
je 0x38c5
leaq (,%r15,8), %r12
addq %r13, %r12
movq %r12, %rdi
callq 0x22c0
movq -0x78(%rbp), %rbx
addq -0x70(%rbp), %r15
xorl %eax, %eax
xchgb %al, (%r15)
movq (%rbx), %rsi
addq $0x10, %rsi
leaq -0xa8(%rbp), %rdi
callq 0x2120
movq (%rbx), %rsi
movq %rbx, %rdi
callq 0x3c8c
leaq -0x50(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0xa8(%rbp), %rsi
movq -0xa0(%rbp), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %rdi
callq 0x2d5e
movq %r13, %rbx
movq -0x88(%rbp), %rax
movq (%rax), %r13
movq $0x0, -0x38(%rbp)
movl $0x38, %edi
callq 0x21e0
leaq 0x3566(%rip), %rcx      # 0x6d80
movq %rcx, (%rax)
movq %r15, 0x8(%rax)
movq %r13, 0x10(%rax)
movq %rax, %rcx
addq $0x28, %rcx
movq %rcx, 0x18(%rax)
movq -0x60(%rbp), %rdx
leaq -0x50(%rbp), %rsi
cmpq %rsi, %rdx
je 0x384b
movq %rdx, 0x18(%rax)
movq -0x50(%rbp), %rcx
movq %rcx, 0x28(%rax)
jmp 0x3851
movups (%rsi), %xmm0
movups %xmm0, (%rcx)
movq %rbx, %r13
movq -0x58(%rbp), %rcx
movq %rcx, 0x20(%rax)
movq %rsi, -0x60(%rbp)
movq $0x0, -0x58(%rbp)
movb $0x0, -0x50(%rbp)
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x40(%rbp), %rsi
xorl %edx, %edx
callq 0x21b0
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x388e
movq (%rdi), %rax
callq *0x8(%rax)
cmpq $0x0, (%r12)
movq -0x88(%rbp), %rbx
jne 0x3a7d
movq -0x38(%rbp), %rax
movq %rax, (%r12)
movq $0x0, -0x38(%rbp)
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x38c2
callq 0x21c0
incl %r14d
movq -0x68(%rbp), %rdi
callq 0x2170
incl %r14d
cmpl 0x8(%rbx), %r14d
jb 0x375f
movq -0x80(%rbp), %rax
movb (%rax), %al
testb $0x1, %al
jne 0x3752
leaq 0xdb5(%rip), %rsi       # 0x46a5
movl $0x5, %edi
xorl %eax, %eax
callq 0x2050
leaq -0x60(%rbp), %r14
movq $0x2, (%r14)
movq $0x0, 0x8(%r14)
movq -0x30(%rbp), %r12
movq %r14, %rdi
movq %r14, %rsi
callq 0x20a0
cmpl $-0x1, %eax
jne 0x392d
callq 0x2030
cmpl $0x4, (%rax)
je 0x3913
cmpl $0x0, 0x8(%rbx)
je 0x395c
xorl %r15d, %r15d
movq %r13, %r14
movq -0x70(%rbp), %rax
movb (%rax,%r15), %al
testb $0x1, %al
je 0x394d
movq %r14, %rdi
callq 0x22c0
incq %r15
movl 0x8(%rbx), %eax
addq $0x8, %r14
cmpq %rax, %r15
jb 0x3939
testq %r12, %r12
je 0x3977
shlq $0x3, %r12
cmpq $0x0, -0x8(%r13,%r12)
jne 0x3a7d
addq $-0x8, %r12
jne 0x3965
movq -0xb0(%rbp), %rsp
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x3996
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 0x39f0
movq %rax, %r15
jmp 0x39d3
jmp 0x39bc
movq %rax, %r15
jmp 0x39e5
movq %rax, %r15
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x39d3
movq (%rdi), %rax
callq *0x8(%rax)
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
je 0x39e5
callq 0x21c0
movq -0x68(%rbp), %rdi
callq 0x2170
jmp 0x39f3
movq %rax, %r15
movq -0x30(%rbp), %r12
jmp 0x3a46
jmp 0x3a31
jmp 0x3a31
movq %rax, %r15
movq -0x40(%rbp), %rdi
testq %rdi, %rdi
je 0x3a16
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x3a16
jmp 0x3a36
movq %rax, %r15
movq -0x30(%rbp), %r12
movq -0x60(%rbp), %rdi
leaq -0x50(%rbp), %rax
cmpq %rax, %rdi
movq %rbx, %r13
je 0x3a3d
callq 0x21c0
jmp 0x3a3d
movq %rax, %r15
jmp 0x3a46
movq %rax, %r15
movq -0x30(%rbp), %r12
movq -0x68(%rbp), %rdi
callq 0x2170
testq %r12, %r12
je 0x3a5d
shlq $0x3, %r12
cmpq $0x0, -0x8(%r13,%r12)
jne 0x3a7d
addq $-0x8, %r12
jne 0x3a4f
movq -0xa8(%rbp), %rdi
leaq -0x98(%rbp), %rax
cmpq %rax, %rdi
je 0x3a75
callq 0x21c0
movq %r15, %rdi
callq 0x22e0
callq 0x2090