// File: /workspace/github_cpp_makefile_star2_O2/ksabry[P]bfbrute/src/DataCache.h
// Function: DataCache<32ul, 12ul>::AddComposite(AlignedData<32ul>*, AlignedData<32ul>*, char*, char*, unsigned int, unsigned int)
void AddComposite(
		AlignedData<data_size>* leftData, AlignedData<data_size>* rightData, 
		char * leftProgram, char * rightProgram, 
		unsigned leftProgramSize, unsigned rightProgramSize)
	{
		//char leftDataIndex = leftData[0] - startDataIndex;
		//char rightDataIndex = rightData[0] - startDataIndex;

		currentDataIdx = leftData->idx + rightData->idx;
		if (currentDataIdx < lowDataIdx || currentDataIdx >= highDataIdx)
			return;

		if (leftData->idx > 0)
		{
			for (uint8_t rightI = data_size - leftData->idx; rightI < data_size; rightI++)
				if (rightData->data[rightI] != 0)
					return;
			memcpy(currentData, leftData->data, data_size);
			for (uint8_t rightI = 0; rightI < data_size - leftData->idx; rightI++)
				currentData[rightI + leftData->idx] += rightData->data[rightI];
		}
		else
		{
			for (uint8_t i = 0; i < -leftData->idx; i++)
				if (rightData->data[i] != 0)
					return;
			memcpy(currentData, leftData->data, data_size);
			for (uint8_t rightI = -leftData->idx; rightI < data_size; rightI++)
				currentData[rightI + leftData->idx] += rightData->data[rightI];
		}

		memcpy(currentProgram, leftProgram, leftProgramSize);
		memcpy(currentProgram + leftProgramSize, rightProgram, rightProgramSize);
		
		currentDataStart = Min(leftData->start, rightData->start + leftData->idx);
		currentDataEnd = Max(leftData->end, rightData->end + leftData->idx);

		if (currentDataStart > 10000 || currentDataEnd > 10000)
		{
			volatile int x = 0;
		}

		AddData();
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r15
movl 0x40(%rsp), %ebp
movq 0x20(%rsi), %rax
movq 0x20(%rdx), %rdx
addq %rax, %rdx
movq %rdx, 0x1c0(%rdi)
cmpq 0x8(%rdi), %rdx
jl 0x42aa
movq %rdi, %rbx
cmpq 0x10(%rdi), %rdx
jge 0x42aa
movq %r8, %r12
movq %rsi, %r14
testq %rax, %rax
jle 0x4293
pushq $0x20
popq %rdx
subl %eax, %edx
movzbl %dl, %eax
cmpq $0x1f, %rax
ja 0x42b9
cmpb $0x0, (%r15,%rax)
leaq 0x1(%rax), %rax
je 0x4280
jmp 0x42aa
negq %rax
xorl %edx, %edx
movzbl %dl, %esi
cmpq %rax, %rsi
jae 0x42fe
leal 0x1(%rsi), %edx
cmpb $0x0, (%r15,%rsi)
je 0x4298
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1a0(%rbx), %rax
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x1b0(%rbx)
movups %xmm0, 0x1a0(%rbx)
xorl %esi, %esi
pushq $0x20
popq %rdx
movzbl %sil, %esi
movq 0x20(%r14), %rdi
movq %rdx, %r8
subq %rdi, %r8
cmpq %rsi, %r8
jbe 0x433f
movb (%r15,%rsi), %r8b
addq %rsi, %rdi
addb %r8b, (%rax,%rdi)
incl %esi
jmp 0x42dc
leaq 0x1a0(%rbx), %rax
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x1b0(%rbx)
movups %xmm0, 0x1a0(%rbx)
xorl %edx, %edx
subl 0x20(%r14), %edx
movzbl %dl, %edx
cmpq $0x1f, %rdx
ja 0x433f
movb (%r15,%rdx), %sil
movq 0x20(%r14), %rdi
addq %rax, %rdi
addb %sil, (%rdx,%rdi)
incq %rdx
jmp 0x4325
leaq 0x1d8(%rbx), %rdi
movl %r9d, %r13d
movq %rcx, %rsi
movq %r13, %rdx
callq 0x2190
leaq (%rbx,%r13), %rdi
addq $0x1d8, %rdi            # imm = 0x1D8
movl %ebp, %edx
movq %r12, %rsi
callq 0x2190
movq 0x20(%r14), %rax
movq 0x28(%r14), %rcx
movq 0x28(%r15), %rdx
addq %rax, %rdx
cmpq %rdx, %rcx
cmovlq %rcx, %rdx
movq %rdx, 0x1c8(%rbx)
addq 0x30(%r15), %rax
movq 0x30(%r14), %rcx
cmpq %rax, %rcx
cmovgq %rcx, %rax
movq %rax, 0x1d0(%rbx)
movl $0x2711, %ecx           # imm = 0x2711
cmpq %rcx, %rdx
setl %dl
cmpq %rcx, %rax
setl %al
testb %al, %dl
jne 0x43b9
movl $0x0, 0x4(%rsp)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x37d2
nop