// File: /workspace/github_cpp_makefile_star2_O2/ksabry[P]bfbrute/src/ProgramSearch.h
// Function: ProgramSearch<ProgramIterator<400ul, 32ul, 12ul, 32ul>, DataCache<32ul, 12ul>>::FindStringThread(unsigned long)
void FindStringThread(uint_fast32_t threadIdx)
	{
		static const uint_fast32_t countUpdate = 100000;
		static const uint_fast32_t countSave = 1000000;

		auto& iterator = iterators[threadIdx];

		uint_fast32_t threadCount = 0;
		while (iterator.Next())
		{
			uint_fast32_t stringDist;

			if (++threadCount % countUpdate == 0)
			{
				lock.lock();
				this->count += countUpdate;

				if (printProgress)
				{
					uint_fast64_t currentCount = 0;
					for (int i = 0; i < THREAD_COUNT; i++)
					{
						currentCount += iterators[i].currentCount;
					}

					double proportion = static_cast<double>(currentCount) / static_cast<double>(programSizeCount);
					auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - sizeStart).count();
					uint_fast64_t remaining = static_cast<double>(elapsed) * (1-proportion) / proportion;

					auto seconds = remaining % 60;
					auto minutes = remaining / 60 % 60;
					auto hours = remaining / 3600 % 24;
					auto days = remaining / 86400;
					
					std::cout 
						<< std::right
						<< " " << programSize
						<< " " << std::setw(10) << std::setprecision(6) << std::fixed << proportion * 100 << "%"
						<< " " << iterator.GetProgram()
						<< " Estimated remaining " << std::setw(3) << days << ":" << std::setfill('0') << std::setw(2) << hours << ":" << std::setw(2) << minutes << ":" << std::setw(2) << seconds << std::setfill(' ')
						<< "          \r" << std::flush;
				}
				lock.unlock();
			}

			if (threadCount % countSave == 0)
			{
				SaveFindStringProgress();
			}

			if (!iterator.Execute(inputs[0], input_sizes[0]))
			{
				continue;
			}

			stringDist = iterator.StringDistance(outputs[0], output_sizes[0], SHOW_ALL_PROGRAMS_LENGTH - programSize);
			if (stringDist + programSize > SHOW_ALL_PROGRAMS_LENGTH)
			{
				continue;
			}

			std::string postProgram = iterator.StringDistanceOutput(outputs[0], output_sizes[0], SHOW_ALL_PROGRAMS_LENGTH - programSize);
			programResult = std::string(iterator.GetProgram()) + postProgram;

			lock.lock();

			std::cout 
				<< std::right << std::setw(3) << std::setfill(' ') << stringDist + programSize
				<< " " << programResult << std::endl;

			std::ofstream file("output.txt", std::ofstream::app);
			file
				<< std::right << std::setw(3) << std::setfill(' ') << stringDist + programSize
				<< " " << programResult << std::endl;
			file.close();
			
			if (printProgress)
			{
				uint_fast64_t currentCount = 0;
				for (int i = 0; i < THREAD_COUNT; i++)
				{
					currentCount += iterators[i].currentCount;
				}

				double proportion = static_cast<double>(currentCount) / static_cast<double>(programSizeCount);
				auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() - sizeStart).count();
				uint_fast64_t remaining = static_cast<double>(elapsed) * (1-proportion) / proportion;

				auto seconds = remaining % 60;
				auto minutes = remaining / 60 % 60;
				auto hours = remaining / 3600 % 24;
				auto days = remaining / 86400;
				
				std::cout 
					<< std::right
					<< " " << programSize
					<< " " << std::setw(10) << std::setprecision(6) << std::fixed << proportion * 100 << "%"
					<< " " << iterator.GetProgram()
					<< " Estimated remaining " << std::setw(3) << days << ":" << std::setfill('0') << std::setw(2) << hours << ":" << std::setw(2) << minutes << ":" << std::setw(2) << seconds << std::setfill(' ')
					<< "          \r" << std::flush;
			}

			lock.unlock();

			SaveFindStringProgress();
		}
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movq %rdi, %rbx
imulq $0x4578, %rsi, %rax     # imm = 0x4578
leaq (%rdi,%rax), %r14
addq $0x401f8, %r14          # imm = 0x401F8
leaq 0x859f8(%rdi), %rax
movq %rax, 0x18(%rsp)
xorl %r12d, %r12d
movq %r14, %rdi
callq 0x621c
testb %al, %al
je 0x604f
incq %r12
movq %r12, %rax
xorl %edx, %edx
movl $0x186a0, %ecx          # imm = 0x186A0
divq %rcx
testq %rdx, %rdx
jne 0x5b70
leaq 0x7961(%rip), %rdi      # 0xd218
callq 0x48fe
addq $0x186a0, 0x85a98(%rbx) # imm = 0x186A0
cmpb $0x1, (%rbx)
jne 0x5b64
xorl %ecx, %ecx
xorl %eax, %eax
cmpq $0x45780, %rcx          # imm = 0x45780
je 0x58ee
addq 0x44468(%rbx,%rcx), %rax
addq $0x4578, %rcx           # imm = 0x4578
jmp 0x58d4
movq %rax, %xmm0
movq 0x2715(%rip), %xmm1     # 0x8010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x2719(%rip), %xmm2     # 0x8020
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq 0x85a28(%rbx), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
movapd %xmm3, 0x20(%rsp)
callq 0x2030
subq 0x85a30(%rbx), %rax
cqto
movl $0x3b9aca00, %ecx       # imm = 0x3B9ACA00
idivq %rcx
cvtsi2sd %rax, %xmm0
movsd 0x26d0(%rip), %xmm1     # 0x8030
movapd 0x20(%rsp), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
divsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd 0x26b2(%rip), %xmm1     # 0x8038
cvttsd2si %xmm1, %rcx
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, %rax
xorl %edx, %edx
pushq $0x3c
popq %rsi
divq %rsi
movq %rdx, 0x10(%rsp)
xorl %edx, %edx
divq %rsi
movq %rdx, 0x8(%rsp)
movq %rcx, %rax
xorl %edx, %edx
movl $0xe10, %esi            # imm = 0xE10
divq %rsi
xorl %edx, %edx
pushq $0x18
popq %rsi
divq %rsi
movq %rdx, %rbp
movq %rcx, %rax
xorl %edx, %edx
movl $0x15180, %ecx          # imm = 0x15180
divq %rcx
movq %rax, %r15
movq 0x75fe(%rip), %rdi      # 0xcfd8
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl 0x18(%rdi,%rax), %ecx
movl $0xffffff4f, %edx       # imm = 0xFFFFFF4F
andl %edx, %ecx
orl $0x80, %ecx
movl %ecx, 0x18(%rdi,%rax)
leaq 0x2701(%rip), %r13      # 0x80fe
movq %r13, %rsi
callq 0x2210
movq 0x85a20(%rbx), %rsi
movq %rax, %rdi
callq 0x2140
movq %rax, %rdi
movq %r13, %rsi
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0xa, 0x10(%rax,%rdx)
movq -0x18(%rcx), %rdx
movq $0x6, 0x8(%rax,%rdx)
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
movl $0xfffffefb, %esi       # imm = 0xFFFFFEFB
andl %esi, %edx
orl $0x4, %edx
movl %edx, 0x18(%rax,%rcx)
movapd 0x20(%rsp), %xmm0
mulsd 0x25e0(%rip), %xmm0     # 0x8040
movq %rax, %rdi
callq 0x2320
movq %rax, %rdi
leaq 0x2bfd(%rip), %rsi      # 0x866f
callq 0x2210
movq %rax, %rdi
movq %r13, %rsi
callq 0x2210
movq %rax, %r13
movq %r14, %rdi
callq 0x62de
movq %r13, %rdi
movq %rax, %rsi
callq 0x2210
movq %rax, %rdi
leaq 0x2bcf(%rip), %rsi      # 0x8671
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x3, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x2bbb(%rip), %r15      # 0x8687
movq %r15, %rsi
callq 0x2210
movq %rax, %rdi
pushq $0x30
popq %rsi
callq 0x2310
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
pushq $0x2
popq %r13
movq %r13, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2140
movq %rax, %rdi
movq %r15, %rsi
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r13, 0x10(%rax,%rcx)
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x2140
movq %rax, %rdi
movq %r15, %rsi
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq %r13, 0x10(%rax,%rcx)
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x2140
movq %rax, %rdi
pushq $0x20
popq %rsi
callq 0x2310
movq %rax, %rdi
leaq 0x2b32(%rip), %rsi      # 0x8689
callq 0x2210
movq %rax, %rdi
callq 0x2150
leaq 0x76ad(%rip), %rdi      # 0xd218
callq 0x2170
movq %r12, %rax
xorl %edx, %edx
movl $0xf4240, %ecx          # imm = 0xF4240
divq %rcx
testq %rdx, %rdx
jne 0x5b8a
movq %rbx, %rdi
callq 0x63b4
movq 0x85a38(%rbx), %rax
movq 0x85a50(%rbx), %rcx
movq (%rax), %rsi
movq (%rcx), %rdx
movq %r14, %rdi
callq 0x64e4
testb %al, %al
je 0x5887
movq 0x85a68(%rbx), %rax
movq 0x85a80(%rbx), %rcx
movq (%rax), %rsi
movq (%rcx), %rdx
pushq $0x55
popq %rcx
subq 0x85a20(%rbx), %rcx
movq %r14, %rdi
callq 0x66d8
movq %rax, %r15
movq 0x85a20(%rbx), %rax
leaq (%rax,%r15), %rcx
cmpq $0x55, %rcx
ja 0x5887
movq 0x85a68(%rbx), %rcx
movq 0x85a80(%rbx), %rsi
movq (%rcx), %rdx
movq (%rsi), %rcx
pushq $0x55
popq %r8
subq %rax, %r8
leaq 0x38(%rsp), %rdi
movq %r14, %rsi
callq 0x673c
movq %r14, %rdi
callq 0x62de
leaq 0x58(%rsp), %r13
movq %r13, %rdi
movq %rax, %rsi
leaq 0x7(%rsp), %rdx
callq 0x26c6
leaq 0x78(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
leaq 0x38(%rsp), %rdx
callq 0x67b1
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x2270
movq %rbp, %rdi
callq 0x20b0
movq %r13, %rdi
callq 0x20b0
leaq 0x75ae(%rip), %rdi      # 0xd218
callq 0x48fe
movq 0x7362(%rip), %rdi      # 0xcfd8
movq (%rdi), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rdi,%rcx), %edx
movl $0xffffff4f, %esi       # imm = 0xFFFFFF4F
andl %esi, %edx
orl $0x80, %edx
movl %edx, 0x18(%rdi,%rcx)
movq -0x18(%rax), %rax
movq $0x3, 0x10(%rdi,%rax)
pushq $0x20
popq %rsi
callq 0x2310
movq 0x85a20(%rbx), %rsi
addq %r15, %rsi
movq %rax, %rdi
callq 0x2140
movq %rax, %rdi
leaq 0x243b(%rip), %rsi      # 0x80fe
callq 0x2210
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x20d0
leaq 0x78(%rsp), %r13
movq %r13, %rdi
leaq 0x29a9(%rip), %rsi      # 0x8695
pushq $0x1
popq %rdx
callq 0x2250
movq 0x78(%rsp), %rax
movq -0x18(%rax), %rcx
movl 0x90(%rsp,%rcx), %edx
movl $0xffffff4f, %esi       # imm = 0xFFFFFF4F
andl %esi, %edx
orl $0x80, %edx
movl %edx, 0x90(%rsp,%rcx)
movq -0x18(%rax), %rax
movq $0x3, 0x88(%rsp,%rax)
movq %r13, %rdi
pushq $0x20
popq %rsi
callq 0x2310
addq 0x85a20(%rbx), %r15
movq %rax, %rdi
movq %r15, %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x23af(%rip), %rsi      # 0x80fe
callq 0x2210
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x21d0
movq %rax, %rdi
callq 0x20d0
leaq 0x78(%rsp), %rdi
callq 0x22b0
cmpb $0x1, (%rbx)
jne 0x6022
xorl %ecx, %ecx
xorl %eax, %eax
cmpq $0x45780, %rcx          # imm = 0x45780
je 0x5d9a
addq 0x44468(%rbx,%rcx), %rax
addq $0x4578, %rcx           # imm = 0x4578
jmp 0x5d80
movq %rax, %xmm0
movq 0x2269(%rip), %xmm1     # 0x8010
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x226d(%rip), %xmm2     # 0x8020
subpd %xmm2, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq 0x85a28(%rbx), %xmm0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
subpd %xmm2, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
movapd %xmm3, 0x20(%rsp)
callq 0x2030
subq 0x85a30(%rbx), %rax
cqto
movl $0x3b9aca00, %ecx       # imm = 0x3B9ACA00
idivq %rcx
cvtsi2sd %rax, %xmm0
movsd 0x2224(%rip), %xmm1     # 0x8030
movapd 0x20(%rsp), %xmm2
subsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
divsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
subsd 0x2206(%rip), %xmm1     # 0x8038
cvttsd2si %xmm1, %rcx
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, %rax
xorl %edx, %edx
pushq $0x3c
popq %rsi
divq %rsi
movq %rdx, 0x8(%rsp)
xorl %edx, %edx
divq %rsi
movq %rdx, 0x10(%rsp)
movq %rcx, %rax
xorl %edx, %edx
movl $0xe10, %esi            # imm = 0xE10
divq %rsi
xorl %edx, %edx
pushq $0x18
popq %rsi
divq %rsi
movq %rdx, %rbp
movq %rcx, %rax
xorl %edx, %edx
movl $0x15180, %ecx          # imm = 0x15180
divq %rcx
movq %rax, %r15
movq 0x7152(%rip), %rdi      # 0xcfd8
movq (%rdi), %rax
movq -0x18(%rax), %rax
movl 0x18(%rdi,%rax), %ecx
movl $0xffffff4f, %edx       # imm = 0xFFFFFF4F
andl %edx, %ecx
orl $0x80, %ecx
movl %ecx, 0x18(%rdi,%rax)
leaq 0x2255(%rip), %rsi      # 0x80fe
callq 0x2210
movq 0x85a20(%rbx), %rsi
movq %rax, %rdi
callq 0x2140
movq %rax, %rdi
leaq 0x2237(%rip), %rsi      # 0x80fe
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rdx
movq $0xa, 0x10(%rax,%rdx)
movq -0x18(%rcx), %rdx
movq $0x6, 0x8(%rax,%rdx)
movq -0x18(%rcx), %rcx
movl 0x18(%rax,%rcx), %edx
movl $0xfffffefb, %esi       # imm = 0xFFFFFEFB
andl %esi, %edx
orl $0x4, %edx
movl %edx, 0x18(%rax,%rcx)
movapd 0x20(%rsp), %xmm0
mulsd 0x2133(%rip), %xmm0     # 0x8040
movq %rax, %rdi
callq 0x2320
movq %rax, %rdi
leaq 0x2750(%rip), %rsi      # 0x866f
callq 0x2210
movq %rax, %rdi
leaq 0x21d0(%rip), %rsi      # 0x80fe
callq 0x2210
movq %rax, %r13
movq %r14, %rdi
callq 0x62de
movq %r13, %rdi
movq %rax, %rsi
callq 0x2210
movq %rax, %rdi
leaq 0x271e(%rip), %rsi      # 0x8671
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x3, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %r15, %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x270a(%rip), %rsi      # 0x8687
callq 0x2210
movq %rax, %rdi
pushq $0x30
popq %rsi
callq 0x2310
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movq %rbp, %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x26d5(%rip), %rsi      # 0x8687
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movq 0x10(%rsp), %rsi
callq 0x2140
movq %rax, %rdi
leaq 0x26a9(%rip), %rsi      # 0x8687
callq 0x2210
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
movq $0x2, 0x10(%rax,%rcx)
movq %rax, %rdi
movq 0x8(%rsp), %rsi
callq 0x2140
movq %rax, %rdi
pushq $0x20
popq %rsi
callq 0x2310
movq %rax, %rdi
leaq 0x2674(%rip), %rsi      # 0x8689
callq 0x2210
movq %rax, %rdi
callq 0x2150
leaq 0x71ef(%rip), %rdi      # 0xd218
callq 0x2170
movq %rbx, %rdi
callq 0x63b4
leaq 0x78(%rsp), %rdi
callq 0x22e0
leaq 0x38(%rsp), %rdi
callq 0x20b0
jmp 0x5887
addq $0x278, %rsp            # imm = 0x278
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6076
jmp 0x6076
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x20b0
jmp 0x608a
jmp 0x6076
movq %rax, %rbx
jmp 0x608a
jmp 0x607d
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x22e0
leaq 0x38(%rsp), %rdi
callq 0x20b0
movq %rbx, %rdi
callq 0x2390