// File: /workspace/github_cpp_makefile_star2_O2/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
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 0x5473
movq 0x30(%rbx), %rdi
callq 0x38e2
movl %eax, %r14d
movq 0x38(%rbx), %rdi
callq 0x38e2
cmpl %eax, %r14d
jne 0x5502
movq 0x30(%rbx), %rdi
callq 0x38d8
movl %eax, %r14d
movq 0x30(%rbx), %rdi
callq 0x38e2
movl %eax, %r15d
movl %eax, -0x2c(%rbp)
movq 0x30(%rbx), %rdi
callq 0x38ec
movq %rax, %r12
movq %rbx, -0x38(%rbp)
movq 0x38(%rbx), %rdi
callq 0x38ec
movq %rax, %r13
imull %r14d, %r15d
movslq %r15d, %rax
pushq $0x3
popq %rcx
mulq %rcx
pushq $-0x1
popq %rdi
cmovnoq %rax, %rdi
callq 0x3030
movq %rax, %r15
xorl %ebx, %ebx
testl %r14d, %r14d
movl $0x0, %r9d
cmovgl %r14d, %r9d
movl -0x2c(%rbp), %eax
testl %eax, %eax
movl %eax, %r10d
cmovlel %ebx, %r10d
movl %r14d, -0x30(%rbp)
movslq %r14d, %rax
leaq (%rax,%rax,2), %r11
pushq $0xa
popq %r14
xorl %ecx, %ecx
cmpq %r10, %rcx
je 0x5441
movl %ecx, %eax
xorl %edx, %edx
divl %r14d
movl %eax, %esi
movq %rbx, %r8
xorl %edi, %edi
cmpq %rdi, %r9
je 0x5439
movl %edi, %eax
xorl %edx, %edx
divl %r14d
addl %esi, %eax
movq %r12, %rdx
testb $0x1, %al
je 0x541c
movq %r13, %rdx
movb 0x2(%rdx,%r8), %al
movb %al, 0x2(%r15,%r8)
movzwl (%rdx,%r8), %eax
movw %ax, (%r15,%r8)
incq %rdi
addq $0x3, %r8
jmp 0x5404
incq %rcx
addq %r11, %rbx
jmp 0x53f1
movq -0x38(%rbp), %rbx
addq $0x8, %rbx
movq %rbx, %rdi
movl -0x30(%rbp), %esi
movl -0x2c(%rbp), %edx
callq 0x3936
movq %rbx, %rdi
movq %r15, %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 0xe11(%rip), %rsi       # 0x62a0
leaq -0x850(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x3050
leaq 0xd3a(%rip), %rsi       # 0x61e6
leaq -0x440(%rbp), %rdi
movq %rbx, %rdx
callq 0x5b4c
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq %rax, %rbx
leaq 0x43e1(%rip), %rax      # 0x98b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x438(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30d0
leaq 0x439a(%rip), %rsi      # 0x9888
movq 0x4aeb(%rip), %rdx      # 0x9fe0
movq %rbx, %rdi
callq 0x31c0
jmp 0x558c
movq 0x30(%rbx), %rdi
callq 0x38e2
movl %eax, %r14d
movq 0x38(%rbx), %rdi
callq 0x38e2
leaq 0xdaa(%rip), %rsi       # 0x62c8
leaq -0x850(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x3050
leaq 0xcab(%rip), %rsi       # 0x61e6
leaq -0x440(%rbp), %rdi
movq %rbx, %rdx
callq 0x5b4c
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq %rax, %rbx
leaq 0x4352(%rip), %rax      # 0x98b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x438(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30d0
leaq 0x430b(%rip), %rsi      # 0x9888
movq 0x4a5c(%rip), %rdx      # 0x9fe0
movq %rbx, %rdi
callq 0x31c0
jmp 0x558e
movq %rax, %rbx
leaq -0x440(%rbp), %rdi
callq 0x3208
movq %rbx, %rdi
callq 0x31d0
nop