// File: /workspace/github_c_makefile_star2_O2/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 $0xa8, %rsp
leaq 0x580(%rsp), %rax
leaq 0xe0(%rsp), %rbx
movq 0x268(%rbx), %rdi
movq 0xd8(%rax), %r15
movslq 0x58(%rbx), %rax
movslq 0x48(%rbx), %rdx
imulq %rax, %rdx
shlq $0x2, %rdx
movq %r15, %rsi
callq 0x32b0
xorl %ebp, %ebp
movl 0x48(%rbx), %ecx
cmpl %ecx, %ebp
jge 0x30756
xorl %r14d, %r14d
cmpl 0x84(%rbx), %r14d
jge 0x3074f
movl 0x6c(%rbx), %esi
imull 0x70(%rbx), %esi
movl 0xfc(%rbx), %edi
movl %esi, %ecx
imull %r14d, %ecx
movl %ecx, %eax
cltd
idivl %esi
movl 0x58(%rbx), %eax
imull %ebp, %eax
movl 0x100(%rbx), %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(%rbx), %rdi
addl %esi, %esi
xorl %edx, %edx
callq 0x1a4f8
cmpl $0x0, 0x104(%rbx)
jne 0x306e2
movl 0x58(%rbx), %ecx
movl 0x6c(%rbx), %esi
imull 0x70(%rbx), %esi
movl 0xfc(%rbx), %edi
movl %esi, %eax
imull %r14d, %eax
cltd
idivl %esi
imull %ebp, %ecx
addl %ecx, %edx
movl 0x100(%rbx), %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(%rbx), %rdi
xorl %edx, %edx
callq 0x1a4f8
cmpl $0x0, 0xf8(%rbx)
jne 0x30747
cmpq $0x0, 0x490(%rbx)
jne 0x30747
movl 0x58(%rbx), %edi
movl 0x6c(%rbx), %esi
movl 0xfc(%rbx), %ecx
imull 0x70(%rbx), %esi
movl %esi, %eax
imull %r14d, %eax
cltd
idivl %esi
imull %ebp, %edi
addl %edi, %edx
movl 0x100(%rbx), %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(%rbx), %rdi
imull %ecx, %esi
xorl %edx, %edx
callq 0x1a4f8
incl %r14d
jmp 0x3063b
incl %ebp
jmp 0x3062d
movq 0x490(%rbx), %rax
testq %rax, %rax
je 0x307db
movl 0x100(%rbx), %r13d
incl %r13d
xorl %r12d, %r12d
pushq $0x1
popq %rbp
movslq 0x30(%rax), %rcx
cmpq %rcx, %r12
jge 0x30848
movq 0x38(%rax), %rax
movl (%rax,%r12,4), %r14d
movslq %r13d, %r13
leaq (%r15,%r13,4), %rdi
leaq (,%r13,4), %rax
movl 0x48(%rbx), %edx
movl 0x70(%rbx), %r8d
imull 0x84(%rbx), %r8d
imull 0x6c(%rbx), %r8d
movl 0x54(%rbx), %ecx
movss 0x18c(%rbx), %xmm0
addq 0x268(%rbx), %rax
movl %r14d, %esi
movl %ebp, %r9d
pushq %rax
pushq %r8
callq 0x1b943
popq %rax
popq %rcx
addl %r14d, %r13d
incq %r12
movq 0x490(%rbx), %rax
jmp 0x30772
cmpl $0x0, 0xf8(%rbx)
je 0x30848
movl 0x100(%rbx), %edx
movl 0x104(%rbx), %esi
cmpl $0x1, %esi
adcl $0x0, %edx
movl 0x54(%rbx), %eax
movl 0x6c(%rbx), %r8d
imull 0x70(%rbx), %r8d
imull %r8d, %edx
movslq %edx, %r10
leaq (%r15,%r10,4), %rdi
shlq $0x2, %r10
addl 0xfc(%rbx), %esi
movl 0x84(%rbx), %r9d
imull %r9d, %ecx
cltd
idivl %r9d
addq 0x268(%rbx), %r10
pushq $0x1
popq %r9
movss 0x1b7cf(%rip), %xmm0    # 0x4c008
movl %ecx, %edx
movl %eax, %ecx
pushq %r10
pushq %r8
callq 0x1b943
popq %rax
popq %rcx
movq 0x260(%rbx), %rdi
movslq 0x58(%rbx), %rax
movslq 0x48(%rbx), %rdx
imulq %rax, %rdx
shlq $0x2, %rdx
movq $0x0, 0x8(%rsp)
xorl %esi, %esi
callq 0x31c0
leaq 0x580(%rsp), %rcx
cmpl $0x0, 0xf8(%rcx)
je 0x312d8
leaq 0x1c(%rsp), %rax
andl $0x0, (%rax)
movq 0x1d8(%rbx), %rax
andl $0x0, (%rax)
movq 0x8(%rcx), %rax
movq %rax, 0xa0(%rsp)
movq 0xe0(%rcx), %rax
movq %rax, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
xorps %xmm0, %xmm0
movss %xmm0, 0x18(%rsp)
movss %xmm0, 0x14(%rsp)
movaps %xmm0, 0x70(%rsp)
movss %xmm0, 0x10(%rsp)
xorl %ecx, %ecx
movl 0x48(%rbx), %esi
cmpl %esi, %ecx
jge 0x31241
cmpq $0x0, 0x490(%rbx)
movslq %ecx, %r14
movl %ecx, (%rsp)
movl %ecx, %esi
je 0x30a52
pushq $-0x1
popq %r15
cmpl $0x1d, %r15d
je 0x30a52
incl %r15d
movslq 0x100(%rbx), %rax
incq %rax
movslq %r15d, %rcx
imulq %rax, %rcx
movq 0x30(%rsp), %rax
leaq (%rax,%rcx,4), %rax
movslq 0x68(%rbx), %rcx
imulq %r14, %rcx
leaq (%rax,%rcx,4), %rdi
pushq $0x1
popq %rsi
callq 0x2b3f1
movl (%rsp), %esi
ucomiss 0x1b73b(%rip), %xmm0    # 0x4c078
jne 0x30945
jnp 0x30a52
ucomiss 0x2038c(%rip), %xmm0    # 0x50cd8
jbe 0x308f8
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
ucomiss 0x2037f(%rip), %xmm0    # 0x50cd8
jbe 0x308f8
movl 0x68(%rbx), %eax
imull %esi, %eax
movl 0x100(%rbx), %ecx
addl %ecx, %eax
incl %ecx
imull %r15d, %ecx
addl %eax, %ecx
movslq %ecx, %rax
movq 0x30(%rsp), %rcx
cvttss2si (%rcx,%rax,4), %r14d
xorps %xmm0, %xmm0
xorl %r15d, %r15d
xorl %r12d, %r12d
movl 0x6c(%rbx), %r10d
movl 0xfc(%rbx), %r8d
imull 0x70(%rbx), %r10d
movl 0x84(%rbx), %eax
imull %r10d, %eax
movl 0x100(%rbx), %r9d
leal 0x1(%r9), %ecx
movl 0x58(%rbx), %esi
imull (%rsp), %esi
leal (%r8,%r9), %r13d
incl %r13d
movq 0x268(%rbx), %rdi
cmpl %eax, %r12d
jge 0x311c0
movl %r12d, %eax
cltd
idivl %r10d
imull %eax, %r13d
addl %r13d, %ecx
imull %r10d, %ecx
addl %edx, %esi
addl %esi, %ecx
addl %r9d, %r13d
imull %r10d, %r13d
addl %esi, %r13d
movslq %r13d, %rax
movss (%rdi,%rax,4), %xmm1
movss %xmm1, 0x40(%rsp)
movss %xmm0, 0x20(%rsp)
xorps %xmm0, %xmm0
subss %xmm1, %xmm0
mulss 0x148(%rbx), %xmm0
movq 0x260(%rbx), %rdx
movss %xmm0, (%rdx,%rax,4)
movslq %ecx, %rax
leaq (%rdi,%rax,4), %rdi
movq 0x490(%rbx), %rsi
movl %r14d, %edx
movl %r10d, %ecx
callq 0x3248a
mulss 0x40(%rsp), %xmm0
movss 0x20(%rsp), %xmm1
ucomiss %xmm1, %xmm0
cmoval %r12d, %r15d
maxss %xmm1, %xmm0
incl %r12d
jmp 0x30988
xorl %r9d, %r9d
cmpl 0x6c(%rbx), %r9d
jge 0x30d10
cvtsi2sd %r9d, %xmm0
addsd 0x1b6b4(%rip), %xmm0    # 0x4c120
movapd %xmm0, 0x80(%rsp)
xorl %r8d, %r8d
movl %r9d, 0x4(%rsp)
cmpl 0x70(%rbx), %r8d
jge 0x30d08
cvtsi2sd %r8d, %xmm0
addsd 0x1b68c(%rip), %xmm0    # 0x4c120
movapd 0x80(%rsp), %xmm1
unpcklpd %xmm0, %xmm1            # xmm1 = xmm1[0],xmm0[0]
movapd %xmm1, 0x90(%rsp)
xorl %r12d, %r12d
movslq 0x84(%rbx), %rax
cmpq %rax, %r12
jge 0x30d00
movl 0x6c(%rbx), %r11d
movl 0x70(%rbx), %r10d
movl %r11d, %ecx
imull %r12d, %ecx
addl %r9d, %ecx
imull %r10d, %ecx
addl %r8d, %ecx
movl %r11d, %r15d
imull %r10d, %r15d
movl %ecx, %eax
cltd
idivl %r15d
movl 0x58(%rbx), %r13d
imull %esi, %r13d
movl 0x100(%rbx), %eax
movl 0xfc(%rbx), %esi
addl %esi, %eax
incl %eax
subl %edx, %ecx
imull %eax, %ecx
addl %edx, %r13d
addl %ecx, %r13d
movq 0x268(%rbx), %rdi
movq 0x230(%rbx), %rsi
subq $0x8, %rsp
movl %r12d, %edx
movl %r13d, %ecx
movl %r8d, %ebp
pushq %r15
pushq %r11
pushq %r10
callq 0x3135f
addq $0x20, %rsp
movapd %xmm0, 0x40(%rsp)
movapd %xmm1, 0x60(%rsp)
xorl %r15d, %r15d
xorpd %xmm0, %xmm0
movss %xmm0, 0x20(%rsp)
cmpl $0x1e, %r15d
je 0x30ba9
movslq 0x100(%rbx), %rax
incq %rax
movslq %r15d, %rcx
imulq %rax, %rcx
movq 0x30(%rsp), %rax
leaq (%rax,%rcx,4), %rax
movslq 0x68(%rbx), %rcx
imulq %r14, %rcx
leaq (%rax,%rcx,4), %rdi
pushq $0x1
popq %rsi
callq 0x2b3f1
ucomiss 0x1b4f4(%rip), %xmm0    # 0x4c078
jne 0x30b88
jnp 0x30ba9
movaps %xmm0, %xmm2
movapd %xmm1, %xmm3
movaps 0x40(%rsp), %xmm0
movaps 0x60(%rsp), %xmm1
callq 0x2b1cb
maxss 0x20(%rsp), %xmm0
incl %r15d
jmp 0x30b43
movq 0x6c(%rbx), %r15
movq %r15, %xmm1
pshufd $0x55, %xmm1, %xmm0     # xmm0 = xmm1[1,1,1,1]
movd %xmm0, %r11d
movl %r15d, %eax
imull %r12d, %eax
movl 0x4(%rsp), %r9d
addl %r9d, %eax
imull %r11d, %eax
addl %ebp, %eax
movl 0x100(%rbx), %ecx
movl %r15d, %r10d
imull %r11d, %r10d
cltd
idivl %r10d
movl 0x58(%rbx), %esi
movl (%rsp), %edi
movl %edi, %r8d
imull %edi, %esi
movl 0xfc(%rbx), %edi
addl %ecx, %edi
incl %edi
imull %eax, %edi
addl %ecx, %edi
imull %r10d, %edi
addl %edx, %esi
addl %edi, %esi
movq 0x268(%rbx), %rdi
movslq %esi, %rcx
movss (%rdi,%rcx,4), %xmm2
pxor %xmm0, %xmm0
subss %xmm2, %xmm0
mulss 0x148(%rbx), %xmm0
movq 0x260(%rbx), %rax
movss %xmm0, (%rax,%rcx,4)
cmpl $0x0, 0x104(%rbx)
je 0x30c53
movss 0x1b3c7(%rip), %xmm0    # 0x4c008
subss (%rdi,%rcx,4), %xmm0
mulss 0x148(%rbx), %xmm0
movss %xmm0, (%rax,%rcx,4)
movss 0x20(%rsp), %xmm0
ucomiss 0x164(%rbx), %xmm0
jbe 0x30c66
andl $0x0, (%rax,%rcx,4)
movq 0xa0(%rsp), %rcx
cmpq $0x31ff, (%rcx)         # imm = 0x31FF
movl %r8d, %esi
ja 0x30ce5
cvtdq2pd %xmm1, %xmm0
movss %xmm2, 0x20(%rsp)
movapd 0x90(%rsp), %xmm2
divpd %xmm0, %xmm2
cvtpd2ps %xmm2, %xmm0
shufps $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
movq 0x230(%rbx), %rsi
cvtdq2ps %xmm1, %xmm2
shufps $0xe1, %xmm2, %xmm2     # xmm2 = xmm2[1,0,2,3]
movsd (%rsi,%r12,8), %xmm1
divps %xmm2, %xmm1
movl %r12d, %edx
movl %r13d, %ecx
movl %ebp, %r8d
movl 0x4(%rsp), %r9d
movss 0x1e8e2(%rip), %xmm2    # 0x4f5a8
pushq %r10
pushq %rax
pushq %r15
pushq %r11
callq 0x3144e
movss 0x40(%rsp), %xmm2
movl 0x24(%rsp), %r9d
movl 0x20(%rsp), %esi
addq $0x20, %rsp
movss 0x18(%rsp), %xmm0
addss %xmm2, %xmm0
movss %xmm0, 0x18(%rsp)
incq %r12
movl %ebp, %r8d
jmp 0x30aad
incl %r8d
jmp 0x30a7d
incl %r9d
jmp 0x30a55
movq 0x8(%rsp), %rax
addl $0x1e, %eax
movl %eax, 0x80(%rsp)
movq 0x38(%rsp), %rax
addl $0x1e, %eax
movl %eax, 0x5c(%rsp)
xorl %r12d, %r12d
cmpl $0x1e, %r12d
je 0x311a4
movslq 0x100(%rbx), %rax
incq %rax
movslq %r12d, %rcx
imulq %rax, %rcx
movq 0x30(%rsp), %rax
leaq (%rax,%rcx,4), %rax
movslq 0x68(%rbx), %rcx
imulq %r14, %rcx
leaq (%rax,%rcx,4), %rdi
pushq $0x1
popq %rsi
callq 0x2b3f1
movaps %xmm1, 0x60(%rsp)
ucomiss 0x1b306(%rip), %xmm0    # 0x4c078
jne 0x30d7a
jnp 0x311b9
movl %r12d, 0x4(%rsp)
cvtsi2ssl 0x70(%rbx), %xmm1
mulss %xmm0, %xmm1
cvttss2si %xmm1, %ebp
movaps %xmm0, 0x90(%rsp)
cvtsi2ssl 0x6c(%rbx), %xmm1
shufps $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
mulss %xmm0, %xmm1
cvttss2si %xmm1, %r9d
xorl %r13d, %r13d
xorps %xmm0, %xmm0
movl $0x0, 0x20(%rsp)
movl (%rsp), %r8d
movslq 0x84(%rbx), %rax
movl 0x6c(%rbx), %r12d
movl 0x70(%rbx), %r10d
cmpq %rax, %r13
jge 0x30ea0
movss %xmm0, 0x40(%rsp)
movl %r12d, %esi
imull %r13d, %esi
addl %r9d, %esi
imull %r10d, %esi
addl %ebp, %esi
movl %r12d, %r11d
imull %r10d, %r11d
movl %esi, %eax
cltd
idivl %r11d
movl 0x58(%rbx), %ecx
imull %r8d, %ecx
movl 0xfc(%rbx), %eax
movl 0x100(%rbx), %edi
addl %edi, %eax
incl %eax
subl %edx, %esi
imull %eax, %esi
addl %edx, %ecx
addl %esi, %ecx
movq 0x268(%rbx), %rdi
movq 0x230(%rbx), %rsi
subq $0x8, %rsp
movl %r13d, %edx
movl %ebp, %r15d
movl %ebp, %r8d
movl %r9d, %ebp
pushq %r11
pushq %r12
pushq %r10
callq 0x3135f
addq $0x20, %rsp
cmpl $0x0, 0x154(%rbx)
je 0x30e65
movq 0x230(%rbx), %rax
movsd (%rax,%r13,8), %xmm1
movsd 0x6c(%rbx), %xmm0
cvtdq2ps %xmm0, %xmm0
shufps $0xe1, %xmm0, %xmm0     # xmm0 = xmm0[1,0,2,3]
divps %xmm0, %xmm1
xorps %xmm0, %xmm0
xorps %xmm2, %xmm2
movaps 0x60(%rsp), %xmm3
callq 0x2b1cb
movss 0x40(%rsp), %xmm1
ucomiss %xmm1, %xmm0
movl 0x20(%rsp), %eax
cmoval %r13d, %eax
movl %eax, 0x20(%rsp)
maxss %xmm1, %xmm0
incq %r13
movl (%rsp), %r8d
movl %ebp, %r9d
movl %r15d, %ebp
jmp 0x30db8
movl %r12d, %esi
movl 0x20(%rsp), %r15d
imull %r15d, %esi
addl %r9d, %esi
imull %r10d, %esi
addl %ebp, %esi
movl %r12d, %r13d
imull %r10d, %r13d
movl %esi, %eax
cltd
idivl %r13d
movl 0x58(%rbx), %ecx
imull %r8d, %ecx
movl 0xfc(%rbx), %eax
movl 0x100(%rbx), %edi
addl %edi, %eax
incl %eax
subl %edx, %esi
imull %eax, %esi
addl %edx, %ecx
addl %esi, %ecx
movq 0x268(%rbx), %rdi
movq 0x230(%rbx), %rsi
movaps 0x60(%rsp), %xmm1
movaps %xmm1, %xmm0
shufps $0x55, %xmm1, %xmm0     # xmm0 = xmm0[1,1],xmm1[1,1]
mulss %xmm1, %xmm0
movss 0x1b354(%rip), %xmm2    # 0x4c25c
subss %xmm0, %xmm2
mulss 0x140(%rbx), %xmm2
movaps 0x90(%rsp), %xmm0
movl %r15d, %edx
movl %ebp, %r8d
movl %r9d, 0x40(%rsp)
pushq %r13
pushq 0x260(%rbx)
pushq %r12
pushq %r10
callq 0x3144e
addq $0x20, %rsp
movl 0x100(%rbx), %r10d
cmpl $0x5, %r10d
jl 0x30ff9
movl 0x6c(%rbx), %r9d
movl 0x70(%rbx), %ecx
movl %r9d, %eax
imull %r15d, %eax
addl 0x40(%rsp), %eax
imull %ecx, %eax
addl %ebp, %eax
imull %ecx, %r9d
cltd
idivl %r9d
movl 0x58(%rbx), %ecx
movl (%rsp), %r13d
imull %r13d, %ecx
leal 0x1(%r10), %esi
movl 0xfc(%rbx), %edi
addl %esi, %edi
imull %eax, %edi
addl $0x4, %edi
imull %r9d, %edi
addl %edx, %ecx
addl %edi, %ecx
movl 0x4(%rsp), %r12d
imull %r12d, %esi
movslq %esi, %rax
movq 0x30(%rsp), %rdx
leaq (%rdx,%rax,4), %rax
movslq 0x68(%rbx), %rdx
imulq %r14, %rdx
leaq (%rax,%rdx,4), %rdi
addq $0x14, %rdi
movq 0x268(%rbx), %rsi
addl $-0x4, %r10d
movq 0x260(%rbx), %r8
cvttss2si 0x14c(%rbx), %eax
subq $0x8, %rsp
movl %r10d, %edx
pushq %rax
movss %xmm0, 0x70(%rsp)
callq 0x315f0
movss 0x70(%rsp), %xmm0
addq $0x10, %rsp
movl 0x100(%rbx), %r10d
movl %r13d, %esi
jmp 0x31001
movl 0x4(%rsp), %r12d
movl (%rsp), %esi
movl 0x40(%rsp), %ecx
movl 0x6c(%rbx), %r11d
movl 0x70(%rbx), %eax
imull %r11d, %r15d
addl %ecx, %r15d
imull %eax, %r15d
addl %ebp, %r15d
imull %eax, %r11d
movl %r15d, %eax
cltd
idivl %r11d
movl %edx, %ecx
movl 0x58(%rbx), %r9d
imull %esi, %r9d
movl 0xfc(%rbx), %r8d
leal (%r8,%r10), %edx
incl %edx
imull %eax, %edx
leal (%rdx,%r10), %eax
imull %r11d, %eax
addl %ecx, %r9d
addl %r9d, %eax
movq 0x268(%rbx), %rdi
cltq
movss (%rdi,%rax,4), %xmm4
movss 0x1afa5(%rip), %xmm1    # 0x4c008
subss %xmm4, %xmm1
mulss 0x144(%rbx), %xmm1
movq 0x260(%rbx), %rsi
movss %xmm1, (%rsi,%rax,4)
cmpl $0x0, 0x108(%rbx)
je 0x3109d
movss (%rdi,%rax,4), %xmm1
movaps %xmm0, %xmm2
subss %xmm1, %xmm2
mulss 0x144(%rbx), %xmm2
movss %xmm2, (%rsi,%rax,4)
cmpl $0x0, 0x104(%rbx)
je 0x310bb
xorps %xmm1, %xmm1
subss (%rdi,%rax,4), %xmm1
mulss 0x144(%rbx), %xmm1
movss %xmm1, (%rsi,%rax,4)
leal 0x1(%r10), %eax
movl %eax, %ecx
imull %r12d, %ecx
movl 0x68(%rbx), %r15d
imull (%rsp), %r15d
addl %r10d, %r15d
addl %ecx, %r15d
movslq %r15d, %rcx
movq 0x30(%rsp), %r10
cvttss2si (%r10,%rcx,4), %ecx
movq 0x1b8(%rbx), %r10
testq %r10, %r10
je 0x310f5
movslq %ecx, %rcx
movl (%r10,%rcx,4), %ecx
movaps 0x70(%rsp), %xmm3
movaps %xmm3, %xmm1
addss 0x1af03(%rip), %xmm1    # 0x4c008
movss 0x1b127(%rip), %xmm2    # 0x4c234
cmpltss %xmm0, %xmm2
andps %xmm2, %xmm1
andnps %xmm3, %xmm2
orps %xmm1, %xmm2
movaps %xmm2, 0x20(%rsp)
movss 0x10(%rsp), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0x10(%rsp)
movss 0x14(%rsp), %xmm1
addss %xmm4, %xmm1
movss %xmm1, 0x14(%rsp)
addl %eax, %edx
imull %r11d, %edx
addl %r9d, %edx
movq 0x490(%rbx), %r9
movss 0x150(%rbx), %xmm0
xorl %eax, %eax
cmpl $0x0, 0xf8(%rbx)
sete %al
subq $0x8, %rsp
pushq %rax
leaq 0x2c(%rsp), %rax
pushq %rax
pushq %r11
callq 0x31628
addq $0x20, %rsp
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
movq 0x8(%rsp), %rax
incl %eax
movq %rax, 0x8(%rsp)
incl %r12d
movaps 0x20(%rsp), %xmm0
movaps %xmm0, 0x70(%rsp)
jmp 0x30d2e
movl 0x5c(%rsp), %eax
movq %rax, 0x38(%rsp)
movl (%rsp), %ecx
movl 0x80(%rsp), %eax
jmp 0x31235
movq 0x8(%rsp), %rax
jmp 0x31232
movl %r15d, %eax
cltd
idivl %r10d
imull %eax, %r13d
addl %r13d, %ecx
imull %r10d, %ecx
addl %edx, %esi
addl %esi, %ecx
addl %r9d, %r13d
imull %r10d, %r13d
addl %esi, %r13d
movq 0x260(%rbx), %rsi
movq 0x490(%rbx), %r9
movss 0x150(%rbx), %xmm0
xorl %eax, %eax
cmpl $0x0, 0xf8(%rbx)
sete %al
subq $0x8, %rsp
movl %ecx, %edx
movl %r14d, %ecx
pushq %rax
leaq 0x2c(%rsp), %rax
pushq %rax
pushq %r10
callq 0x31628
addq $0x20, %rsp
movslq %r13d, %rax
movq 0x260(%rbx), %rcx
andl $0x0, (%rcx,%rax,4)
movq 0x8(%rsp), %rax
incl %eax
movl (%rsp), %ecx
incl %ecx
movq %rax, 0x8(%rsp)
jmp 0x308d3
movq 0x260(%rbx), %rdi
imull 0x58(%rbx), %esi
callq 0x4b4c
mulss %xmm0, %xmm0
movq 0x1d8(%rbx), %rax
movss %xmm0, (%rax)
movq 0x38(%rsp), %rsi
cvtsi2ss %esi, %xmm4
movss 0x10(%rsp), %xmm0
divss %xmm4, %xmm0
cvtsi2ssl 0x8(%rsp), %xmm1
cvtss2sd %xmm0, %xmm0
movss 0x1c(%rsp), %xmm2
divss %xmm1, %xmm2
cvtss2sd %xmm2, %xmm1
movss 0x14(%rsp), %xmm2
divss %xmm4, %xmm2
movl 0x6c(%rbx), %eax
imull 0x70(%rbx), %eax
imull 0x84(%rbx), %eax
imull 0x48(%rbx), %eax
cvtss2sd %xmm2, %xmm2
cvtsi2ss %eax, %xmm3
movss 0x18(%rsp), %xmm5
divss %xmm3, %xmm5
cvtss2sd %xmm5, %xmm3
movaps 0x70(%rsp), %xmm5
divss %xmm4, %xmm5
cvtss2sd %xmm5, %xmm4
leaq 0x1fa16(%rip), %rdi     # 0x50ce7
movb $0x5, %al
callq 0x3160
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq