// File: CodyNault[P]Image-Filter-Dataflow/src/filters.cpp
// Function: Checkerboard::Execute()
void Checkerboard::Execute()
{
	TwoInputCheck();
        if(inputImg1->GetWidth() != inputImg2->GetWidth()){
                char msg[1028];
                sprintf(msg, "Checkerboard: widths must match: %d, %d", inputImg1->GetWidth(), inputImg2->GetWidth());
                DataFlowException except("Blender", msg);
                throw except;
        }
        if(inputImg1->GetHeight() != inputImg2->GetHeight()){

                char msg[1028];
                sprintf(msg, "Checkerboard: heights must match: %d, %d", inputImg1->GetHeight(), inputImg2->GetHeight());
                DataFlowException except("Blender", msg);
                throw except;
        }
	int width = inputImg1->GetWidth();
        int height = inputImg1->GetHeight();
        Pixel *buffer1 = inputImg1->GetBuffer();
        Pixel *buffer2 = inputImg2->GetBuffer();
        Pixel *combinedBuffer = new Pixel[ width * height];
        float red = 0.0, green = 0.0, blue = 0.0;
        for(int i = 0; i < height; i++)
        {
                for(int j = 0; j < width; j++)
                {
			if((( i / 10 + j / 10) % 2 == 0)){
				combinedBuffer[i * width + j] = buffer1[i * width + j];
			}else{
				combinedBuffer[i * width + j] = buffer2[i * width + j];
			}
                }
        }
        outputImg.ResetSize(width, height);
        outputImg.SetBuffer(combinedBuffer);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10c0, %rsp           # imm = 0x10C0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x1078(%rbp)
addq $0x28, %rdi
callq 0x4070
movq -0x1078(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3db0
movl %eax, %ecx
movq -0x1078(%rbp), %rax
movl %ecx, -0x1070(%rbp)
movq 0x38(%rax), %rdi
callq 0x3db0
movl %eax, %ecx
movl -0x1070(%rbp), %eax
cmpl %ecx, %eax
je 0x77da
movq -0x1078(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3db0
movl %eax, %ecx
movq -0x1078(%rbp), %rax
movl %ecx, -0x1094(%rbp)
movq 0x38(%rax), %rdi
callq 0x3db0
movl -0x1094(%rbp), %edx
movl %eax, %ecx
leaq 0x1b4a(%rip), %rsi      # 0x928c
xorl %eax, %eax
leaq -0x410(%rbp), %rdi
movq %rdi, -0x1090(%rbp)
callq 0x3050
movq -0x1090(%rbp), %rdx
leaq 0x1a6d(%rip), %rsi      # 0x91d2
leaq -0x818(%rbp), %rdi
movq %rdi, -0x1088(%rbp)
callq 0x8420
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq -0x1088(%rbp), %rsi
movq %rax, %rdi
movq %rdi, -0x1080(%rbp)
callq 0x4240
movq -0x1080(%rbp), %rdi
leaq 0x50e2(%rip), %rsi      # 0xc888
leaq -0x351d(%rip), %rdx     # 0x4290
callq 0x31c0
jmp 0x7b27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x820(%rbp)
movl %eax, -0x824(%rbp)
leaq -0x818(%rbp), %rdi
callq 0x4290
jmp 0x7b1b
movq -0x1078(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3dd0
movl %eax, %ecx
movq -0x1078(%rbp), %rax
movl %ecx, -0x1098(%rbp)
movq 0x38(%rax), %rdi
callq 0x3dd0
movl %eax, %ecx
movl -0x1098(%rbp), %eax
cmpl %ecx, %eax
je 0x78e1
movq -0x1078(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3dd0
movl %eax, %ecx
movq -0x1078(%rbp), %rax
movl %ecx, -0x10b4(%rbp)
movq 0x38(%rax), %rdi
callq 0x3dd0
movl -0x10b4(%rbp), %edx
movl %eax, %ecx
leaq 0x1a6b(%rip), %rsi      # 0x92b4
xorl %eax, %eax
leaq -0xc30(%rbp), %rdi
movq %rdi, -0x10b0(%rbp)
callq 0x3050
movq -0x10b0(%rbp), %rdx
leaq 0x1966(%rip), %rsi      # 0x91d2
leaq -0x1038(%rbp), %rdi
movq %rdi, -0x10a8(%rbp)
callq 0x8420
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq -0x10a8(%rbp), %rsi
movq %rax, %rdi
movq %rdi, -0x10a0(%rbp)
callq 0x4240
movq -0x10a0(%rbp), %rdi
leaq 0x4fdb(%rip), %rsi      # 0xc888
leaq -0x3624(%rip), %rdx     # 0x4290
callq 0x31c0
jmp 0x7b27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x820(%rbp)
movl %eax, -0x824(%rbp)
leaq -0x1038(%rbp), %rdi
callq 0x4290
jmp 0x7b1b
movq -0x1078(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3db0
movl %eax, %ecx
movq -0x1078(%rbp), %rax
movl %ecx, -0x103c(%rbp)
movq 0x30(%rax), %rdi
callq 0x3dd0
movl %eax, %ecx
movq -0x1078(%rbp), %rax
movl %ecx, -0x1040(%rbp)
movq 0x30(%rax), %rdi
callq 0x3df0
movq %rax, %rcx
movq -0x1078(%rbp), %rax
movq %rcx, -0x1048(%rbp)
movq 0x38(%rax), %rdi
callq 0x3df0
movq %rax, -0x1050(%rbp)
movl -0x103c(%rbp), %eax
imull -0x1040(%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, -0x1058(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x105c(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1060(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x1064(%rbp)
movl $0x0, -0x1068(%rbp)
movl -0x1068(%rbp), %eax
cmpl -0x1040(%rbp), %eax
jge 0x7adf
movl $0x0, -0x106c(%rbp)
movl -0x106c(%rbp), %eax
cmpl -0x103c(%rbp), %eax
jge 0x7ac9
movl -0x1068(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, -0x10b8(%rbp)
movl -0x106c(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x10b8(%rbp), %eax
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x7a60
movq -0x1048(%rbp), %rcx
movl -0x1068(%rbp), %eax
imull -0x103c(%rbp), %eax
addl -0x106c(%rbp), %eax
cltq
imulq $0x3, %rax, %rax
addq %rax, %rcx
movq -0x1058(%rbp), %rax
movl -0x1068(%rbp), %edx
imull -0x103c(%rbp), %edx
addl -0x106c(%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 0x7ab3
movq -0x1050(%rbp), %rcx
movl -0x1068(%rbp), %eax
imull -0x103c(%rbp), %eax
addl -0x106c(%rbp), %eax
cltq
imulq $0x3, %rax, %rax
addq %rax, %rcx
movq -0x1058(%rbp), %rax
movl -0x1068(%rbp), %edx
imull -0x103c(%rbp), %edx
addl -0x106c(%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 0x7ab5
movl -0x106c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x106c(%rbp)
jmp 0x79c0
jmp 0x7acb
movl -0x1068(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1068(%rbp)
jmp 0x79a4
movq -0x1078(%rbp), %rdi
addq $0x8, %rdi
movl -0x103c(%rbp), %esi
movl -0x1040(%rbp), %edx
callq 0x3e90
movq -0x1078(%rbp), %rdi
addq $0x8, %rdi
movq -0x1058(%rbp), %rsi
callq 0x3eb0
addq $0x10c0, %rsp           # imm = 0x10C0
popq %rbp
retq
movq -0x820(%rbp), %rdi
callq 0x31d0
nopw (%rax,%rax)