// File: /workspace/github_c_makefile_star2_O2/zpole[P]IICV/vl/svm.c
// Function: vl_svm_sdca_train
void _vl_svm_sdca_train (VlSvm *self)
{
  double * norm2 ;
  vl_index * permutation ;
  vl_uindex i, t  ;
  double inner, delta, multiplier, p ;

  double startTime = vl_get_cpu_time () ;
  VlRand * rand = vl_get_rand() ;

  norm2 = (double*) vl_calloc(self->numData, sizeof(double));
  permutation = vl_calloc(self->numData, sizeof(vl_index)) ;

  {
    double * buffer = vl_calloc(self->dimension, sizeof(double)) ;
    for (i = 0 ; i < (unsigned)self->numData; i++) {
      double n2 ;
      permutation [i] = i ;
      memset(buffer, 0, self->dimension * sizeof(double)) ;
      self->accumulateFn (self->data, i, buffer, 1) ;
      n2 = self->innerProductFn (self->data, i, buffer) ;
      n2 += self->biasMultiplier * self->biasMultiplier ;
      norm2[i] = n2 / (self->lambda * self->numData) ;
    }
    vl_free(buffer) ;
  }

  for (t = 0 ; 1 ; ++t) {

    if (t % self->numData == 0) {
      /* once a new epoch is reached (all data have been visited),
       change permutation */
      vl_rand_permute_indexes(rand, permutation, self->numData) ;
    }

    /* pick a sample and compute update */
    i = permutation[t % self->numData] ;
    p = (self->weights) ? self->weights[i] : 1.0 ;
    if (p > 0) {
      inner = self->innerProductFn(self->data, i, self->model) ;
      inner += self->bias * self->biasMultiplier ;
      delta = p * self->dcaUpdateFn(self->alpha[i] / p, inner, p * norm2[i], self->labels[i]) ;
    } else {
      delta = 0 ;
    }

    /* apply update */
    if (delta != 0) {
      self->alpha[i] += delta ;
      multiplier = delta / (self->numData * self->lambda) ;
      self->accumulateFn(self->data,i,self->model,multiplier) ;
      self->bias += self->biasMultiplier * multiplier;
    }

    /* call diagnostic occasionally */
    if ((t + 1) % self->diagnosticFrequency == 0 || t + 1 == self->maxNumIterations) {
      _vl_svm_update_statistics (self) ;
      self->statistics.elapsedTime = vl_get_cpu_time() - startTime ;
      self->statistics.iteration = t ;
      self->statistics.epoch = t / self->numData ;

      self->statistics.status = VlSvmStatusTraining ;
      if (self->statistics.dualityGap < self->epsilon) {
        self->statistics.status = VlSvmStatusConverged ;
      }
      else if (t + 1 == self->maxNumIterations) {
        self->statistics.status = VlSvmStatusMaxNumIterationsReached ;
      }

      if (self->diagnosticFn) {
        self->diagnosticFn(self, self->diagnosticFnData) ;
      }

      if (self->statistics.status != VlSvmStatusTraining) {
        break ;
      }
    }
  } /* next iteration */

  vl_free (norm2) ;
  vl_free (permutation) ;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x9370
movsd %xmm0, 0x10(%rsp)
callq 0x9910
movq %rax, 0x8(%rsp)
movq 0x38(%rbx), %rdi
pushq $0x8
popq %r13
movq %r13, %rsi
callq 0x9960
movq %rax, %r15
movq 0x38(%rbx), %rdi
movq %r13, %rsi
callq 0x9960
movq %rax, %r12
movq 0x8(%rbx), %rdi
movq %r13, %rsi
callq 0x9960
movq %rax, %r13
movl 0x38(%rbx), %eax
xorl %ebp, %ebp
movl %eax, %eax
cmpq %rax, %rbp
jae 0x2b2eb
movq %rbp, (%r12,%rbp,8)
movq 0x8(%rbx), %rdx
shlq $0x3, %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x9420
movq 0x30(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movsd 0x1fac(%rip), %xmm0     # 0x2d238
callq *0x98(%rbx)
movq 0x30(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq *0x90(%rbx)
movq 0x38(%rbx), %rax
movq %rax, %xmm1
punpckldq 0x1ead(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0x1eb5(%rip), %xmm1     # 0x2d170
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
movsd 0x20(%rbx), %xmm1
mulsd %xmm1, %xmm1
mulsd 0x28(%rbx), %xmm2
addsd %xmm0, %xmm1
divsd %xmm2, %xmm1
movsd %xmm1, (%r15,%rbp,8)
incq %rbp
jmp 0x2b259
movq %r13, %rdi
callq 0x95b0
xorl %ebp, %ebp
pushq $0x2
popq %r14
movq %rbp, %r13
movq 0x38(%rbx), %rcx
movq %rbp, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x2b326
movq 0x8(%rsp), %rdi
movq %r12, %rsi
movq %rcx, %rdx
callq 0x9330
movq %r13, %rax
xorl %edx, %edx
divq 0x38(%rbx)
movq (%r12,%rdx,8), %rbp
movq 0x48(%rbx), %rax
movsd 0x1f02(%rip), %xmm0     # 0x2d238
testq %rax, %rax
je 0x2b34e
movsd (%rax,%rbp,8), %xmm0
ucomisd 0x1cb8(%rip), %xmm0     # 0x2d000
jbe 0x2b419
movsd %xmm0, (%rsp)
movq 0x10(%rbx), %rdx
movq 0x30(%rbx), %rdi
movq %rbp, %rsi
callq *0x90(%rbx)
movsd 0x18(%rbx), %xmm1
mulsd 0x20(%rbx), %xmm1
addsd %xmm0, %xmm1
movq 0x120(%rbx), %rax
movsd (%rax,%rbp,8), %xmm0
movsd (%rsp), %xmm3
divsd %xmm3, %xmm0
movsd (%r15,%rbp,8), %xmm2
mulsd %xmm3, %xmm2
movq 0x40(%rbx), %rax
movsd (%rax,%rbp,8), %xmm3
callq *0x88(%rbx)
mulsd (%rsp), %xmm0
ucomisd 0x1c53(%rip), %xmm0     # 0x2d000
jne 0x2b3b1
jnp 0x2b419
movq 0x120(%rbx), %rax
movsd (%rax,%rbp,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rbp,8)
movsd 0x38(%rbx), %xmm2
unpcklps 0x1d8e(%rip), %xmm2     # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x1d96(%rip), %xmm2     # 0x2d170
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
mulsd 0x28(%rbx), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, (%rsp)
movq 0x10(%rbx), %rdx
movq 0x30(%rbx), %rdi
movq %rbp, %rsi
callq *0x98(%rbx)
movsd (%rsp), %xmm0
mulsd 0x20(%rbx), %xmm0
addsd 0x18(%rbx), %xmm0
movsd %xmm0, 0x18(%rbx)
leaq 0x1(%r13), %rbp
movq %rbp, %rax
xorl %edx, %edx
divq 0x68(%rbx)
testq %rdx, %rdx
je 0x2b438
cmpq 0xa8(%rbx), %rbp
jne 0x2b2f9
movq %rbx, %rdi
callq 0x2afba
callq 0x9370
subsd 0x10(%rsp), %xmm0
movsd %xmm0, 0x108(%rbx)
movq %r13, 0xc0(%rbx)
movq %r13, %rax
xorl %edx, %edx
divq 0x38(%rbx)
movq %rax, 0xc8(%rbx)
movl $0x1, 0xb8(%rbx)
movsd 0xb0(%rbx), %xmm0
ucomisd 0xf8(%rbx), %xmm0
movl %r14d, %ecx
ja 0x2b498
pushq $0x3
popq %rcx
pushq $0x1
popq %rax
cmpq 0xa8(%rbx), %rbp
jne 0x2b4a0
movl %ecx, 0xb8(%rbx)
movl %ecx, %eax
movq 0x58(%rbx), %rcx
testq %rcx, %rcx
je 0x2b4b8
movq 0x60(%rbx), %rsi
movq %rbx, %rdi
callq *%rcx
movl 0xb8(%rbx), %eax
cmpl $0x1, %eax
je 0x2b2f9
movq %r15, %rdi
callq 0x95b0
movq %r12, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x95b0