// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movsd %xmm0, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm0
movsd %xmm0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movsd 0x20(%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
imull -0x34(%rbp), %eax
movl %eax, -0x50(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x58(%rbp)
movq 0x10(%rbp), %rax
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl $0x0, -0x5c(%rbp)
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x50(%rbp), %eax
jge 0x1f696
movq -0x18(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x1f61d
jp 0x1f61d
jmp 0x1f686
movsd 0x4a03(%rip), %xmm0     # 0x24028
subsd -0x48(%rbp), %xmm0
movq -0x18(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movaps 0x5ae2(%rip), %xmm1     # 0x25120
pand %xmm1, %xmm2
movsd 0x49d6(%rip), %xmm1     # 0x24020
mulsd -0x48(%rbp), %xmm1
movq -0x18(%rbp), %rax
movslq -0x60(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
movq -0x18(%rbp), %rax
movslq -0x60(%rbp), %rcx
mulsd (%rax,%rcx,8), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movq 0x10(%rbp), %rax
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x1f688
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1f5f7
cmpl $0x1, -0x38(%rbp)
jne 0x1f719
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1f714
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x496d(%rip), %xmm0     # 0x24028
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x1f707
movsd -0x28(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x4951(%rip), %xmm1     # 0x24028
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x4938(%rip), %xmm2     # 0x24028
subsd (%rax,%rcx,8), %xmm2
movsd -0x58(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1f709
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1f6a3
jmp 0x1faa0
cmpl $0x0, -0x38(%rbp)
jne 0x1f783
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1f77e
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x48ea(%rip), %xmm0     # 0x24028
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x1f771
movsd -0x28(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x48ce(%rip), %xmm2     # 0x24028
subsd (%rax,%rcx,8), %xmm2
movsd -0x58(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1f773
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1f726
jmp 0x1fa9e
cmpl $0x3, -0x38(%rbp)
jne 0x1f898
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1f893
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd 0x4873(%rip), %xmm0     # 0x24028
subsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f7f1
movsd -0x28(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x4853(%rip), %xmm2     # 0x24028
subsd (%rax,%rcx,8), %xmm2
movsd -0x58(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1f883
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd 0x4822(%rip), %xmm0     # 0x24028
addsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f881
movsd 0x480f(%rip), %xmm0     # 0x24028
mulsd -0x28(%rbp), %xmm0
movsd 0x58ba(%rip), %xmm1     # 0x250e0
mulsd -0x40(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd 0x47e4(%rip), %xmm2     # 0x24028
subsd %xmm2, %xmm1
subsd -0x40(%rbp), %xmm1
mulsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x47c2(%rip), %xmm1     # 0x24028
subsd %xmm1, %xmm2
subsd -0x40(%rbp), %xmm2
movsd -0x58(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1f883
jmp 0x1f885
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1f794
jmp 0x1fa9c
cmpl $0x4, -0x38(%rbp)
jne 0x1f9ac
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1f9a7
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd 0x475e(%rip), %xmm0     # 0x24028
subsd -0x40(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1f918
movsd -0x28(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x473e(%rip), %xmm2     # 0x24028
subsd (%rax,%rcx,8), %xmm2
movsd -0x40(%rbp), %xmm1
movsd 0x598c(%rip), %xmm3     # 0x25288
divsd %xmm3, %xmm1
subsd %xmm1, %xmm2
movsd -0x58(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1f997
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x4700(%rip), %xmm0     # 0x24028
ucomisd (%rax,%rcx,8), %xmm0
jbe 0x1f995
movsd 0x46f1(%rip), %xmm0     # 0x24028
mulsd -0x28(%rbp), %xmm0
movsd 0x5944(%rip), %xmm1     # 0x25288
mulsd -0x40(%rbp), %xmm1
divsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movsd 0x46c6(%rip), %xmm2     # 0x24028
subsd %xmm2, %xmm1
mulsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm2
movsd 0x46a9(%rip), %xmm1     # 0x24028
subsd %xmm1, %xmm2
movsd -0x58(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
jmp 0x1f997
jmp 0x1f999
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1f8a9
jmp 0x1fa9a
cmpl $0x2, -0x38(%rbp)
jne 0x1fa2f
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1fa2d
movsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
callq 0x34d0
movaps %xmm0, %xmm1
movsd 0x4629(%rip), %xmm0     # 0x24028
addsd %xmm1, %xmm0
callq 0x3220
movaps %xmm0, %xmm2
movsd -0x68(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1f9b9
jmp 0x1fa98
cmpl $0x5, -0x38(%rbp)
jne 0x1fa96
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x1fa94
movsd -0x28(%rbp), %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x45cf(%rip), %xmm1     # 0x24028
subsd (%rax,%rcx,8), %xmm1
mulsd %xmm1, %xmm0
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movsd 0x45b6(%rip), %xmm2     # 0x24028
subsd (%rax,%rcx,8), %xmm2
movsd -0x58(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1fa3c
jmp 0x1fa96
jmp 0x1fa98
jmp 0x1fa9a
jmp 0x1fa9c
jmp 0x1fa9e
jmp 0x1faa0
movl -0x5c(%rbp), %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movsd -0x58(%rbp), %xmm0
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop