// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/image.c
// Function: draw_detections
void draw_detections(image im, detection *dets, int num, float thresh, char **names, image **alphabet, int classes)
{
    int i,j;

    for(i = 0; i < num; ++i){
        char labelstr[4096] = {0};
        int class = -1;
        for(j = 0; j < classes; ++j){
            if (dets[i].prob[j] > thresh){
                if (class < 0) {
                    strcat(labelstr, names[j]);
                    class = j;
                } else {
                    strcat(labelstr, ", ");
                    strcat(labelstr, names[j]);
                }
                printf("%s: %.0f%%\n", names[j], dets[i].prob[j]*100);
            }
        }
        if(class >= 0){
            int width = im.h * .006;

            /*
               if(0){
               width = pow(prob, 1./2.)*10+1;
               alphabet = 0;
               }
             */

            //printf("%d %s: %.0f%%\n", i, names[class], prob*100);
            int offset = class*123457 % classes;
            float red = get_color(2,offset,classes);
            float green = get_color(1,offset,classes);
            float blue = get_color(0,offset,classes);
            float rgb[3];

            //width = prob*20+2;

            rgb[0] = red;
            rgb[1] = green;
            rgb[2] = blue;
            box b = dets[i].bbox;
            //printf("%f %f %f %f\n", b.x, b.y, b.w, b.h);

            int left  = (b.x-b.w/2.)*im.w;
            int right = (b.x+b.w/2.)*im.w;
            int top   = (b.y-b.h/2.)*im.h;
            int bot   = (b.y+b.h/2.)*im.h;

            if(left < 0) left = 0;
            if(right > im.w-1) right = im.w-1;
            if(top < 0) top = 0;
            if(bot > im.h-1) bot = im.h-1;

            draw_box_width(im, left, top, right, bot, width, red, green, blue);
            if (alphabet) {
                image label = get_label(alphabet, labelstr, (im.h*.03));
                draw_label(im, top + width, left, label, rgb);
                free_image(label);
            }
            if (dets[i].mask){
                image mask = float_to_image(14, 14, 1, dets[i].mask);
                image resized_mask = resize_image(mask, b.w*im.w, b.h*im.h);
                image tmask = threshold_image(resized_mask, .5);
                embed_image(tmask, im, left, top);
                free_image(mask);
                free_image(resized_mask);
                free_image(tmask);
            }
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1158, %rsp           # imm = 0x1158
movq %rcx, 0xa0(%rsp)
movss %xmm0, 0x9c(%rsp)
movq %rdi, 0x60(%rsp)
testl %esi, %esi
jle 0x16749
movl %r8d, %ebp
leaq 0x1190(%rsp), %rax
movl 0x4(%rax), %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x3f34d(%rip), %xmm0    # 0x55460
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %edi
movq %rdi, 0x50(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %r8d, %xmm0
movss %xmm0, 0x90(%rsp)
movl (%rax), %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x108(%rsp)
leal -0x1(%rax), %edi
movl %edi, 0x8c(%rsp)
movsd 0x3f313(%rip), %xmm0    # 0x55468
movsd %xmm1, 0x118(%rsp)
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %edi
movl %edi, 0x84(%rsp)
leal -0x1(%rcx), %edi
movl %edi, 0x88(%rsp)
movq %rax, 0x110(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %eax, %xmm0
movss %xmm0, 0x80(%rsp)
movq %rcx, 0x120(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %ecx, %xmm0
movss %xmm0, 0x7c(%rsp)
movl %esi, %eax
movq %rax, 0x128(%rsp)
movl %r8d, %r13d
xorl %ebx, %ebx
movl %r8d, 0x4c(%rsp)
movq %rdx, 0xa8(%rsp)
movq %r13, 0x100(%rsp)
movl $0x1000, %edx           # imm = 0x1000
leaq 0x150(%rsp), %rdi
xorl %esi, %esi
callq 0x31d0
movq %rbx, 0x130(%rsp)
leaq (%rbx,%rbx,2), %rax
testl %ebp, %ebp
movq %rax, 0x68(%rsp)
jle 0x162c3
shlq $0x4, %rax
movq 0x60(%rsp), %rcx
leaq (%rcx,%rax), %rbx
addq $0x18, %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
xorl %r14d, %r14d
movq %rbx, 0x40(%rsp)
movq (%rbx), %r15
movss (%r15,%r14,4), %xmm0
ucomiss 0x9c(%rsp), %xmm0
jbe 0x162b5
testl %ebp, %ebp
js 0x16275
movl %ebp, %ebx
movq %r13, %rbp
leaq 0x150(%rsp), %r13
movq %r13, %rdi
callq 0x3150
movw $0x202c, 0x150(%rsp,%rax) # imm = 0x202C
movb $0x0, 0x152(%rsp,%rax)
movq 0xa8(%rsp), %r12
movq (%r12,%r14,8), %rsi
movq %r13, %rdi
movq %rbp, %r13
movl %ebx, %ebp
movq 0x40(%rsp), %rbx
callq 0x3420
jmp 0x16291
movq 0xa8(%rsp), %r12
movq (%r12,%r14,8), %rsi
leaq 0x150(%rsp), %rdi
callq 0x3420
movl %r14d, %ebp
movq (%r12,%r14,8), %rsi
movss (%r15,%r14,4), %xmm0
mulss 0x3cfa1(%rip), %xmm0    # 0x53244
cvtss2sd %xmm0, %xmm0
leaq 0x3f3fd(%rip), %rdi     # 0x556ab
movb $0x1, %al
callq 0x3170
incq %r14
cmpq %r14, %r13
jne 0x16213
jmp 0x162c8
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %ebp, %ebp
movl %ebp, %eax
movl 0x4c(%rsp), %ebp
js 0x16730
imull $0x1e241, %eax, %eax    # imm = 0x1E241
cltd
idivl %ebp
xorps %xmm0, %xmm0
cvtsi2ss %edx, %xmm0
divss 0x90(%rsp), %xmm0
mulss 0x3cf49(%rip), %xmm0    # 0x53240
movss %xmm0, 0x40(%rsp)
cvtss2sd %xmm0, %xmm0
movsd %xmm0, 0x70(%rsp)
callq 0x33f0
movaps %xmm0, 0xf0(%rsp)
cvttsd2si %xmm0, %ebx
movsd 0x70(%rsp), %xmm0
callq 0x3490
cvttsd2si %xmm0, %eax
cvttpd2dq 0xf0(%rsp), %xmm0
cvtdq2ps %xmm0, %xmm0
movss 0x40(%rsp), %xmm3
subss %xmm0, %xmm3
movss 0x3ccc3(%rip), %xmm5    # 0x53008
subss %xmm3, %xmm5
movslq %ebx, %rcx
leaq (%rcx,%rcx,2), %rcx
cltq
leaq (%rax,%rax,2), %rax
leaq 0x53f53(%rip), %rdx     # 0x6a2b0
movss 0x8(%rdx,%rax,4), %xmm1
mulss %xmm3, %xmm1
movss 0x8(%rdx,%rcx,4), %xmm0
mulss %xmm5, %xmm0
addss %xmm1, %xmm0
movss 0x4(%rdx,%rax,4), %xmm2
mulss %xmm3, %xmm2
movss 0x4(%rdx,%rcx,4), %xmm1
mulss %xmm5, %xmm1
mulss (%rdx,%rax,4), %xmm3
addss %xmm2, %xmm1
mulss (%rdx,%rcx,4), %xmm5
addss %xmm3, %xmm5
movss %xmm0, 0xcc(%rsp)
movss %xmm1, 0xd0(%rsp)
movss %xmm5, 0xd4(%rsp)
movq 0x68(%rsp), %rcx
shlq $0x4, %rcx
movq 0x60(%rsp), %rax
movss 0x8(%rax,%rcx), %xmm2
cvtss2sd (%rax,%rcx), %xmm6
movss %xmm2, 0x98(%rsp)
cvtss2sd %xmm2, %xmm7
movsd 0x3cd3c(%rip), %xmm4    # 0x53120
mulsd %xmm4, %xmm7
movaps %xmm6, %xmm2
subsd %xmm7, %xmm2
movsd 0x108(%rsp), %xmm3
mulsd %xmm3, %xmm2
cvttsd2si %xmm2, %edx
addsd %xmm6, %xmm7
mulsd %xmm3, %xmm7
cvttsd2si %xmm7, %r12d
xorps %xmm6, %xmm6
cvtss2sd 0x4(%rax,%rcx), %xmm6
movq %rcx, 0x68(%rsp)
movss 0xc(%rax,%rcx), %xmm2
movss %xmm2, 0x94(%rsp)
xorps %xmm7, %xmm7
cvtss2sd %xmm2, %xmm7
mulsd %xmm4, %xmm7
movaps %xmm6, %xmm2
subsd %xmm7, %xmm2
movsd 0x118(%rsp), %xmm3
mulsd %xmm3, %xmm2
cvttsd2si %xmm2, %ecx
addsd %xmm6, %xmm7
mulsd %xmm3, %xmm7
cvttsd2si %xmm7, %ebp
testl %edx, %edx
movl $0x0, %eax
cmovlel %eax, %edx
movl %edx, 0x3c(%rsp)
cmpl %r12d, 0x110(%rsp)
cmovlel 0x8c(%rsp), %r12d
testl %ecx, %ecx
cmovlel %eax, %ecx
movq %rcx, 0x58(%rsp)
cmpl %ebp, 0x120(%rsp)
cmovlel 0x88(%rsp), %ebp
cmpl $0x0, 0x50(%rsp)
leaq 0x1190(%rsp), %r13
jle 0x16511
movl 0x3c(%rsp), %r14d
movq 0x58(%rsp), %rax
movl %eax, %ebx
movq 0x50(%rsp), %rax
movl %eax, %r15d
movss %xmm5, 0x40(%rsp)
movss %xmm0, 0xf0(%rsp)
movss %xmm1, 0x70(%rsp)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm2
movups %xmm2, (%rsp)
movl %r14d, %edi
movl %ebx, %esi
movl %r12d, %edx
movl %ebp, %ecx
movaps %xmm5, %xmm2
callq 0x15cf1
movss 0x70(%rsp), %xmm1
movss 0xf0(%rsp), %xmm0
movss 0x40(%rsp), %xmm5
decl %ebp
decl %r12d
incl %ebx
incl %r14d
decl %r15d
jne 0x164c9
cmpq $0x0, 0xa0(%rsp)
je 0x165a0
leaq 0xb0(%rsp), %rdi
movq 0xa0(%rsp), %rsi
leaq 0x150(%rsp), %rdx
movl 0x84(%rsp), %ecx
callq 0x159f1
movq 0x50(%rsp), %rax
movq 0x58(%rsp), %rcx
leal (%rcx,%rax), %edi
movq 0xc0(%rsp), %rax
movq %rax, 0x28(%rsp)
movups 0xb0(%rsp), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movups (%r13), %xmm0
movups %xmm0, (%rsp)
movl 0x3c(%rsp), %esi
leaq 0xcc(%rsp), %rdx
callq 0x15b46
movq 0xc0(%rsp), %rdi
testq %rdi, %rdi
je 0x165a0
callq 0x3040
movq 0x68(%rsp), %rax
addq 0x60(%rsp), %rax
movq 0x20(%rax), %r12
testq %r12, %r12
movq 0x100(%rsp), %r13
je 0x1672c
movabsq $0xe0000000e, %rax      # imm = 0xE0000000E
movq %rax, 0xb0(%rsp)
movl $0x1, 0xb8(%rsp)
movss 0x98(%rsp), %xmm0
mulss 0x80(%rsp), %xmm0
cvttss2si %xmm0, %esi
movq %r12, 0xc0(%rsp)
movss 0x94(%rsp), %xmm0
mulss 0x7c(%rsp), %xmm0
cvttss2si %xmm0, %edx
movq 0xc0(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xb0(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x138(%rsp), %rdi
callq 0x1676b
movl 0x138(%rsp), %eax
movl 0x13c(%rsp), %r15d
movl 0x140(%rsp), %ecx
movq 0x148(%rsp), %rbp
movq $0x0, 0xe8(%rsp)
movl %r15d, 0xdc(%rsp)
movl %eax, 0xd8(%rsp)
movl %ecx, 0xe0(%rsp)
imull %eax, %r15d
imull %ecx, %r15d
movslq %r15d, %rbx
movl $0x4, %esi
movq %rbx, %rdi
callq 0x3260
movss 0x3c975(%rip), %xmm2    # 0x53008
movss 0x3cb99(%rip), %xmm1    # 0x53234
movq %rax, %r14
movq %rax, 0xe8(%rsp)
testl %ebx, %ebx
jle 0x166ca
movl %r15d, %eax
xorl %ecx, %ecx
movaps %xmm1, %xmm0
cmpltss (%rbp,%rcx,4), %xmm0
andps %xmm2, %xmm0
movss %xmm0, (%r14,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x166af
leaq 0x1190(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x28(%rsp)
movups (%rcx), %xmm0
movups %xmm0, 0x18(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x10(%rsp)
movups 0xd8(%rsp), %xmm0
movups %xmm0, (%rsp)
movl 0x3c(%rsp), %edi
movq 0x58(%rsp), %rsi
callq 0x158a0
movq %r12, %rdi
callq 0x3040
testq %rbp, %rbp
je 0x1671f
movq %rbp, %rdi
callq 0x3040
testq %r14, %r14
je 0x1672c
movq %r14, %rdi
callq 0x3040
movl 0x4c(%rsp), %ebp
movq 0x130(%rsp), %rbx
incq %rbx
cmpq 0x128(%rsp), %rbx
jne 0x161c8
addq $0x1158, %rsp           # imm = 0x1158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq