// File: /workspace/github_cpp_makefile_star2_O1/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
movapd %xmm0, %xmm9
movq %rcx, %r14
movq 0x50(%rsp), %rcx
movl 0x4(%rsi), %eax
movsd 0x8(%rsi), %xmm0
movsd 0x20(%rsi), %xmm1
movl (%rdi), %r15d
imull 0x4(%rdi), %r9d
movq $0x0, (%rcx)
testl %r9d, %r9d
jle 0x14529
movsd (%rcx), %xmm2
movsd 0x2d9f(%rip), %xmm3     # 0x17268
subsd %xmm1, %xmm3
mulsd 0x2bfb(%rip), %xmm1     # 0x170d0
movl %r9d, %esi
xorl %edi, %edi
xorpd %xmm4, %xmm4
movapd 0x2c0a(%rip), %xmm5     # 0x170f0
xorl %ebp, %ebp
movsd (%rdx,%rdi,8), %xmm6
ucomisd %xmm4, %xmm6
jne 0x144f5
jnp 0x1451f
movapd %xmm6, %xmm7
andpd %xmm5, %xmm7
movapd %xmm1, %xmm8
mulsd %xmm6, %xmm8
mulsd %xmm6, %xmm8
mulsd %xmm3, %xmm7
addsd %xmm8, %xmm7
addsd %xmm7, %xmm2
movsd %xmm2, (%rcx)
incl %ebp
incq %rdi
cmpq %rdi, %rsi
jne 0x144e8
jmp 0x1452b
xorl %ebp, %ebp
xorpd %xmm8, %xmm8
cmpl $0x5, %eax
ja 0x14798
movl %eax, %eax
leaq 0x2ece(%rip), %rcx      # 0x17410
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %r15d, %r15d
jle 0x14798
xorpd %xmm1, %xmm1
xorl %eax, %eax
movsd 0x2d06(%rip), %xmm0     # 0x17268
movsd (%r14,%rax,8), %xmm8
movapd %xmm0, %xmm2
subsd %xmm8, %xmm2
mulsd %xmm9, %xmm2
addsd %xmm1, %xmm2
cmpltsd %xmm0, %xmm8
andpd %xmm8, %xmm2
andnpd %xmm1, %xmm8
orpd %xmm2, %xmm8
incq %rax
movapd %xmm8, %xmm1
cmpq %rax, %r15
jne 0x14562
jmp 0x14798
testl %r15d, %r15d
jle 0x14798
movsd 0x2cb6(%rip), %xmm1     # 0x17268
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movapd %xmm0, %xmm4
addsd %xmm0, %xmm4
movapd %xmm9, %xmm3
mulsd 0x2b01(%rip), %xmm0     # 0x170d0
divsd %xmm4, %xmm3
xorl %eax, %eax
movsd 0x2c93(%rip), %xmm4     # 0x17270
movsd (%r14,%rax,8), %xmm5
ucomisd %xmm5, %xmm2
jbe 0x145fc
movapd %xmm1, %xmm6
subsd %xmm5, %xmm6
subsd %xmm0, %xmm6
mulsd %xmm9, %xmm6
jmp 0x14612
ucomisd %xmm5, %xmm1
jbe 0x14617
addsd %xmm4, %xmm5
movapd %xmm3, %xmm6
mulsd %xmm5, %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm8
incq %rax
cmpq %rax, %r15
jne 0x145dd
jmp 0x14798
testl %r15d, %r15d
jle 0x14798
xorl %r12d, %r12d
movsd %xmm9, 0x8(%rsp)
movapd %xmm8, 0x10(%rsp)
movsd (%r14,%r12,8), %xmm0
xorpd 0x2ab4(%rip), %xmm0     # 0x17100
callq 0x33f0
addsd 0x2c0f(%rip), %xmm0     # 0x17268
callq 0x3190
movapd 0x10(%rsp), %xmm8
movsd 0x8(%rsp), %xmm9
mulsd %xmm9, %xmm0
addsd %xmm0, %xmm8
incq %r12
cmpq %r12, %r15
jne 0x14637
jmp 0x14798
testl %r15d, %r15d
jle 0x14798
movsd 0x2bd4(%rip), %xmm1     # 0x17268
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movapd %xmm0, %xmm3
addsd %xmm1, %xmm3
movsd 0x2a04(%rip), %xmm5     # 0x170b0
mulsd %xmm0, %xmm5
movapd %xmm9, %xmm4
divsd %xmm5, %xmm4
xorl %eax, %eax
movsd 0x2bad(%rip), %xmm5     # 0x17270
movsd (%r14,%rax,8), %xmm6
ucomisd %xmm6, %xmm2
jbe 0x146de
movapd %xmm1, %xmm7
subsd %xmm6, %xmm7
mulsd %xmm9, %xmm7
jmp 0x146f8
ucomisd %xmm6, %xmm3
jbe 0x146fd
addsd %xmm5, %xmm6
subsd %xmm0, %xmm6
movapd %xmm4, %xmm7
mulsd %xmm6, %xmm7
mulsd %xmm6, %xmm7
addsd %xmm7, %xmm8
incq %rax
cmpq %rax, %r15
jne 0x146c3
jmp 0x14798
testl %r15d, %r15d
jle 0x14798
xorpd %xmm1, %xmm1
xorl %eax, %eax
movsd 0x2b47(%rip), %xmm0     # 0x17268
movsd (%r14,%rax,8), %xmm8
movapd %xmm0, %xmm2
subsd %xmm8, %xmm2
movapd %xmm2, %xmm3
mulsd %xmm9, %xmm3
mulsd %xmm2, %xmm3
addsd %xmm1, %xmm3
cmpltsd %xmm0, %xmm8
andpd %xmm8, %xmm3
andnpd %xmm1, %xmm8
orpd %xmm3, %xmm8
incq %rax
movapd %xmm8, %xmm1
cmpq %rax, %r15
jne 0x14721
jmp 0x14798
testl %r15d, %r15d
jle 0x14798
xorl %eax, %eax
movsd 0x2af4(%rip), %xmm0     # 0x17268
movapd %xmm0, %xmm1
subsd (%r14,%rax,8), %xmm1
movapd %xmm1, %xmm2
mulsd %xmm9, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm8
incq %rax
cmpq %rax, %r15
jne 0x14774
movl %ebp, (%rbx)
movapd %xmm8, %xmm0
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq