// File: /workspace/github_c_makefile_star2_O1/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 $0x78, %rsp
movq %r9, 0x48(%rsp)
movaps %xmm0, %xmm2
movq %rcx, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movl %esi, 0x10(%rsp)
movl %edi, 0xc(%rsp)
leaq 0xb0(%rsp), %r15
movq 0x268(%r15), %rsi
cmpl $0x2, 0x48(%r15)
movss %xmm0, 0x8(%rsp)
jne 0x3fdf7
subq $0x4a0, %rsp            # imm = 0x4A0
movl $0x94, %ecx
movq %rsi, %rbx
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
callq 0x3fbdb
movq %rbx, %rsi
movss 0x4a8(%rsp), %xmm2
addq $0x4a0, %rsp            # imm = 0x4A0
movl 0x6c(%r15), %ebx
movl 0x70(%r15), %eax
movq %rbx, 0x68(%rsp)
movq %rax, 0x38(%rsp)
imull %eax, %ebx
testl %ebx, %ebx
jle 0x3ff9e
movl 0x84(%r15), %ecx
movl 0xfc(%r15), %r14d
leal 0x5(%r14), %edi
movq 0x230(%r15), %rax
movq %rax, 0x58(%rsp)
movq 0x128(%r15), %rax
movq %rax, 0x50(%rsp)
xorl %r8d, %r8d
xorl %r13d, %r13d
movq %rsi, 0x40(%rsp)
movq %rcx, 0x60(%rsp)
movl %edi, 0x14(%rsp)
movl %r8d, %eax
cltd
idivl 0x38(%rsp)
movl %edx, 0x1c(%rsp)
movl %eax, 0x18(%rsp)
testl %ecx, %ecx
jle 0x3ff90
xorl %ebp, %ebp
movq %r8, 0x70(%rsp)
movl %ebx, %eax
imull %ebp, %eax
addl %r8d, %eax
cltd
idivl %ebx
movl %eax, %r12d
imull %edi, %r12d
leal 0x4(%r12), %eax
imull %ebx, %eax
addl %edx, %eax
cltq
movss (%rsi,%rax,4), %xmm0
ucomiss %xmm0, %xmm2
jae 0x3ff84
movl %edx, %r15d
movl %r12d, %ecx
imull %ebx, %ecx
addl %edx, %ecx
movl %r13d, 0x24(%rsp)
movslq %r13d, %rax
leaq (%rax,%rax,2), %r13
shlq $0x4, %r13
movq 0x50(%rsp), %rax
movl (%rax,%rbp,4), %edx
subq $0x8, %rsp
movq 0x48(%rsp), %rdi
movq 0x60(%rsp), %rsi
movl 0x24(%rsp), %r8d
movl 0x20(%rsp), %r9d
pushq %rbx
pushq 0x40(%rsp)
pushq 0x40(%rsp)
pushq 0x88(%rsp)
pushq 0x60(%rsp)
movss %xmm0, 0x50(%rsp)
callq 0x3f69f
movss 0x50(%rsp), %xmm3
movq 0x70(%rsp), %rsi
movss 0x38(%rsp), %xmm2
addq $0x30, %rsp
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movq 0x550(%rsp), %rax
movups %xmm0, (%rax,%r13)
movss %xmm3, 0x28(%rax,%r13)
movl %r14d, 0x10(%rax,%r13)
testl %r14d, %r14d
jle 0x3ff6e
addq 0x550(%rsp), %r13
addl $0x5, %r12d
movq 0x18(%r13), %rax
imull %ebx, %r12d
addl %r12d, %r15d
xorl %ecx, %ecx
movslq %r15d, %r15
movss (%rsi,%r15,4), %xmm0
mulss %xmm3, %xmm0
movaps %xmm2, %xmm1
cmpltss %xmm0, %xmm1
andps %xmm0, %xmm1
movss %xmm1, (%rax,%rcx,4)
incq %rcx
addl %ebx, %r15d
cmpq %rcx, %r14
jne 0x3ff46
movl 0x24(%rsp), %r13d
incl %r13d
movq 0x60(%rsp), %rcx
movl 0x14(%rsp), %edi
movq 0x70(%rsp), %r8
incq %rbp
cmpq %rcx, %rbp
jne 0x3fe71
incl %r8d
cmpl %ebx, %r8d
jne 0x3fe52
jmp 0x3ffa1
xorl %r13d, %r13d
subq $0x8, %rsp
movq 0x558(%rsp), %rdi
movl %r13d, %esi
movl 0x14(%rsp), %edx
movl 0x18(%rsp), %ecx
movq 0x30(%rsp), %r8
movq 0x38(%rsp), %r9
pushq 0x50(%rsp)
callq 0x3fa0c
addq $0x10, %rsp
movl %r13d, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)