// File: /workspace/github_c_makefile_star2_O1/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
movl $0x1, %edi
movl $0x128, %esi            # imm = 0x128
callq 0x98f0
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 0xb90c(%rip), %rax      # 0x3bf40
movq %rax, 0x70(%r14)
movq 0xb971(%rip), %rax      # 0x3bfb0
movq %rax, 0x78(%r14)
movq 0xb99e(%rip), %rax      # 0x3bfe8
movq %rax, 0x80(%r14)
movq 0xb930(%rip), %rax      # 0x3bf88
movq %r15, %xmm0
punpckldq 0x2b1b(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x2b23(%rip), %xmm0     # 0x33190
movq %rax, 0x88(%r14)
movapd %xmm0, %xmm2
unpckhpd %xmm0, %xmm2            # xmm2 = xmm2[1],xmm0[1]
addsd %xmm0, %xmm2
movapd %xmm2, 0x10(%rsp)
movsd 0x3d0a(%rip), %xmm0     # 0x34398
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
callq 0x94c0
cvttss2si %xmm0, %rax
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movapd 0x10(%rsp), %xmm1
maxsd %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x355a(%rip), %xmm1     # 0x33c20
cvttsd2si %xmm1, %rdx
andq %rcx, %rdx
orq %rax, %rdx
xorpd %xmm0, %xmm0
movupd %xmm0, 0x90(%r14)
xorl %eax, %eax
movq %rax, 0xa0(%r14)
movq %rdx, 0xa8(%r14)
movabsq $0x3f847ae147ae147b, %rcx # imm = 0x3F847AE147AE147B
movq %rcx, 0xb0(%r14)
movq %rcx, 0x118(%r14)
movq %rax, 0x120(%r14)
movl $0x8, %esi
movq %r12, %rdi
callq 0x98f0
movq %rax, 0x10(%r14)
testq %rax, %rax
je 0x3075b
cmpl $0x2, (%rbx)
jne 0x30742
movq 0x38(%rbx), %rdi
movl $0x8, %esi
callq 0x98f0
movq %rax, 0x120(%rbx)
testq %rax, %rax
je 0x3075b
movl $0x8, %esi
movq %r15, %rdi
callq 0x98f0
movq %rax, 0x110(%rbx)
testq %rax, %rax
jne 0x307ad
addq $0x10, %r14
movq 0x110(%rbx), %rdi
testq %rdi, %rdi
je 0x3077b
callq 0x9580
movq $0x0, 0x110(%rbx)
movq (%r14), %rdi
testq %rdi, %rdi
je 0x3078f
callq 0x9580
movq $0x0, (%r14)
movq 0x120(%rbx), %rdi
testq %rdi, %rdi
je 0x307ab
callq 0x9580
movq $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