// File: /workspace/github_cpp_makefile_star2_O2/IsaacLaw12[P]RayTracer/./src/Image.cpp
// Function: Image::blur_pixel(int, int, int)
void Image::blur_pixel(int index_x, int index_y, int blur_size){
    // Original color matrices are not affected. Their blurred averages are
    //     written to post_* matrices
    double red_avg = 0;
    double green_avg = 0;
    double blue_avg = 0;
    int avg_num = 0;
    if (blur_size <= 0) return;

    for (int x=-blur_size; x<=blur_size; x++){
        for (int y=-blur_size; y<=blur_size; y++){
            int x_index = index_x + x;
            if (x_index < 0 || x_index >= image_width){
               continue;
            }
            int y_index = index_y + y;
            if (y_index < 0 || y_index >= image_height){
               continue;
            }
            red_avg += red_pixels(x_index, y_index);
            green_avg += green_pixels(x_index, y_index);
            blue_avg += blue_pixels(x_index, y_index);
            avg_num++;
        }
    }
    if (avg_num > 0){
        post_red_pixels(index_x, index_y) = red_avg / avg_num;
        post_green_pixels(index_x, index_y) = green_avg / avg_num;
        post_blue_pixels(index_x, index_y) = blue_avg / avg_num;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, 0x28(%rsp)
testl %ecx, %ecx
jle 0x449d
movl %ecx, %r14d
movq %rdi, %rbx
movl %ecx, %eax
negl %eax
leaq 0x18(%rdi), %rsi
movq %rsi, 0x18(%rsp)
leaq 0x30(%rdi), %rsi
movq %rsi, 0x40(%rsp)
leaq 0x48(%rdi), %rsi
movq %rsi, 0x38(%rsp)
xorl %r8d, %r8d
xorpd %xmm0, %xmm0
movl %eax, 0x20(%rsp)
movl %eax, %esi
xorpd %xmm1, %xmm1
movsd %xmm1, 0x10(%rsp)
movsd %xmm1, 0x8(%rsp)
movl %edx, 0x24(%rsp)
cmpl %r14d, %esi
jg 0x43fa
movq 0x28(%rsp), %rax
movq %rsi, 0x30(%rsp)
leal (%rsi,%rax), %r12d
movl 0x20(%rsp), %ebp
cmpl %r14d, %ebp
jg 0x43ee
testl %r12d, %r12d
js 0x43e7
cmpl 0x10(%rbx), %r12d
jge 0x43e7
movl %edx, %eax
addl %ebp, %eax
js 0x43e7
cmpl 0x14(%rbx), %eax
jge 0x43e7
movl %eax, %r13d
movq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
movsd %xmm0, (%rsp)
movq %rbx, %r15
movl %r8d, %ebx
callq 0x4544
movsd 0x8(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x40(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4544
movsd 0x10(%rsp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, 0x10(%rsp)
movq 0x38(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x4544
movl %ebx, %r8d
movq %r15, %rbx
movl 0x24(%rsp), %edx
movsd (%rsp), %xmm0
addsd (%rax), %xmm0
incl %r8d
incl %ebp
jmp 0x4350
movq 0x30(%rsp), %rsi
incl %esi
jmp 0x4335
testl %r8d, %r8d
jle 0x449d
cvtsi2sd %r8d, %xmm1
movsd %xmm1, 0x18(%rsp)
movsd 0x8(%rsp), %xmm2
divsd %xmm1, %xmm2
movsd %xmm2, 0x8(%rsp)
leaq 0x60(%rbx), %rdi
movslq 0x28(%rsp), %r14
movslq %edx, %r15
movq %r14, %rsi
movq %r15, %rdx
movsd %xmm0, (%rsp)
callq 0x4544
movsd 0x8(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd 0x10(%rsp), %xmm0
divsd 0x18(%rsp), %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x78(%rbx), %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4544
movsd 0x10(%rsp), %xmm0
movsd %xmm0, (%rax)
movsd (%rsp), %xmm0
divsd 0x18(%rsp), %xmm0
movsd %xmm0, (%rsp)
addq $0x90, %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4544
movsd (%rsp), %xmm0
movsd %xmm0, (%rax)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq