// File: /workspace/github_cpp_makefile_star2_O1/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
movl 0x4(%rsi), %eax
movslq 0x4(%rdi), %rcx
testq %rcx, %rcx
jle 0x141ff
movsd 0x20(%rsi), %xmm0
movsd 0x30c6(%rip), %xmm1     # 0x17268
subsd %xmm0, %xmm1
mulsd 0x2f22(%rip), %xmm0     # 0x170d0
xorpd %xmm2, %xmm2
xorl %r8d, %r8d
movapd 0x2f33(%rip), %xmm3     # 0x170f0
xorl %ebp, %ebp
xorpd %xmm8, %xmm8
movsd (%rdx,%r8,8), %xmm4
ucomisd %xmm2, %xmm4
jne 0x141d2
jnp 0x141f5
movapd %xmm4, %xmm5
andpd %xmm3, %xmm5
movapd %xmm0, %xmm6
mulsd %xmm4, %xmm6
mulsd %xmm4, %xmm6
mulsd %xmm1, %xmm5
addsd %xmm6, %xmm5
addsd %xmm5, %xmm8
incl %ebp
incq %r8
cmpq %r8, %rcx
jne 0x141c4
jmp 0x14206
xorl %ebp, %ebp
xorpd %xmm8, %xmm8
cmpl $0x5, %eax
ja 0x14465
movl (%rdi), %r13d
movsd 0x8(%rsi), %xmm0
movl %eax, %eax
leaq 0x31d8(%rip), %rcx      # 0x173f8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r13d, %r13d
jle 0x14465
xorl %eax, %eax
movsd 0x302c(%rip), %xmm0     # 0x17268
movsd (%r15,%rax,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x14260
movsbq (%r14,%rax), %rcx
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
mulsd 0x8(%rbx,%rcx,8), %xmm2
addsd %xmm2, %xmm8
incq %rax
cmpq %rax, %r13
jne 0x1423c
jmp 0x14465
testl %r13d, %r13d
jle 0x14465
movsd 0x2fea(%rip), %xmm1     # 0x17268
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movapd %xmm0, %xmm3
addsd %xmm0, %xmm3
mulsd 0x2e3a(%rip), %xmm0     # 0x170d0
xorl %eax, %eax
movsd 0x2fd0(%rip), %xmm4     # 0x17270
movsd (%r15,%rax,8), %xmm5
ucomisd %xmm5, %xmm2
jbe 0x142c5
movsbq (%r14,%rax), %rcx
movapd %xmm1, %xmm6
subsd %xmm5, %xmm6
subsd %xmm0, %xmm6
mulsd 0x8(%rbx,%rcx,8), %xmm6
jmp 0x142e6
ucomisd %xmm5, %xmm1
jbe 0x142eb
movsbq (%r14,%rax), %rcx
movsd 0x8(%rbx,%rcx,8), %xmm6
divsd %xmm3, %xmm6
addsd %xmm4, %xmm5
mulsd %xmm5, %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm8
incq %rax
cmpq %rax, %r13
jne 0x142a0
jmp 0x14465
testl %r13d, %r13d
jle 0x14465
xorl %r12d, %r12d
movsd %xmm8, 0x10(%rsp)
movsbq (%r14,%r12), %rax
movsd 0x8(%rbx,%rax,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd (%r15,%r12,8), %xmm0
xorpd 0x2dd6(%rip), %xmm0     # 0x17100
callq 0x33f0
addsd 0x2f31(%rip), %xmm0     # 0x17268
callq 0x3190
movsd 0x10(%rsp), %xmm8
mulsd 0x8(%rsp), %xmm0
addsd %xmm0, %xmm8
incq %r12
cmpq %r12, %r13
jne 0x14304
jmp 0x14465
testl %r13d, %r13d
jle 0x14465
movsd 0x2efc(%rip), %xmm1     # 0x17268
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movapd %xmm0, %xmm3
addsd %xmm1, %xmm3
movsd 0x2d2c(%rip), %xmm4     # 0x170b0
mulsd %xmm0, %xmm4
xorl %eax, %eax
movsd 0x2ede(%rip), %xmm5     # 0x17270
movsd (%r15,%rax,8), %xmm6
ucomisd %xmm6, %xmm2
jbe 0x143b3
movsbq (%r14,%rax), %rcx
movapd %xmm1, %xmm7
subsd %xmm6, %xmm7
mulsd 0x8(%rbx,%rcx,8), %xmm7
jmp 0x143d8
ucomisd %xmm6, %xmm3
jbe 0x143dd
movsbq (%r14,%rax), %rcx
movsd 0x8(%rbx,%rcx,8), %xmm7
divsd %xmm4, %xmm7
addsd %xmm5, %xmm6
subsd %xmm0, %xmm6
mulsd %xmm6, %xmm7
mulsd %xmm6, %xmm7
addsd %xmm7, %xmm8
incq %rax
cmpq %rax, %r13
jne 0x14392
jmp 0x14465
testl %r13d, %r13d
jle 0x14465
xorl %eax, %eax
movsd 0x2e72(%rip), %xmm0     # 0x17268
movsd (%r15,%rax,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x14422
movsbq (%r14,%rax), %rcx
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd 0x8(%rbx,%rcx,8), %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm8
incq %rax
cmpq %rax, %r13
jne 0x143f6
jmp 0x14465
testl %r13d, %r13d
jle 0x14465
xorl %eax, %eax
movsd 0x2e2d(%rip), %xmm0     # 0x17268
movsbq (%r14,%rax), %rcx
movapd %xmm0, %xmm1
subsd (%r15,%rax,8), %xmm1
movsd 0x8(%rbx,%rcx,8), %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm8
incq %rax
cmpq %rax, %r13
jne 0x1443b
movq 0x50(%rsp), %rax
movl %ebp, (%rax)
movapd %xmm8, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq