// File: /workspace/github_cpp_makefile_star2_O3/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
movl 0x4(%rdx), %eax
testl %esi, %esi
jle 0x15ed1
movsd 0x20(%rdx), %xmm0
movsd 0x3426(%rip), %xmm1     # 0x19298
subsd %xmm0, %xmm1
mulsd 0x3282(%rip), %xmm0     # 0x19100
movl %esi, %esi
xorpd %xmm2, %xmm2
xorl %r8d, %r8d
movapd 0x3291(%rip), %xmm3     # 0x19120
xorl %ebp, %ebp
xorpd %xmm8, %xmm8
movsd (%rcx,%r8,8), %xmm4
ucomisd %xmm2, %xmm4
jne 0x15ea4
jnp 0x15ec7
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, %rsi
jne 0x15e96
jmp 0x15ed8
xorl %ebp, %ebp
xorpd %xmm8, %xmm8
cmpl $0x5, %eax
ja 0x1614b
movq 0x50(%rsp), %r12
movsd 0x8(%rdx), %xmm0
movl %eax, %eax
leaq 0x3578(%rip), %rcx      # 0x1946c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %edi, %edi
jle 0x1614b
movl %edi, %eax
xorl %ecx, %ecx
movsd 0x3387(%rip), %xmm0     # 0x19298
movsd (%r14,%rcx,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x15f36
movsbq (%rbx,%rcx), %rdx
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
mulsd 0x8(%r12,%rdx,8), %xmm2
addsd %xmm2, %xmm8
incq %rcx
cmpq %rcx, %rax
jne 0x15f11
jmp 0x1614b
testl %edi, %edi
jle 0x1614b
movsd 0x3345(%rip), %xmm1     # 0x19298
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movapd %xmm0, %xmm3
mulsd 0x3199(%rip), %xmm0     # 0x19100
addsd %xmm3, %xmm3
movl %edi, %eax
xorl %ecx, %ecx
movsd 0x3329(%rip), %xmm4     # 0x192a0
movsd (%r14,%rcx,8), %xmm5
ucomisd %xmm5, %xmm2
jbe 0x15f9d
movsbq (%rbx,%rcx), %rdx
movapd %xmm1, %xmm6
subsd %xmm5, %xmm6
subsd %xmm0, %xmm6
mulsd 0x8(%r12,%rdx,8), %xmm6
jmp 0x15fbf
ucomisd %xmm5, %xmm1
jbe 0x15fc4
movsbq (%rbx,%rcx), %rdx
movsd 0x8(%r12,%rdx,8), %xmm6
divsd %xmm3, %xmm6
addsd %xmm4, %xmm5
mulsd %xmm5, %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm8
incq %rcx
cmpq %rcx, %rax
jne 0x15f77
jmp 0x1614b
testl %edi, %edi
jle 0x1614b
movl %edi, %r13d
xorl %r15d, %r15d
movsd %xmm8, 0x10(%rsp)
movsbq (%rbx,%r15), %rax
movsd 0x8(%r12,%rax,8), %xmm0
movsd %xmm0, 0x8(%rsp)
movsd (%r14,%r15,8), %xmm0
xorpd 0x312a(%rip), %xmm0     # 0x19130
callq 0x3400
addsd 0x3285(%rip), %xmm0     # 0x19298
callq 0x31a0
movsd 0x10(%rsp), %xmm8
mulsd 0x8(%rsp), %xmm0
addsd %xmm0, %xmm8
incq %r15
cmpq %r15, %r13
jne 0x15fdf
jmp 0x1614b
testl %edi, %edi
jle 0x1614b
movsd 0x3251(%rip), %xmm1     # 0x19298
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movapd %xmm0, %xmm3
addsd %xmm1, %xmm3
movsd 0x3081(%rip), %xmm4     # 0x190e0
mulsd %xmm0, %xmm4
movl %edi, %eax
xorl %ecx, %ecx
movsd 0x3231(%rip), %xmm5     # 0x192a0
movsd (%r14,%rcx,8), %xmm6
ucomisd %xmm6, %xmm2
jbe 0x16091
movsbq (%rbx,%rcx), %rdx
movapd %xmm1, %xmm7
subsd %xmm6, %xmm7
mulsd 0x8(%r12,%rdx,8), %xmm7
jmp 0x160b7
ucomisd %xmm6, %xmm3
jbe 0x160bc
movsbq (%rbx,%rcx), %rdx
movsd 0x8(%r12,%rdx,8), %xmm7
divsd %xmm4, %xmm7
addsd %xmm5, %xmm6
subsd %xmm0, %xmm6
mulsd %xmm6, %xmm7
mulsd %xmm6, %xmm7
addsd %xmm7, %xmm8
incq %rcx
cmpq %rcx, %rax
jne 0x1606f
jmp 0x1614b
testl %edi, %edi
jle 0x1614b
movl %edi, %eax
xorl %ecx, %ecx
movsd 0x31bf(%rip), %xmm0     # 0x19298
movsd (%r14,%rcx,8), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x16106
movsbq (%rbx,%rcx), %rdx
movapd %xmm0, %xmm2
subsd %xmm1, %xmm2
movsd 0x8(%r12,%rdx,8), %xmm1
mulsd %xmm2, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm8
incq %rcx
cmpq %rcx, %rax
jne 0x160d9
jmp 0x1614b
testl %edi, %edi
jle 0x1614b
movl %edi, %eax
xorl %ecx, %ecx
movsd 0x3178(%rip), %xmm0     # 0x19298
movsbq (%rbx,%rcx), %rdx
movapd %xmm0, %xmm1
subsd (%r14,%rcx,8), %xmm1
movsd 0x8(%r12,%rdx,8), %xmm2
mulsd %xmm1, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm8
incq %rcx
cmpq %rcx, %rax
jne 0x16120
movq 0x58(%rsp), %rax
movl %ebp, (%rax)
movapd %xmm8, %xmm0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq