// File: cjlin1[P]liblinear/linear.cpp
// Function: l2r_l2_svr_fun::grad(double*, double*)
void l2r_l2_svr_fun::grad(double *w, double *g)
{
	int i;
	double *y=prob->y;
	int l=prob->l;
	int w_size=get_nr_variable();
	double d;

	sizeI = 0;
	for(i=0;i<l;i++)
	{
		d = wx[i] - y[i];

		// generate index set I
		if(d < -p)
		{
			tmp[sizeI] = C[i]*(d+p);
			I[sizeI] = i;
			sizeI++;
		}
		else if(d > p)
		{
			tmp[sizeI] = C[i]*(d-p);
			I[sizeI] = i;
			sizeI++;
		}

	}
	subXTv(tmp, g);

	for(i=0;i<w_size;i++)
		g[i] = w[i] + 2*g[i];
	if(regularize_bias == 0)
		g[w_size-1] -= w[w_size-1];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
movq 0x10(%rdi), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq 0x10(%rdi), %rax
movl (%rax), %eax
movl %eax, -0x2c(%rbp)
movq (%rdi), %rax
callq *0x18(%rax)
movl %eax, %ecx
movq -0x40(%rbp), %rax
movl %ecx, -0x30(%rbp)
movl $0x0, 0x40(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x5ade
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movq -0x28(%rbp), %rcx
movslq -0x1c(%rbp), %rdx
subsd (%rcx,%rdx,8), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm1
movsd 0x48(%rax), %xmm0
movq %xmm0, %rax
movabsq $-0x8000000000000000, %rcx # imm = 0x8000000000000000
xorq %rcx, %rax
movq %rax, %xmm0
ucomisd %xmm1, %xmm0
jbe 0x5a79
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd -0x38(%rbp), %xmm1
addsd 0x48(%rax), %xmm1
mulsd %xmm1, %xmm0
movq 0x20(%rax), %rcx
movslq 0x40(%rax), %rdx
movsd %xmm0, (%rcx,%rdx,8)
movl -0x1c(%rbp), %esi
movq 0x38(%rax), %rcx
movslq 0x40(%rax), %rdx
movl %esi, (%rcx,%rdx,4)
movl 0x40(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x40(%rax)
jmp 0x5ace
movq -0x40(%rbp), %rax
movsd -0x38(%rbp), %xmm0
ucomisd 0x48(%rax), %xmm0
jbe 0x5acc
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rcx
movslq -0x1c(%rbp), %rdx
movsd (%rcx,%rdx,8), %xmm0
movsd -0x38(%rbp), %xmm1
subsd 0x48(%rax), %xmm1
mulsd %xmm1, %xmm0
movq 0x20(%rax), %rcx
movslq 0x40(%rax), %rdx
movsd %xmm0, (%rcx,%rdx,8)
movl -0x1c(%rbp), %esi
movq 0x38(%rax), %rcx
movslq 0x40(%rax), %rdx
movl %esi, (%rcx,%rdx,4)
movl 0x40(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x40(%rax)
jmp 0x5ace
jmp 0x5ad0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x59de
movq -0x40(%rbp), %rdi
movq 0x20(%rdi), %rsi
movq -0x18(%rbp), %rdx
callq 0x54d0
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x5b38
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd (%rax,%rcx,8), %xmm0
addsd %xmm0, %xmm0
addsd %xmm1, %xmm0
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movsd %xmm0, (%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x5af6
movq -0x40(%rbp), %rax
cmpl $0x0, 0x30(%rax)
jne 0x5b6f
movq -0x10(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm1
movq -0x18(%rbp), %rax
movl -0x30(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movsd (%rax,%rcx,8), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, (%rax,%rcx,8)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)