// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/box.c
// Function: do_nms_obj
void do_nms_obj(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(i = 0; i < total; ++i){
        dets[i].sort_class = -1;
    }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movss %xmm0, 0x1c(%rsp)
movl %edx, 0xc(%rsp)
movq %rdi, %r14
leal -0x1(%rsi), %r15d
testl %esi, %esi
jle 0x3661b
xorl %eax, %eax
xorps %xmm0, %xmm0
movslq %eax, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movss 0x28(%r14,%rcx), %xmm1
ucomiss %xmm0, %xmm1
jne 0x3660d
jp 0x3660d
addq %r14, %rcx
movups (%rcx), %xmm1
movups 0x10(%rcx), %xmm2
movups 0x20(%rcx), %xmm3
movaps %xmm3, 0x70(%rsp)
movaps %xmm2, 0x60(%rsp)
movaps %xmm1, 0x50(%rsp)
movslq %r15d, %r15
leaq (%r15,%r15,2), %rdx
shlq $0x4, %rdx
movups (%r14,%rdx), %xmm1
movups 0x10(%r14,%rdx), %xmm2
movups 0x20(%r14,%rdx), %xmm3
movups %xmm3, 0x20(%rcx)
movups %xmm2, 0x10(%rcx)
movups %xmm1, (%rcx)
movaps 0x50(%rsp), %xmm1
movaps 0x60(%rsp), %xmm2
movaps 0x70(%rsp), %xmm3
movups %xmm3, 0x20(%r14,%rdx)
movups %xmm2, 0x10(%r14,%rdx)
movups %xmm1, (%r14,%rdx)
decl %r15d
decl %eax
leal 0x1(%rax), %ecx
cmpl %r15d, %eax
movl %ecx, %eax
jl 0x3658b
leal 0x1(%r15), %eax
movq %rax, 0x20(%rsp)
movl %r15d, %eax
movq %rax, 0x10(%rsp)
testl %r15d, %r15d
js 0x36656
movq 0x10(%rsp), %rax
shlq $0x4, %rax
leaq (%rax,%rax,2), %rax
addq $0x30, %rax
xorl %ecx, %ecx
movl $0xffffffff, 0x2c(%r14,%rcx) # imm = 0xFFFFFFFF
addq $0x30, %rcx
cmpq %rcx, %rax
jne 0x36644
movslq 0x20(%rsp), %rsi
leaq -0x146(%rip), %rcx      # 0x3651c
movl $0x30, %edx
movq %r14, %rdi
callq 0x30d0
testl %r15d, %r15d
js 0x36742
movl 0xc(%rsp), %eax
shlq $0x2, %rax
movq %rax, 0x28(%rsp)
leaq 0x58(%r14), %r15
xorl %r13d, %r13d
xorps %xmm1, %xmm1
movq 0x10(%rsp), %r12
leaq (,%r13,2), %rax
addq %r13, %rax
shlq $0x4, %rax
movss 0x28(%r14,%rax), %xmm0
ucomiss %xmm1, %xmm0
jne 0x366b1
jnp 0x3672d
cmpq 0x10(%rsp), %r13
jae 0x3672d
addq %r14, %rax
movsd (%rax), %xmm0
movaps %xmm0, 0x40(%rsp)
movsd 0x8(%rax), %xmm0
movaps %xmm0, 0x30(%rsp)
movq %r15, %rbp
movq %r12, %rbx
movss (%rbp), %xmm0
ucomiss %xmm1, %xmm0
jne 0x366e0
jnp 0x36724
movsd -0x28(%rbp), %xmm2
movsd -0x20(%rbp), %xmm3
movaps 0x40(%rsp), %xmm0
movaps 0x30(%rsp), %xmm1
callq 0x36754
xorps %xmm1, %xmm1
ucomiss 0x1c(%rsp), %xmm0
jbe 0x36724
movl $0x0, (%rbp)
cmpl $0x0, 0xc(%rsp)
jle 0x36724
movq -0x10(%rbp), %rdi
xorl %esi, %esi
movq 0x28(%rsp), %rdx
callq 0x31d0
xorps %xmm1, %xmm1
addq $0x30, %rbp
decq %rbx
jne 0x366d4
incq %r13
decq %r12
addq $0x30, %r15
cmpq 0x20(%rsp), %r13
jne 0x36694
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq