// File: /workspace/github_c_makefile_star2_O2/SimpleDoger[P]Darknet_CPU_Only/region_layer.c
// Function: get_region_detections
void get_region_detections(layer l, int w, int h, int netw, int neth, float thresh, int *map, float tree_thresh, int relative, detection *dets)
{
    int i,j,n,z;
    float *predictions = l.output;
    if (l.batch == 2) {
        float *flip = l.output + l.outputs;
        for (j = 0; j < l.h; ++j) {
            for (i = 0; i < l.w/2; ++i) {
                for (n = 0; n < l.n; ++n) {
                    for(z = 0; z < l.classes + l.coords + 1; ++z){
                        int i1 = z*l.w*l.h*l.n + n*l.w*l.h + j*l.w + i;
                        int i2 = z*l.w*l.h*l.n + n*l.w*l.h + j*l.w + (l.w - i - 1);
                        float swap = flip[i1];
                        flip[i1] = flip[i2];
                        flip[i2] = swap;
                        if(z == 0){
                            flip[i1] = -flip[i1];
                            flip[i2] = -flip[i2];
                        }
                    }
                }
            }
        }
        for(i = 0; i < l.outputs; ++i){
            l.output[i] = (l.output[i] + flip[i])/2.;
        }
    }
    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 index = n*l.w*l.h + i;
            for(j = 0; j < l.classes; ++j){
                dets[index].prob[j] = 0;
            }
            int obj_index  = entry_index(l, 0, n*l.w*l.h + i, l.coords);
            int box_index  = entry_index(l, 0, n*l.w*l.h + i, 0);
            int mask_index = entry_index(l, 0, n*l.w*l.h + i, 4);
            float scale = l.background ? 1 : predictions[obj_index];
            dets[index].bbox = get_region_box(predictions, l.biases, n, box_index, col, row, l.w, l.h, l.w*l.h);
            dets[index].objectness = scale > thresh ? scale : 0;
            if(dets[index].mask){
                for(j = 0; j < l.coords - 4; ++j){
                    dets[index].mask[j] = l.output[mask_index + j*l.w*l.h];
                }
            }

            int class_index = entry_index(l, 0, n*l.w*l.h + i, l.coords + !l.background);
            if(l.softmax_tree){

                hierarchy_predictions(predictions + class_index, l.classes, l.softmax_tree, 0, l.w*l.h);
                if(map){
                    for(j = 0; j < 200; ++j){
                        int class_index = entry_index(l, 0, n*l.w*l.h + i, l.coords + 1 + map[j]);
                        float prob = scale*predictions[class_index];
                        dets[index].prob[j] = (prob > thresh) ? prob : 0;
                    }
                } else {
                    int j =  hierarchy_top_prediction(predictions + class_index, l.softmax_tree, tree_thresh, l.w*l.h);
                    dets[index].prob[j] = (scale > thresh) ? scale : 0;
                }
            } else {
                if(dets[index].objectness){
                    for(j = 0; j < l.classes; ++j){
                        int class_index = entry_index(l, 0, n*l.w*l.h + i, l.coords + 1 + j);
                        float prob = scale*predictions[class_index];
                        dets[index].prob[j] = (prob > thresh) ? prob : 0;
                    }
                }
            }
        }
    }
    correct_region_boxes(dets, l.w*l.h*l.n, w, h, netw, neth, relative);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %r9, 0x98(%rsp)
movss %xmm1, 0x74(%rsp)
movq %r8, 0xa0(%rsp)
movl %ecx, 0x6c(%rsp)
movl %edx, 0x68(%rsp)
movl %esi, 0x64(%rsp)
movl %edi, 0x60(%rsp)
leaq 0x110(%rsp), %r9
movq 0x268(%r9), %rbx
cmpl $0x2, 0x48(%r9)
jne 0x31a82
movslq 0x58(%r9), %rax
movq %rax, 0x50(%rsp)
leaq (%rbx,%rax,4), %rsi
movl 0x6c(%r9), %edi
movl 0x70(%r9), %r8d
pushq $0x2
popq %rcx
movl %r8d, %eax
cltd
idivl %ecx
movl 0x84(%r9), %ecx
movl 0xfc(%r9), %r10d
movl 0x100(%r9), %edx
movq %r10, 0x48(%rsp)
movq %rdx, 0x38(%rsp)
leal (%rdx,%r10), %r9d
xorl %r14d, %r14d
testl %ecx, %ecx
movl $0x0, %edx
cmovgl %ecx, %edx
testl %eax, %eax
cmovlel %r14d, %eax
movl %eax, 0x40(%rsp)
testl %edi, %edi
movl $0x0, %eax
cmovgl %edi, %eax
movl %eax, (%rsp)
movslq %r9d, %r10
movq %rdi, 0x10(%rsp)
movl %edi, %r11d
imull %r8d, %r11d
movl %r11d, %ebp
movl %ecx, 0x2c(%rsp)
imull %ecx, %ebp
movq %r8, 0x8(%rsp)
leal -0x1(%r8), %ecx
movaps 0x1a7a2(%rip), %xmm3    # 0x4c150
xorl %edi, %edi
cmpl (%rsp), %edi
je 0x31aac
movl %edi, 0x4(%rsp)
xorl %eax, %eax
movl %ecx, 0x18(%rsp)
movl %ecx, %edi
movq %r14, 0x58(%rsp)
movl %r14d, %r15d
cmpl 0x40(%rsp), %eax
je 0x31a64
movl %eax, 0x80(%rsp)
xorl %ecx, %ecx
movl %edi, 0x20(%rsp)
movl %edi, %r14d
movl %r15d, %r8d
cmpl %edx, %ecx
je 0x31a4d
movl %r14d, %r13d
movl %r8d, %edi
xorl %r12d, %r12d
cmpq %r10, %r12
jg 0x31a43
movslq %edi, %r9
movss (%rsi,%r9,4), %xmm1
movslq %r13d, %rax
movss (%rsi,%rax,4), %xmm2
movss %xmm2, (%rsi,%r9,4)
movss %xmm1, (%rsi,%rax,4)
testq %r12, %r12
jne 0x31a39
movss (%rsi,%r9,4), %xmm1
xorps %xmm3, %xmm1
movss %xmm1, (%rsi,%r9,4)
movss (%rsi,%rax,4), %xmm1
xorps %xmm3, %xmm1
movss %xmm1, (%rsi,%rax,4)
incq %r12
addl %ebp, %edi
addl %ebp, %r13d
jmp 0x319f7
incl %ecx
addl %r11d, %r8d
addl %r11d, %r14d
jmp 0x319ea
movl 0x80(%rsp), %eax
incl %eax
incl %r15d
movl 0x20(%rsp), %edi
decl %edi
jmp 0x319cd
movl 0x4(%rsp), %edi
incl %edi
movq 0x8(%rsp), %rax
movq 0x58(%rsp), %r14
addl %eax, %r14d
movl 0x18(%rsp), %ecx
addl %eax, %ecx
jmp 0x319b0
movl 0x6c(%r9), %r10d
movl 0x70(%r9), %r11d
movl 0x84(%r9), %eax
movl 0xfc(%r9), %ecx
movl 0x100(%r9), %esi
xorl %edx, %edx
testl %eax, %eax
movl %eax, 0x2c(%rsp)
cmovgl %eax, %edx
jmp 0x31afe
xorl %eax, %eax
movq 0x50(%rsp), %rdi
testl %edi, %edi
movl $0x0, %ecx
cmovgl %edi, %ecx
movss 0x1a76f(%rip), %xmm2    # 0x4c234
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %r11
leaq 0x110(%rsp), %r9
cmpq %rax, %rcx
je 0x31af4
movss (%rbx,%rax,4), %xmm1
addss (%rsi,%rax,4), %xmm1
mulss %xmm2, %xmm1
movss %xmm1, (%rbx,%rax,4)
incq %rax
jmp 0x31ad7
movq 0x48(%rsp), %rcx
movq 0x38(%rsp), %rsi
movl %r10d, %r14d
imull %r11d, %r14d
leal 0x1(%rsi), %eax
movl %eax, 0x30(%rsp)
leal (%rsi,%rcx), %eax
incl %eax
movl %eax, 0x50(%rsp)
movl 0x104(%r9), %eax
xorl %edi, %edi
movl %eax, 0x7c(%rsp)
testl %eax, %eax
sete %dil
movl %edi, 0x78(%rsp)
movq 0x230(%r9), %rax
movq %rax, 0xb8(%rsp)
xorl %edi, %edi
testl %ecx, %ecx
movl $0x0, %r13d
cmovgl %ecx, %r13d
leal -0x4(%rsi), %eax
testl %eax, %eax
cmovlel %edi, %eax
movq %rax, 0xb0(%rsp)
testl %r14d, %r14d
movl $0x0, %eax
cmovgl %r14d, %eax
movl %eax, 0x70(%rsp)
movq 0x490(%r9), %rax
movq %rax, 0x40(%rsp)
movl %edx, %eax
movq %rax, 0x58(%rsp)
movss %xmm0, 0x34(%rsp)
movq %r10, 0x10(%rsp)
movq %r11, 0x8(%rsp)
movq %rcx, 0x48(%rsp)
movq %rsi, 0x38(%rsp)
cmpl 0x70(%rsp), %edi
je 0x31e49
movl %edi, %eax
cltd
idivl %r11d
movl %eax, 0x4(%rsp)
movl %edx, (%rsp)
xorl %r8d, %r8d
movq %rdi, 0x18(%rsp)
cmpq 0x58(%rsp), %r8
je 0x31e42
movl %r14d, %eax
imull %r8d, %eax
addl %edi, %eax
movslq %eax, %rcx
imulq $0x30, %rcx, %rbp
movq 0x5b0(%rsp), %rcx
addq %rbp, %rcx
addq $0x18, %rcx
xorl %edx, %edx
cmpq %rdx, %r13
je 0x31bf2
movq (%rcx), %rsi
andl $0x0, (%rsi,%rdx,4)
incq %rdx
jmp 0x31be1
cltd
idivl %r14d
movl %edx, %r15d
movl %eax, %r12d
imull 0x50(%rsp), %r12d
movss 0x1a3fe(%rip), %xmm0    # 0x4c008
cmpl $0x0, 0x7c(%rsp)
jne 0x31c27
movq 0x38(%rsp), %rax
addl %r12d, %eax
imull %r14d, %eax
addl %r15d, %eax
cltq
movss (%rbx,%rax,4), %xmm0
movaps %xmm0, 0x80(%rsp)
movl %r12d, %ecx
imull %r14d, %ecx
addl %r15d, %ecx
subq $0x8, %rsp
movq %rbx, %rdi
movq 0xc0(%rsp), %rsi
movq %r8, 0x28(%rsp)
movl %r8d, %edx
movl 0x8(%rsp), %r8d
movl 0xc(%rsp), %r9d
pushq %r14
pushq %r10
pushq %r11
callq 0x3135f
movaps 0xa0(%rsp), %xmm3
addq $0x20, %rsp
movlhps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0]
movq 0x5b0(%rsp), %rax
movups %xmm0, (%rax,%rbp)
movss 0x34(%rsp), %xmm0
movaps %xmm0, %xmm2
cmpltss %xmm3, %xmm2
andps %xmm3, %xmm2
movss %xmm2, 0x28(%rax,%rbp)
movq 0x20(%rax,%rbp), %rax
testq %rax, %rax
movq 0xb0(%rsp), %rsi
je 0x31cd1
leal 0x4(%r12), %ecx
imull %r14d, %ecx
addl %r15d, %ecx
xorl %edx, %edx
cmpq %rdx, %rsi
je 0x31cd1
movslq %ecx, %rcx
movss (%rbx,%rcx,4), %xmm1
movss %xmm1, (%rax,%rdx,4)
incq %rdx
addl %r14d, %ecx
jmp 0x31cb7
addq 0x5b0(%rsp), %rbp
movq 0x40(%rsp), %rdx
testq %rdx, %rdx
je 0x31d98
movaps %xmm2, 0xc0(%rsp)
movq 0x38(%rsp), %rax
addl %r12d, %eax
addl 0x78(%rsp), %eax
imull %r14d, %eax
addl %r15d, %eax
cltq
leaq (%rbx,%rax,4), %rdi
movq %rdi, 0xa8(%rsp)
movq 0x48(%rsp), %rsi
xorl %ecx, %ecx
movl %r14d, %r8d
callq 0x324ad
movq 0xa0(%rsp), %rsi
testq %rsi, %rsi
je 0x31df8
addl 0x30(%rsp), %r12d
movq 0x18(%rbp), %rax
xorl %ecx, %ecx
movss 0x34(%rsp), %xmm0
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %r11
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %r8
movaps 0x80(%rsp), %xmm3
cmpq $0xc8, %rcx
je 0x31e3a
movl (%rsi,%rcx,4), %edx
addl %r12d, %edx
imull %r14d, %edx
addl %r15d, %edx
movslq %edx, %rdx
movss (%rbx,%rdx,4), %xmm2
mulss %xmm3, %xmm2
movaps %xmm0, %xmm1
cmpltss %xmm2, %xmm1
andps %xmm2, %xmm1
movss %xmm1, (%rax,%rcx,4)
incq %rcx
jmp 0x31d5d
movss 0x28(%rbp), %xmm1
ucomiss 0x1a2d4(%rip), %xmm1    # 0x4c078
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %r11
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %r8
jne 0x31dbc
jnp 0x31e3a
addl 0x30(%rsp), %r12d
imull %r14d, %r12d
addl %r12d, %r15d
xorl %eax, %eax
cmpq %rax, %r13
je 0x31e3a
movslq %r15d, %r15
movss (%rbx,%r15,4), %xmm2
mulss %xmm3, %xmm2
movaps %xmm0, %xmm1
cmpltss %xmm2, %xmm1
andps %xmm2, %xmm1
movq 0x18(%rbp), %rcx
movss %xmm1, (%rcx,%rax,4)
incq %rax
addl %r14d, %r15d
jmp 0x31dca
movq 0xa8(%rsp), %rdi
movq 0x40(%rsp), %rsi
movss 0x74(%rsp), %xmm0
movl %r14d, %edx
callq 0x32512
movq 0x18(%rbp), %rcx
cltq
movaps 0xc0(%rsp), %xmm0
movss %xmm0, (%rcx,%rax,4)
movq 0x10(%rsp), %r10
movq 0x8(%rsp), %r11
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %r8
incq %r8
jmp 0x31bb5
incl %edi
jmp 0x31b96
movl 0x2c(%rsp), %esi
imull %r14d, %esi
subq $0x8, %rsp
movq 0x5b8(%rsp), %rdi
movl 0x68(%rsp), %edx
movl 0x6c(%rsp), %ecx
movl 0x70(%rsp), %r8d
movl 0x74(%rsp), %r9d
pushq 0xa0(%rsp)
callq 0x317f1
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq