// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
addq $0x28, %rdi
callq 0x3aee
movq 0x30(%r15), %rdi
callq 0x3978
movl %eax, %r14d
movq 0x38(%r15), %rdi
callq 0x3978
cmpl %eax, %r14d
jne 0x5413
movq 0x30(%r15), %rdi
callq 0x3982
movl %eax, %r14d
movq 0x38(%r15), %rdi
callq 0x3982
cmpl %eax, %r14d
jne 0x54a2
movq 0x30(%r15), %rdi
callq 0x3978
movl %eax, %r14d
movq 0x30(%r15), %rdi
callq 0x3982
movl %eax, %r12d
movq 0x30(%r15), %rdi
callq 0x398c
movq %rax, %rbx
movq %r15, -0x38(%rbp)
movq 0x38(%r15), %rdi
callq 0x398c
movq %rax, %r13
movl %r12d, %eax
movl %r14d, -0x2c(%rbp)
imull %r14d, %eax
cltq
movl $0x3, %ecx
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x3030
movq %rax, %r15
movl %r12d, -0x30(%rbp)
testl %r12d, %r12d
jle 0x53e1
movl -0x30(%rbp), %eax
movl -0x2c(%rbp), %ecx
leaq (%rcx,%rcx,2), %rdx
xorl %esi, %esi
movl $0xcccccccd, %edi       # imm = 0xCCCCCCCD
xorl %r8d, %r8d
cmpl $0x0, -0x2c(%rbp)
jle 0x53d6
movl %r8d, %r9d
imulq %rdi, %r9
shrq $0x23, %r9
movq %rsi, %r10
xorl %r11d, %r11d
movl %r11d, %r14d
imulq %rdi, %r14
shrq $0x23, %r14
addl %r9d, %r14d
movq %rbx, %r12
testb $0x1, %r14b
je 0x53b6
movq %r13, %r12
movb 0x2(%r12,%r10), %r14b
movb %r14b, 0x2(%r15,%r10)
movzwl (%r12,%r10), %r14d
movw %r14w, (%r15,%r10)
incq %r11
addq $0x3, %r10
cmpq %r11, %rcx
jne 0x539c
incq %r8
addq %rdx, %rsi
cmpq %rax, %r8
jne 0x5385
movq -0x38(%rbp), %rbx
addq $0x8, %rbx
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
callq 0x39ea
movq %rbx, %rdi
movq %r15, %rsi
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39f6
movq 0x30(%r15), %rdi
callq 0x3978
movl %eax, %r14d
movq 0x38(%r15), %rdi
callq 0x3978
leaq 0xe71(%rip), %rsi       # 0x62a0
leaq -0x850(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x3050
leaq 0xd9a(%rip), %rsi       # 0x61e6
leaq -0x440(%rbp), %rdi
movq %rbx, %rdx
callq 0x5ae8
movl $0x408, %edi            # imm = 0x408
callq 0x3090
movq %rax, %rbx
leaq 0x3441(%rip), %rax      # 0x88b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x438(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30b0
leaq 0x33fa(%rip), %rsi      # 0x8888
movq 0x3b4b(%rip), %rdx      # 0x8fe0
movq %rbx, %rdi
callq 0x31a0
jmp 0x552c
movq 0x30(%r15), %rdi
callq 0x3982
movl %eax, %r14d
movq 0x38(%r15), %rdi
callq 0x3982
leaq 0xe0a(%rip), %rsi       # 0x62c8
leaq -0x850(%rbp), %rbx
movq %rbx, %rdi
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0x3050
leaq 0xd0b(%rip), %rsi       # 0x61e6
leaq -0x440(%rbp), %rdi
movq %rbx, %rdx
callq 0x5ae8
movl $0x408, %edi            # imm = 0x408
callq 0x3090
movq %rax, %rbx
leaq 0x33b2(%rip), %rax      # 0x88b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x438(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30b0
leaq 0x336b(%rip), %rsi      # 0x8888
movq 0x3abc(%rip), %rdx      # 0x8fe0
movq %rbx, %rdi
callq 0x31a0
jmp 0x552e
movq %rax, %rbx
leaq -0x440(%rbp), %rdi
callq 0x31e8
movq %rbx, %rdi
callq 0x31b0
nop