// File: /workspace/github_cpp_makefile_star2_O3/btbujiangjun[P]abcdl/src/framework/Pool.cpp
// Function: abcdl::framework::L2Pooling::pool(abcdl::algebra::Matrix<float>&, abcdl::algebra::Matrix<float> const&, unsigned long, unsigned long, unsigned long)
void L2Pooling::pool(abcdl::algebra::Mat& pool,
                     const abcdl::algebra::Mat& mat,
                     const size_t rows,
                     const size_t cols,
                     const size_t scale){
    real* data = new real[rows * cols];
    for(size_t j = 0; j != rows; j++){
        for(size_t k = 0; k != cols; k++){
            real pooling_value = 0;
            for(size_t m = 0; m != scale; m++){
                for(size_t n = 0; n != scale; n++){
                    real value = mat.get_data(j * scale + m, k * scale + n);
                    if(value != 0){
                        pooling_value += (value * value);
                    }
                }
            }
            data[j * cols + k] = sqrt(pooling_value);
        }
    }
    pool.set_shallow_data(data, rows, cols);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %r9, %r15
movq %rcx, %rbx
movq %rdx, %r13
movq %rsi, 0x30(%rsp)
movq %r8, 0x8(%rsp)
movq %r8, %rax
imulq %rcx, %rax
movq %rax, %rcx
shrq $0x3e, %rcx
shlq $0x2, %rax
xorl %edi, %edi
negq %rcx
sbbq %rdi, %rdi
orq %rax, %rdi
callq 0x8030
movq %rax, 0x18(%rsp)
movq %rbx, 0x20(%rsp)
testq %rbx, %rbx
je 0x16bd4
movq $0x0, 0x28(%rsp)
xorps %xmm2, %xmm2
leaq 0x60(%rsp), %rdx
movq $0x0, 0x10(%rsp)
cmpq $0x0, 0x8(%rsp)
je 0x16bb7
movq 0x10(%rsp), %rax
imulq 0x8(%rsp), %rax
movq 0x18(%rsp), %rcx
leaq (%rcx,%rax,4), %rax
movq %rax, 0x48(%rsp)
xorl %ebp, %ebp
xorl %esi, %esi
xorps %xmm0, %xmm0
testq %r15, %r15
je 0x16b7d
movq 0x28(%rsp), %r14
xorl %edi, %edi
xorl %ebx, %ebx
movq 0x8(%r13), %rax
movq %r14, %r12
imulq %rax, %r12
addq %rbp, %r12
addq %rbx, %r12
imulq (%r13), %rax
cmpq %rax, %r12
jae 0x16b0a
movq 0x10(%r13), %rax
movss (%rax,%r12,4), %xmm3
movaps %xmm3, %xmm1
mulss %xmm3, %xmm1
addss %xmm0, %xmm1
cmpneqss %xmm2, %xmm3
andps %xmm3, %xmm1
andnps %xmm0, %xmm3
orps %xmm1, %xmm3
movaps %xmm3, %xmm0
incq %rbx
cmpq %rbx, %r15
jne 0x16abf
jmp 0x16b6e
movq %rdi, 0x38(%rsp)
movaps %xmm0, 0x50(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, %rdi
leaq 0x23421(%rip), %rsi     # 0x39f44
movl $0x44, %edx
movl $0x3, %ecx
callq 0x37222
movl $0x1f, %edx
leaq 0x60(%rsp), %rdi
leaq 0x2341a(%rip), %rsi     # 0x39f5d
callq 0x8350
leaq 0x60(%rsp), %rdi
callq 0x3744a
xorps %xmm2, %xmm2
leaq 0x60(%rsp), %rdx
movq 0x40(%rsp), %rsi
movaps 0x50(%rsp), %xmm0
movq 0x38(%rsp), %rdi
jmp 0x16ada
incq %rdi
incq %r14
cmpq %r15, %rdi
jne 0x16abd
ucomiss %xmm2, %xmm0
jb 0x16b88
sqrtss %xmm0, %xmm0
jmp 0x16b9c
movq %rdx, %rbx
movq %rsi, %r14
callq 0x8540
movq %r14, %rsi
movq %rbx, %rdx
xorps %xmm2, %xmm2
movq 0x48(%rsp), %rax
movss %xmm0, (%rax,%rsi,4)
incq %rsi
addq %r15, %rbp
cmpq 0x8(%rsp), %rsi
jne 0x16aaa
movq 0x10(%rsp), %rcx
incq %rcx
addq %r15, 0x28(%rsp)
movq %rcx, 0x10(%rsp)
cmpq 0x20(%rsp), %rcx
jne 0x16a81
movq 0x30(%rsp), %rdi
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x8(%rsp), %rcx
callq 0x1878a
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x3744a
movq %rbx, %rdi
callq 0x8500