// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/box.c
// Function: do_nms_sort
void do_nms_sort(detection *dets, int total, int classes, float thresh)
{
    int i, j, k;
    k = total-1;
    for(i = 0; i <= k; ++i){
        if(dets[i].objectness == 0){
            detection swap = dets[i];
            dets[i] = dets[k];
            dets[k] = swap;
            --k;
            --i;
        }
    }
    total = k+1;

    for(k = 0; k < classes; ++k){
        for(i = 0; i < total; ++i){
            dets[i].sort_class = k;
        }
        qsort(dets, total, sizeof(detection), nms_comparator);
        for(i = 0; i < total; ++i){
            if(dets[i].prob[k] == 0) continue;
            box a = dets[i].bbox;
            for(j = i+1; j < total; ++j){
                box b = dets[j].bbox;
                if (box_iou(a, b) > thresh){
                    dets[j].prob[k] = 0;
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movss %xmm0, 0x4(%rsp)
movq %rdi, %rbx
decl %esi
xorl %eax, %eax
xorps %xmm0, %xmm0
movslq %esi, %r14
cmpl %esi, %eax
jg 0x2b2c5
movslq %eax, %rcx
imulq $0x30, %rcx, %rcx
movss 0x28(%rbx,%rcx), %xmm1
ucomiss %xmm0, %xmm1
jne 0x2b2be
jp 0x2b2be
addq %rbx, %rcx
movups (%rcx), %xmm1
movups 0x10(%rcx), %xmm2
movups 0x20(%rcx), %xmm3
movaps %xmm3, 0x80(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm1, 0x60(%rsp)
imulq $0x30, %r14, %rsi
movups (%rbx,%rsi), %xmm1
movups 0x10(%rbx,%rsi), %xmm2
movups 0x20(%rbx,%rsi), %xmm3
movups %xmm3, 0x20(%rcx)
movups %xmm2, 0x10(%rcx)
movups %xmm1, (%rcx)
movaps 0x60(%rsp), %xmm1
movaps 0x70(%rsp), %xmm2
movaps 0x80(%rsp), %xmm3
movups %xmm3, 0x20(%rbx,%rsi)
movups %xmm2, 0x10(%rbx,%rsi)
movups %xmm1, (%rbx,%rsi)
decl %r14d
decl %eax
movl %r14d, %esi
incl %eax
jmp 0x2b23a
leal 0x1(%rsi), %eax
cltq
movq %rax, 0x28(%rsp)
xorl %r12d, %r12d
testl %edx, %edx
cmovlel %r12d, %edx
movq %rdx, 0x30(%rsp)
movl %esi, %eax
movq %rax, 0x20(%rsp)
leaq 0x2c(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x48(%rbx), %rax
movq %rax, 0x10(%rsp)
movq %r14, 0x38(%rsp)
cmpq 0x30(%rsp), %r12
je 0x2b3df
movq 0x18(%rsp), %rax
xorl %ecx, %ecx
cmpq %r14, %rcx
jg 0x2b31e
movl %r12d, (%rax)
incq %rcx
addq $0x30, %rax
jmp 0x2b30d
movq %rbx, %rdi
movq 0x28(%rsp), %rsi
pushq $0x30
popq %rdx
leaq -0x340(%rip), %rcx      # 0x2aff0
callq 0x30c0
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x20(%rsp), %rbp
xorl %r13d, %r13d
cmpq %r14, %r13
jg 0x2b3d7
imulq $0x30, %r13, %rax
movq %rbx, %r14
movq 0x18(%rbx,%rax), %rcx
movss (%rcx,%r12,4), %xmm0
ucomiss 0x20d0f(%rip), %xmm0    # 0x4c078
jne 0x2b383
jp 0x2b383
incq %r13
decq %rbp
addq $0x30, 0x8(%rsp)
movq %r14, %rbx
movq 0x38(%rsp), %r14
jmp 0x2b347
addq %r14, %rax
movsd (%rax), %xmm0
movaps %xmm0, 0x50(%rsp)
movsd 0x8(%rax), %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x8(%rsp), %r15
movq %rbp, %rbx
subq $0x1, %rbx
jb 0x2b36d
movsd -0x18(%r15), %xmm2
movsd -0x10(%r15), %xmm3
movaps 0x50(%rsp), %xmm0
movaps 0x40(%rsp), %xmm1
callq 0x2b1cb
ucomiss 0x4(%rsp), %xmm0
jbe 0x2b3d1
movq (%r15), %rax
andl $0x0, (%rax,%r12,4)
addq $0x30, %r15
jmp 0x2b3a1
incq %r12
jmp 0x2b2fb
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq