// File: /workspace/github_cpp_makefile_star2_O2/qmmlib[P]QmmLibrary/linear.cpp
// Function: mmcd_obj(problem const*, parameter const*, double*, double*, signed char*, double*, int*)
static double mmcd_obj(const problem *prob_col,const parameter *param,double *w, double *z, schar *y, double *C, int *nnzp) {

	loss_var loss_type = param->loss_type;
	double loss_param = param->loss_param;
	double reg_param = param->reg_param;
	int l = prob_col->l;  // N in paper
	int w_size = prob_col->n;  // M in paper

	double v = 0;
	int nnz = 0;
	int j;

	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 += (1-reg_param)*fabs(w[j]) + reg_param * 0.5 *w[j]*w[j];
			nnz++;
		}
	}
	if (loss_type == L2) {
		for(j=0; j<l; j++)
			if(z[j] < 1)
				v += C[GETI(j)]*(1-z[j])*(1-z[j]);
	} else if (loss_type == L1) {
		for(j=0; j<l; j++)
			if(z[j] < 1)
				v += C[GETI(j)]*(1-z[j]);
	} else if (loss_type == HU1) {
		for(j=0; j<l; j++)
			if(z[j] < 1-loss_param)
				v += C[GETI(j)]*(1-z[j]);
			else if (z[j] < 1 + loss_param)
				v += C[GETI(j)]*1/(4*loss_param)*(z[j]-1-loss_param)*(z[j]-1-loss_param);
	} else if (loss_type == HU2) {
		for(j=0; j<l; j++)
			if(z[j] < 1-loss_param)
				v += C[GETI(j)]*(1-z[j]-loss_param/2);
			else if (z[j] < 1)
				v += C[GETI(j)]*1/(2*loss_param)*(z[j]-1)*(z[j]-1);
	} else if (loss_type == LOG) {
		for(j=0; j<l; j++)
			v += C[GETI(j)]*log(1+exp(-z[j]));
	} else if (loss_type == LS) {
		for(j=0; j<l; j++)
			v += C[GETI(j)]*(1-z[j])*(1-z[j]);
	}
	*nnzp = nnz;
	return v;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, %r14
movq %rcx, %r15
movq 0x50(%rsp), %r8
movl 0x4(%rsi), %eax
movsd 0x8(%rsi), %xmm8
movsd 0x20(%rsi), %xmm1
movl (%rdi), %r13d
movl 0x4(%rdi), %ecx
movsd 0x338d(%rip), %xmm9     # 0x16298
movapd %xmm9, %xmm2
subsd %xmm1, %xmm2
mulsd 0x31e4(%rip), %xmm1     # 0x16100
xorl %esi, %esi
testl %ecx, %ecx
cmovlel %esi, %ecx
xorpd %xmm3, %xmm3
movapd 0x31f1(%rip), %xmm4     # 0x16120
xorpd %xmm0, %xmm0
xorl %ebp, %ebp
cmpq %rsi, %rcx
je 0x12f6e
movsd (%rdx,%rsi,8), %xmm5
ucomisd %xmm3, %xmm5
jne 0x12f47
jnp 0x12f69
movapd %xmm5, %xmm6
andpd %xmm4, %xmm6
movapd %xmm1, %xmm7
mulsd %xmm5, %xmm7
mulsd %xmm5, %xmm7
mulsd %xmm2, %xmm6
addsd %xmm7, %xmm6
addsd %xmm6, %xmm0
incl %ebp
incq %rsi
jmp 0x12f35
cmpl $0x5, %eax
ja 0x130ba
movl %eax, %eax
leaq 0x34b8(%rip), %rcx      # 0x16438
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
cmpq %rax, %r13
je 0x130ba
movsd (%r15,%rax,8), %xmm2
ucomisd %xmm2, %xmm9
jbe 0x12fc0
movsbq (%r14,%rax), %rcx
movapd %xmm9, %xmm1
subsd %xmm2, %xmm1
mulsd 0x8(%rbx,%rcx,8), %xmm1
addsd %xmm1, %xmm0
incq %rax
jmp 0x12f92
movapd %xmm9, %xmm1
subsd %xmm8, %xmm1
movapd %xmm8, %xmm2
addsd %xmm8, %xmm2
mulsd 0x311e(%rip), %xmm8     # 0x16100
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
movsd 0x32ad(%rip), %xmm3     # 0x162a0
cmpq %rax, %r13
je 0x130ba
movsd (%r15,%rax,8), %xmm4
ucomisd %xmm4, %xmm1
jbe 0x13023
movsbq (%r14,%rax), %rcx
movapd %xmm9, %xmm5
subsd %xmm4, %xmm5
subsd %xmm8, %xmm5
mulsd 0x8(%rbx,%rcx,8), %xmm5
jmp 0x13045
ucomisd %xmm4, %xmm9
jbe 0x13049
movsbq (%r14,%rax), %rcx
movsd 0x8(%rbx,%rcx,8), %xmm5
divsd %xmm2, %xmm5
addsd %xmm3, %xmm4
mulsd %xmm4, %xmm5
mulsd %xmm4, %xmm5
addsd %xmm5, %xmm0
incq %rax
jmp 0x12ff3
movsd %xmm0, 0x8(%rsp)
xorl %r12d, %r12d
testl %r13d, %r13d
cmovlel %r12d, %r13d
cmpq %r12, %r13
je 0x130af
movsbq (%r14,%r12), %rax
movsd 0x8(%rbx,%rax,8), %xmm0
movsd %xmm0, 0x10(%rsp)
movsd (%r15,%r12,8), %xmm0
xorpd 0x30ae(%rip), %xmm0     # 0x16130
callq 0x3440
addsd 0x3209(%rip), %xmm0     # 0x16298
callq 0x31b0
mulsd 0x10(%rsp), %xmm0
movsd 0x8(%rsp), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, 0x8(%rsp)
incq %r12
jmp 0x1305e
movq 0x50(%rsp), %r8
movsd 0x8(%rsp), %xmm0
movl %ebp, (%r8)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movapd %xmm9, %xmm1
subsd %xmm8, %xmm1
movapd %xmm8, %xmm2
addsd %xmm9, %xmm2
movsd 0x2ff8(%rip), %xmm3     # 0x160e0
mulsd %xmm8, %xmm3
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
movsd 0x31a2(%rip), %xmm4     # 0x162a0
cmpq %rax, %r13
je 0x130ba
movsd (%r15,%rax,8), %xmm5
ucomisd %xmm5, %xmm1
jbe 0x13125
movsbq (%r14,%rax), %rcx
movapd %xmm9, %xmm6
subsd %xmm5, %xmm6
mulsd 0x8(%rbx,%rcx,8), %xmm6
jmp 0x1314b
ucomisd %xmm5, %xmm2
jbe 0x1314f
movsbq (%r14,%rax), %rcx
movsd 0x8(%rbx,%rcx,8), %xmm6
divsd %xmm3, %xmm6
addsd %xmm4, %xmm5
subsd %xmm8, %xmm5
mulsd %xmm5, %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm0
incq %rax
jmp 0x130fe
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
cmpq %rax, %r13
je 0x130ba
movsd (%r15,%rax,8), %xmm2
ucomisd %xmm2, %xmm9
jbe 0x13193
movsbq (%r14,%rax), %rcx
movapd %xmm9, %xmm1
subsd %xmm2, %xmm1
movsd 0x8(%rbx,%rcx,8), %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm0
incq %rax
jmp 0x1315d
xorl %eax, %eax
testl %r13d, %r13d
cmovlel %eax, %r13d
cmpq %rax, %r13
je 0x130ba
movsbq (%r14,%rax), %rcx
movapd %xmm9, %xmm2
subsd (%r15,%rax,8), %xmm2
movsd 0x8(%rbx,%rcx,8), %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm0
incq %rax
jmp 0x131a1