// File: cjlin1[P]liblinear/linear.cpp
// Function: solve_oneclass_svm(problem const*, parameter const*, double*, double*)
static int solve_oneclass_svm(const problem *prob, const parameter *param, double *w, double *rho)
{
	int l = prob->l;
	int w_size = prob->n;
	double eps = param->eps;
	double nu = param->nu;
	int i, j, s, iter = 0;
	double Gi, Gj;
	double Qij, quad_coef, delta, sum;
	double old_alpha_i;
	double *QD = new double[l];
	double *G = new double[l];
	int *index = new int[l];
	double *alpha = new double[l];
	int max_inner_iter;
	int max_iter = 1000;
	int active_size = l;

	double negGmax;                 // max { -grad(f)_i | i in Iup }
	double negGmin;                 // min { -grad(f)_i | i in Ilow }
	// Iup = { i | alpha_i < 1 }, Ilow = { i | alpha_i > 0 }
	feature_node *max_negG_of_Iup = new feature_node[l];
	feature_node *min_negG_of_Ilow = new feature_node[l];
	feature_node node;

	int n = (int)(nu*l);            // # of alpha's at upper bound
	for(i=0; i<n; i++)
		alpha[i] = 1;
	if (n<l)
		alpha[i] = nu*l-n;
	for(i=n+1; i<l; i++)
		alpha[i] = 0;

	for(i=0; i<w_size; i++)
		w[i] = 0;
	for(i=0; i<l; i++)
	{
		feature_node * const xi = prob->x[i];
		QD[i] = sparse_operator::nrm2_sq(xi);
		sparse_operator::axpy(alpha[i], xi, w);

		index[i] = i;
	}

	while (iter < max_iter)
	{
		negGmax = -INF;
		negGmin = INF;

		for (s=0; s<active_size; s++)
		{
			i = index[s];
			feature_node * const xi = prob->x[i];
			G[i] = sparse_operator::dot(w, xi);
			if (alpha[i] < 1)
				negGmax = max(negGmax, -G[i]);
			if (alpha[i] > 0)
				negGmin = min(negGmin, -G[i]);
		}

		if (negGmax - negGmin < eps)
		{
			if (active_size == l)
				break;
			else
			{
				active_size = l;
				info("*");
				continue;
			}
		}

		for(s=0; s<active_size; s++)
		{
			i = index[s];
			if ((alpha[i] == 1 && -G[i] > negGmax) ||
			    (alpha[i] == 0 && -G[i] < negGmin))
			{
				active_size--;
				swap(index[s], index[active_size]);
				s--;
			}
		}

		max_inner_iter = max(active_size/10, 1);
		int len_Iup = 0;
		int len_Ilow = 0;
		for(s=0; s<active_size; s++)
		{
			i = index[s];
			node.index = i;
			node.value = -G[i];

			if (alpha[i] < 1)
			{
				max_negG_of_Iup[len_Iup] = node;
				len_Iup++;
			}

			if (alpha[i] > 0)
			{
				min_negG_of_Ilow[len_Ilow] = node;
				len_Ilow++;
			}
		}
		max_inner_iter = min(max_inner_iter, min(len_Iup, len_Ilow));

		quick_select_min_k(max_negG_of_Iup, 0, len_Iup-1, len_Iup-max_inner_iter);
		qsort(&(max_negG_of_Iup[len_Iup-max_inner_iter]), max_inner_iter, sizeof(struct feature_node), compare_feature_node);

		quick_select_min_k(min_negG_of_Ilow, 0, len_Ilow-1, max_inner_iter);
		qsort(min_negG_of_Ilow, max_inner_iter, sizeof(struct feature_node), compare_feature_node);

		for (s=0; s<max_inner_iter; s++)
		{
			i = max_negG_of_Iup[len_Iup-s-1].index;
			j = min_negG_of_Ilow[s].index;

			if ((alpha[i] == 0 && alpha[j] == 0) ||
			    (alpha[i] == 1 && alpha[j] == 1))
				continue;

			feature_node const * xi = prob->x[i];
			feature_node const * xj = prob->x[j];

			Gi = sparse_operator::dot(w, xi);
			Gj = sparse_operator::dot(w, xj);

			int violating_pair = 0;
			if (alpha[i] < 1 && alpha[j] > 0 && -Gj + 1e-12 < -Gi)
				violating_pair = 1;
			else
				if (alpha[i] > 0 && alpha[j] < 1 && -Gi + 1e-12 < -Gj)
					violating_pair = 1;
			if (violating_pair == 0)
				continue;

			Qij = sparse_operator::sparse_dot(xi, xj);
			quad_coef = QD[i] + QD[j] - 2*Qij;
			if(quad_coef <= 0)
				quad_coef = 1e-12;
			delta = (Gi - Gj) / quad_coef;
			old_alpha_i = alpha[i];
			sum = alpha[i] + alpha[j];
			alpha[i] = alpha[i] - delta;
			alpha[j] = alpha[j] + delta;
			if (sum > 1)
			{
				if (alpha[i] > 1)
				{
					alpha[i] = 1;
					alpha[j] = sum - 1;
				}
			}
			else
			{
				if (alpha[j] < 0)
				{
					alpha[j] = 0;
					alpha[i] = sum;
				}
			}
			if (sum > 1)
			{
				if (alpha[j] > 1)
				{
					alpha[j] = 1;
					alpha[i] = sum - 1;
				}
			}
			else
			{
				if (alpha[i] < 0)
				{
					alpha[i] = 0;
					alpha[j] = sum;
				}
			}
			delta = alpha[i] - old_alpha_i;
			sparse_operator::axpy(delta, xi, w);
			sparse_operator::axpy(-delta, xj, w);
		}
		iter++;
		if (iter % 10 == 0)
			info(".");
	}
	info("\noptimization finished, #iter = %d\n",iter);
	if (iter >= max_iter)
		info("\nWARNING: reaching max number of iterations\n\n");

	// calculate object value
	double v = 0;
	for(i=0; i<w_size; i++)
		v += w[i]*w[i];
	int nSV = 0;
	for(i=0; i<l; i++)
	{
		if (alpha[i] > 0)
			++nSV;
	}
	info("Objective value = %lf\n", v/2);
	info("nSV = %d\n", nSV);

	// calculate rho
	double nr_free = 0;
	double ub = INF, lb = -INF, sum_free = 0;
	for(i=0; i<l; i++)
	{
		double G = sparse_operator::dot(w, prob->x[i]);
		if (alpha[i] == 1)
			lb = max(lb, G);
		else if (alpha[i] == 0)
			ub = min(ub, G);
		else
		{
			++nr_free;
			sum_free += G;
		}
	}

	if (nr_free > 0)
		*rho = sum_free/nr_free;
	else
		*rho = (ub + lb)/2;
	info("rho = %lf\n", *rho);

	delete [] QD;
	delete [] G;
	delete [] index;
	delete [] alpha;
	delete [] max_negG_of_Iup;
	delete [] min_negG_of_Ilow;

	return iter;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movsd 0x38(%rax), %xmm0
movsd %xmm0, -0x38(%rbp)
movl $0x0, -0x48(%rbp)
movslq -0x24(%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, -0x88(%rbp)
movslq -0x24(%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, -0x90(%rbp)
movslq -0x24(%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, -0x98(%rbp)
movslq -0x24(%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, -0xa0(%rbp)
movl $0x3e8, -0xa8(%rbp)     # imm = 0x3E8
movl -0x24(%rbp), %eax
movl %eax, -0xac(%rbp)
movslq -0x24(%rbp), %rax
movl $0x10, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, -0xc8(%rbp)
movslq -0x24(%rbp), %rax
movl $0x10, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x2030
movq %rax, -0xd0(%rbp)
movsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xe4(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0xe4(%rbp), %eax
jge 0x8689
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd 0x99af(%rip), %xmm0     # 0x12028
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x865b
movl -0xe4(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x86d5
movsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x24(%rbp), %xmm2
cvtsi2sdl -0xe4(%rbp), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x8707
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x86e1
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x8731
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x870e
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x87af
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rdi
callq 0x11640
movq -0x88(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0xf0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11590
movl -0x3c(%rbp), %edx
movq -0x98(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x8738
jmp 0x87b1
movl -0x48(%rbp), %eax
cmpl -0xa8(%rbp), %eax
jge 0x919c
movsd 0xa638(%rip), %xmm0     # 0x12e00
movsd %xmm0, -0xb8(%rbp)
movsd 0x9838(%rip), %xmm0     # 0x12010
movsd %xmm0, -0xc0(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0xac(%rbp), %eax
jge 0x88f9
movq -0x98(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0xf8(%rbp)
movq -0x18(%rbp), %rdi
movq -0xf8(%rbp), %rsi
callq 0x11520
movq -0x90(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd 0x97d7(%rip), %xmm0     # 0x12028
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x8894
movsd -0xb8(%rbp), %xmm0
movq -0x90(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
callq 0x7070
movsd %xmm0, -0xb8(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x88e9
movsd -0xc0(%rbp), %xmm0
movq -0x90(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq %xmm1, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
callq 0x5f30
movsd %xmm0, -0xc0(%rbp)
jmp 0x88eb
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x87e7
movsd -0xb8(%rbp), %xmm1
subsd -0xc0(%rbp), %xmm1
movsd -0x30(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x8940
movl -0xac(%rbp), %eax
cmpl -0x24(%rbp), %eax
jne 0x8924
jmp 0x919c
movl -0x24(%rbp), %eax
movl %eax, -0xac(%rbp)
leaq 0xa5b6(%rip), %rdi      # 0x12eea
movb $0x0, %al
callq 0x7120
jmp 0x87b1
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0xac(%rbp), %eax
jge 0x8a5c
movq -0x98(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x96a9(%rip), %xmm1     # 0x12028
ucomisd %xmm1, %xmm0
jne 0x89b8
jp 0x89b8
movq -0x90(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
ucomisd -0xb8(%rbp), %xmm0
ja 0x8a08
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8a4c
jp 0x8a4c
movq -0x90(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd -0xc0(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x8a4c
movl -0xac(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xac(%rbp)
movq -0x98(%rbp), %rdi
movslq -0x44(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x98(%rbp), %rsi
movslq -0xac(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rsi
callq 0x70b0
movl -0x44(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x8a4e
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x8947
movl -0xac(%rbp), %eax
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, %edi
movl $0x1, %esi
callq 0xc1a0
movl %eax, -0xa4(%rbp)
movl $0x0, -0xfc(%rbp)
movl $0x0, -0x100(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0xac(%rbp), %eax
jge 0x8ba4
movq -0x98(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0xe0(%rbp)
movq -0x90(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movsd %xmm0, -0xd8(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd 0x9526(%rip), %xmm0     # 0x12028
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x8b42
movq -0xc8(%rbp), %rax
movslq -0xfc(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0xe0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xd8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x8b94
movq -0xd0(%rbp), %rax
movslq -0x100(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq -0xe0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xd8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movl -0x100(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x100(%rbp)
jmp 0x8b96
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x8a97
movl -0xa4(%rbp), %eax
movl %eax, -0x154(%rbp)
movl -0xfc(%rbp), %edi
movl -0x100(%rbp), %esi
callq 0xac40
movl -0x154(%rbp), %edi
movl %eax, %esi
callq 0xac40
movl %eax, -0xa4(%rbp)
movq -0xc8(%rbp), %rdi
movl -0xfc(%rbp), %edx
subl $0x1, %edx
movl -0xfc(%rbp), %ecx
subl -0xa4(%rbp), %ecx
xorl %esi, %esi
callq 0x11280
movq -0xc8(%rbp), %rdi
movl -0xfc(%rbp), %eax
subl -0xa4(%rbp), %eax
cltq
shlq $0x4, %rax
addq %rax, %rdi
movslq -0xa4(%rbp), %rsi
movl $0x10, %edx
leaq 0x86da(%rip), %rcx      # 0x11300
callq 0x22b0
movq -0xd0(%rbp), %rdi
movl -0x100(%rbp), %edx
subl $0x1, %edx
movl -0xa4(%rbp), %ecx
xorl %esi, %esi
callq 0x11280
movq -0xd0(%rbp), %rdi
movslq -0xa4(%rbp), %rsi
movl $0x10, %edx
leaq 0x869e(%rip), %rcx      # 0x11300
callq 0x22b0
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0xa4(%rbp), %eax
jge 0x9170
movq -0xc8(%rbp), %rax
movl -0xfc(%rbp), %ecx
subl -0x44(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0xd0(%rbp), %rax
movslq -0x44(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %eax
movl %eax, -0x40(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8cee
jp 0x8cee
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x8cee
jp 0x8cee
jmp 0x8d2e
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x9322(%rip), %xmm1     # 0x12028
ucomisd %xmm1, %xmm0
jne 0x8d33
jp 0x8d33
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x9302(%rip), %xmm1     # 0x12028
ucomisd %xmm1, %xmm0
jne 0x8d33
jp 0x8d33
jmp 0x9162
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x108(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x110(%rbp)
movq -0x18(%rbp), %rdi
movq -0x108(%rbp), %rsi
callq 0x11520
movsd %xmm0, -0x50(%rbp)
movq -0x18(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x11520
movsd %xmm0, -0x58(%rbp)
movl $0x0, -0x114(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd 0x9280(%rip), %xmm0     # 0x12028
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x8e21
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x8e21
movsd -0x58(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x9e94(%rip), %xmm0     # 0x12c80
addsd %xmm0, %xmm1
movsd -0x50(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x8e21
movl $0x1, -0x114(%rbp)
jmp 0x8eaa
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x8ea8
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd 0x91db(%rip), %xmm0     # 0x12028
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x8ea8
movsd -0x50(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm1
movsd 0x9e08(%rip), %xmm0     # 0x12c80
addsd %xmm0, %xmm1
movsd -0x58(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x8ea8
movl $0x1, -0x114(%rbp)
jmp 0x8eaa
cmpl $0x0, -0x114(%rbp)
jne 0x8eb8
jmp 0x9162
movq -0x108(%rbp), %rdi
movq -0x110(%rbp), %rsi
callq 0x116a0
movsd %xmm0, -0x60(%rbp)
movq -0x88(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x88(%rbp), %rax
movslq -0x40(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd -0x60(%rbp), %xmm1
addsd %xmm1, %xmm1
subsd %xmm1, %xmm0
movsd %xmm0, -0x68(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x68(%rbp), %xmm0
jb 0x8f19
movsd 0x9d6c(%rip), %xmm0     # 0x12c80
movsd %xmm0, -0x68(%rbp)
movsd -0x50(%rbp), %xmm0
subsd -0x58(%rbp), %xmm0
divsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x80(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
addsd (%rax,%rcx,8), %xmm0
movsd %xmm0, -0x78(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
subsd -0x70(%rbp), %xmm0
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd -0x70(%rbp), %xmm0
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movsd -0x78(%rbp), %xmm0
movsd 0x906a(%rip), %xmm1     # 0x12028
ucomisd %xmm1, %xmm0
jbe 0x901d
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x904c(%rip), %xmm1     # 0x12028
ucomisd %xmm1, %xmm0
jbe 0x901b
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd 0x9033(%rip), %xmm0     # 0x12028
movsd %xmm0, (%rax,%rcx,8)
movsd -0x78(%rbp), %xmm0
movsd 0x9021(%rip), %xmm1     # 0x12028
subsd %xmm1, %xmm0
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x905c
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x905a
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movsd -0x78(%rbp), %xmm0
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x905c
movsd -0x78(%rbp), %xmm0
movsd 0x8fbf(%rip), %xmm1     # 0x12028
ucomisd %xmm1, %xmm0
jbe 0x90c8
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x8fa1(%rip), %xmm1     # 0x12028
ucomisd %xmm1, %xmm0
jbe 0x90c6
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd 0x8f88(%rip), %xmm0     # 0x12028
movsd %xmm0, (%rax,%rcx,8)
movsd -0x78(%rbp), %xmm0
movsd 0x8f76(%rip), %xmm1     # 0x12028
subsd %xmm1, %xmm0
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x9107
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
xorps %xmm0, %xmm0
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x9105
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
xorps %xmm0, %xmm0
movsd %xmm0, (%rax,%rcx,8)
movsd -0x78(%rbp), %xmm0
movq -0xa0(%rbp), %rax
movslq -0x40(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
jmp 0x9107
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
subsd -0x80(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
movq -0x108(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11590
movsd -0x70(%rbp), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
movq -0x110(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x11590
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x8c6e
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 0x9197
leaq 0x9d58(%rip), %rdi      # 0x12ee8
movb $0x0, %al
callq 0x7120
jmp 0x87b1
movl -0x48(%rbp), %esi
leaq 0x9d46(%rip), %rdi      # 0x12eec
movb $0x0, %al
callq 0x7120
movl -0x48(%rbp), %eax
cmpl -0xa8(%rbp), %eax
jl 0x91c6
leaq 0xa389(%rip), %rdi      # 0x13548
movb $0x0, %al
callq 0x7120
xorps %xmm0, %xmm0
movsd %xmm0, -0x120(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x921d
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq -0x18(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd -0x120(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x120(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x91d8
movl $0x0, -0x124(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x926b
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x925e
movl -0x124(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x124(%rbp)
jmp 0x9260
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x922e
movsd -0x120(%rbp), %xmm0
movsd 0x9b75(%rip), %xmm1     # 0x12df0
divsd %xmm1, %xmm0
leaq 0x9cb7(%rip), %rdi      # 0x12f3d
movb $0x1, %al
callq 0x7120
movl -0x124(%rbp), %esi
leaq 0x9cba(%rip), %rdi      # 0x12f54
movb $0x0, %al
callq 0x7120
xorps %xmm0, %xmm0
movsd %xmm0, -0x130(%rbp)
movsd 0x8d5c(%rip), %xmm0     # 0x12010
movsd %xmm0, -0x138(%rbp)
movsd 0x9b3c(%rip), %xmm0     # 0x12e00
movsd %xmm0, -0x140(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x148(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x93c6
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x3c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x11520
movsd %xmm0, -0x150(%rbp)
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movsd 0x8d05(%rip), %xmm1     # 0x12028
ucomisd %xmm1, %xmm0
jne 0x934a
jp 0x934a
movsd -0x140(%rbp), %xmm0
movsd -0x150(%rbp), %xmm1
callq 0x7070
movsd %xmm0, -0x140(%rbp)
jmp 0x93b6
movq -0xa0(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x9384
jp 0x9384
movsd -0x138(%rbp), %xmm0
movsd -0x150(%rbp), %xmm1
callq 0x5f30
movsd %xmm0, -0x138(%rbp)
jmp 0x93b4
movsd 0x8c9c(%rip), %xmm0     # 0x12028
addsd -0x130(%rbp), %xmm0
movsd %xmm0, -0x130(%rbp)
movsd -0x150(%rbp), %xmm0
addsd -0x148(%rbp), %xmm0
movsd %xmm0, -0x148(%rbp)
jmp 0x93b6
jmp 0x93b8
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x92de
movsd -0x130(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x93f1
movsd -0x148(%rbp), %xmm0
divsd -0x130(%rbp), %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
jmp 0x9415
movsd -0x138(%rbp), %xmm0
addsd -0x140(%rbp), %xmm0
movsd 0x99e7(%rip), %xmm1     # 0x12df0
divsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movsd %xmm0, (%rax)
movq -0x20(%rbp), %rax
movsd (%rax), %xmm0
leaq 0xa152(%rip), %rdi      # 0x13576
movb $0x1, %al
callq 0x7120
movq -0x88(%rbp), %rax
movq %rax, -0x160(%rbp)
cmpq $0x0, %rax
je 0x944b
movq -0x160(%rbp), %rdi
callq 0x21b0
movq -0x90(%rbp), %rax
movq %rax, -0x168(%rbp)
cmpq $0x0, %rax
je 0x946b
movq -0x168(%rbp), %rdi
callq 0x21b0
movq -0x98(%rbp), %rax
movq %rax, -0x170(%rbp)
cmpq $0x0, %rax
je 0x948b
movq -0x170(%rbp), %rdi
callq 0x21b0
movq -0xa0(%rbp), %rax
movq %rax, -0x178(%rbp)
cmpq $0x0, %rax
je 0x94ab
movq -0x178(%rbp), %rdi
callq 0x21b0
movq -0xc8(%rbp), %rax
movq %rax, -0x180(%rbp)
cmpq $0x0, %rax
je 0x94cb
movq -0x180(%rbp), %rdi
callq 0x21b0
movq -0xd0(%rbp), %rax
movq %rax, -0x188(%rbp)
cmpq $0x0, %rax
je 0x94eb
movq -0x188(%rbp), %rdi
callq 0x21b0
movl -0x48(%rbp), %eax
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
nopw (%rax,%rax)