// File: /workspace/github_c_makefile_star2_O3/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 $0x78, %rsp
movss %xmm0, 0x4(%rsp)
movl %edx, (%rsp)
movl %esi, %r15d
movq %rdi, %rbx
testl %esi, %esi
jle 0x38989
decl %r15d
xorl %eax, %eax
xorps %xmm0, %xmm0
movslq %eax, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x4, %rcx
movss 0x28(%rbx,%rcx), %xmm1
ucomiss %xmm0, %xmm1
jne 0x38768
jp 0x38768
addq %rbx, %rcx
movups (%rcx), %xmm1
movups 0x10(%rcx), %xmm2
movups 0x20(%rcx), %xmm3
movaps %xmm3, 0x60(%rsp)
movaps %xmm2, 0x50(%rsp)
movaps %xmm1, 0x40(%rsp)
movslq %r15d, %r15
leaq (%r15,%r15,2), %rdx
shlq $0x4, %rdx
movups (%rbx,%rdx), %xmm1
movups 0x10(%rbx,%rdx), %xmm2
movups 0x20(%rbx,%rdx), %xmm3
movups %xmm3, 0x20(%rcx)
movups %xmm2, 0x10(%rcx)
movups %xmm1, (%rcx)
movaps 0x40(%rsp), %xmm1
movaps 0x50(%rsp), %xmm2
movaps 0x60(%rsp), %xmm3
movups %xmm3, 0x20(%rbx,%rdx)
movups %xmm2, 0x10(%rbx,%rdx)
movups %xmm1, (%rbx,%rdx)
decl %r15d
decl %eax
leal 0x1(%rax), %ecx
cmpl %r15d, %eax
movl %ecx, %eax
jl 0x386ed
leal 0x1(%r15), %eax
testl %r15d, %r15d
js 0x3898e
movl %eax, %ecx
addl $0x3, %eax
movq %rcx, 0x8(%rsp)
decq %rcx
movq %rcx, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
shrl $0x2, %eax
shlq $0x6, %rax
leaq (%rax,%rax,2), %rax
movdqa 0x1c9c3(%rip), %xmm1    # 0x55170
movdqa 0x1c8cb(%rip), %xmm2    # 0x55080
xorl %ecx, %ecx
movdqa 0x1c8d1(%rip), %xmm3    # 0x55090
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movdqa 0x1c9b1(%rip), %xmm5    # 0x55180
movdqa %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %edx
notl %edx
testb $0x1, %dl
je 0x3880b
movl $0xffffffff, 0x2c(%rbx,%rcx) # imm = 0xFFFFFFFF
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x38821
movl $0xffffffff, 0x5c(%rbx,%rcx) # imm = 0xFFFFFFFF
movdqa %xmm1, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
pxor %xmm4, %xmm6
pextrw $0x0, %xmm6, %edx
testb $0x1, %dl
je 0x38863
movl $0xffffffff, 0x8c(%rbx,%rcx) # imm = 0xFFFFFFFF
pextrw $0x4, %xmm6, %edx
testb $0x1, %dl
je 0x38878
movl $0xffffffff, 0xbc(%rbx,%rcx) # imm = 0xFFFFFFFF
paddq %xmm5, %xmm2
paddq %xmm5, %xmm1
addq $0xc0, %rcx
cmpq %rcx, %rax
jne 0x387cf
leaq -0x217(%rip), %rcx      # 0x38680
movl $0x30, %edx
movq %rbx, %rdi
movq 0x8(%rsp), %rsi
callq 0x30c0
testl %r15d, %r15d
js 0x3897a
movl (%rsp), %eax
shlq $0x2, %rax
movq %rax, 0x18(%rsp)
movl %r15d, %r12d
leaq 0x58(%rbx), %r14
xorl %r15d, %r15d
pxor %xmm1, %xmm1
movq %r12, 0x10(%rsp)
leaq (%r15,%r15,2), %rax
shlq $0x4, %rax
movss 0x28(%rbx,%rax), %xmm0
ucomiss %xmm1, %xmm0
jne 0x388e6
jnp 0x38965
cmpq 0x10(%rsp), %r15
jae 0x38965
addq %rbx, %rax
movsd (%rax), %xmm0
movaps %xmm0, 0x30(%rsp)
movsd 0x8(%rax), %xmm0
movaps %xmm0, 0x20(%rsp)
movq %r14, %r13
movq %r12, %rbp
movss (%r13), %xmm0
ucomiss %xmm1, %xmm0
jne 0x38916
jnp 0x3895c
movq -0x28(%r13), %xmm2
movq -0x20(%r13), %xmm3
movaps 0x30(%rsp), %xmm0
movaps 0x20(%rsp), %xmm1
callq 0x389b3
xorps %xmm1, %xmm1
ucomiss 0x4(%rsp), %xmm0
jbe 0x3895c
movl $0x0, (%r13)
cmpl $0x0, (%rsp)
jle 0x3895c
movq -0x10(%r13), %rdi
xorl %esi, %esi
movq 0x18(%rsp), %rdx
callq 0x31c0
xorps %xmm1, %xmm1
addq $0x30, %r13
decq %rbp
jne 0x38909
incq %r15
decq %r12
addq $0x30, %r14
cmpq 0x8(%rsp), %r15
jne 0x388d1
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movslq %r15d, %rsi
jmp 0x38991
movslq %eax, %rsi
leaq -0x318(%rip), %rcx      # 0x38680
movl $0x30, %edx
movq %rbx, %rdi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x30c0