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

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x828, %rsp            # imm = 0x828
movq %rdi, %rbx
addq $0x28, %rdi
callq 0x3a3a
movq 0x30(%rbx), %rdi
callq 0x38d8
movl %eax, %r14d
movq 0x38(%rbx), %rdi
callq 0x38d8
cmpl %eax, %r14d
jne 0x48ec
movq 0x30(%rbx), %rdi
callq 0x38e2
movl %eax, %r12d
movl %eax, -0x30(%rbp)
movq 0x38(%rbx), %rdi
callq 0x38e2
movl %eax, %r14d
movq 0x30(%rbx), %rdi
callq 0x38d8
movl %eax, %r15d
addl %r12d, %r14d
movq 0x30(%rbx), %rdi
callq 0x38ec
movq %rax, %r12
movq 0x38(%rbx), %rdi
callq 0x38ec
movq %rax, -0x38(%rbp)
movl %r15d, %eax
imull %r14d, %eax
cltq
pushq $0x3
popq %rcx
mulq %rcx
pushq $-0x1
popq %rdi
cmovnoq %rax, %rdi
callq 0x3030
xorl %r13d, %r13d
testl %r15d, %r15d
movl $0x0, %r8d
cmovgl %r15d, %r8d
movslq -0x30(%rbp), %rcx
movq %rax, %r9
movslq %r15d, %rdi
testl %r14d, %r14d
movl $0x0, %edx
cmovgl %r14d, %edx
leaq (%rdi,%rdi,2), %rsi
imulq %rcx, %rdi
imulq $-0x3, %rdi, %rdi
addq -0x38(%rbp), %rdi
leaq (%r8,%r8,2), %r8
movq %rax, -0x30(%rbp)
cmpq %rdx, %r13
je 0x48bd
xorl %r10d, %r10d
cmpq %r10, %r8
je 0x48af
cmpq %rcx, %r13
jge 0x4895
movb 0x2(%r12,%r10), %r11b
movb %r11b, 0x2(%r9,%r10)
movzwl (%r12,%r10), %r11d
jmp 0x48a4
movb 0x2(%rdi,%r10), %r11b
movb %r11b, 0x2(%r9,%r10)
movzwl (%rdi,%r10), %r11d
movw %r11w, (%r9,%r10)
addq $0x3, %r10
jmp 0x487a
incq %r13
addq %rsi, %r9
addq %rsi, %rdi
addq %rsi, %r12
jmp 0x4872
addq $0x8, %rbx
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
callq 0x3936
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3942
movq 0x30(%rbx), %rdi
callq 0x38d8
movl %eax, %r14d
movq 0x38(%rbx), %rdi
callq 0x38d8
leaq 0x1892(%rip), %rsi      # 0x619a
leaq -0x850(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x3050
leaq 0x1899(%rip), %rsi      # 0x61be
leaq -0x440(%rbp), %rdi
movq %rbx, %rdx
callq 0x5b4c
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq %rax, %rbx
leaq 0x4f68(%rip), %rax      # 0x98b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x438(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30d0
leaq 0x4f21(%rip), %rsi      # 0x9888
movq 0x5672(%rip), %rdx      # 0x9fe0
movq %rbx, %rdi
callq 0x31c0
movq %rax, %rbx
leaq -0x440(%rbp), %rdi
callq 0x3208
movq %rbx, %rdi
callq 0x31d0
nop