// File: /workspace/github_cpp_makefile_star2_O1/CodyNault[P]Image-Filter-Dataflow/src/filters.cpp
// Function: Crop::Execute()
void Crop::Execute(void)
{
    OneInputCheck();
    if (Istart < 0 || Istop < 0 || Jstart < 0 || Jstop < 0)
    {
        char msg[1024];
        sprintf(msg, "%s: uninitialized region", FilterName());
        DataFlowException e(FilterName(), msg);
        throw e;
    }
    if (Istart >= inputImg1->GetWidth() || Istop >= inputImg1->GetWidth())
    {
        char msg[1024];
        sprintf(msg, "%s: region outside image width", FilterName());
        DataFlowException e(FilterName(), msg);
        throw e;
    }
    if (Jstart >= inputImg1->GetHeight() || Jstop >= inputImg1->GetHeight())
    {
        char msg[1024];
        sprintf(msg, "%s: region outside image height", FilterName());
        DataFlowException e(FilterName(), msg);
        throw e;
    }
    if (Istop < Istart || Jstop < Jstart)
    {
        char msg[1024];
        sprintf(msg, "%s: invalid region", FilterName());
        DataFlowException e(FilterName(), msg);
        throw e;
    }

    int height = Jstop-Jstart+1;
    int width  = Istop-Istart+1;
    int inputWidth = inputImg1->GetWidth();
    Pixel *outBuffer = new Pixel[width * height];
    Pixel *inBuffer1 = inputImg1->GetBuffer();
    for (int i = Istart ; i <= Istop ; i++)
        for (int j = Jstart ; j <= Jstop ; j++)
        {
            int idx1 = j*inputWidth+i;
            int idx  = (j-Jstart)*width+(i-Istart);
            outBuffer[idx].red   = inBuffer1[idx1].red;
            outBuffer[idx].green = inBuffer1[idx1].green;
            outBuffer[idx].blue = inBuffer1[idx1].blue;
        }
    outputImg.ResetSize(width, height);
    outputImg.SetBuffer(outBuffer);
}

// 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 0x3a5c
movl 0x40(%rbx), %r14d
testl %r14d, %r14d
js 0x4ed3
cmpl $0x0, 0x44(%rbx)
js 0x4ed3
cmpl $0x0, 0x48(%rbx)
js 0x4ed3
cmpl $0x0, 0x4c(%rbx)
js 0x4ed3
movq 0x30(%rbx), %rdi
callq 0x3978
cmpl %eax, %r14d
jge 0x4f59
movl 0x44(%rbx), %r14d
movq 0x30(%rbx), %rdi
callq 0x3978
cmpl %eax, %r14d
jge 0x4f59
movl 0x48(%rbx), %r14d
movq 0x30(%rbx), %rdi
callq 0x3982
cmpl %eax, %r14d
jge 0x4fdf
movl 0x4c(%rbx), %r14d
movq 0x30(%rbx), %rdi
callq 0x3982
cmpl %eax, %r14d
jge 0x4fdf
movl 0x44(%rbx), %r14d
subl 0x40(%rbx), %r14d
jl 0x5065
movl 0x4c(%rbx), %r15d
subl 0x48(%rbx), %r15d
jl 0x5065
incl %r15d
incl %r14d
movq 0x30(%rbx), %rdi
callq 0x3978
movl %eax, %r13d
movl %r15d, -0x30(%rbp)
movl %r15d, %eax
movl %r14d, -0x2c(%rbp)
imull %r14d, %eax
cltq
movl $0x3, %ecx
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x3030
movq %rax, -0x38(%rbp)
movq 0x30(%rbx), %rdi
callq 0x398c
movslq 0x40(%rbx), %rcx
movq %rbx, -0x40(%rbp)
movl 0x44(%rbx), %edx
cmpl %edx, %ecx
jg 0x4ea0
movq -0x40(%rbp), %rdi
movslq 0x48(%rdi), %rsi
movl 0x4c(%rdi), %edi
movslq %r13d, %r10
movslq -0x2c(%rbp), %r9
incl %edx
movq -0x38(%rbp), %r8
addq $0x2, %r8
leaq (%r9,%r9,2), %r9
leaq (%r10,%r10,2), %r10
movq %rsi, %r11
imulq %r10, %r11
leaq (%rcx,%rcx,2), %r14
addq %r11, %r14
addq %rax, %r14
addq $0x2, %r14
movl %edi, %r15d
subl %esi, %r15d
incl %r15d
xorl %r13d, %r13d
cmpl %edi, %esi
jg 0x4e92
movslq %r13d, %rax
leaq (%rax,%rax,2), %r12
addq %r8, %r12
movl %r15d, %r11d
movq %r14, %rax
movb -0x2(%rax), %bl
movb %bl, -0x2(%r12)
movb -0x1(%rax), %bl
movb %bl, -0x1(%r12)
movb (%rax), %bl
movb %bl, (%r12)
addq %r9, %r12
addq %r10, %rax
decl %r11d
jne 0x4e71
incq %rcx
incl %r13d
addq $0x3, %r14
cmpl %ecx, %edx
jne 0x4e5d
movq -0x40(%rbp), %rbx
addq $0x8, %rbx
movq %rbx, %rdi
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %edx
callq 0x39ea
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
addq $0x828, %rsp            # imm = 0x828
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x39f6
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x1352(%rip), %rsi      # 0x6235
leaq -0x850(%rbp), %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3050
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq -0x448(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5ae8
movl $0x408, %edi            # imm = 0x408
callq 0x3090
movq %rax, %rbx
leaq 0x398a(%rip), %rax      # 0x88b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x440(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30b0
leaq 0x3943(%rip), %rsi      # 0x8888
movq 0x4094(%rip), %rdx      # 0x8fe0
movq %rbx, %rdi
callq 0x31a0
jmp 0x50e6
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x12e5(%rip), %rsi      # 0x624e
leaq -0x850(%rbp), %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3050
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq -0x448(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5ae8
movl $0x408, %edi            # imm = 0x408
callq 0x3090
movq %rax, %rbx
leaq 0x3904(%rip), %rax      # 0x88b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x440(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30b0
leaq 0x38bd(%rip), %rsi      # 0x8888
movq 0x400e(%rip), %rdx      # 0x8fe0
movq %rbx, %rdi
callq 0x31a0
jmp 0x50e6
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x127e(%rip), %rsi      # 0x626d
leaq -0x850(%rbp), %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3050
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq -0x448(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5ae8
movl $0x408, %edi            # imm = 0x408
callq 0x3090
movq %rax, %rbx
leaq 0x387e(%rip), %rax      # 0x88b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x440(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30b0
leaq 0x3837(%rip), %rsi      # 0x8888
movq 0x3f88(%rip), %rdx      # 0x8fe0
movq %rbx, %rdi
callq 0x31a0
jmp 0x50e6
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x1218(%rip), %rsi      # 0x628d
leaq -0x850(%rbp), %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3050
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq -0x448(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5ae8
movl $0x408, %edi            # imm = 0x408
callq 0x3090
movq %rax, %rbx
leaq 0x37f8(%rip), %rax      # 0x88b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x440(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30b0
leaq 0x37b1(%rip), %rsi      # 0x8888
movq 0x3f02(%rip), %rdx      # 0x8fe0
movq %rbx, %rdi
callq 0x31a0
jmp 0x50ec
jmp 0x50ec
jmp 0x50ec
movq %rax, %rbx
leaq -0x448(%rbp), %rdi
callq 0x31e8
movq %rbx, %rdi
callq 0x31b0
nop