// File: /workspace/github_c_makefile_star2_O0/SimpleDoger[P]Darknet_CPU_Only/maxpool_layer.c
// Function: forward_maxpool_layer
void forward_maxpool_layer(const maxpool_layer l, network net)
{
    int b,i,j,k,m,n;
    int w_offset = -l.pad/2;
    int h_offset = -l.pad/2;

    int h = l.out_h;
    int w = l.out_w;
    int c = l.c;

    for(b = 0; b < l.batch; ++b){
        for(k = 0; k < c; ++k){
            for(i = 0; i < h; ++i){
                for(j = 0; j < w; ++j){
                    int out_index = j + w*(i + h*(k + c*b));
                    float max = -FLT_MAX;
                    int max_i = -1;
                    for(n = 0; n < l.size; ++n){
                        for(m = 0; m < l.size; ++m){
                            int cur_h = h_offset + i*l.stride + n;
                            int cur_w = w_offset + j*l.stride + m;
                            int index = cur_w + l.w*(cur_h + l.h*(k + b*l.c));
                            int valid = (cur_h >= 0 && cur_h < l.h &&
                                         cur_w >= 0 && cur_w < l.w);
                            float val = (valid != 0) ? net.input[index] : -FLT_MAX;
                            max_i = (val > max) ? index : max_i;
                            max   = (val > max) ? val   : max;
                        }
                    }
                    l.output[out_index] = max;
                    l.indexes[out_index] = max_i;
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x4b0(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq 0x10(%rbp), %rcx
movq %rcx, -0x58(%rbp)
xorl %eax, %eax
subl 0xa8(%rcx), %eax
movl $0x2, %esi
cltd
idivl %esi
movl %eax, -0x1c(%rbp)
xorl %eax, %eax
subl 0xa8(%rcx), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x58(%rbp), %rax
movl %ecx, -0x20(%rbp)
movl 0x78(%rax), %ecx
movl %ecx, -0x24(%rbp)
movl 0x7c(%rax), %ecx
movl %ecx, -0x28(%rbp)
movl 0x74(%rax), %eax
movl %eax, -0x2c(%rbp)
movl $0x0, -0x4(%rbp)
movq -0x58(%rbp), %rcx
movl -0x4(%rbp), %eax
cmpl 0x48(%rcx), %eax
jge 0x30f3b
movl $0x0, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x30f2b
movl $0x0, -0x8(%rbp)
movl -0x8(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x30f1b
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x30f0b
movl -0xc(%rbp), %eax
movl -0x28(%rbp), %ecx
movl -0x8(%rbp), %edx
movl -0x24(%rbp), %esi
movl -0x10(%rbp), %edi
movl -0x2c(%rbp), %r8d
imull -0x4(%rbp), %r8d
addl %r8d, %edi
imull %edi, %esi
addl %esi, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x30(%rbp)
movss 0x43417(%rip), %xmm0    # 0x7416c
movss %xmm0, -0x34(%rbp)
movl $0xffffffff, -0x38(%rbp) # imm = 0xFFFFFFFF
movl $0x0, -0x18(%rbp)
movq -0x58(%rbp), %rcx
movl -0x18(%rbp), %eax
cmpl 0x90(%rcx), %eax
jge 0x30ed3
movl $0x0, -0x14(%rbp)
movq -0x58(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x90(%rcx), %eax
jge 0x30ec3
movq -0x58(%rbp), %r9
movl -0x20(%rbp), %eax
movl -0x8(%rbp), %ecx
imull 0x98(%r9), %ecx
addl %ecx, %eax
addl -0x18(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x1c(%rbp), %eax
movl -0xc(%rbp), %ecx
imull 0x98(%r9), %ecx
addl %ecx, %eax
addl -0x14(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %eax
movl 0x70(%r9), %ecx
movl -0x3c(%rbp), %edx
movl 0x6c(%r9), %esi
movl -0x10(%rbp), %edi
movl -0x4(%rbp), %r8d
imull 0x74(%r9), %r8d
addl %r8d, %edi
imull %edi, %esi
addl %esi, %edx
imull %edx, %ecx
addl %ecx, %eax
movl %eax, -0x44(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x3c(%rbp)
movb %al, -0x61(%rbp)
jl 0x30e26
movq -0x58(%rbp), %rdx
movl -0x3c(%rbp), %ecx
xorl %eax, %eax
cmpl 0x6c(%rdx), %ecx
movb %al, -0x61(%rbp)
jge 0x30e26
xorl %eax, %eax
cmpl $0x0, -0x40(%rbp)
movb %al, -0x61(%rbp)
jl 0x30e26
movq -0x58(%rbp), %rcx
movl -0x40(%rbp), %eax
cmpl 0x70(%rcx), %eax
setl %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x48(%rbp)
cmpl $0x0, -0x48(%rbp)
je 0x30e52
movq -0x60(%rbp), %rax
movq 0xd8(%rax), %rax
movslq -0x44(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
movss %xmm0, -0x68(%rbp)
jmp 0x30e61
movss 0x43312(%rip), %xmm0    # 0x7416c
movss %xmm0, -0x68(%rbp)
jmp 0x30e61
movss -0x68(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
movss -0x4c(%rbp), %xmm0
ucomiss -0x34(%rbp), %xmm0
jbe 0x30e7e
movl -0x44(%rbp), %eax
movl %eax, -0x6c(%rbp)
jmp 0x30e84
movl -0x38(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x38(%rbp)
movss -0x4c(%rbp), %xmm0
ucomiss -0x34(%rbp), %xmm0
jbe 0x30ea1
movss -0x4c(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
jmp 0x30eab
movss -0x34(%rbp), %xmm0
movss %xmm0, -0x70(%rbp)
movss -0x70(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x30d82
jmp 0x30ec5
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x30d68
movq -0x58(%rbp), %rax
movss -0x34(%rbp), %xmm0
movq 0x268(%rax), %rcx
movslq -0x30(%rbp), %rdx
movss %xmm0, (%rcx,%rdx,4)
movl -0x38(%rbp), %edx
movq 0x1a0(%rax), %rax
movslq -0x30(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x30d19
jmp 0x30f0d
movl -0x8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8(%rbp)
jmp 0x30d06
jmp 0x30f1d
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x30cf3
jmp 0x30f2d
movl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4(%rbp)
jmp 0x30cdc
popq %rbp
retq
nopl (%rax)