// File: /workspace/github_c_makefile_star2_O1/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 $0xa8, %rsp
movq %rdx, 0x58(%rsp)
movl 0x174(%rsp), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
je 0x35fcd
movaps %xmm0, %xmm2
leaq 0xe0(%rsp), %rax
movq 0x268(%rax), %rdx
movl 0xc(%rsp), %ecx
movl %ecx, %r8d
imull %r8d, %r8d
movl 0x84(%rax), %r9d
movl 0xfc(%rax), %ebp
movl %ebp, %r10d
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x2c(%rsp)
imull %r8d, %r10d
movq %r10, 0x90(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %edi, %xmm0
movss %xmm0, 0x28(%rsp)
leal (%rbp,%r9), %ecx
xorps %xmm0, %xmm0
cvtsi2ss %esi, %xmm0
movss %xmm0, 0x24(%rsp)
imull %r8d, %ecx
cmpl $0x1, 0xac(%rax)
movl $0x2, %eax
sbbl $0x0, %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x60(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %edi, %xmm0
movsd %xmm0, 0x88(%rsp)
xorps %xmm0, %xmm0
cvtsi2sd %esi, %xmm0
movsd %xmm0, 0x80(%rsp)
movslq %ecx, %rax
cmpl $0x1, %r8d
adcl $0x0, %r8d
movq %r8, 0x70(%rsp)
movq %r9, 0x50(%rsp)
movslq %r9d, %rcx
movq %rcx, 0x68(%rsp)
movq %rdx, 0x48(%rsp)
leaq (%rdx,%rax,4), %rax
movq %rax, 0x78(%rsp)
movq $0x0, 0x18(%rsp)
movq $0x0, 0x10(%rsp)
movss %xmm2, 0x30(%rsp)
movq 0x78(%rsp), %rbx
cmpl $0x0, 0x50(%rsp)
jle 0x35fa9
movq 0x10(%rsp), %rdi
movl %edi, %eax
cltd
idivl 0xc(%rsp)
movl 0x18(%rsp), %ecx
movq 0x48(%rsp), %rsi
leaq (%rsi,%rcx,4), %r15
imulq 0x68(%rsp), %rdi
movq %rdi, 0x98(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
movss %xmm0, 0x38(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x34(%rsp)
xorl %r13d, %r13d
movq 0x98(%rsp), %rax
leaq (%rax,%r13), %r14
movq 0x90(%rsp), %rax
addl %r14d, %eax
cltq
movq 0x48(%rsp), %rcx
movss (%rcx,%rax,4), %xmm0
movss %xmm0, 0x3c(%rsp)
movq %r14, %r12
shlq $0x4, %r12
movss (%rbx,%r12), %xmm0
addss 0x38(%rsp), %xmm0
movss %xmm0, 0x40(%rsp)
movss 0x4(%rbx,%r12), %xmm0
addss 0x34(%rsp), %xmm0
movss %xmm0, 0x44(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0x8(%rbx,%r12), %xmm0
movsd 0x60(%rsp), %xmm1
callq 0x3120
movsd %xmm0, 0xa0(%rsp)
xorps %xmm0, %xmm0
cvtss2sd 0xc(%rbx,%r12), %xmm0
movsd 0x60(%rsp), %xmm1
callq 0x3120
movss 0x3c(%rsp), %xmm3
movss 0x30(%rsp), %xmm2
leaq (%r14,%r14,2), %rax
shlq $0x4, %rax
movss 0x2c(%rsp), %xmm1
movss 0x40(%rsp), %xmm4
divss %xmm1, %xmm4
mulss 0x28(%rsp), %xmm4
movss 0x44(%rsp), %xmm5
divss %xmm1, %xmm5
mulss 0x24(%rsp), %xmm5
movsd 0xa0(%rsp), %xmm1
mulsd 0x88(%rsp), %xmm1
cvtsd2ss %xmm1, %xmm1
mulsd 0x80(%rsp), %xmm0
cvtsd2ss %xmm0, %xmm0
movq 0x58(%rsp), %rcx
movss %xmm4, (%rcx,%rax)
movss %xmm5, 0x4(%rcx,%rax)
movss %xmm1, 0x8(%rcx,%rax)
movss %xmm0, 0xc(%rcx,%rax)
movss %xmm3, 0x28(%rcx,%rax)
testl %ebp, %ebp
jle 0x35f9b
addq 0x58(%rsp), %rax
movq 0x18(%rax), %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 0x35f79
incq %r13
cmpq 0x50(%rsp), %r13
jne 0x35e63
movq 0x10(%rsp), %rcx
incq %rcx
movq 0x18(%rsp), %rax
addl %ebp, %eax
movq %rax, 0x18(%rsp)
movq %rcx, 0x10(%rsp)
cmpq 0x70(%rsp), %rcx
jne 0x35e14
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop