// File: /workspace/github_cpp_makefile_star2_O1/btbujiangjun[P]abcdl/src/framework/Pool.cpp
// Function: abcdl::framework::MeanPooling::pool(abcdl::algebra::Matrix<float>&, abcdl::algebra::Matrix<float> const&, unsigned long, unsigned long, unsigned long)
void MeanPooling::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];
    size_t pooling_size = scale * scale;
    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++){
                    pooling_value += mat.get_data(j * scale + m, k * scale + n);
                }
            }
            data[j * cols + k] = pooling_value / pooling_size;
        }
    }
    pool.set_shallow_data(data, rows, cols);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1d8, %rsp            # imm = 0x1D8
movq %r9, %r15
movq %r8, %rbx
movq %rcx, %r14
movq %rdx, %r13
movq %rsi, 0x20(%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 %rbx, %rcx
movq %rax, 0x10(%rsp)
movq %r14, 0x18(%rsp)
testq %r14, %r14
je 0x16a82
movq %r15, %rax
imulq %r15, %rax
testq %rax, %rax
js 0x16931
cvtsi2ss %rax, %xmm0
jmp 0x16946
movq %rax, %rdx
shrq %rdx
andl $0x1, %eax
orq %rdx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
xorl %esi, %esi
leaq 0x50(%rsp), %rdi
movq $0x0, (%rsp)
movq %rcx, 0x28(%rsp)
movss %xmm0, 0x8(%rsp)
testq %rcx, %rcx
je 0x16a69
movq (%rsp), %rax
imulq %rcx, %rax
movq 0x10(%rsp), %rdx
leaq (%rdx,%rax,4), %r8
xorl %ebp, %ebp
xorl %r9d, %r9d
movq %rsi, 0x38(%rsp)
movq %r8, 0x30(%rsp)
xorps %xmm1, %xmm1
testq %r15, %r15
je 0x16a50
movq %rsi, %r14
xorl %r10d, %r10d
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 0x169cc
movq 0x10(%r13), %rax
addss (%rax,%r12,4), %xmm1
incq %rbx
cmpq %rbx, %r15
jne 0x1699d
jmp 0x16a41
movq %r10, 0x40(%rsp)
movss %xmm1, 0xc(%rsp)
movq %r9, 0x48(%rsp)
leaq 0x23561(%rip), %rsi     # 0x39f44
movl $0x44, %edx
movl $0x3, %ecx
callq 0x373d6
movl $0x1f, %edx
leaq 0x50(%rsp), %rdi
leaq 0x2355a(%rip), %rsi     # 0x39f5d
callq 0x8350
leaq 0x50(%rsp), %rdi
callq 0x375fe
movq 0x28(%rsp), %rcx
movss 0x8(%rsp), %xmm0
movq 0x38(%rsp), %rsi
leaq 0x50(%rsp), %rdi
movq 0x30(%rsp), %r8
movq 0x48(%rsp), %r9
movss 0xc(%rsp), %xmm1
movq 0x40(%rsp), %r10
jmp 0x169b8
incq %r10
incq %r14
cmpq %r15, %r10
jne 0x1699b
divss %xmm0, %xmm1
movss %xmm1, (%r8,%r9,4)
incq %r9
addq %r15, %rbp
cmpq %rcx, %r9
jne 0x16989
movq (%rsp), %rdx
incq %rdx
addq %r15, %rsi
movq %rdx, (%rsp)
cmpq 0x18(%rsp), %rdx
jne 0x16960
movq 0x20(%rsp), %rdi
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
callq 0x18a12
addq $0x1d8, %rsp            # imm = 0x1D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x375fe
movq %rbx, %rdi
callq 0x8500
nop