// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/vl/svm.c
// Function: vl_svm_new_with_abstract_data
VlSvm *
vl_svm_new_with_abstract_data (VlSvmSolverType solver,
                               void * data,
                               vl_size dimension,
                               vl_size numData,
                               double const * labels,
                               double lambda)
{
  VlSvm * self = vl_calloc(1,sizeof(VlSvm)) ;

  assert(dimension >= 1) ;
  assert(numData >= 1) ;
  assert(labels) ;

  self->solver = solver ;

  self->dimension = dimension ;
  self->model = 0 ;
  self->bias = 0 ;
  self->biasMultiplier = 1.0 ;

  self->lambda = lambda ;
  self->data = data ;
  self->numData = numData ;
  self->labels = labels ;

  self->diagnosticFrequency = numData ;
  self->diagnosticFn = 0 ;
  self->diagnosticFnData = 0 ;

  self->lossFn = vl_svm_hinge_loss ;
  self->conjugateLossFn = vl_svm_hinge_conjugate_loss ;
  self->lossDerivativeFn = vl_svm_hinge_loss_derivative ;
  self->dcaUpdateFn = vl_svm_hinge_dca_update ;

  self->innerProductFn = 0 ;
  self->accumulateFn = 0 ;

  self->iteration = 0 ;
  self->maxNumIterations = VL_MAX((double)numData, vl_ceil_f(10.0 / lambda)) ;
  self->epsilon = 1e-2 ;

  /* SGD */
  self->biasLearningRate = 0.01 ;

  /* SDCA */
  self->alpha = 0 ;

  /* allocations */
  self->model = vl_calloc(dimension, sizeof(double)) ;
  if (self->model == NULL) goto err_alloc ;

  if (self->solver == VlSvmSolverSdca) {
    self->alpha = vl_calloc(self->numData, sizeof(double)) ;
    if (self->alpha == NULL) goto err_alloc ;
  }

  self->scores = vl_calloc(numData, sizeof(double)) ;
  if (self->scores == NULL) goto err_alloc ;

  return self ;

err_alloc:
  if (self->scores) {
    vl_free (self->scores) ;
    self->scores = 0 ;
  }
  if (self->model) {
    vl_free (self->model) ;
    self->model = 0 ;
  }
  if (self->alpha) {
    vl_free (self->alpha) ;
    self->alpha = 0 ;
  }
  return 0 ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movsd %xmm0, 0x8(%rsp)
movq %r8, %r13
movq %rcx, %rbx
movq %rdx, %r12
movq %rsi, %rbp
movl %edi, %r15d
pushq $0x1
popq %rdi
movl $0x128, %esi            # imm = 0x128
callq 0x9960
movq %rax, %r14
movl %r15d, (%rax)
movq %rbx, %r15
movq %rax, %rbx
movq %r12, 0x8(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rax)
movabsq $0x3ff0000000000000, %rax # imm = 0x3FF0000000000000
movq %rax, 0x20(%r14)
movsd 0x8(%rsp), %xmm1
movsd %xmm1, 0x28(%r14)
movq %rbp, 0x30(%r14)
movq %r15, 0x38(%r14)
movq %r13, 0x40(%r14)
movq %r15, 0x68(%r14)
movups %xmm0, 0x58(%r14)
movq 0xc7cc(%rip), %rax      # 0x36f40
movq %rax, 0x70(%r14)
movq 0xc831(%rip), %rax      # 0x36fb0
movq %rax, 0x78(%r14)
movq 0xc85e(%rip), %rax      # 0x36fe8
movq %rax, 0x80(%r14)
movq 0xc7f0(%rip), %rax      # 0x36f88
movq %r15, %xmm0
punpckldq 0x29bb(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x29c3(%rip), %xmm0     # 0x2d170
movq %rax, 0x88(%r14)
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
movapd %xmm2, 0x10(%rsp)
movsd 0x3b3a(%rip), %xmm0     # 0x2e308
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x94f0
cvttss2si %xmm0, %rax
cvtsi2sd %rax, %xmm0
movapd 0x10(%rsp), %xmm1
maxsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rcx
subsd 0x33c9(%rip), %xmm1     # 0x2dbc8
sarq $0x3f, %rcx
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
andq $0x0, 0xa0(%r14)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x90(%r14)
movq %rdx, 0xa8(%r14)
movabsq $0x3f847ae147ae147b, %rax # imm = 0x3F847AE147AE147B
movq %rax, 0xb0(%r14)
movq %rax, 0x118(%r14)
andq $0x0, 0x120(%r14)
pushq $0x8
popq %rsi
movq %r12, %rdi
callq 0x9960
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x2a892
cmpl $0x2, (%rbx)
jne 0x2a87b
movq 0x38(%rbx), %rdi
pushq $0x8
popq %rsi
callq 0x9960
movq %rax, 0x120(%rbx)
testq %rax, %rax
je 0x2a892
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x9960
movq %rax, 0x110(%rbx)
testq %rax, %rax
jne 0x2a8db
addq $0x10, %r14
movq 0x110(%rbx), %rdi
testq %rdi, %rdi
je 0x2a8af
callq 0x95b0
andq $0x0, 0x110(%rbx)
movq (%r14), %rdi
testq %rdi, %rdi
je 0x2a8c0
callq 0x95b0
andq $0x0, (%r14)
movq 0x120(%rbx), %rdi
testq %rdi, %rdi
je 0x2a8d9
callq 0x95b0
andq $0x0, 0x120(%rbx)
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq