// File: myudelson[P]hmm-scalable/utils.cpp
// Function: projectsimplex(double*, signed char)
void projectsimplex(NUMBER* ar, NPAR size) {
    NPAR i, num_at_hi, num_at_lo; // number of elements at lower,upper boundary
    NPAR *at_hi = Calloc(NPAR, (size_t)size);
    NPAR *at_lo = Calloc(NPAR, (size_t)size);
    NUMBER err, lambda;
    NUMBER* ar_copy = Calloc(NUMBER, (size_t)size);
    memcpy(ar_copy, ar, sizeof(NUMBER)*(size_t)size);
    int iter = 0;
    while( !issimplex(ar, size) ) {
        lambda = 0;
        num_at_hi = 0;
        num_at_lo = 0;
        err = -1;
        // threshold
        for(i=0; i<size; i++) {
            at_lo[i] = (ar[i]<=/*lb[i]*/0)?1:0;
            ar[i] = (at_lo[i]==1)?/*lb[i]*/0:ar[i];
            num_at_lo = (NPAR)( num_at_lo + at_lo[i] );
            
            at_hi[i] = (ar[i]>=/*ub[i]*/1)?1:0;
            ar[i] = (at_hi[i]==1)?/*ub[i]*/1:ar[i];
            num_at_hi = (NPAR)( num_at_hi + at_hi[i] );
            
            err += ar[i];
        }
        //		if (size > (num_at_hi + num_at_lo) )
        //			lambda = err / (size - (num_at_hi + num_at_lo));
        if ( err > 0 && size > num_at_lo )
            lambda = err / (size - num_at_lo);
        else if ( err < 0 && size > num_at_hi )
            lambda = err / (size - num_at_hi);
        
        int will_suffer_from_lambda = 0; // those values that, if lessened by lambda, will be below 0 or over 1
        NUMBER err2 = 0.0, lambda2 = 0.0;
        for(i=0; i<size; i++) {
            if( (at_lo[i]==0 && at_hi[i]==0) ) {
                if( ar[i] < lambda ) {
                    will_suffer_from_lambda++;
                    err2 += ar[i];
                }
            }
        }
        
        if( will_suffer_from_lambda == 0 ) {
            for(i=0; i<size; i++) {
                ar[i] -= (at_lo[i]==0 && err>0)?lambda:0;
                ar[i] -= (at_hi[i]==0 && err<0)?lambda:0;
            }
        } else {
            lambda2 = (err-err2) / ( size - (num_at_hi + num_at_lo) - will_suffer_from_lambda );
            for(i=0; i<size; i++) {
                if( at_lo[i]==0 && at_hi[i]==0 ) {
                    ar[i] = (ar[i]<lambda)?0:(ar[i]-lambda2);
                }
            }
        }
        iter++;
        if(iter==100) {
            string ar_was = "";
            for(int i=0; i<size; i++) ar_was = ar_was + std::to_string(ar_copy[i]).substr(0,5) + std::to_string((i<(size-1))?',':' ');
            string ar_is = "";
            for(int i=0; i<size; i++) ar_is = ar_is + std::to_string(ar[i]).substr(0,5) + std::to_string((i<(size-1))?',':' ');
            fprintf(stderr,"WARNING! Stuck in projectsimplex()! ar was %s and now is %s.\n",ar_was.c_str(),ar_is.c_str());
            break;//exit(1);
        }
    } // until satisfied
    // force last to be 1 - sum of all but last -- this code, actually breaks things
    //    err = 0;
    //    for(i=0; i<(size); i++) {
    //        err += ar[i];
    //    }
    //    err = 1;
    //    for(i=0; i<(size-1); i++) {
    //        err -= ar[i];
    //    }
    //    ar[size-1] = err;
    //    err = 1;
    //    for(i=1; i<(size-0); i++) {
    //        err -= ar[i];
    //    }
    //    ar[0] = err;
    
    NUMBER sum = 0.0;
    for(i=0; i<size; i++) {
        sum += ar[i];
        if(ar[i]<0 || ar[i] >1) {
            string ar_was = "";
            for(int i=0; i<size; i++) ar_was = ar_was + std::to_string(ar_copy[i]).substr(0,5) + std::to_string((i<(size-1))?',':' ');
            string ar_is = "";
            for(int i=0; i<size; i++) ar_is = ar_is + std::to_string(ar[i]).substr(0,5) + std::to_string((i<(size-1))?',':' ');
            fprintf(stderr, "ERROR! projected value is not within [0, 1] range! ar was %s and now is %s.\n",ar_was.c_str(),ar_is.c_str());
        }
    }
//    if( fabs(sum-1)>SAFETY)
//        fprintf(stderr, "ERROR! projected simplex does not sum to 1!\n");
	
    free(at_hi);
    free(at_lo);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3f0, %rsp            # imm = 0x3F0
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
movsbq -0x9(%rbp), %rdi
movl $0x1, %esi
callq 0x5180
movq %rax, -0x18(%rbp)
movsbq -0x9(%rbp), %rdi
movl $0x1, %esi
callq 0x5180
movq %rax, -0x20(%rbp)
movsbq -0x9(%rbp), %rdi
movl $0x8, %esi
callq 0x5180
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movq -0x8(%rbp), %rsi
movsbq -0x9(%rbp), %rdx
shlq $0x3, %rdx
callq 0x5250
movl $0x0, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movsbl -0x9(%rbp), %esi
callq 0x74c0
xorb $-0x1, %al
testb $0x1, %al
jne 0x7a03
jmp 0x82ae
xorps %xmm0, %xmm0
movsd %xmm0, -0x30(%rbp)
movb $0x0, -0xb(%rbp)
movb $0x0, -0xc(%rbp)
movsd 0x47ffd(%rip), %xmm0    # 0x4fa18
movsd %xmm0, -0x28(%rbp)
movb $0x0, -0xa(%rbp)
movsbl -0xa(%rbp), %eax
movsbl -0x9(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7b7f
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
xorps %xmm0, %xmm0
xorl %eax, %eax
movl $0x1, %ecx
ucomisd %xmm1, %xmm0
cmovael %ecx, %eax
movb %al, %dl
movq -0x20(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x20(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x7a80
xorps %xmm0, %xmm0
movsd %xmm0, -0x390(%rbp)
jmp 0x7a96
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x390(%rbp)
movsd -0x390(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsbl -0xc(%rbp), %eax
movq -0x20(%rbp), %rcx
movsbq -0xa(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movb %al, -0xc(%rbp)
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x47f30(%rip), %xmm1    # 0x4fa08
xorl %eax, %eax
movl $0x1, %ecx
ucomisd %xmm1, %xmm0
cmovael %ecx, %eax
movb %al, %dl
movq -0x18(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movb %dl, (%rax,%rcx)
movq -0x18(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x1, %eax
jne 0x7b18
movsd 0x47efa(%rip), %xmm0    # 0x4fa08
movsd %xmm0, -0x398(%rbp)
jmp 0x7b2e
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x398(%rbp)
movsd -0x398(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsbl -0xb(%rbp), %eax
movq -0x18(%rbp), %rcx
movsbq -0xa(%rbp), %rdx
movsbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movb %al, -0xb(%rbp)
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movb -0xa(%rbp), %al
addb $0x1, %al
movb %al, -0xa(%rbp)
jmp 0x7a24
movsd -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x7bb7
movsbl -0x9(%rbp), %eax
movsbl -0xc(%rbp), %ecx
cmpl %ecx, %eax
jle 0x7bb7
movsd -0x28(%rbp), %xmm0
movsbl -0x9(%rbp), %eax
movsbl -0xc(%rbp), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x7beb
xorps %xmm0, %xmm0
ucomisd -0x28(%rbp), %xmm0
jbe 0x7be9
movsbl -0x9(%rbp), %eax
movsbl -0xb(%rbp), %ecx
cmpl %ecx, %eax
jle 0x7be9
movsd -0x28(%rbp), %xmm0
movsbl -0x9(%rbp), %eax
movsbl -0xb(%rbp), %ecx
subl %ecx, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x30(%rbp)
jmp 0x7beb
movl $0x0, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x48(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x50(%rbp)
movb $0x0, -0xa(%rbp)
movsbl -0xa(%rbp), %eax
movsbl -0x9(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7c7e
movq -0x20(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x7c72
movq -0x18(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x7c72
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x30(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7c70
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x48(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x7c72
jmp 0x7c74
movb -0xa(%rbp), %al
addb $0x1, %al
movb %al, -0xa(%rbp)
jmp 0x7c06
cmpl $0x0, -0x40(%rbp)
jne 0x7d60
movb $0x0, -0xa(%rbp)
movsbl -0xa(%rbp), %eax
movsbl -0x9(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7d5b
movq -0x20(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x7ccb
movsd -0x28(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x7ccb
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x3a0(%rbp)
jmp 0x7cd8
xorps %xmm0, %xmm0
movsd %xmm0, -0x3a0(%rbp)
jmp 0x7cd8
movsd -0x3a0(%rbp), %xmm1
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x18(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x7d22
xorps %xmm0, %xmm0
ucomisd -0x28(%rbp), %xmm0
jbe 0x7d22
movsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x3a8(%rbp)
jmp 0x7d2f
xorps %xmm0, %xmm0
movsd %xmm0, -0x3a8(%rbp)
jmp 0x7d2f
movsd -0x3a8(%rbp), %xmm1
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movb -0xa(%rbp), %al
addb $0x1, %al
movb %al, -0xa(%rbp)
jmp 0x7c8c
jmp 0x7e2a
movsd -0x28(%rbp), %xmm0
subsd -0x48(%rbp), %xmm0
movsbl -0x9(%rbp), %eax
movsbl -0xb(%rbp), %ecx
movsbl -0xc(%rbp), %edx
addl %edx, %ecx
subl %ecx, %eax
subl -0x40(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movb $0x0, -0xa(%rbp)
movsbl -0xa(%rbp), %eax
movsbl -0x9(%rbp), %ecx
cmpl %ecx, %eax
jge 0x7e28
movq -0x20(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x7e19
movq -0x18(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x0, %eax
jne 0x7e19
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0x30(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x7de8
xorps %xmm0, %xmm0
movsd %xmm0, -0x3b0(%rbp)
jmp 0x7e03
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
subsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x3b0(%rbp)
movsd -0x3b0(%rbp), %xmm0
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x7e1b
movb -0xa(%rbp), %al
addb $0x1, %al
movb %al, -0xa(%rbp)
jmp 0x7d8e
jmp 0x7e2a
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x64, -0x3c(%rbp)
jne 0x82a9
leaq -0x71(%rbp), %rdi
movq %rdi, -0x3b8(%rbp)
callq 0x5550
movq -0x3b8(%rbp), %rdx
leaq 0x48e20(%rip), %rsi     # 0x50c7b
leaq -0x70(%rbp), %rdi
callq 0xc470
jmp 0x7e66
leaq -0x71(%rbp), %rdi
callq 0x5320
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
movsbl -0x9(%rbp), %ecx
cmpl %ecx, %eax
jge 0x802d
movq -0x38(%rbp), %rax
movslq -0x88(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq -0x108(%rbp), %rdi
callq 0xc640
jmp 0x7ea9
xorl %eax, %eax
movl %eax, %edx
leaq -0xe8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
movl $0x5, %ecx
callq 0x52f0
jmp 0x7ec7
leaq -0xc8(%rbp), %rdi
leaq -0x70(%rbp), %rsi
leaq -0xe8(%rbp), %rdx
callq 0xc5f0
jmp 0x7ee0
movl -0x88(%rbp), %eax
movsbl -0x9(%rbp), %ecx
decl %ecx
subl %ecx, %eax
movl $0x2c, %eax
movl $0x20, %esi
cmovll %eax, %esi
leaq -0x128(%rbp), %rdi
callq 0xc690
jmp 0x7f09
leaq -0xa8(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
leaq -0x128(%rbp), %rdx
callq 0xc520
jmp 0x7f25
leaq -0x70(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x53a0
leaq -0xa8(%rbp), %rdi
callq 0x5170
leaq -0x128(%rbp), %rdi
callq 0x5170
leaq -0xc8(%rbp), %rdi
callq 0x5170
leaq -0xe8(%rbp), %rdi
callq 0x5170
leaq -0x108(%rbp), %rdi
callq 0x5170
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x7e79
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x5320
jmp 0x87cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x829b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x801c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x8010
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x8004
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x5170
leaq -0xc8(%rbp), %rdi
callq 0x5170
leaq -0xe8(%rbp), %rdi
callq 0x5170
leaq -0x108(%rbp), %rdi
callq 0x5170
jmp 0x829b
leaq -0x149(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x5550
movq -0x3c0(%rbp), %rdx
leaq 0x48c2d(%rip), %rsi     # 0x50c7b
leaq -0x148(%rbp), %rdi
callq 0xc470
jmp 0x805c
leaq -0x149(%rbp), %rdi
callq 0x5320
movl $0x0, -0x150(%rbp)
movl -0x150(%rbp), %eax
movsbl -0x9(%rbp), %ecx
cmpl %ecx, %eax
jge 0x822c
movq -0x8(%rbp), %rax
movslq -0x150(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq -0x1d0(%rbp), %rdi
callq 0xc640
jmp 0x80a2
xorl %eax, %eax
movl %eax, %edx
leaq -0x1b0(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
movl $0x5, %ecx
callq 0x52f0
jmp 0x80c0
leaq -0x190(%rbp), %rdi
leaq -0x148(%rbp), %rsi
leaq -0x1b0(%rbp), %rdx
callq 0xc5f0
jmp 0x80dc
movl -0x150(%rbp), %eax
movsbl -0x9(%rbp), %ecx
decl %ecx
subl %ecx, %eax
movl $0x2c, %eax
movl $0x20, %esi
cmovll %eax, %esi
leaq -0x1f0(%rbp), %rdi
callq 0xc690
jmp 0x8105
leaq -0x170(%rbp), %rdi
leaq -0x190(%rbp), %rsi
leaq -0x1f0(%rbp), %rdx
callq 0xc520
jmp 0x8121
leaq -0x148(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x53a0
leaq -0x170(%rbp), %rdi
callq 0x5170
leaq -0x1f0(%rbp), %rdi
callq 0x5170
leaq -0x190(%rbp), %rdi
callq 0x5170
leaq -0x1b0(%rbp), %rdi
callq 0x5170
leaq -0x1d0(%rbp), %rdi
callq 0x5170
movl -0x150(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x150(%rbp)
jmp 0x8072
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x149(%rbp), %rdi
callq 0x5320
jmp 0x829b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x828f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x821e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x8212
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x8206
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x5170
leaq -0x190(%rbp), %rdi
callq 0x5170
leaq -0x1b0(%rbp), %rdi
callq 0x5170
leaq -0x1d0(%rbp), %rdi
callq 0x5170
jmp 0x828f
movq 0x52da5(%rip), %rax     # 0x5afd8
movq (%rax), %rax
movq %rax, -0x3d0(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x5110
movq %rax, -0x3c8(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x5110
movq -0x3d0(%rbp), %rdi
movq -0x3c8(%rbp), %rdx
movq %rax, %rcx
leaq 0x4782f(%rip), %rsi     # 0x4faa0
movb $0x0, %al
callq 0x5440
leaq -0x148(%rbp), %rdi
callq 0x5170
leaq -0x70(%rbp), %rdi
callq 0x5170
jmp 0x82ae
leaq -0x148(%rbp), %rdi
callq 0x5170
leaq -0x70(%rbp), %rdi
callq 0x5170
jmp 0x87cc
jmp 0x79eb
xorps %xmm0, %xmm0
movsd %xmm0, -0x1f8(%rbp)
movb $0x0, -0xa(%rbp)
movsbl -0xa(%rbp), %eax
movsbl -0x9(%rbp), %ecx
cmpl %ecx, %eax
jge 0x87b1
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x1f8(%rbp), %xmm0
movsd %xmm0, -0x1f8(%rbp)
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
ja 0x831e
movq -0x8(%rbp), %rax
movsbq -0xa(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x476f4(%rip), %xmm1    # 0x4fa08
ucomisd %xmm1, %xmm0
jbe 0x87a2
leaq -0x219(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
callq 0x5550
movq -0x3d8(%rbp), %rdx
leaq 0x4893c(%rip), %rsi     # 0x50c7b
leaq -0x218(%rbp), %rdi
callq 0xc470
jmp 0x834d
leaq -0x219(%rbp), %rdi
callq 0x5320
movl $0x0, -0x220(%rbp)
movl -0x220(%rbp), %eax
movsbl -0x9(%rbp), %ecx
cmpl %ecx, %eax
jge 0x8520
movq -0x38(%rbp), %rax
movslq -0x220(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq -0x2a0(%rbp), %rdi
callq 0xc640
jmp 0x8393
xorl %eax, %eax
movl %eax, %edx
leaq -0x280(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
movl $0x5, %ecx
callq 0x52f0
jmp 0x83b1
leaq -0x260(%rbp), %rdi
leaq -0x218(%rbp), %rsi
leaq -0x280(%rbp), %rdx
callq 0xc5f0
jmp 0x83cd
movl -0x220(%rbp), %eax
movsbl -0x9(%rbp), %ecx
decl %ecx
subl %ecx, %eax
movl $0x2c, %eax
movl $0x20, %esi
cmovll %eax, %esi
leaq -0x2c0(%rbp), %rdi
callq 0xc690
jmp 0x83f6
leaq -0x240(%rbp), %rdi
leaq -0x260(%rbp), %rsi
leaq -0x2c0(%rbp), %rdx
callq 0xc520
jmp 0x8412
leaq -0x218(%rbp), %rdi
leaq -0x240(%rbp), %rsi
callq 0x53a0
leaq -0x240(%rbp), %rdi
callq 0x5170
leaq -0x2c0(%rbp), %rdi
callq 0x5170
leaq -0x260(%rbp), %rdi
callq 0x5170
leaq -0x280(%rbp), %rdi
callq 0x5170
leaq -0x2a0(%rbp), %rdi
callq 0x5170
movl -0x220(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x220(%rbp)
jmp 0x8363
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x219(%rbp), %rdi
callq 0x5320
jmp 0x87cc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x8794
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x850f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x8503
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x84f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x2c0(%rbp), %rdi
callq 0x5170
leaq -0x260(%rbp), %rdi
callq 0x5170
leaq -0x280(%rbp), %rdi
callq 0x5170
leaq -0x2a0(%rbp), %rdi
callq 0x5170
jmp 0x8794
leaq -0x2e1(%rbp), %rdi
movq %rdi, -0x3e0(%rbp)
callq 0x5550
movq -0x3e0(%rbp), %rdx
leaq 0x4873a(%rip), %rsi     # 0x50c7b
leaq -0x2e0(%rbp), %rdi
callq 0xc470
jmp 0x854f
leaq -0x2e1(%rbp), %rdi
callq 0x5320
movl $0x0, -0x2e8(%rbp)
movl -0x2e8(%rbp), %eax
movsbl -0x9(%rbp), %ecx
cmpl %ecx, %eax
jge 0x871f
movq -0x8(%rbp), %rax
movslq -0x2e8(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
leaq -0x368(%rbp), %rdi
callq 0xc640
jmp 0x8595
xorl %eax, %eax
movl %eax, %edx
leaq -0x348(%rbp), %rdi
leaq -0x368(%rbp), %rsi
movl $0x5, %ecx
callq 0x52f0
jmp 0x85b3
leaq -0x328(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
leaq -0x348(%rbp), %rdx
callq 0xc5f0
jmp 0x85cf
movl -0x2e8(%rbp), %eax
movsbl -0x9(%rbp), %ecx
decl %ecx
subl %ecx, %eax
movl $0x2c, %eax
movl $0x20, %esi
cmovll %eax, %esi
leaq -0x388(%rbp), %rdi
callq 0xc690
jmp 0x85f8
leaq -0x308(%rbp), %rdi
leaq -0x328(%rbp), %rsi
leaq -0x388(%rbp), %rdx
callq 0xc520
jmp 0x8614
leaq -0x2e0(%rbp), %rdi
leaq -0x308(%rbp), %rsi
callq 0x53a0
leaq -0x308(%rbp), %rdi
callq 0x5170
leaq -0x388(%rbp), %rdi
callq 0x5170
leaq -0x328(%rbp), %rdi
callq 0x5170
leaq -0x348(%rbp), %rdi
callq 0x5170
leaq -0x368(%rbp), %rdi
callq 0x5170
movl -0x2e8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2e8(%rbp)
jmp 0x8565
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x2e1(%rbp), %rdi
callq 0x5320
jmp 0x8794
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x8788
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x8711
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x8705
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x86f9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x5170
leaq -0x328(%rbp), %rdi
callq 0x5170
leaq -0x348(%rbp), %rdi
callq 0x5170
leaq -0x368(%rbp), %rdi
callq 0x5170
jmp 0x8788
movq 0x528b2(%rip), %rax     # 0x5afd8
movq (%rax), %rax
movq %rax, -0x3f0(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x5110
movq %rax, -0x3e8(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x5110
movq -0x3f0(%rbp), %rdi
movq -0x3e8(%rbp), %rdx
movq %rax, %rcx
leaq 0x47377(%rip), %rsi     # 0x4fade
movb $0x0, %al
callq 0x5440
leaq -0x2e0(%rbp), %rdi
callq 0x5170
leaq -0x218(%rbp), %rdi
callq 0x5170
jmp 0x87a2
leaq -0x2e0(%rbp), %rdi
callq 0x5170
leaq -0x218(%rbp), %rdi
callq 0x5170
jmp 0x87cc
jmp 0x87a4
movb -0xa(%rbp), %al
addb $0x1, %al
movb %al, -0xa(%rbp)
jmp 0x82bd
movq -0x18(%rbp), %rdi
callq 0x5380
movq -0x20(%rbp), %rdi
callq 0x5380
addq $0x3f0, %rsp            # imm = 0x3F0
popq %rbp
retq
movq -0x80(%rbp), %rdi
callq 0x5540
nopw %cs:(%rax,%rax)