// File: /workspace/github_cpp_makefile_star2_O2/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 $0x818, %rsp            # imm = 0x818
movq %rdi, %rbx
addq $0x28, %rdi
callq 0x39a8
movl 0x40(%rbx), %r14d
testl %r14d, %r14d
js 0x4f15
cmpl $0x0, 0x44(%rbx)
js 0x4f15
cmpl $0x0, 0x48(%rbx)
js 0x4f15
cmpl $0x0, 0x4c(%rbx)
js 0x4f15
movq 0x30(%rbx), %rdi
callq 0x38d8
cmpl %eax, %r14d
jge 0x4f9b
movl 0x44(%rbx), %r14d
movq 0x30(%rbx), %rdi
callq 0x38d8
cmpl %eax, %r14d
jge 0x4f9b
movl 0x48(%rbx), %r14d
movq 0x30(%rbx), %rdi
callq 0x38e2
cmpl %eax, %r14d
jge 0x5021
movl 0x4c(%rbx), %r14d
movq 0x30(%rbx), %rdi
callq 0x38e2
cmpl %eax, %r14d
jge 0x5021
movl 0x44(%rbx), %r14d
subl 0x40(%rbx), %r14d
jl 0x50a7
movl 0x4c(%rbx), %r15d
subl 0x48(%rbx), %r15d
jl 0x50a7
incl %r15d
incl %r14d
movq 0x30(%rbx), %rdi
callq 0x38d8
movl %eax, %r12d
movl %r15d, -0x2c(%rbp)
movl %r15d, %eax
imull %r14d, %eax
cltq
pushq $0x3
popq %rcx
mulq %rcx
pushq $-0x1
popq %rdi
cmovnoq %rax, %rdi
callq 0x3030
movq %rax, %r13
movq 0x30(%rbx), %rdi
callq 0x38ec
movslq 0x40(%rbx), %rcx
movslq 0x44(%rbx), %rdx
movslq 0x48(%rbx), %r15
movslq 0x4c(%rbx), %rdi
movl %r14d, -0x30(%rbp)
movslq %r14d, %rsi
movslq %r12d, %r8
leaq (%r8,%r8,2), %r8
movq %r8, %r9
imulq %r15, %r9
leaq (%rcx,%rcx,2), %r10
addq %r9, %r10
leaq (%rax,%r10), %r12
addq $0x2, %r12
movq %r13, -0x38(%rbp)
movq %r13, %r9
addq $0x2, %r9
leaq (%rsi,%rsi,2), %r10
xorl %r11d, %r11d
cmpq %rdx, %rcx
jg 0x4ee6
movslq %r11d, %rax
leaq (%rax,%rax,2), %r13
addq %r9, %r13
movq %r12, %rax
movq %r15, %rsi
cmpq %rdi, %rsi
jg 0x4eda
movb -0x2(%rax), %r14b
movb %r14b, -0x2(%r13)
movb -0x1(%rax), %r14b
movb %r14b, -0x1(%r13)
movb (%rax), %r14b
movb %r14b, (%r13)
incq %rsi
addq %r8, %rax
addq %r10, %r13
jmp 0x4eb3
incq %rcx
addq $0x3, %r12
incl %r11d
jmp 0x4e9e
addq $0x8, %rbx
movq %rbx, %rdi
movl -0x30(%rbp), %esi
movl -0x2c(%rbp), %edx
callq 0x3936
movq %rbx, %rdi
movq -0x38(%rbp), %rsi
addq $0x818, %rsp            # imm = 0x818
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3942
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x1310(%rip), %rsi      # 0x6235
leaq -0x840(%rbp), %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3050
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq -0x440(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5b4c
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq %rax, %rbx
leaq 0x4948(%rip), %rax      # 0x98b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x438(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30d0
leaq 0x4901(%rip), %rsi      # 0x9888
movq 0x5052(%rip), %rdx      # 0x9fe0
movq %rbx, %rdi
callq 0x31c0
jmp 0x5128
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x12a3(%rip), %rsi      # 0x624e
leaq -0x840(%rbp), %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3050
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq -0x440(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5b4c
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq %rax, %rbx
leaq 0x48c2(%rip), %rax      # 0x98b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x438(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30d0
leaq 0x487b(%rip), %rsi      # 0x9888
movq 0x4fcc(%rip), %rdx      # 0x9fe0
movq %rbx, %rdi
callq 0x31c0
jmp 0x5128
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x123c(%rip), %rsi      # 0x626d
leaq -0x840(%rbp), %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3050
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq -0x440(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5b4c
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq %rax, %rbx
leaq 0x483c(%rip), %rax      # 0x98b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x438(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30d0
leaq 0x47f5(%rip), %rsi      # 0x9888
movq 0x4f46(%rip), %rdx      # 0x9fe0
movq %rbx, %rdi
callq 0x31c0
jmp 0x5128
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq 0x11d6(%rip), %rsi      # 0x628d
leaq -0x840(%rbp), %r14
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3050
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x20(%rax)
leaq -0x440(%rbp), %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0x5b4c
movl $0x408, %edi            # imm = 0x408
callq 0x30a0
movq %rax, %rbx
leaq 0x47b6(%rip), %rax      # 0x98b0
movq %rax, (%rbx)
leaq 0x8(%rbx), %rdi
leaq -0x438(%rbp), %rsi
movl $0x400, %edx            # imm = 0x400
callq 0x30d0
leaq 0x476f(%rip), %rsi      # 0x9888
movq 0x4ec0(%rip), %rdx      # 0x9fe0
movq %rbx, %rdi
callq 0x31c0
jmp 0x512e
jmp 0x512e
jmp 0x512e
movq %rax, %rbx
leaq -0x440(%rbp), %rdi
callq 0x3208
movq %rbx, %rdi
callq 0x31d0
nop