// File: /workspace/github_c_makefile_star2_O3/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 $0xc8, %rsp
movq %rdx, 0x30(%rsp)
movl 0x194(%rsp), %eax
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x38132
movaps %xmm0, %xmm2
leaq 0x100(%rsp), %rax
movq 0x268(%rax), %rdx
movl 0x4(%rsp), %ecx
movl %ecx, %r8d
imull %r8d, %r8d
movl 0x84(%rax), %r9d
movl 0xfc(%rax), %ebp
movl %ebp, %r10d
imull %r8d, %r10d
movq %r10, 0x50(%rsp)
cvtsi2ss %ecx, %xmm3
leal (%r9,%rbp), %ecx
imull %r8d, %ecx
movd %esi, %xmm0
movd %edi, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
cmpl $0x1, 0xac(%rax)
movl $0x2, %eax
sbbl $0x0, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x38(%rsp)
cvtdq2ps %xmm1, %xmm0
movaps %xmm0, 0x70(%rsp)
cvtdq2pd %xmm1, %xmm0
movapd %xmm0, 0x60(%rsp)
movslq %ecx, %rax
movq %r9, 0x28(%rsp)
movslq %r9d, %rcx
movq %rcx, 0x40(%rsp)
cmpl $0x1, %r8d
adcl $0x0, %r8d
movq %r8, 0x48(%rsp)
movq %rdx, 0x20(%rsp)
leaq (%rdx,%rax,4), %r14
shufps $0x0, %xmm3, %xmm3      # xmm3 = xmm3[0,0,0,0]
movaps %xmm3, 0x80(%rsp)
movq $0x0, 0x10(%rsp)
movq $0x0, 0x8(%rsp)
movss %xmm2, 0x18(%rsp)
cmpl $0x0, 0x28(%rsp)
jle 0x3810e
movq 0x8(%rsp), %rdi
movl %edi, %eax
cltd
idivl 0x4(%rsp)
movl 0x10(%rsp), %ecx
movq 0x20(%rsp), %rsi
leaq (%rsi,%rcx,4), %r15
xorps %xmm1, %xmm1
cvtsi2ss %edx, %xmm1
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
imulq 0x40(%rsp), %rdi
movq %rdi, 0x58(%rsp)
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movaps %xmm1, 0x90(%rsp)
xorl %r13d, %r13d
movq 0x58(%rsp), %rax
leaq (%rax,%r13), %rbx
movq 0x50(%rsp), %rax
addl %ebx, %eax
cltq
movq 0x20(%rsp), %rcx
movss (%rcx,%rax,4), %xmm0
movss %xmm0, 0x1c(%rsp)
leaq (%rbx,%rbx,2), %r12
shlq $0x4, %rbx
xorps %xmm0, %xmm0
cvtss2sd 0x8(%r14,%rbx), %xmm0
shlq $0x4, %r12
movsd (%r14,%rbx), %xmm1
addps 0x90(%rsp), %xmm1
divps 0x80(%rsp), %xmm1
mulps 0x70(%rsp), %xmm1
movaps %xmm1, 0xb0(%rsp)
movsd 0x38(%rsp), %xmm1
callq 0x3110
movaps %xmm0, 0xa0(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0xc(%r14,%rbx), %xmm0
movsd 0x38(%rsp), %xmm1
callq 0x3110
movss 0x1c(%rsp), %xmm3
movss 0x18(%rsp), %xmm2
movaps 0xa0(%rsp), %xmm1
movlhps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
mulpd 0x60(%rsp), %xmm1
cvtpd2ps %xmm1, %xmm0
movapd 0xb0(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movq 0x30(%rsp), %rax
movupd %xmm1, (%rax,%r12)
movss %xmm3, 0x28(%rax,%r12)
testl %ebp, %ebp
jle 0x38100
addq 0x30(%rsp), %r12
movq 0x18(%r12), %rax
xorl %ecx, %ecx
movss (%r15,%rcx,4), %xmm0
mulss %xmm3, %xmm0
movaps %xmm2, %xmm1
cmpltss %xmm0, %xmm1
andps %xmm0, %xmm1
movss %xmm1, (%rax,%rcx,4)
incq %rcx
cmpq %rcx, %rbp
jne 0x380de
incq %r13
cmpq 0x28(%rsp), %r13
jne 0x3800b
movq 0x8(%rsp), %rcx
incq %rcx
movq 0x10(%rsp), %rax
addl %ebp, %eax
movq %rax, 0x10(%rsp)
movq %rcx, 0x8(%rsp)
cmpq 0x48(%rsp), %rcx
jne 0x37fc0
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq