// File: /workspace/github_cpp_makefile_star2_O3/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 %r9, %rbx
movapd %xmm0, %xmm9
movq %r8, %r14
movq 0x58(%rsp), %r8
movl 0x4(%rdx), %eax
movsd 0x8(%rdx), %xmm0
movsd 0x20(%rdx), %xmm1
imull 0x50(%rsp), %esi
movq $0x0, (%r8)
testl %esi, %esi
jle 0x1620b
movsd 0x30f1(%rip), %xmm2     # 0x19298
subsd %xmm1, %xmm2
mulsd 0x2f4d(%rip), %xmm1     # 0x19100
movl %esi, %edx
xorpd %xmm3, %xmm3
xorl %esi, %esi
movapd 0x2f5d(%rip), %xmm4     # 0x19120
xorl %ebp, %ebp
xorpd %xmm5, %xmm5
movsd (%rcx,%rsi,8), %xmm6
ucomisd %xmm3, %xmm6
jne 0x161d6
jnp 0x16201
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, (%r8)
incl %ebp
incq %rsi
cmpq %rsi, %rdx
jne 0x161c9
jmp 0x1620d
xorl %ebp, %ebp
xorpd %xmm8, %xmm8
cmpl $0x5, %eax
ja 0x16481
movl %eax, %eax
leaq 0x3260(%rip), %rcx      # 0x19484
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
testl %edi, %edi
jle 0x16481
movl %edi, %eax
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
movsd 0x3053(%rip), %xmm0     # 0x19298
movsd (%r14,%rcx,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 %rcx
movapd %xmm8, %xmm1
cmpq %rcx, %rax
jne 0x16245
jmp 0x16481
testl %edi, %edi
jle 0x16481
movsd 0x3004(%rip), %xmm1     # 0x19298
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movapd %xmm0, %xmm4
addsd %xmm0, %xmm4
movapd %xmm9, %xmm3
divsd %xmm4, %xmm3
mulsd 0x2e4b(%rip), %xmm0     # 0x19100
movl %edi, %eax
xorl %ecx, %ecx
movsd 0x2fdf(%rip), %xmm4     # 0x192a0
movsd (%r14,%rcx,8), %xmm5
ucomisd %xmm5, %xmm2
jbe 0x162e0
movapd %xmm1, %xmm6
subsd %xmm5, %xmm6
subsd %xmm0, %xmm6
mulsd %xmm9, %xmm6
jmp 0x162f6
ucomisd %xmm5, %xmm1
jbe 0x162fb
addsd %xmm4, %xmm5
movapd %xmm3, %xmm6
mulsd %xmm5, %xmm6
mulsd %xmm5, %xmm6
addsd %xmm6, %xmm8
incq %rcx
cmpq %rcx, %rax
jne 0x162c1
jmp 0x16481
testl %edi, %edi
jle 0x16481
movl %edi, %r15d
xorl %r12d, %r12d
movsd %xmm9, 0x8(%rsp)
movapd %xmm8, 0x10(%rsp)
movsd (%r14,%r12,8), %xmm0
xorpd 0x2dfe(%rip), %xmm0     # 0x19130
callq 0x3400
addsd 0x2f59(%rip), %xmm0     # 0x19298
callq 0x31a0
movapd 0x10(%rsp), %xmm8
movsd 0x8(%rsp), %xmm9
mulsd %xmm9, %xmm0
addsd %xmm0, %xmm8
incq %r12
cmpq %r12, %r15
jne 0x1631d
jmp 0x16481
testl %edi, %edi
jle 0x16481
movsd 0x2f1f(%rip), %xmm1     # 0x19298
movapd %xmm1, %xmm2
subsd %xmm0, %xmm2
movapd %xmm0, %xmm3
addsd %xmm1, %xmm3
movsd 0x2d4f(%rip), %xmm5     # 0x190e0
mulsd %xmm0, %xmm5
movapd %xmm9, %xmm4
divsd %xmm5, %xmm4
movl %edi, %eax
xorl %ecx, %ecx
movsd 0x2ef6(%rip), %xmm5     # 0x192a0
movsd (%r14,%rcx,8), %xmm6
ucomisd %xmm6, %xmm2
jbe 0x163c5
movapd %xmm1, %xmm7
subsd %xmm6, %xmm7
mulsd %xmm9, %xmm7
jmp 0x163df
ucomisd %xmm6, %xmm3
jbe 0x163e4
addsd %xmm5, %xmm6
subsd %xmm0, %xmm6
movapd %xmm4, %xmm7
mulsd %xmm6, %xmm7
mulsd %xmm6, %xmm7
addsd %xmm7, %xmm8
incq %rcx
cmpq %rcx, %rax
jne 0x163aa
jmp 0x16481
testl %edi, %edi
jle 0x16481
movl %edi, %eax
xorpd %xmm1, %xmm1
xorl %ecx, %ecx
movsd 0x2e8f(%rip), %xmm0     # 0x19298
movsd (%r14,%rcx,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 %rcx
movapd %xmm8, %xmm1
cmpq %rcx, %rax
jne 0x16409
jmp 0x16481
testl %edi, %edi
jle 0x16481
movl %edi, %eax
xorl %ecx, %ecx
movsd 0x2e3b(%rip), %xmm0     # 0x19298
movapd %xmm0, %xmm1
subsd (%r14,%rcx,8), %xmm1
movapd %xmm1, %xmm2
mulsd %xmm9, %xmm2
mulsd %xmm1, %xmm2
addsd %xmm2, %xmm8
incq %rcx
cmpq %rcx, %rax
jne 0x1645d
movl %ebp, (%rbx)
movapd %xmm8, %xmm0
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop