// File: CodyNault[P]Image-Filter-Dataflow/src/filters.cpp
// Function: LRConcat::Execute()
void LRConcat::Execute()
{
	TwoInputCheck();
	if(inputImg1->GetHeight() != inputImg2->GetHeight()){
		char msg[1028];
		sprintf(msg, "LRConcat: heights must match: %d, %d", inputImg1->GetHeight(), inputImg2->GetHeight());
		DataFlowException except("LRConcat", msg);
		throw except;
	}
	int leftWidth = inputImg1->GetWidth();
	int rightWidth = inputImg2->GetWidth();
	int newWidth = leftWidth + rightWidth;
	int newHeight = inputImg1->GetHeight();
	Pixel *leftBuffer = inputImg1->GetBuffer();
	Pixel *rightBuffer = inputImg2->GetBuffer();
	Pixel *combinedBuffer = new Pixel[ newWidth * newHeight];
	for(int i = 0; i < newHeight; i++)
	{
		for(int j = 0; j < newWidth; j++)
		{
			if( j < leftWidth)
			{
				combinedBuffer[i*newWidth + j] = leftBuffer[i * leftWidth + j];	
			}else{
				combinedBuffer[i*newWidth + j] = rightBuffer[i * rightWidth + j - leftWidth];	
			}
		}
	}
	outputImg.ResetSize(newWidth, newHeight);
	outputImg.SetBuffer(combinedBuffer);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x890, %rsp            # imm = 0x890
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x868(%rbp)
addq $0x28, %rdi
callq 0x4070
movq -0x868(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3dd0
movl %eax, %ecx
movq -0x868(%rbp), %rax
movl %ecx, -0x85c(%rbp)
movq 0x38(%rax), %rdi
callq 0x3dd0
movl %eax, %ecx
movl -0x85c(%rbp), %eax
cmpl %ecx, %eax
je 0x60fa
movq -0x868(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3dd0
movl %eax, %ecx
movq -0x868(%rbp), %rax
movl %ecx, -0x884(%rbp)
movq 0x38(%rax), %rdi
callq 0x3dd0
movl -0x884(%rbp), %edx
movl %eax, %ecx
leaq 0x30f6(%rip), %rsi      # 0x9158
xorl %eax, %eax
leaq -0x410(%rbp), %rdi
movq %rdi, -0x880(%rbp)
callq 0x3050
movq -0x880(%rbp), %rdx
leaq 0x30f8(%rip), %rsi      # 0x917d
leaq -0x818(%rbp), %rdi
movq %rdi, -0x878(%rbp)
callq 0x8420
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq -0x878(%rbp), %rsi
movq %rax, %rdi
movq %rdi, -0x870(%rbp)
callq 0x4240
movq -0x870(%rbp), %rdi
leaq 0x67c2(%rip), %rsi      # 0xc888
leaq -0x1e3d(%rip), %rdx     # 0x4290
callq 0x31c0
jmp 0x6324
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x820(%rbp)
movl %eax, -0x824(%rbp)
leaq -0x818(%rbp), %rdi
callq 0x4290
jmp 0x6318
movq -0x868(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3db0
movl %eax, %ecx
movq -0x868(%rbp), %rax
movl %ecx, -0x828(%rbp)
movq 0x38(%rax), %rdi
callq 0x3db0
movl %eax, %ecx
movq -0x868(%rbp), %rax
movl %ecx, -0x82c(%rbp)
movl -0x828(%rbp), %ecx
addl -0x82c(%rbp), %ecx
movl %ecx, -0x830(%rbp)
movq 0x30(%rax), %rdi
callq 0x3dd0
movl %eax, %ecx
movq -0x868(%rbp), %rax
movl %ecx, -0x834(%rbp)
movq 0x30(%rax), %rdi
callq 0x3df0
movq %rax, %rcx
movq -0x868(%rbp), %rax
movq %rcx, -0x840(%rbp)
movq 0x38(%rax), %rdi
callq 0x3df0
movq %rax, -0x848(%rbp)
movl -0x830(%rbp), %eax
imull -0x834(%rbp), %eax
cltq
movl $0x3, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x3030
movq %rax, -0x850(%rbp)
movl $0x0, -0x854(%rbp)
movl -0x854(%rbp), %eax
cmpl -0x834(%rbp), %eax
jge 0x62dc
movl $0x0, -0x858(%rbp)
movl -0x858(%rbp), %eax
cmpl -0x830(%rbp), %eax
jge 0x62c6
movl -0x858(%rbp), %eax
cmpl -0x828(%rbp), %eax
jge 0x6257
movq -0x840(%rbp), %rcx
movl -0x854(%rbp), %eax
imull -0x828(%rbp), %eax
addl -0x858(%rbp), %eax
cltq
imulq $0x3, %rax, %rax
addq %rax, %rcx
movq -0x850(%rbp), %rax
movl -0x854(%rbp), %edx
imull -0x830(%rbp), %edx
addl -0x858(%rbp), %edx
movslq %edx, %rdx
imulq $0x3, %rdx, %rdx
addq %rdx, %rax
movw (%rcx), %dx
movw %dx, (%rax)
movb 0x2(%rcx), %cl
movb %cl, 0x2(%rax)
jmp 0x62b0
movq -0x848(%rbp), %rcx
movl -0x854(%rbp), %eax
imull -0x82c(%rbp), %eax
addl -0x858(%rbp), %eax
subl -0x828(%rbp), %eax
cltq
imulq $0x3, %rax, %rax
addq %rax, %rcx
movq -0x850(%rbp), %rax
movl -0x854(%rbp), %edx
imull -0x830(%rbp), %edx
addl -0x858(%rbp), %edx
movslq %edx, %rdx
imulq $0x3, %rdx, %rdx
addq %rdx, %rax
movw (%rcx), %dx
movw %dx, (%rax)
movb 0x2(%rcx), %cl
movb %cl, 0x2(%rax)
jmp 0x62b2
movl -0x858(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x858(%rbp)
jmp 0x61e2
jmp 0x62c8
movl -0x854(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x854(%rbp)
jmp 0x61c6
movq -0x868(%rbp), %rdi
addq $0x8, %rdi
movl -0x830(%rbp), %esi
movl -0x834(%rbp), %edx
callq 0x3e90
movq -0x868(%rbp), %rdi
addq $0x8, %rdi
movq -0x850(%rbp), %rsi
callq 0x3eb0
addq $0x890, %rsp            # imm = 0x890
popq %rbp
retq
movq -0x820(%rbp), %rdi
callq 0x31d0
nopw %cs:(%rax,%rax)