// File: /workspace/github_c_makefile_star2_O3/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 0x9350
movsd %xmm0, 0x10(%rsp)
callq 0x98a0
movq %rax, %r14
movq 0x38(%rbx), %rdi
movl $0x8, %esi
callq 0x98f0
movq %rax, %r15
movq 0x38(%rbx), %rdi
movl $0x8, %esi
callq 0x98f0
movq %rax, %r12
movq 0x8(%rbx), %rdi
movl $0x8, %esi
callq 0x98f0
movq %rax, %r13
cmpl $0x0, 0x38(%rbx)
je 0x30f12
xorl %ebp, %ebp
movq %rbp, (%r12,%rbp,8)
movq 0x8(%rbx), %rdx
shlq $0x3, %rdx
movq %r13, %rdi
xorl %esi, %esi
callq 0x9400
movq 0x30(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
movsd 0x13c3(%rip), %xmm0     # 0x32270
callq *0x98(%rbx)
movq 0x30(%rbx), %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq *0x90(%rbx)
movsd 0x20(%rbx), %xmm1
movq 0x38(%rbx), %rax
movq %rax, %xmm2
punpckldq 0x12a7(%rip), %xmm2 # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
mulsd %xmm1, %xmm1
subpd 0x12ab(%rip), %xmm2     # 0x32190
movapd %xmm2, %xmm3
unpckhpd %xmm2, %xmm3            # xmm3 = xmm3[1],xmm2[1]
addsd %xmm0, %xmm1
addsd %xmm2, %xmm3
mulsd 0x28(%rbx), %xmm3
divsd %xmm3, %xmm1
movsd %xmm1, (%r15,%rbp,8)
incq %rbp
movl %eax, %eax
cmpq %rax, %rbp
jb 0x30e85
movq %r13, %rdi
callq 0x9580
xorl %ebp, %ebp
movq %rbp, %r13
movq 0x38(%rbx), %rcx
movq %rbp, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x30f47
movq %r14, %rdi
movq %r12, %rsi
movq %rcx, %rdx
callq 0x9320
movq %r13, %rax
xorl %edx, %edx
divq 0x38(%rbx)
movq (%r12,%rdx,8), %rbp
movq 0x48(%rbx), %rax
movsd 0x1319(%rip), %xmm0     # 0x32270
testq %rax, %rax
je 0x30f6f
movsd (%rax,%rbp,8), %xmm0
ucomisd 0x10c7(%rip), %xmm0     # 0x32030
jbe 0x3103f
movsd %xmm0, 0x8(%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 0x8(%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 0x8(%rsp), %xmm0
ucomisd 0x105f(%rip), %xmm0     # 0x32030
jne 0x30fd5
jnp 0x3103f
movq 0x120(%rbx), %rax
movsd (%rax,%rbp,8), %xmm1
addsd %xmm0, %xmm1
movsd %xmm1, (%rax,%rbp,8)
movsd 0x38(%rbx), %xmm2
unpcklps 0x118a(%rip), %xmm2     # xmm2 = xmm2[0],mem[0],xmm2[1],mem[1]
subpd 0x1192(%rip), %xmm2     # 0x32190
movapd %xmm2, %xmm1
unpckhpd %xmm2, %xmm1            # xmm1 = xmm1[1],xmm2[1]
addsd %xmm2, %xmm1
mulsd 0x28(%rbx), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rsp)
movq 0x10(%rbx), %rdx
movq 0x30(%rbx), %rdi
movq %rbp, %rsi
callq *0x98(%rbx)
movsd 0x8(%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 0x3105e
cmpq 0xa8(%rbx), %rbp
jne 0x30f1c
movq %rbx, %rdi
callq 0x30bc3
callq 0x9350
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
movl $0x2, %ecx
ucomisd 0xf8(%rbx), %xmm0
ja 0x310c4
movl $0x1, %eax
movl $0x3, %ecx
cmpq 0xa8(%rbx), %rbp
jne 0x310cc
movl %ecx, 0xb8(%rbx)
movl %ecx, %eax
movq 0x58(%rbx), %rcx
testq %rcx, %rcx
je 0x310e4
movq 0x60(%rbx), %rsi
movq %rbx, %rdi
callq *%rcx
movl 0xb8(%rbx), %eax
cmpl $0x1, %eax
je 0x30f1c
movq %r15, %rdi
callq 0x9580
movq %r12, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x9580