// File: /workspace/github_cpp_makefile_star2_O1/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 $0x818, %rsp            # imm = 0x818
movq %rdi, %rbx
addq $0x28, %rdi
callq 0x3aee
movq 0x30(%rbx), %rdi
callq 0x3978
movl %eax, %r14d
movq 0x38(%rbx), %rdi
callq 0x3978
cmpl %eax, %r14d
jne 0x484c
movq 0x30(%rbx), %rdi
callq 0x3982
movl %eax, %r12d
movq 0x38(%rbx), %rdi
callq 0x3982
movl %eax, %r14d
movq 0x30(%rbx), %rdi
callq 0x3978
movl %eax, %r15d
movl %r12d, -0x2c(%rbp)
addl %r12d, %r14d
movq 0x30(%rbx), %rdi
callq 0x398c
movq %rax, %r12
movq 0x38(%rbx), %rdi
callq 0x398c
movq %rax, %r13
movl %r15d, %eax
imull %r14d, %eax
cltq
movl $0x3, %ecx
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x3030
testl %r14d, %r14d
jle 0x481b
movslq -0x2c(%rbp), %r11
movslq %r15d, %rsi
movl %r14d, %ecx
movl %r15d, %edi
leaq (%rsi,%rsi,2), %rdx
imulq %r11, %rsi
leaq (%rsi,%rsi,2), %rsi
subq %rsi, %r13
leaq (%rdi,%rdi,2), %rsi
xorl %edi, %edi
movq %rax, %r8
testl %r15d, %r15d
jle 0x480a
xorl %r9d, %r9d
cmpq %r11, %rdi
jge 0x47ec
movb 0x2(%r12,%r9), %r10b
movb %r10b, 0x2(%r8,%r9)
movzwl (%r12,%r9), %r10d
jmp 0x47fc
movb 0x2(%r13,%r9), %r10b
movb %r10b, 0x2(%r8,%r9)
movzwl (%r13,%r9), %r10d
movw %r10w, (%r8,%r9)
addq $0x3, %r9
cmpq %r9, %rsi
jne 0x47d6
incq %rdi
addq %rdx, %r8
addq %rdx, %r13
addq %rdx, %r12
cmpq %rcx, %rdi
jne 0x47ce
addq $0x8, %rbx
movq %rbx, %rdi
movl %r15d, %esi
movl %r14d, %edx
movq %rax, %r14
callq 0x39ea
movq %rbx, %rdi
movq %r14, %rsi
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39f6
movq 0x30(%rbx), %rdi
callq 0x3978
movl %eax, %r14d
movq 0x38(%rbx), %rdi
callq 0x3978
leaq 0x1932(%rip), %rsi      # 0x619a
leaq -0x840(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x3050
leaq 0x1939(%rip), %rsi      # 0x61be
leaq -0x438(%rbp), %rdi
movq %rbx, %rdx
callq 0x5ae8
movl $0x408, %edi            # imm = 0x408
callq 0x3090
movq %rax, %rbx
leaq 0x4008(%rip), %rax      # 0x88b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x430(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30b0
leaq 0x3fc1(%rip), %rsi      # 0x8888
movq 0x4712(%rip), %rdx      # 0x8fe0
movq %rbx, %rdi
callq 0x31a0
movq %rax, %rbx
leaq -0x438(%rbp), %rdi
callq 0x31e8
movq %rbx, %rdi
callq 0x31b0
nop