// File: /workspace/github_cpp_makefile_star2_O1/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 0x47f2
movq %rdi, %rbx
cmpq 0x10(%rdi), %rdx
jge 0x47f2
movq %r8, %r12
movq %rsi, %r14
testq %rax, %rax
jle 0x46e3
movb $0x20, %sil
subb %al, %sil
cmpb $0x20, %sil
setae %dl
jae 0x468e
movzbl %sil, %eax
cmpb $0x0, (%r15,%rax)
jne 0x4686
incq %rax
cmpb $0x20, %al
je 0x468e
leaq 0x1(%rax), %rdx
cmpb $0x0, (%r15,%rax)
movq %rdx, %rax
je 0x4669
addq $-0x2, %rdx
cmpq $0x1f, %rdx
setae %dl
testb %dl, %dl
je 0x47f2
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x1b0(%rbx)
movups %xmm0, 0x1a0(%rbx)
movq 0x20(%r14), %rax
cmpq $0x20, %rax
je 0x472c
leaq 0x1a0(%rbx), %rdx
movb $0x1, %dil
xorl %esi, %esi
movb (%r15,%rsi), %r8b
addq %rsi, %rax
addb %r8b, (%rdx,%rax)
movzbl %dil, %esi
movq 0x20(%r14), %rax
movl $0x20, %r8d
subq %rax, %r8
movl %esi, %edi
incb %dil
cmpq %rsi, %r8
ja 0x46bb
jmp 0x472c
js 0x47bc
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x1b0(%rbx)
movups %xmm0, 0x1a0(%rbx)
xorl %edx, %edx
subb 0x20(%r14), %dl
cmpb $0x1f, %dl
ja 0x472c
leaq 0x1a0(%rbx), %rax
movzbl %dl, %edx
movb (%r15,%rdx), %sil
movq 0x20(%r14), %rdi
addq %rax, %rdi
addb %sil, (%rdx,%rdi)
incq %rdx
cmpb $0x20, %dl
jne 0x4715
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 0x47a6
movl $0x0, 0x4(%rsp)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3c68
cmpb $0x0, (%r15)
je 0x47ca
shrq $0x3f, %rax
movl %eax, %edx
jmp 0x47ea
negq %rax
movb $0x1, %dil
movzbl %dil, %esi
cmpq %rax, %rsi
setl %dl
jge 0x46e9
leal 0x1(%rsi), %edi
cmpb $0x0, (%r15,%rsi)
je 0x47d0
testb %dl, %dl
je 0x46e9
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop