// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/yolo_layer.c
// Function: get_yolo_detections
int get_yolo_detections(layer l, int w, int h, int netw, int neth, float thresh, int *map, int relative, detection *dets)
{
    int i,j,n;
    float *predictions = l.output;
    if (l.batch == 2) avg_flipped_yolo(l);
    int count = 0;
    for (i = 0; i < l.w*l.h; ++i){
        int row = i / l.w;
        int col = i % l.w;
        for(n = 0; n < l.n; ++n){
            int obj_index  = entry_index(l, 0, n*l.w*l.h + i, 4);
            float objectness = predictions[obj_index];
            if(objectness <= thresh) continue;
            int box_index  = entry_index(l, 0, n*l.w*l.h + i, 0);
            dets[count].bbox = get_yolo_box(predictions, l.biases, l.mask[n], box_index, col, row, l.w, l.h, netw, neth, l.w*l.h);
            dets[count].objectness = objectness;
            dets[count].classes = l.classes;
            for(j = 0; j < l.classes; ++j){
                int class_index = entry_index(l, 0, n*l.w*l.h + i, 4 + 1 + j);
                float prob = objectness*predictions[class_index];
                dets[count].prob[j] = (prob > thresh) ? prob : 0;
            }
            ++count;
        }
    }
    correct_yolo_boxes(dets, count, w, h, netw, neth, relative);
    return count;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %r9, 0x48(%rsp)
movaps %xmm0, %xmm2
movq %rcx, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movl %esi, 0x10(%rsp)
movl %edi, 0xc(%rsp)
leaq 0xc0(%rsp), %r14
movq 0x268(%r14), %r13
cmpl $0x2, 0x48(%r14)
movss %xmm0, 0x8(%rsp)
jne 0x35be9
subq $0x4a0, %rsp            # imm = 0x4A0
movl $0x94, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x359d2
movss 0x4a8(%rsp), %xmm2
addq $0x4a0, %rsp            # imm = 0x4A0
movl 0x6c(%r14), %ebx
movl 0x70(%r14), %eax
movq %rbx, 0x70(%rsp)
movq %rax, 0x40(%rsp)
imull %eax, %ebx
movl 0x84(%r14), %ecx
movl 0xfc(%r14), %eax
leal 0x5(%rax), %esi
movq 0x230(%r14), %rdx
movq %rdx, 0x58(%rsp)
movq 0x128(%r14), %rdx
movq %rdx, 0x50(%rsp)
xorl %r12d, %r12d
testl %eax, %eax
movl $0x0, %r14d
movq %rax, 0x60(%rsp)
cmovgl %eax, %r14d
testl %ecx, %ecx
cmovlel %r12d, %ecx
testl %ebx, %ebx
movl $0x0, %eax
cmovgl %ebx, %eax
movl %eax, 0x14(%rsp)
xorl %edi, %edi
movq %rcx, 0x68(%rsp)
movl %esi, 0x18(%rsp)
cmpl 0x14(%rsp), %edi
je 0x35db5
movl %edi, %eax
cltd
idivl 0x40(%rsp)
movl %eax, 0x20(%rsp)
movl %edx, 0x1c(%rsp)
xorl %r8d, %r8d
movl %edi, 0x24(%rsp)
cmpq %rcx, %r8
je 0x35dae
movl %ebx, %eax
imull %r8d, %eax
addl %edi, %eax
cltd
idivl %ebx
movl %eax, %r15d
imull %esi, %r15d
leal 0x4(%r15), %eax
imull %ebx, %eax
addl %edx, %eax
cltq
movss (%r13,%rax,4), %xmm0
ucomiss %xmm0, %xmm2
jae 0x35da6
movl %r15d, %ecx
imull %ebx, %ecx
addl %edx, %ecx
movq %r12, 0x80(%rsp)
movslq %r12d, %rax
imulq $0x30, %rax, %r12
movq 0x560(%rsp), %rax
leaq (%rax,%r12), %rbp
movq 0x50(%rsp), %rax
movq %r8, 0x78(%rsp)
movl %edx, 0x28(%rsp)
movl (%rax,%r8,4), %edx
subq $0x8, %rsp
movq %r13, %rdi
movq 0x60(%rsp), %rsi
movl 0x24(%rsp), %r8d
movl 0x28(%rsp), %r9d
pushq %rbx
pushq 0x48(%rsp)
pushq 0x48(%rsp)
pushq 0x90(%rsp)
pushq 0x68(%rsp)
movss %xmm0, 0x5c(%rsp)
callq 0x35516
movss 0x5c(%rsp), %xmm3
movss 0x38(%rsp), %xmm2
addq $0x30, %rsp
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movq 0x560(%rsp), %rcx
movups %xmm0, (%rcx,%r12)
movss %xmm3, 0x28(%rcx,%r12)
movq 0x60(%rsp), %rax
movl %eax, 0x10(%rcx,%r12)
addl $0x5, %r15d
imull %ebx, %r15d
addl 0x28(%rsp), %r15d
xorl %eax, %eax
cmpq %rax, %r14
je 0x35d89
movslq %r15d, %r15
movss (%r13,%r15,4), %xmm0
mulss %xmm3, %xmm0
movaps %xmm2, %xmm1
cmpltss %xmm0, %xmm1
andps %xmm0, %xmm1
movq 0x18(%rbp), %rcx
movss %xmm1, (%rcx,%rax,4)
incq %rax
addl %ebx, %r15d
jmp 0x35d5a
movq 0x80(%rsp), %r12
incl %r12d
movq 0x68(%rsp), %rcx
movl 0x18(%rsp), %esi
movl 0x24(%rsp), %edi
movq 0x78(%rsp), %r8
incq %r8
jmp 0x35c7a
incl %edi
jmp 0x35c5a
subq $0x8, %rsp
movq 0x568(%rsp), %rdi
movl %r12d, %esi
movl 0x14(%rsp), %edx
movl 0x18(%rsp), %ecx
movq 0x38(%rsp), %r8
movq 0x40(%rsp), %r9
pushq 0x50(%rsp)
callq 0x35871
popq %rax
popq %rcx
movl %r12d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop