// File: /workspace/github_cpp_makefile_star2_O2/qmmlib[P]QmmLibrary/linear.cpp
// Function: mmcd_sm_obj(problem*, parameter const*, double*, double*, double, int*, int, double&)
static double mmcd_sm_obj(problem *prob_col,const parameter *param,double *w, double *z,  double C, int *nnzp, int num_class, double &reg_value) {

	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*num_class;  // M in paper

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

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq 0x50(%rsp), %rcx
movl 0x4(%rsi), %eax
movsd 0x8(%rsi), %xmm9
movsd 0x20(%rsi), %xmm1
movl (%rdi), %r15d
imull 0x4(%rdi), %r9d
andq $0x0, (%rcx)
movsd 0x304e(%rip), %xmm10    # 0x16298
movapd %xmm10, %xmm2
subsd %xmm1, %xmm2
mulsd 0x2ea5(%rip), %xmm1     # 0x16100
xorl %esi, %esi
testl %r9d, %r9d
cmovlel %esi, %r9d
xorpd %xmm3, %xmm3
movapd 0x2eb0(%rip), %xmm4     # 0x16120
xorpd %xmm5, %xmm5
xorl %ebp, %ebp
cmpq %rsi, %r9
je 0x132b7
movsd (%rdx,%rsi,8), %xmm6
ucomisd %xmm3, %xmm6
jne 0x13288
jnp 0x132b2
movapd %xmm6, %xmm7
andpd %xmm4, %xmm7
movapd %xmm1, %xmm8
mulsd %xmm6, %xmm8
mulsd %xmm6, %xmm8
mulsd %xmm2, %xmm7
addsd %xmm8, %xmm7
addsd %xmm7, %xmm5
movsd %xmm5, (%rcx)
incl %ebp
incq %rsi
jmp 0x13276
cmpl $0x5, %eax
ja 0x134f9
movl %eax, %eax
leaq 0x3187(%rip), %rcx      # 0x16450
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
xorpd %xmm7, %xmm7
cmpq %rax, %r15
je 0x134fd
movsd (%r14,%rax,8), %xmm2
movapd %xmm10, %xmm1
subsd %xmm2, %xmm1
mulsd %xmm0, %xmm1
addsd %xmm7, %xmm1
cmpltsd %xmm10, %xmm2
andpd %xmm2, %xmm1
andnpd %xmm7, %xmm2
orpd %xmm1, %xmm2
incq %rax
movapd %xmm2, %xmm7
jmp 0x132df
movapd %xmm10, %xmm1
subsd %xmm9, %xmm1
movapd %xmm9, %xmm3
addsd %xmm9, %xmm3
movapd %xmm0, %xmm2
divsd %xmm3, %xmm2
mulsd 0x2dc1(%rip), %xmm9     # 0x16100
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
xorpd %xmm7, %xmm7
movsd 0x2f4c(%rip), %xmm3     # 0x162a0
cmpq %rax, %r15
je 0x134fd
movsd (%r14,%rax,8), %xmm4
ucomisd %xmm4, %xmm1
jbe 0x1337d
movapd %xmm10, %xmm5
subsd %xmm4, %xmm5
subsd %xmm9, %xmm5
mulsd %xmm0, %xmm5
jmp 0x13394
ucomisd %xmm4, %xmm10
jbe 0x13398
addsd %xmm3, %xmm4
movapd %xmm2, %xmm5
mulsd %xmm4, %xmm5
mulsd %xmm4, %xmm5
addsd %xmm5, %xmm7
incq %rax
jmp 0x13354
movsd %xmm0, 0x8(%rsp)
xorl %r12d, %r12d
testl %r15d, %r15d
cmovlel %r12d, %r15d
xorpd %xmm7, %xmm7
cmpq %r12, %r15
je 0x134fd
movsd (%r14,%r12,8), %xmm0
xorpd 0x2d68(%rip), %xmm0     # 0x16130
movapd %xmm7, 0x10(%rsp)
callq 0x3440
addsd 0x2ebd(%rip), %xmm0     # 0x16298
callq 0x31b0
movapd 0x10(%rsp), %xmm7
mulsd 0x8(%rsp), %xmm0
addsd %xmm0, %xmm7
incq %r12
jmp 0x133b1
movapd %xmm10, %xmm1
subsd %xmm9, %xmm1
movapd %xmm9, %xmm2
addsd %xmm10, %xmm2
movsd 0x2ccf(%rip), %xmm4     # 0x160e0
mulsd %xmm9, %xmm4
movapd %xmm0, %xmm3
divsd %xmm4, %xmm3
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
xorpd %xmm7, %xmm7
movsd 0x2e6d(%rip), %xmm4     # 0x162a0
cmpq %rax, %r15
je 0x134fd
movsd (%r14,%rax,8), %xmm5
ucomisd %xmm5, %xmm1
jbe 0x13457
movapd %xmm10, %xmm6
subsd %xmm5, %xmm6
mulsd %xmm0, %xmm6
jmp 0x13472
ucomisd %xmm5, %xmm2
jbe 0x13476
addsd %xmm4, %xmm5
subsd %xmm9, %xmm5
movapd %xmm3, %xmm6
mulsd %xmm5, %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm7
incq %rax
jmp 0x13433
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
xorpd %xmm7, %xmm7
cmpq %rax, %r15
je 0x134fd
movsd (%r14,%rax,8), %xmm3
movapd %xmm10, %xmm1
subsd %xmm3, %xmm1
movapd %xmm1, %xmm2
mulsd %xmm0, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm7, %xmm2
cmpltsd %xmm10, %xmm3
andpd %xmm3, %xmm2
andnpd %xmm7, %xmm3
orpd %xmm2, %xmm3
incq %rax
movapd %xmm3, %xmm7
jmp 0x13488
xorl %eax, %eax
testl %r15d, %r15d
cmovlel %eax, %r15d
xorpd %xmm7, %xmm7
cmpq %rax, %r15
je 0x134fd
movapd %xmm10, %xmm2
subsd (%r14,%rax,8), %xmm2
movapd %xmm2, %xmm1
mulsd %xmm0, %xmm1
mulsd %xmm2, %xmm1
addsd %xmm1, %xmm7
incq %rax
jmp 0x134d4
xorpd %xmm7, %xmm7
movl %ebp, (%rbx)
movapd %xmm7, %xmm0
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq