// File: cjlin1[P]liblinear/linear.cpp
// Function: solve_l1r_l2_svc(problem const*, parameter const*, double*, double, double, double)
static int solve_l1r_l2_svc(const problem *prob_col, const parameter* param, double *w, double Cp, double Cn, double eps)
{
	int l = prob_col->l;
	int w_size = prob_col->n;
	int regularize_bias = param->regularize_bias;
	int j, s, iter = 0;
	int max_iter = 1000;
	int active_size = w_size;
	int max_num_linesearch = 20;

	double sigma = 0.01;
	double d, G_loss, G, H;
	double Gmax_old = INF;
	double Gmax_new, Gnorm1_new;
	double Gnorm1_init = -1.0; // Gnorm1_init is initialized at the first iteration
	double d_old, d_diff;
	double loss_old = 0, loss_new;
	double appxcond, cond;

	int *index = new int[w_size];
	schar *y = new schar[l];
	double *b = new double[l]; // b = 1-ywTx
	double *xj_sq = new double[w_size];
	feature_node *x;

	double C[3] = {Cn,0,Cp};

	// Initial w can be set here.
	for(j=0; j<w_size; j++)
		w[j] = 0;

	for(j=0; j<l; j++)
	{
		b[j] = 1;
		if(prob_col->y[j] > 0)
			y[j] = 1;
		else
			y[j] = -1;
	}
	for(j=0; j<w_size; j++)
	{
		index[j] = j;
		xj_sq[j] = 0;
		x = prob_col->x[j];
		while(x->index != -1)
		{
			int ind = x->index-1;
			x->value *= y[ind]; // x->value stores yi*xij
			double val = x->value;
			b[ind] -= w[j]*val;
			xj_sq[j] += C[GETI(ind)]*val*val;
			x++;
		}
	}

	while(iter < max_iter)
	{
		Gmax_new = 0;
		Gnorm1_new = 0;

		for(j=0; j<active_size; j++)
		{
			int i = j+rand()%(active_size-j);
			swap(index[i], index[j]);
		}

		for(s=0; s<active_size; s++)
		{
			j = index[s];
			G_loss = 0;
			H = 0;

			x = prob_col->x[j];
			while(x->index != -1)
			{
				int ind = x->index-1;
				if(b[ind] > 0)
				{
					double val = x->value;
					double tmp = C[GETI(ind)]*val;
					G_loss -= tmp*b[ind];
					H += tmp*val;
				}
				x++;
			}
			G_loss *= 2;

			G = G_loss;
			H *= 2;
			H = max(H, 1e-12);

			double violation = 0;
			double Gp = 0, Gn = 0;
			if(j == w_size-1 && regularize_bias == 0)
				violation = fabs(G);
			else
			{
				Gp = G+1;
				Gn = G-1;
				if(w[j] == 0)
				{
					if(Gp < 0)
						violation = -Gp;
					else if(Gn > 0)
						violation = Gn;
					else if(Gp>Gmax_old/l && Gn<-Gmax_old/l)
					{
						active_size--;
						swap(index[s], index[active_size]);
						s--;
						continue;
					}
				}
				else if(w[j] > 0)
					violation = fabs(Gp);
				else
					violation = fabs(Gn);
			}
			Gmax_new = max(Gmax_new, violation);
			Gnorm1_new += violation;

			// obtain Newton direction d
			if(j == w_size-1 && regularize_bias == 0)
				d = -G/H;
			else
			{
				if(Gp < H*w[j])
					d = -Gp/H;
				else if(Gn > H*w[j])
					d = -Gn/H;
				else
					d = -w[j];
			}

			if(fabs(d) < 1.0e-12)
				continue;

			double delta;
			if(j == w_size-1 && regularize_bias == 0)
				delta = G*d;
			else
				delta = fabs(w[j]+d)-fabs(w[j]) + G*d;
			d_old = 0;
			int num_linesearch;
			for(num_linesearch=0; num_linesearch < max_num_linesearch; num_linesearch++)
			{
				d_diff = d_old - d;
				if(j == w_size-1 && regularize_bias == 0)
					cond = -sigma*delta;
				else
					cond = fabs(w[j]+d)-fabs(w[j]) - sigma*delta;

				appxcond = xj_sq[j]*d*d + G_loss*d + cond;
				if(appxcond <= 0)
				{
					x = prob_col->x[j];
					sparse_operator::axpy(d_diff, x, b);
					break;
				}

				if(num_linesearch == 0)
				{
					loss_old = 0;
					loss_new = 0;
					x = prob_col->x[j];
					while(x->index != -1)
					{
						int ind = x->index-1;
						if(b[ind] > 0)
							loss_old += C[GETI(ind)]*b[ind]*b[ind];
						double b_new = b[ind] + d_diff*x->value;
						b[ind] = b_new;
						if(b_new > 0)
							loss_new += C[GETI(ind)]*b_new*b_new;
						x++;
					}
				}
				else
				{
					loss_new = 0;
					x = prob_col->x[j];
					while(x->index != -1)
					{
						int ind = x->index-1;
						double b_new = b[ind] + d_diff*x->value;
						b[ind] = b_new;
						if(b_new > 0)
							loss_new += C[GETI(ind)]*b_new*b_new;
						x++;
					}
				}

				cond = cond + loss_new - loss_old;
				if(cond <= 0)
					break;
				else
				{
					d_old = d;
					d *= 0.5;
					delta *= 0.5;
				}
			}

			w[j] += d;

			// recompute b[] if line search takes too many steps
			if(num_linesearch >= max_num_linesearch)
			{
				info("#");
				for(int i=0; i<l; i++)
					b[i] = 1;

				for(int i=0; i<w_size; i++)
				{
					if(w[i]==0) continue;
					x = prob_col->x[i];
					sparse_operator::axpy(-w[i], x, b);
				}
			}
		}

		if(iter == 0)
			Gnorm1_init = Gnorm1_new;
		iter++;
		if(iter % 10 == 0)
			info(".");

		if(Gnorm1_new <= eps*Gnorm1_init)
		{
			if(active_size == w_size)
				break;
			else
			{
				active_size = w_size;
				info("*");
				Gmax_old = INF;
				continue;
			}
		}

		Gmax_old = Gmax_new;
	}

	info("\noptimization finished, #iter = %d\n", iter);
	if(iter >= max_iter)
		info("\nWARNING: reaching max number of iterations\n");

	// calculate objective value

	double v = 0;
	int nnz = 0;
	for(j=0; j<w_size; j++)
	{
		x = prob_col->x[j];
		while(x->index != -1)
		{
			x->value *= prob_col->y[x->index-1]; // restore x->value
			x++;
		}
		if(w[j] != 0)
		{
			v += fabs(w[j]);
			nnz++;
		}
	}
	if (regularize_bias == 0)
		v -= fabs(w[w_size-1]);
	for(j=0; j<l; j++)
		if(b[j] > 0)
			v += C[GETI(j)]*b[j]*b[j];

	info("Objective value = %lf\n", v);
	info("#nonzeros/#features = %d/%d\n", nnz, w_size);

	delete [] index;
	delete [] y;
	delete [] b;
	delete [] xj_sq;

	return iter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movsd %xmm0, -0x20(%rbp)
movsd %xmm1, -0x28(%rbp)
movsd %xmm2, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, -0x3c(%rbp)
movl $0x0, -0x48(%rbp)
movl $0x3e8, -0x4c(%rbp)     # imm = 0x3E8
movl -0x38(%rbp), %eax
movl %eax, -0x50(%rbp)
movl $0x14, -0x54(%rbp)
movsd 0x500a(%rip), %xmm0     # 0x12030
movsd %xmm0, -0x60(%rbp)
movsd 0x4fdd(%rip), %xmm0     # 0x12010
movsd %xmm0, -0x88(%rbp)
movsd 0x4fc5(%rip), %xmm0     # 0x12008
movsd %xmm0, -0xa0(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xb8(%rbp)
movslq -0x38(%rbp), %rax
movl $0x4, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, -0xd8(%rbp)
movslq -0x34(%rbp), %rdi
callq 0x2030
movq %rax, -0xe0(%rbp)
movslq -0x34(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, -0xe8(%rbp)
movslq -0x38(%rbp), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, -0xf0(%rbp)
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x110(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x108(%rbp)
movsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x100(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0xd139
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xd116
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xd1a7
movq -0xe8(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd 0x4ecd(%rip), %xmm0     # 0x12028
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd18b
movq -0xe0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0xd19a
movq -0xe0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movb $-0x1, (%rax,%rcx)
jmp 0xd19c
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xd140
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0xd312
movl -0x40(%rbp), %edx
movq -0xd8(%rbp), %rax
movslq -0x40(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0xf0(%rbp), %rax
movslq -0x40(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xd302
movq -0xf8(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x114(%rbp)
movq -0xe0(%rbp), %rax
movslq -0x114(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cvtsi2sd %eax, %xmm0
movq -0xf8(%rbp), %rax
mulsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movq -0xf8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x120(%rbp)
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd -0x120(%rbp), %xmm2
movq -0xe8(%rbp), %rax
movslq -0x114(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm0, %rdx
movabsq $-0x8000000000000000, %rsi # imm = 0x8000000000000000
xorq %rsi, %rdx
movq %rdx, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0xe0(%rbp), %rax
movslq -0x114(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $0x1, %eax
cltq
movsd -0x110(%rbp,%rax,8), %xmm0
mulsd -0x120(%rbp), %xmm0
movsd -0x120(%rbp), %xmm2
movq -0xf0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movq -0xf8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xf8(%rbp)
jmp 0xd1f5
jmp 0xd304
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xd1ae
jmp 0xd314
movl -0x48(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0xdf3f
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x98(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0xd3a1
movl -0x40(%rbp), %eax
movl %eax, -0x190(%rbp)
callq 0x2090
movl -0x50(%rbp), %ecx
subl -0x40(%rbp), %ecx
cltd
idivl %ecx
movl -0x190(%rbp), %eax
addl %edx, %eax
movl %eax, -0x124(%rbp)
movq -0xd8(%rbp), %rdi
movslq -0x124(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0xd8(%rbp), %rsi
movslq -0x40(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x70b0
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xd33d
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0xde9f
movq -0xd8(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x40(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x70(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xd4ef
movq -0xf8(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x128(%rbp)
movq -0xe8(%rbp), %rax
movslq -0x128(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd4d8
movq -0xf8(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x130(%rbp)
movq -0xe0(%rbp), %rax
movslq -0x128(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $0x1, %eax
cltq
movsd -0x110(%rbp,%rax,8), %xmm0
mulsd -0x130(%rbp), %xmm0
movsd %xmm0, -0x138(%rbp)
movsd -0x138(%rbp), %xmm0
movq -0xe8(%rbp), %rax
movslq -0x128(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x70(%rbp), %xmm1
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x138(%rbp), %xmm0
movsd -0x130(%rbp), %xmm2
movsd -0x80(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0xf8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xf8(%rbp)
jmp 0xd3ec
movsd 0x58f9(%rip), %xmm0     # 0x12df0
mulsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x78(%rbp)
movsd 0x58dd(%rip), %xmm0     # 0x12df0
mulsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x80(%rbp)
movsd -0x80(%rbp), %xmm0
movsd 0x5756(%rip), %xmm1     # 0x12c80
callq 0x7070
movsd %xmm0, -0x80(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x140(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x148(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x150(%rbp)
movl -0x40(%rbp), %eax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0xd585
cmpl $0x0, -0x3c(%rbp)
jne 0xd585
movsd -0x78(%rbp), %xmm0
movaps 0x572c(%rip), %xmm1     # 0x12ca0
pand %xmm1, %xmm0
movsd %xmm0, -0x140(%rbp)
jmp 0xd71f
movsd 0x4a9b(%rip), %xmm0     # 0x12028
addsd -0x78(%rbp), %xmm0
movsd %xmm0, -0x148(%rbp)
movsd -0x78(%rbp), %xmm0
movsd 0x4a81(%rip), %xmm1     # 0x12028
subsd %xmm1, %xmm0
movsd %xmm0, -0x150(%rbp)
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xd6cd
jp 0xd6cd
xorps %xmm0, %xmm0
ucomisd -0x148(%rbp), %xmm0
jbe 0xd60c
movsd -0x148(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x140(%rbp)
jmp 0xd6cb
movsd -0x150(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd632
movsd -0x150(%rbp), %xmm0
movsd %xmm0, -0x140(%rbp)
jmp 0xd6c9
movsd -0x148(%rbp), %xmm0
movsd -0x88(%rbp), %xmm1
cvtsi2sdl -0x34(%rbp), %xmm2
divsd %xmm2, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd6c7
movsd -0x150(%rbp), %xmm1
movsd -0x88(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
cvtsi2sdl -0x34(%rbp), %xmm2
divsd %xmm2, %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd6c7
movl -0x50(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x50(%rbp)
movq -0xd8(%rbp), %rdi
movslq -0x44(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0xd8(%rbp), %rsi
movslq -0x50(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x70b0
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xde91
jmp 0xd6c9
jmp 0xd6cb
jmp 0xd71d
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd700
movsd -0x148(%rbp), %xmm0
movaps 0x55ae(%rip), %xmm1     # 0x12ca0
pand %xmm1, %xmm0
movsd %xmm0, -0x140(%rbp)
jmp 0xd71b
movsd -0x150(%rbp), %xmm0
movaps 0x5591(%rip), %xmm1     # 0x12ca0
pand %xmm1, %xmm0
movsd %xmm0, -0x140(%rbp)
jmp 0xd71d
jmp 0xd71f
movsd -0x90(%rbp), %xmm0
movsd -0x140(%rbp), %xmm1
callq 0x7070
movsd %xmm0, -0x90(%rbp)
movsd -0x140(%rbp), %xmm0
addsd -0x98(%rbp), %xmm0
movsd %xmm0, -0x98(%rbp)
movl -0x40(%rbp), %eax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0xd792
cmpl $0x0, -0x3c(%rbp)
jne 0xd792
movsd -0x78(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0xd855
movsd -0x148(%rbp), %xmm1
movsd -0x80(%rbp), %xmm0
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
ucomisd %xmm1, %xmm0
jbe 0xd7dd
movsd -0x148(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0xd853
movsd -0x150(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0xd828
movsd -0x150(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
divsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0xd851
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0xd853
jmp 0xd855
movsd -0x68(%rbp), %xmm1
movaps 0x543f(%rip), %xmm0     # 0x12ca0
pand %xmm0, %xmm1
movsd 0x5413(%rip), %xmm0     # 0x12c80
ucomisd %xmm1, %xmm0
jbe 0xd878
jmp 0xde91
movl -0x40(%rbp), %eax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0xd89f
cmpl $0x0, -0x3c(%rbp)
jne 0xd89f
movsd -0x78(%rbp), %xmm0
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x158(%rbp)
jmp 0xd8f2
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
addsd -0x68(%rbp), %xmm1
movaps 0x53e8(%rip), %xmm0     # 0x12ca0
pand %xmm0, %xmm1
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x53d0(%rip), %xmm2     # 0x12ca0
pand %xmm2, %xmm0
subsd %xmm0, %xmm1
movsd -0x78(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x158(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xa8(%rbp)
movl $0x0, -0x15c(%rbp)
movl -0x15c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0xdd7a
movsd -0xa8(%rbp), %xmm0
subsd -0x68(%rbp), %xmm0
movsd %xmm0, -0xb0(%rbp)
movl -0x40(%rbp), %eax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jne 0xd96c
cmpl $0x0, -0x3c(%rbp)
jne 0xd96c
movsd -0x60(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd -0x158(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
jmp 0xd9d9
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
addsd -0x68(%rbp), %xmm1
movaps 0x531b(%rip), %xmm0     # 0x12ca0
pand %xmm0, %xmm1
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x5303(%rip), %xmm2     # 0x12ca0
pand %xmm2, %xmm0
subsd %xmm0, %xmm1
movsd -0x60(%rbp), %xmm0
movsd -0x158(%rbp), %xmm2
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movq -0xf0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
mulsd -0x68(%rbp), %xmm0
movsd -0x68(%rbp), %xmm2
movsd -0x70(%rbp), %xmm1
mulsd -0x68(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
addsd -0xd0(%rbp), %xmm0
movsd %xmm0, -0xc8(%rbp)
xorps %xmm0, %xmm0
ucomisd -0xc8(%rbp), %xmm0
jb 0xda59
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
movsd -0xb0(%rbp), %xmm0
movq -0xf8(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x11590
jmp 0xdd7a
cmpl $0x0, -0x15c(%rbp)
jne 0xdbf6
xorps %xmm0, %xmm0
movsd %xmm0, -0xb8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xdbf1
movq -0xf8(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x160(%rbp)
movq -0xe8(%rbp), %rax
movslq -0x160(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xdb2f
movq -0xe0(%rbp), %rax
movslq -0x160(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $0x1, %eax
cltq
movsd -0x110(%rbp,%rax,8), %xmm0
movq -0xe8(%rbp), %rax
movslq -0x160(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movq -0xe8(%rbp), %rax
movslq -0x160(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0xb8(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xb8(%rbp)
movq -0xe8(%rbp), %rax
movslq -0x160(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0xb0(%rbp), %xmm0
movq -0xf8(%rbp), %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x168(%rbp)
movsd -0x168(%rbp), %xmm0
movq -0xe8(%rbp), %rax
movslq -0x160(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x168(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xdbda
movq -0xe0(%rbp), %rax
movslq -0x160(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $0x1, %eax
cltq
movsd -0x110(%rbp,%rax,8), %xmm0
mulsd -0x168(%rbp), %xmm0
movsd -0x168(%rbp), %xmm2
movsd -0xc0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0xf8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xf8(%rbp)
jmp 0xda93
jmp 0xdcfe
xorps %xmm0, %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xdcfc
movq -0xf8(%rbp), %rax
movl (%rax), %eax
subl $0x1, %eax
movl %eax, -0x16c(%rbp)
movq -0xe8(%rbp), %rax
movslq -0x16c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd -0xb0(%rbp), %xmm0
movq -0xf8(%rbp), %rax
movsd 0x8(%rax), %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x178(%rbp)
movsd -0x178(%rbp), %xmm0
movq -0xe8(%rbp), %rax
movslq -0x16c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x178(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xdce5
movq -0xe0(%rbp), %rax
movslq -0x16c(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $0x1, %eax
cltq
movsd -0x110(%rbp,%rax,8), %xmm0
mulsd -0x178(%rbp), %xmm0
movsd -0x178(%rbp), %xmm2
movsd -0xc0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movq -0xf8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xf8(%rbp)
jmp 0xdc18
jmp 0xdcfe
movsd -0xd0(%rbp), %xmm0
addsd -0xc0(%rbp), %xmm0
subsd -0xb8(%rbp), %xmm0
movsd %xmm0, -0xd0(%rbp)
xorps %xmm0, %xmm0
ucomisd -0xd0(%rbp), %xmm0
jb 0xdd2d
jmp 0xdd7a
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0xa8(%rbp)
movsd 0x42d6(%rip), %xmm0     # 0x12018
mulsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd 0x42c4(%rip), %xmm0     # 0x12018
mulsd -0x158(%rbp), %xmm0
movsd %xmm0, -0x158(%rbp)
jmp 0xdd66
movl -0x15c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x15c(%rbp)
jmp 0xd907
movsd -0x68(%rbp), %xmm0
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x15c(%rbp), %eax
cmpl -0x54(%rbp), %eax
jl 0xde8f
leaq 0x571c(%rip), %rdi      # 0x134c3
movb $0x0, %al
callq 0x7120
movl $0x0, -0x17c(%rbp)
movl -0x17c(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xddef
movq -0xe8(%rbp), %rax
movslq -0x17c(%rbp), %rcx
movsd 0x424f(%rip), %xmm0     # 0x12028
movsd %xmm0, (%rax,%rcx,8)
movl -0x17c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x17c(%rbp)
jmp 0xddb8
movl $0x0, -0x180(%rbp)
movl -0x180(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0xde8d
movq -0x18(%rbp), %rax
movslq -0x180(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xde25
jp 0xde25
jmp 0xde79
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x180(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rax
movslq -0x180(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0xf8(%rbp), %rdi
movq -0xe8(%rbp), %rsi
callq 0x11590
movl -0x180(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x180(%rbp)
jmp 0xddf9
jmp 0xde8f
jmp 0xde91
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xd3a8
cmpl $0x0, -0x48(%rbp)
jne 0xdeb5
movsd -0x98(%rbp), %xmm0
movsd %xmm0, -0xa0(%rbp)
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0xdedc
leaq 0x5013(%rip), %rdi      # 0x12ee8
movb $0x0, %al
callq 0x7120
movsd -0x98(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
mulsd -0xa0(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jb 0xdf2a
movl -0x50(%rbp), %eax
cmpl -0x38(%rbp), %eax
jne 0xdf01
jmp 0xdf3f
movl -0x38(%rbp), %eax
movl %eax, -0x50(%rbp)
leaq 0x4fdc(%rip), %rdi      # 0x12eea
movb $0x0, %al
callq 0x7120
movsd 0x40f3(%rip), %xmm0     # 0x12010
movsd %xmm0, -0x88(%rbp)
jmp 0xd314
movsd -0x90(%rbp), %xmm0
movsd %xmm0, -0x88(%rbp)
jmp 0xd314
movl -0x48(%rbp), %esi
leaq 0x4fa3(%rip), %rdi      # 0x12eec
movb $0x0, %al
callq 0x7120
movl -0x48(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jl 0xdf66
leaq 0x4fb1(%rip), %rdi      # 0x12f10
movb $0x0, %al
callq 0x7120
xorps %xmm0, %xmm0
movsd %xmm0, -0x188(%rbp)
movl $0x0, -0x18c(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x38(%rbp), %eax
jge 0xe053
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rax
cmpl $-0x1, (%rax)
je 0xdff2
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq -0xf8(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0xf8(%rbp), %rax
mulsd 0x8(%rax), %xmm0
movsd %xmm0, 0x8(%rax)
movq -0xf8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xf8(%rbp)
jmp 0xdfa5
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xe00c
jp 0xe00c
jmp 0xe043
movq -0x18(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movaps 0x4c80(%rip), %xmm1     # 0x12ca0
pand %xmm1, %xmm0
addsd -0x188(%rbp), %xmm0
movsd %xmm0, -0x188(%rbp)
movl -0x18c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18c(%rbp)
jmp 0xe045
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xdf82
cmpl $0x0, -0x3c(%rbp)
jne 0xe08a
movq -0x18(%rbp), %rax
movl -0x38(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movaps 0x4c2e(%rip), %xmm0     # 0x12ca0
pand %xmm0, %xmm1
movsd -0x188(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0x188(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0xe117
movq -0xe8(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0xe107
movq -0xe0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl $0x1, %eax
cltq
movsd -0x110(%rbp,%rax,8), %xmm0
movq -0xe8(%rbp), %rax
movslq -0x40(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm0
movq -0xe8(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x188(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x188(%rbp)
jmp 0xe109
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0xe091
movsd -0x188(%rbp), %xmm0
leaq 0x4e17(%rip), %rdi      # 0x12f3d
movb $0x1, %al
callq 0x7120
movl -0x18c(%rbp), %esi
movl -0x38(%rbp), %edx
leaq 0x5388(%rip), %rdi      # 0x134c5
movb $0x0, %al
callq 0x7120
movq -0xd8(%rbp), %rax
movq %rax, -0x198(%rbp)
cmpq $0x0, %rax
je 0xe164
movq -0x198(%rbp), %rdi
callq 0x21b0
movq -0xe0(%rbp), %rax
movq %rax, -0x1a0(%rbp)
cmpq $0x0, %rax
je 0xe184
movq -0x1a0(%rbp), %rdi
callq 0x21b0
movq -0xe8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
cmpq $0x0, %rax
je 0xe1a4
movq -0x1a8(%rbp), %rdi
callq 0x21b0
movq -0xf0(%rbp), %rax
movq %rax, -0x1b0(%rbp)
cmpq $0x0, %rax
je 0xe1c4
movq -0x1b0(%rbp), %rdi
callq 0x21b0
movl -0x48(%rbp), %eax
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq