// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/detection_layer.c
// Function: get_detection_detections
void get_detection_detections(layer l, int w, int h, float thresh, detection *dets)
{
    int i,j,n;
    float *predictions = l.output;
    //int per_cell = 5*num+classes;
    for (i = 0; i < l.side*l.side; ++i){
        int row = i / l.side;
        int col = i % l.side;
        for(n = 0; n < l.n; ++n){
            int index = i*l.n + n;
            int p_index = l.side*l.side*l.classes + i*l.n + n;
            float scale = predictions[p_index];
            int box_index = l.side*l.side*(l.classes + l.n) + (i*l.n + n)*4;
            box b;
            b.x = (predictions[box_index + 0] + col) / l.side * w;
            b.y = (predictions[box_index + 1] + row) / l.side * h;
            b.w = pow(predictions[box_index + 2], (l.sqrt?2:1)) * w;
            b.h = pow(predictions[box_index + 3], (l.sqrt?2:1)) * h;
            dets[index].bbox = b;
            dets[index].objectness = scale;
            for(j = 0; j < l.classes; ++j){
                int class_index = i*l.classes;
                float prob = scale*predictions[class_index+j];
                dets[index].prob[j] = (prob > thresh) ? prob : 0;
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdx, 0x40(%rsp)
movaps %xmm0, %xmm2
movq 0x378(%rsp), %r15
movl 0x1a4(%rsp), %ecx
movl %ecx, %edx
imull %edx, %edx
movslq 0x194(%rsp), %r8
movslq 0x20c(%rsp), %r9
movl %r9d, %eax
imull %edx, %eax
movl %eax, 0x4(%rsp)
leal (%r9,%r8), %eax
movl %ecx, (%rsp)
cvtsi2ss %ecx, %xmm3
movq %rdx, 0x28(%rsp)
imull %edx, %eax
movd %esi, %xmm0
movd %edi, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
xorl %esi, %esi
cmpl $0x1, 0x1bc(%rsp)
pushq $0x2
popq %rcx
sbbl %esi, %ecx
cvtsi2sd %ecx, %xmm0
movsd %xmm0, 0x10(%rsp)
cvtdq2ps %xmm1, %xmm0
movaps %xmm0, 0x80(%rsp)
cvtdq2pd %xmm1, %xmm0
movaps %xmm0, 0x70(%rsp)
testl %r9d, %r9d
movl $0x0, %r12d
cmovgl %r9d, %r12d
cltq
testl %r8d, %r8d
movl $0x0, %ecx
movq %r8, 0x20(%rsp)
cmovgl %r8d, %ecx
movq %rcx, 0x58(%rsp)
leaq (%r15,%rax,4), %rax
movq %rax, 0x30(%rsp)
shufps $0x0, %xmm3, %xmm3      # xmm3 = xmm3[0,0,0,0]
movaps %xmm3, 0x90(%rsp)
shlq $0x2, %r9
movq %r9, 0x18(%rsp)
movq %r15, 0x38(%rsp)
movss %xmm2, 0x8(%rsp)
movq 0x30(%rsp), %r13
movq 0x40(%rsp), %rbp
cmpq 0x28(%rsp), %rsi
je 0x2a871
movl %esi, %eax
cltd
idivl (%rsp)
cvtsi2ss %edx, %xmm1
cvtsi2ss %eax, %xmm0
movq %rsi, %rax
imulq 0x20(%rsp), %rax
movq %rax, 0x48(%rsp)
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movaps %xmm1, 0xa0(%rsp)
xorl %ecx, %ecx
movq %rsi, 0x50(%rsp)
cmpq 0x58(%rsp), %rcx
je 0x2a864
movq 0x48(%rsp), %rax
leaq (%rax,%rcx), %r14
movq %rcx, 0x68(%rsp)
addl %ecx, %eax
addl 0x4(%rsp), %eax
cltq
movq 0x38(%rsp), %rcx
movss (%rcx,%rax,4), %xmm0
movss %xmm0, 0xc(%rsp)
imulq $0x30, %r14, %rax
movq %rax, 0x60(%rsp)
shlq $0x4, %r14
cvtss2sd 0x8(%r13,%r14), %xmm0
leaq (%rax,%rbp), %rbx
movsd (%r13,%r14), %xmm1
addps 0xa0(%rsp), %xmm1
divps 0x90(%rsp), %xmm1
mulps 0x80(%rsp), %xmm1
movaps %xmm1, 0xc0(%rsp)
movsd 0x10(%rsp), %xmm1
callq 0x3110
movaps %xmm0, 0xb0(%rsp)
cvtss2sd 0xc(%r13,%r14), %xmm0
movsd 0x10(%rsp), %xmm1
callq 0x3110
movss 0xc(%rsp), %xmm3
movss 0x8(%rsp), %xmm2
movaps 0xb0(%rsp), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd 0x70(%rsp), %xmm1
cvtpd2ps %xmm1, %xmm0
movapd 0xc0(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movq 0x60(%rsp), %rax
movupd %xmm1, (%rbp,%rax)
movss %xmm3, 0x28(%rbp,%rax)
xorl %eax, %eax
cmpq %rax, %r12
je 0x2a852
movss (%r15,%rax,4), %xmm0
mulss %xmm3, %xmm0
movaps %xmm2, %xmm1
cmpltss %xmm0, %xmm1
andps %xmm0, %xmm1
movq 0x18(%rbx), %rcx
movss %xmm1, (%rcx,%rax,4)
incq %rax
jmp 0x2a82a
movq 0x68(%rsp), %rcx
incq %rcx
movq 0x50(%rsp), %rsi
jmp 0x2a754
incq %rsi
addq 0x18(%rsp), %r15
jmp 0x2a71b
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop