// File: /workspace/github_c_makefile_star2_O1/SimpleDoger[P]Darknet_CPU_Only/region_layer.c
// Function: forward_region_layer
void forward_region_layer(const layer l, network net)
{
    int i,j,b,t,n;
    memcpy(l.output, net.input, l.outputs*l.batch*sizeof(float));

    for (b = 0; b < l.batch; ++b){
        for(n = 0; n < l.n; ++n){
            int index = entry_index(l, b, n*l.w*l.h, 0);
            activate_array(l.output + index, 2*l.w*l.h, LOGISTIC);
            index = entry_index(l, b, n*l.w*l.h, l.coords);
            if(!l.background) activate_array(l.output + index,   l.w*l.h, LOGISTIC);
            index = entry_index(l, b, n*l.w*l.h, l.coords + 1);
            if(!l.softmax && !l.softmax_tree) activate_array(l.output + index, l.classes*l.w*l.h, LOGISTIC);
        }
    }
    if (l.softmax_tree){
        int i;
        int count = l.coords + 1;
        for (i = 0; i < l.softmax_tree->groups; ++i) {
            int group_size = l.softmax_tree->group_size[i];
            softmax_cpu(net.input + count, group_size, l.batch, l.inputs, l.n*l.w*l.h, 1, l.n*l.w*l.h, l.temperature, l.output + count);
            count += group_size;
        }
    } else if (l.softmax){
        int index = entry_index(l, 0, 0, l.coords + !l.background);
        softmax_cpu(net.input + index, l.classes + l.background, l.batch*l.n, l.inputs/l.n, l.w*l.h, 1, l.w*l.h, 1, l.output + index);
    }

    memset(l.delta, 0, l.outputs * l.batch * sizeof(float));
    if(!net.train) return;
    float avg_iou = 0;
    float recall = 0;
    float avg_cat = 0;
    float avg_obj = 0;
    float avg_anyobj = 0;
    int count = 0;
    int class_count = 0;
    *(l.cost) = 0;
    for (b = 0; b < l.batch; ++b) {
        if(l.softmax_tree){
            int onlyclass = 0;
            for(t = 0; t < 30; ++t){
                box truth = float_to_box(net.truth + t*(l.coords + 1) + b*l.truths, 1);
                if(!truth.x) break;
                int class = net.truth[t*(l.coords + 1) + b*l.truths + l.coords];
                float maxp = 0;
                int maxi = 0;
                if(truth.x > 100000 && truth.y > 100000){
                    for(n = 0; n < l.n*l.w*l.h; ++n){
                        int class_index = entry_index(l, b, n, l.coords + 1);
                        int obj_index = entry_index(l, b, n, l.coords);
                        float scale =  l.output[obj_index];
                        l.delta[obj_index] = l.noobject_scale * (0 - l.output[obj_index]);
                        float p = scale*get_hierarchy_probability(l.output + class_index, l.softmax_tree, class, l.w*l.h);
                        if(p > maxp){
                            maxp = p;
                            maxi = n;
                        }
                    }
                    int class_index = entry_index(l, b, maxi, l.coords + 1);
                    int obj_index = entry_index(l, b, maxi, l.coords);
                    delta_region_class(l.output, l.delta, class_index, class, l.classes, l.softmax_tree, l.class_scale, l.w*l.h, &avg_cat, !l.softmax);
                    if(l.output[obj_index] < .3) l.delta[obj_index] = l.object_scale * (.3 - l.output[obj_index]);
                    else  l.delta[obj_index] = 0;
                    l.delta[obj_index] = 0;
                    ++class_count;
                    onlyclass = 1;
                    break;
                }
            }
            if(onlyclass) continue;
        }
        for (j = 0; j < l.h; ++j) {
            for (i = 0; i < l.w; ++i) {
                for (n = 0; n < l.n; ++n) {
                    int box_index = entry_index(l, b, n*l.w*l.h + j*l.w + i, 0);
                    box pred = get_region_box(l.output, l.biases, n, box_index, i, j, l.w, l.h, l.w*l.h);
                    float best_iou = 0;
                    for(t = 0; t < 30; ++t){
                        box truth = float_to_box(net.truth + t*(l.coords + 1) + b*l.truths, 1);
                        if(!truth.x) break;
                        float iou = box_iou(pred, truth);
                        if (iou > best_iou) {
                            best_iou = iou;
                        }
                    }
                    int obj_index = entry_index(l, b, n*l.w*l.h + j*l.w + i, l.coords);
                    avg_anyobj += l.output[obj_index];
                    l.delta[obj_index] = l.noobject_scale * (0 - l.output[obj_index]);
                    if(l.background) l.delta[obj_index] = l.noobject_scale * (1 - l.output[obj_index]);
                    if (best_iou > l.thresh) {
                        l.delta[obj_index] = 0;
                    }

                    if(*(net.seen) < 12800){
                        box truth = {0};
                        truth.x = (i + .5)/l.w;
                        truth.y = (j + .5)/l.h;
                        truth.w = l.biases[2*n]/l.w;
                        truth.h = l.biases[2*n+1]/l.h;
                        delta_region_box(truth, l.output, l.biases, n, box_index, i, j, l.w, l.h, l.delta, .01, l.w*l.h);
                    }
                }
            }
        }
        for(t = 0; t < 30; ++t){
            box truth = float_to_box(net.truth + t*(l.coords + 1) + b*l.truths, 1);

            if(!truth.x) break;
            float best_iou = 0;
            int best_n = 0;
            i = (truth.x * l.w);
            j = (truth.y * l.h);
            box truth_shift = truth;
            truth_shift.x = 0;
            truth_shift.y = 0;
            for(n = 0; n < l.n; ++n){
                int box_index = entry_index(l, b, n*l.w*l.h + j*l.w + i, 0);
                box pred = get_region_box(l.output, l.biases, n, box_index, i, j, l.w, l.h, l.w*l.h);
                if(l.bias_match){
                    pred.w = l.biases[2*n]/l.w;
                    pred.h = l.biases[2*n+1]/l.h;
                }
                pred.x = 0;
                pred.y = 0;
                float iou = box_iou(pred, truth_shift);
                if (iou > best_iou){
                    best_iou = iou;
                    best_n = n;
                }
            }

            int box_index = entry_index(l, b, best_n*l.w*l.h + j*l.w + i, 0);
            float iou = delta_region_box(truth, l.output, l.biases, best_n, box_index, i, j, l.w, l.h, l.delta, l.coord_scale *  (2 - truth.w*truth.h), l.w*l.h);
            if(l.coords > 4){
                int mask_index = entry_index(l, b, best_n*l.w*l.h + j*l.w + i, 4);
                delta_region_mask(net.truth + t*(l.coords + 1) + b*l.truths + 5, l.output, l.coords - 4, mask_index, l.delta, l.w*l.h, l.mask_scale);
            }
            if(iou > .5) recall += 1;
            avg_iou += iou;

            int obj_index = entry_index(l, b, best_n*l.w*l.h + j*l.w + i, l.coords);
            avg_obj += l.output[obj_index];
            l.delta[obj_index] = l.object_scale * (1 - l.output[obj_index]);
            if (l.rescore) {
                l.delta[obj_index] = l.object_scale * (iou - l.output[obj_index]);
            }
            if(l.background){
                l.delta[obj_index] = l.object_scale * (0 - l.output[obj_index]);
            }

            int class = net.truth[t*(l.coords + 1) + b*l.truths + l.coords];
            if (l.map) class = l.map[class];
            int class_index = entry_index(l, b, best_n*l.w*l.h + j*l.w + i, l.coords + 1);
            delta_region_class(l.output, l.delta, class_index, class, l.classes, l.softmax_tree, l.class_scale, l.w*l.h, &avg_cat, !l.softmax);
            ++count;
            ++class_count;
        }
    }
    *(l.cost) = pow(mag_array(l.delta, l.outputs * l.batch), 2);
    printf("Region Avg IOU: %f, Class: %f, Obj: %f, No Obj: %f, Avg Recall: %f,  count: %d\n", avg_iou/count, avg_cat/class_count, avg_obj/count, avg_anyobj/(l.w*l.h*l.n*l.batch), recall/count, count);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
leaq 0xf0(%rsp), %r13
movq 0x268(%r13), %rdi
movq 0x668(%rsp), %rbx
movslq 0x58(%r13), %rax
movslq 0x48(%r13), %rdx
imulq %rax, %rdx
shlq $0x2, %rdx
movq %rbx, %rsi
callq 0x32c0
movl 0x48(%r13), %ecx
testl %ecx, %ecx
jle 0x3ad20
xorl %ebp, %ebp
cmpl $0x0, 0x84(%r13)
jle 0x3ad12
xorl %r14d, %r14d
movl 0x6c(%r13), %esi
imull 0x70(%r13), %esi
movl 0xfc(%r13), %edi
movl %esi, %ecx
imull %r14d, %ecx
movl %ecx, %eax
cltd
idivl %esi
movl 0x58(%r13), %eax
imull %ebp, %eax
movl 0x100(%r13), %r8d
addl %r8d, %edi
incl %edi
subl %edx, %ecx
imull %edi, %ecx
addl %edx, %eax
addl %ecx, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
addq 0x268(%r13), %rdi
addl %esi, %esi
xorl %edx, %edx
callq 0x275e5
cmpl $0x0, 0x104(%r13)
jne 0x3ac97
movl 0x58(%r13), %ecx
movl 0x6c(%r13), %esi
imull 0x70(%r13), %esi
movl 0xfc(%r13), %edi
movl %esi, %eax
imull %r14d, %eax
cltd
idivl %esi
imull %ebp, %ecx
addl %ecx, %edx
movl 0x100(%r13), %ecx
addl %ecx, %edi
incl %edi
imull %eax, %edi
addl %ecx, %edi
imull %esi, %edi
addl %edx, %edi
movslq %edi, %rdi
shlq $0x2, %rdi
addq 0x268(%r13), %rdi
xorl %edx, %edx
callq 0x275e5
cmpl $0x0, 0xf8(%r13)
jne 0x3ad02
cmpq $0x0, 0x490(%r13)
jne 0x3ad02
movl 0x58(%r13), %edi
movl 0x6c(%r13), %esi
movl 0xfc(%r13), %ecx
imull 0x70(%r13), %esi
movl %esi, %eax
imull %r14d, %eax
cltd
idivl %esi
imull %ebp, %edi
addl %edi, %edx
movl 0x100(%r13), %edi
leal (%rdi,%rcx), %r8d
incl %r8d
imull %eax, %r8d
leal (%r8,%rdi), %eax
incl %eax
imull %esi, %eax
addl %edx, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
addq 0x268(%r13), %rdi
imull %ecx, %esi
xorl %edx, %edx
callq 0x275e5
incl %r14d
cmpl 0x84(%r13), %r14d
jl 0x3abf3
incl %ebp
movl 0x48(%r13), %ecx
cmpl %ecx, %ebp
jl 0x3abe2
leaq 0x590(%rsp), %r14
cmpq $0x0, 0x490(%r13)
je 0x3adc0
movq 0x490(%r13), %rax
cmpl $0x0, 0x30(%rax)
jle 0x3ae36
movl 0x100(%r13), %r15d
incl %r15d
xorl %r12d, %r12d
movq 0x38(%rax), %rax
movl (%rax,%r12,4), %ebp
movslq %r15d, %r15
leaq (%rbx,%r15,4), %rdi
leaq (,%r15,4), %rax
movl 0x48(%r13), %edx
movl 0x70(%r13), %r8d
imull 0x84(%r13), %r8d
imull 0x6c(%r13), %r8d
movl 0x54(%r13), %ecx
movss 0x18c(%r13), %xmm0
addq 0x268(%r13), %rax
movl %ebp, %esi
movl $0x1, %r9d
pushq %rax
pushq %r8
callq 0x28b70
addq $0x10, %rsp
addl %ebp, %r15d
incq %r12
movq 0x490(%r13), %rax
movslq 0x30(%rax), %rcx
cmpq %rcx, %r12
jl 0x3ad54
jmp 0x3ae36
cmpl $0x0, 0xf8(%r13)
je 0x3ae36
movl 0x100(%r13), %edx
movl 0x104(%r13), %esi
cmpl $0x1, %esi
adcl $0x0, %edx
movl 0x54(%r13), %eax
movl 0x6c(%r13), %r8d
imull 0x70(%r13), %r8d
imull %r8d, %edx
movslq %edx, %r10
leaq (%rbx,%r10,4), %rdi
shlq $0x2, %r10
addl 0xfc(%r13), %esi
movl 0x84(%r13), %r9d
imull %r9d, %ecx
cltd
idivl %r9d
addq 0x268(%r13), %r10
movss 0x181e9(%rip), %xmm0    # 0x53008
movl %ecx, %edx
movl %eax, %ecx
movl $0x1, %r9d
pushq %r10
pushq %r8
callq 0x28b70
addq $0x10, %rsp
movq 0x260(%r13), %rdi
movslq 0x58(%r13), %rax
movslq 0x48(%r13), %rdx
imulq %rax, %rdx
shlq $0x2, %rdx
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x31d0
cmpl $0x0, 0xf8(%r14)
je 0x3ba99
movl %ebx, 0x2c(%rsp)
movq 0x1d8(%r13), %rax
movl %ebx, (%rax)
movl 0x48(%r13), %esi
testl %esi, %esi
jle 0x3b9d8
movq 0x8(%r14), %rax
movq %rax, 0xb0(%rsp)
movq 0xe0(%r14), %rbx
leaq 0x14(%rbx), %rax
movq %rax, 0x98(%rsp)
xorl %r8d, %r8d
xorps %xmm2, %xmm2
xorps %xmm0, %xmm0
movaps %xmm0, 0x70(%rsp)
xorps %xmm1, %xmm1
movl $0x0, 0x4c(%rsp)
movl $0x0, 0x28(%rsp)
cmpq $0x0, 0x490(%r13)
movslq %r8d, %rbp
movss %xmm1, 0xc(%rsp)
movss %xmm2, 0x8(%rsp)
movq %r8, 0x18(%rsp)
je 0x3b14f
movss %xmm0, 0x14(%rsp)
xorl %r15d, %r15d
xorl %r14d, %r14d
movslq 0x100(%r13), %rax
incq %rax
movslq %r15d, %rcx
imulq %rax, %rcx
leaq (%rbx,%rcx,4), %rax
movslq 0x68(%r13), %rcx
imulq %rbp, %rcx
leaq (%rax,%rcx,4), %rdi
movl $0x1, %esi
callq 0x36a46
ucomiss 0x1815b(%rip), %xmm0    # 0x53078
jne 0x3af25
jnp 0x3b061
movss 0x1cd93(%rip), %xmm1    # 0x57cc0
ucomiss %xmm1, %xmm0
movb $0x1, %al
movq 0x18(%rsp), %r9
jbe 0x3b11a
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
ucomiss %xmm1, %xmm0
jbe 0x3b11a
movl 0x100(%r13), %eax
leal 0x1(%rax), %ecx
movq %r15, 0x60(%rsp)
imull %r15d, %ecx
movl 0x68(%r13), %edx
imull %r9d, %edx
addl %eax, %edx
addl %ecx, %edx
movslq %edx, %rax
cvttss2si (%rbx,%rax,4), %r12d
movl 0x6c(%r13), %ecx
movl 0x70(%r13), %r10d
movl %ecx, %eax
imull %r10d, %eax
imull 0x84(%r13), %eax
testl %eax, %eax
jle 0x3b068
xorps %xmm0, %xmm0
xorl %r15d, %r15d
xorl %r14d, %r14d
movss %xmm0, 0x30(%rsp)
imull %r10d, %ecx
movl 0x100(%r13), %esi
movl %r15d, %eax
cltd
idivl %ecx
leal 0x1(%rsi), %edi
movl 0x58(%r13), %r8d
imull %r9d, %r8d
addl 0xfc(%r13), %edi
imull %eax, %edi
leal (%rdi,%rsi), %eax
incl %eax
imull %ecx, %eax
addl %edx, %r8d
addl %r8d, %eax
addl %esi, %edi
imull %ecx, %edi
addl %r8d, %edi
movq 0x268(%r13), %rdx
movslq %edi, %rsi
movss (%rdx,%rsi,4), %xmm1
movss %xmm1, 0x10(%rsp)
xorps %xmm0, %xmm0
subss %xmm1, %xmm0
mulss 0x148(%r13), %xmm0
movq 0x260(%r13), %rdi
movss %xmm0, (%rdi,%rsi,4)
cltq
leaq (%rdx,%rax,4), %rdi
movq 0x490(%r13), %rsi
movl %r12d, %edx
callq 0x3cc28
movq 0x18(%rsp), %r9
mulss 0x10(%rsp), %xmm0
movss 0x30(%rsp), %xmm1
ucomiss %xmm1, %xmm0
cmoval %r15d, %r14d
maxss %xmm1, %xmm0
incl %r15d
movl 0x6c(%r13), %ecx
movl 0x70(%r13), %r10d
movl %ecx, %eax
imull %r10d, %eax
imull 0x84(%r13), %eax
cmpl %eax, %r15d
jl 0x3af99
jmp 0x3b06b
xorl %eax, %eax
jmp 0x3b11a
xorl %r14d, %r14d
imull %ecx, %r10d
movl 0xfc(%r13), %r8d
movl 0x100(%r13), %ecx
movl %r14d, %eax
cltd
idivl %r10d
movl 0x58(%r13), %esi
imull %r9d, %esi
leal (%r8,%rcx), %r14d
incl %r14d
imull %eax, %r14d
leal (%r14,%rcx), %eax
incl %eax
imull %r10d, %eax
addl %edx, %esi
addl %esi, %eax
addl %ecx, %r14d
imull %r10d, %r14d
addl %esi, %r14d
movq 0x268(%r13), %rdi
movq 0x260(%r13), %rsi
movq 0x490(%r13), %r9
movss 0x150(%r13), %xmm0
xorl %r11d, %r11d
cmpl $0x0, 0xf8(%r13)
sete %r11b
subq $0x8, %rsp
movl %eax, %edx
movl %r12d, %ecx
pushq %r11
leaq 0x3c(%rsp), %rax
pushq %rax
pushq %r10
callq 0x3bdfd
addq $0x20, %rsp
movslq %r14d, %rax
movq 0x260(%r13), %rcx
movl $0x0, (%rcx,%rax,4)
incl 0x28(%rsp)
movl $0x1, %r14d
xorl %eax, %eax
movq 0x60(%rsp), %r15
testb %al, %al
je 0x3b12f
leal 0x1(%r15), %eax
cmpl $0x1d, %r15d
movl %eax, %r15d
jb 0x3aeeb
testl %r14d, %r14d
movss 0x14(%rsp), %xmm0
movss 0xc(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
movq 0x18(%rsp), %r8
jne 0x3b9a1
cmpl $0x0, 0x6c(%r13)
jle 0x3b4ae
movl $0x0, 0x20(%rsp)
cmpl $0x0, 0x70(%r13)
jle 0x3b49a
xorps %xmm3, %xmm3
cvtsi2sdl 0x20(%rsp), %xmm3
addsd 0x17fa2(%rip), %xmm3    # 0x53120
movsd %xmm3, 0xa0(%rsp)
movl $0x0, 0x50(%rsp)
cmpl $0x0, 0x84(%r13)
jle 0x3b486
xorps %xmm1, %xmm1
cvtsi2sdl 0x50(%rsp), %xmm1
addsd 0x17f72(%rip), %xmm1    # 0x53120
movsd %xmm1, 0xa8(%rsp)
xorl %r15d, %r15d
movss %xmm0, 0x14(%rsp)
movl 0x6c(%r13), %r11d
movl 0x70(%r13), %r10d
movl %r11d, %ecx
imull %r15d, %ecx
movl 0x20(%rsp), %r9d
addl %r9d, %ecx
imull %r10d, %ecx
movq %r8, %rsi
movl 0x50(%rsp), %r8d
addl %r8d, %ecx
movl %r11d, %r14d
imull %r10d, %r14d
movl %ecx, %eax
cltd
idivl %r14d
movl 0x58(%r13), %r12d
imull %esi, %r12d
movl 0x100(%r13), %eax
movl 0xfc(%r13), %esi
addl %esi, %eax
incl %eax
subl %edx, %ecx
imull %eax, %ecx
addl %edx, %r12d
addl %ecx, %r12d
movq 0x268(%r13), %rdi
movq 0x230(%r13), %rsi
subq $0x8, %rsp
movl %r15d, %edx
movl %r12d, %ecx
pushq %r14
pushq %r11
pushq %r10
callq 0x3bb20
addq $0x20, %rsp
movaps %xmm0, 0x60(%rsp)
movapd %xmm1, 0x80(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x10(%rsp)
xorl %r14d, %r14d
movslq 0x100(%r13), %rax
incq %rax
movslq %r14d, %rcx
imulq %rax, %rcx
leaq (%rbx,%rcx,4), %rax
movslq 0x68(%r13), %rcx
imulq %rbp, %rcx
leaq (%rax,%rcx,4), %rdi
movl $0x1, %esi
callq 0x36a46
movaps %xmm0, %xmm2
ucomiss 0x17dea(%rip), %xmm0    # 0x53078
jne 0x3b292
jnp 0x3b2c4
movapd %xmm1, %xmm3
movaps 0x60(%rsp), %xmm0
movapd 0x80(%rsp), %xmm1
movaps %xmm2, 0x30(%rsp)
movaps 0x30(%rsp), %xmm2
callq 0x36754
movaps 0x30(%rsp), %xmm2
maxss 0x10(%rsp), %xmm0
movss %xmm0, 0x10(%rsp)
ucomiss 0x17dad(%rip), %xmm2    # 0x53078
jne 0x3b2cf
jnp 0x3b2e0
leal 0x1(%r14), %eax
cmpl $0x1d, %r14d
movl %eax, %r14d
jb 0x3b259
movl 0x6c(%r13), %r14d
movl 0x70(%r13), %r10d
movl %r15d, %eax
imull %r14d, %eax
addl 0x20(%rsp), %eax
imull %r10d, %eax
addl 0x50(%rsp), %eax
movl 0x100(%r13), %ecx
movl %r14d, %r11d
imull %r10d, %r11d
cltd
idivl %r11d
movl 0x58(%r13), %esi
movq 0x18(%rsp), %r8
imull %r8d, %esi
movl 0xfc(%r13), %edi
addl %ecx, %edi
incl %edi
imull %eax, %edi
addl %ecx, %edi
imull %r11d, %edi
addl %edx, %esi
addl %edi, %esi
movq 0x268(%r13), %rdi
movslq %esi, %rcx
movss (%rdi,%rcx,4), %xmm3
xorps %xmm0, %xmm0
subss %xmm3, %xmm0
mulss 0x148(%r13), %xmm0
movq 0x260(%r13), %rax
movss %xmm0, (%rax,%rcx,4)
cmpl $0x0, 0x104(%r13)
je 0x3b382
movss 0x17c99(%rip), %xmm0    # 0x53008
subss (%rdi,%rcx,4), %xmm0
mulss 0x148(%r13), %xmm0
movss %xmm0, (%rax,%rcx,4)
movss 0x10(%rsp), %xmm0
ucomiss 0x164(%r13), %xmm0
movss 0xc(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
jbe 0x3b3a5
movl $0x0, (%rax,%rcx,4)
movq 0xb0(%rsp), %rcx
cmpq $0x31ff, (%rcx)         # imm = 0x31FF
ja 0x3b469
xorps %xmm0, %xmm0
cvtsi2sd %r10d, %xmm0
movsd 0xa8(%rsp), %xmm1
divsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsd2ss %xmm1, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %r14d, %xmm1
movsd 0xa0(%rsp), %xmm2
divsd %xmm1, %xmm2
xorps %xmm1, %xmm1
cvtsd2ss %xmm2, %xmm1
unpcklps %xmm1, %xmm0            # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movq 0x230(%r13), %rsi
xorps %xmm2, %xmm2
cvtsi2ss %r10d, %xmm2
movss (%rsi,%r15,8), %xmm1
movss %xmm3, 0x30(%rsp)
xorps %xmm3, %xmm3
cvtsi2ss %r14d, %xmm3
divss %xmm2, %xmm1
movss 0x4(%rsi,%r15,8), %xmm2
divss %xmm3, %xmm2
unpcklps %xmm2, %xmm1            # xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]
movl %r15d, %edx
movl %r12d, %ecx
movl 0x50(%rsp), %r8d
movl 0x20(%rsp), %r9d
movss 0x1b146(%rip), %xmm2    # 0x56588
pushq %r11
pushq %rax
pushq %r14
pushq %r10
callq 0x3bc19
movss 0x50(%rsp), %xmm3
movq 0x38(%rsp), %r8
movss 0x28(%rsp), %xmm2
movss 0x2c(%rsp), %xmm1
addq $0x20, %rsp
movss 0x14(%rsp), %xmm0
addss %xmm3, %xmm0
incq %r15
movslq 0x84(%r13), %rax
cmpq %rax, %r15
jl 0x3b1ba
movl 0x50(%rsp), %eax
incl %eax
movl %eax, 0x50(%rsp)
cmpl 0x70(%r13), %eax
jl 0x3b18f
movl 0x20(%rsp), %eax
incl %eax
movl %eax, 0x20(%rsp)
cmpl 0x6c(%r13), %eax
jl 0x3b162
xorl %r12d, %r12d
movss %xmm0, 0x14(%rsp)
movss %xmm2, 0x8(%rsp)
movss %xmm1, 0xc(%rsp)
movslq 0x100(%r13), %rax
incq %rax
movslq %r12d, %rcx
imulq %rax, %rcx
leaq (%rbx,%rcx,4), %rax
movslq 0x68(%r13), %rcx
imulq %rbp, %rcx
leaq (%rax,%rcx,4), %rdi
movl $0x1, %esi
callq 0x36a46
movaps %xmm1, 0x80(%rsp)
ucomiss 0x17b7b(%rip), %xmm0    # 0x53078
jne 0x3b505
jnp 0x3b651
movq %r12, 0x20(%rsp)
xorps %xmm1, %xmm1
cvtsi2ssl 0x70(%r13), %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %eax
movl %eax, 0x10(%rsp)
movaps %xmm0, %xmm2
shufps $0x55, %xmm0, %xmm2     # xmm2 = xmm2[1,1],xmm0[1,1]
xorps %xmm1, %xmm1
cvtsi2ssl 0x6c(%r13), %xmm1
mulss %xmm2, %xmm1
cvttss2si %xmm1, %eax
movl %eax, 0x60(%rsp)
cmpl $0x0, 0x84(%r13)
movq 0x18(%rsp), %rdi
movaps %xmm0, 0x50(%rsp)
jle 0x3b65b
xorps %xmm0, %xmm0
xorl %r12d, %r12d
xorl %r15d, %r15d
movss %xmm0, 0x30(%rsp)
movl 0x6c(%r13), %r14d
movl 0x70(%r13), %r10d
movl %r14d, %esi
imull %r12d, %esi
movl 0x60(%rsp), %r9d
addl %r9d, %esi
imull %r10d, %esi
movl 0x10(%rsp), %r8d
addl %r8d, %esi
movl %r14d, %r11d
imull %r10d, %r11d
movl %esi, %eax
cltd
idivl %r11d
movl 0x58(%r13), %ecx
imull %edi, %ecx
movl 0x100(%r13), %eax
movl 0xfc(%r13), %edi
addl %edi, %eax
incl %eax
subl %edx, %esi
imull %eax, %esi
addl %edx, %ecx
addl %esi, %ecx
movq 0x268(%r13), %rdi
movq 0x230(%r13), %rsi
subq $0x8, %rsp
movl %r12d, %edx
pushq %r11
pushq %r14
pushq %r10
callq 0x3bb20
addq $0x20, %rsp
cmpl $0x0, 0x154(%r13)
je 0x3b613
movq 0x230(%r13), %rax
xorps %xmm0, %xmm0
cvtsi2ssl 0x70(%r13), %xmm0
movss (%rax,%r12,8), %xmm1
xorps %xmm2, %xmm2
cvtsi2ssl 0x6c(%r13), %xmm2
divss %xmm0, %xmm1
movss 0x4(%rax,%r12,8), %xmm0
divss %xmm2, %xmm0
unpcklps %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movaps 0x80(%rsp), %xmm3
callq 0x36754
movss 0x30(%rsp), %xmm1
ucomiss %xmm1, %xmm0
maxss %xmm1, %xmm0
cmoval %r12d, %r15d
incq %r12
movslq 0x84(%r13), %rax
cmpq %rax, %r12
movq 0x18(%rsp), %rdi
jl 0x3b55c
jmp 0x3b65e
movq 0x18(%rsp), %r8
jmp 0x3b972
xorl %r15d, %r15d
movl 0x6c(%r13), %r11d
movl 0x70(%r13), %r10d
movl %r11d, %esi
imull %r15d, %esi
movl 0x60(%rsp), %r9d
addl %r9d, %esi
imull %r10d, %esi
movl 0x10(%rsp), %r8d
addl %r8d, %esi
movl %r11d, %r12d
imull %r10d, %r12d
movl %esi, %eax
cltd
idivl %r12d
movl 0x58(%r13), %ecx
imull %edi, %ecx
movl 0x100(%r13), %eax
movl 0xfc(%r13), %edi
addl %edi, %eax
incl %eax
subl %edx, %esi
imull %eax, %esi
addl %edx, %ecx
addl %esi, %ecx
movq 0x268(%r13), %rdi
movq 0x230(%r13), %rsi
movaps 0x80(%rsp), %xmm1
movaps %xmm1, %xmm0
shufps $0x55, %xmm1, %xmm0     # xmm0 = xmm0[1,1],xmm1[1,1]
mulss %xmm1, %xmm0
movss 0x17b87(%rip), %xmm2    # 0x53260
subss %xmm0, %xmm2
mulss 0x140(%r13), %xmm2
movaps 0x50(%rsp), %xmm0
movl %r15d, %edx
pushq %r12
pushq 0x260(%r13)
pushq %r11
pushq %r10
callq 0x3bc19
addq $0x20, %rsp
movl 0x100(%r13), %r9d
cmpl $0x5, %r9d
movq 0x20(%rsp), %r12
jl 0x3b7d8
movq 0x268(%r13), %rcx
movq 0x260(%r13), %rsi
movl 0x6c(%r13), %edi
movl 0x70(%r13), %edx
movl %edi, %eax
imull %r15d, %eax
addl 0x60(%rsp), %eax
imull %edx, %eax
addl 0x10(%rsp), %eax
imull %edx, %edi
movl 0xfc(%r13), %r10d
cltd
idivl %edi
leal 0x1(%r9), %r8d
addl %r8d, %r10d
imull %r10d, %eax
movl 0x58(%r13), %r10d
movq 0x18(%rsp), %r11
imull %r11d, %r10d
addl %edx, %r10d
leal -0x4(%r9), %edx
addl $0x4, %eax
imull %edi, %eax
movss 0x14c(%r13), %xmm1
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm1
movslq %edi, %rdi
addl %eax, %r10d
movslq %r10d, %rax
shlq $0x2, %rax
shlq $0x2, %rdi
movl 0x68(%r13), %r10d
imull %r11d, %r10d
movslq %r10d, %r10
imull %r12d, %r8d
movslq %r8d, %r8
shlq $0x2, %r8
leaq (%r8,%r10,4), %r8
addq 0x98(%rsp), %r8
xorl %r10d, %r10d
movss (%r8,%r10,4), %xmm2
subss (%rcx,%rax), %xmm2
mulss %xmm1, %xmm2
movss %xmm2, (%rsi,%rax)
incq %r10
addq %rdi, %rax
cmpq %r10, %rdx
jne 0x3b7b9
movl 0x6c(%r13), %r10d
movl 0x70(%r13), %eax
imull %r10d, %r15d
addl 0x60(%rsp), %r15d
imull %eax, %r15d
addl 0x10(%rsp), %r15d
imull %eax, %r10d
movl %r15d, %eax
cltd
idivl %r10d
movl %edx, %ecx
movl 0x58(%r13), %r11d
imull 0x18(%rsp), %r11d
movl 0xfc(%r13), %r8d
leal (%r8,%r9), %edx
incl %edx
imull %eax, %edx
leal (%rdx,%r9), %eax
imull %r10d, %eax
addl %ecx, %r11d
addl %r11d, %eax
movq 0x268(%r13), %rdi
cltq
movss (%rdi,%rax,4), %xmm1
movss 0x177cb(%rip), %xmm2    # 0x53008
subss %xmm1, %xmm2
mulss 0x144(%r13), %xmm2
movq 0x260(%r13), %rsi
movss %xmm2, (%rsi,%rax,4)
cmpl $0x0, 0x108(%r13)
movss 0x8(%rsp), %xmm4
je 0x3b880
movss (%rdi,%rax,4), %xmm2
movaps %xmm0, %xmm3
subss %xmm2, %xmm3
mulss 0x144(%r13), %xmm3
movss %xmm3, (%rsi,%rax,4)
cmpl $0x0, 0x104(%r13)
je 0x3b8a0
xorps %xmm2, %xmm2
subss (%rdi,%rax,4), %xmm2
mulss 0x144(%r13), %xmm2
movss %xmm2, (%rsi,%rax,4)
leal 0x1(%r9), %eax
movl %eax, %ecx
imull %r12d, %ecx
movl 0x68(%r13), %r14d
imull 0x18(%rsp), %r14d
addl %r9d, %ecx
addl %r14d, %ecx
movslq %ecx, %rcx
cvttss2si (%rbx,%rcx,4), %ecx
movq 0x1b8(%r13), %r9
testq %r9, %r9
movss 0xc(%rsp), %xmm3
je 0x3b8db
movslq %ecx, %rcx
movl (%r9,%rcx,4), %ecx
movaps 0x70(%rsp), %xmm5
movaps %xmm5, %xmm2
addss 0x1771d(%rip), %xmm2    # 0x53008
movss 0x17941(%rip), %xmm6    # 0x53234
cmpltss %xmm0, %xmm6
andps %xmm6, %xmm2
andnps %xmm5, %xmm6
orps %xmm2, %xmm6
movaps %xmm6, 0x30(%rsp)
addss %xmm0, %xmm4
movss %xmm4, 0x8(%rsp)
addss %xmm1, %xmm3
movss %xmm3, 0xc(%rsp)
addl %eax, %edx
imull %r10d, %edx
addl %r11d, %edx
movq 0x490(%r13), %r9
movss 0x150(%r13), %xmm0
xorl %eax, %eax
cmpl $0x0, 0xf8(%r13)
sete %al
subq $0x8, %rsp
pushq %rax
leaq 0x3c(%rsp), %rax
pushq %rax
pushq %r10
callq 0x3bdfd
addq $0x20, %rsp
incl 0x4c(%rsp)
incl 0x28(%rsp)
movaps 0x30(%rsp), %xmm0
movaps %xmm0, 0x70(%rsp)
movq 0x18(%rsp), %r8
movaps 0x50(%rsp), %xmm0
ucomiss 0x176ff(%rip), %xmm0    # 0x53078
movss 0x14(%rsp), %xmm0
movss 0xc(%rsp), %xmm1
movss 0x8(%rsp), %xmm2
jne 0x3b98f
jnp 0x3b9a1
leal 0x1(%r12), %eax
cmpl $0x1d, %r12d
movl %eax, %r12d
jb 0x3b4b7
incl %r8d
movl 0x48(%r13), %esi
cmpl %esi, %r8d
jl 0x3aebd
xorps %xmm3, %xmm3
cvtsi2ssl 0x28(%rsp), %xmm3
movss %xmm3, 0x30(%rsp)
movl 0x4c(%rsp), %ebx
movss %xmm0, 0x14(%rsp)
movss %xmm1, 0xc(%rsp)
movss %xmm2, 0x8(%rsp)
jmp 0x3b9f8
xorps %xmm0, %xmm0
movss %xmm0, 0x30(%rsp)
movss %xmm0, 0x14(%rsp)
movss %xmm0, 0xc(%rsp)
movaps %xmm0, 0x70(%rsp)
movss %xmm0, 0x8(%rsp)
movq 0x260(%r13), %rdi
imull 0x58(%r13), %esi
callq 0xf121
mulss %xmm0, %xmm0
movq 0x1d8(%r13), %rax
movss %xmm0, (%rax)
xorps %xmm4, %xmm4
cvtsi2ss %ebx, %xmm4
movss 0x8(%rsp), %xmm0
divss %xmm4, %xmm0
cvtss2sd %xmm0, %xmm0
movss 0x2c(%rsp), %xmm1
divss 0x30(%rsp), %xmm1
cvtss2sd %xmm1, %xmm1
movss 0xc(%rsp), %xmm2
divss %xmm4, %xmm2
movl 0x6c(%r13), %eax
imull 0x70(%r13), %eax
imull 0x84(%r13), %eax
imull 0x48(%r13), %eax
cvtss2sd %xmm2, %xmm2
xorps %xmm3, %xmm3
cvtsi2ss %eax, %xmm3
movss 0x14(%rsp), %xmm5
divss %xmm3, %xmm5
xorps %xmm3, %xmm3
cvtss2sd %xmm5, %xmm3
movaps 0x70(%rsp), %xmm5
divss %xmm4, %xmm5
xorps %xmm4, %xmm4
cvtss2sd %xmm5, %xmm4
leaq 0x1c23f(%rip), %rdi     # 0x57ccf
movl %ebx, %esi
movb $0x5, %al
callq 0x3170
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq