// File: /workspace/github_cpp_makefile_star2_O3/tetsuok[P]kernel-pa/learner.cc
// Function: kernel::Learner::Train(char const*, int)
bool Learner::Train(const char* filename, int iter) {
  vector<example> examples;
  size_t maxid = 0;
  if (!Read(filename, examples, &maxid)) {
    LOG(ERROR) << "cannot read training data " << filename;
    return false;
  }

  const std::size_t num_examples = examples.size();

  for (int t = 0; t < iter; ++t) {
    fprintf(stderr, "iter = %d\n", t+1);
    for (const auto e : examples) {
      const float m = Margin(e.first);
      const float loss = HingeLoss(m, e.second);
      if (loss >= 0.0) {
        const float rate = LearningRate(loss, e.first);
        UpdateIndex(e.first, static_cast<unsigned int>(alpha_.size()));
        UpdateAlpha(e.first, rate, e.second);
      }
    }
  }

  fprintf(stderr, "INFO: the number of support vectors = %lu\n",
          margin_.size());
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x40(%rsp), %rdx
movaps %xmm0, (%rdx)
xorl %eax, %eax
movq %rax, 0x10(%rdx)
leaq 0x60(%rsp), %rcx
movq %rax, (%rcx)
callq 0x3200
movl %eax, %ebx
testb %al, %al
jne 0x3778
movl $0x2, 0x20(%rsp)
movq 0x5981(%rip), %rdi      # 0x8ff0
leaq 0x29f9(%rip), %rsi      # 0x606f
movl $0x4, %edx
callq 0x2180
movq 0x5969(%rip), %rdi      # 0x8ff0
leaq 0x29e6(%rip), %rsi      # 0x6074
movl $0x5, %edx
callq 0x2180
movq 0x5951(%rip), %rdi      # 0x8ff0
leaq 0x29d4(%rip), %rsi      # 0x607a
movl $0x3, %edx
callq 0x2180
movq 0x5939(%rip), %rdi      # 0x8ff0
leaq 0x2abc(%rip), %rsi      # 0x617a
movl $0xa, %edx
callq 0x2180
movq 0x5921(%rip), %rdi      # 0x8ff0
leaq 0x299c(%rip), %rsi      # 0x6072
movl $0x1, %edx
callq 0x2180
movq 0x5909(%rip), %rdi      # 0x8ff0
movl $0x2f, %esi
callq 0x2260
movq %rax, %r14
leaq 0x2999(%rip), %rsi      # 0x6094
movl $0x2, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x2a85(%rip), %rsi      # 0x6194
movl $0x1a, %edx
movq %r14, %rdi
callq 0x2180
testq %r15, %r15
je 0x3739
movq %r15, %rdi
callq 0x20d0
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2180
jmp 0x3753
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r14, %rdi
addq %rax, %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x2240
leaq 0x20(%rsp), %rdi
callq 0x2ae0
leaq 0x40(%rsp), %rdi
callq 0x4130
movl %ebx, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb %bl, 0xf(%rsp)
movl %ebp, 0x10(%rsp)
testl %ebp, %ebp
jle 0x38b2
leaq 0x20(%rsp), %r12
xorl %r13d, %r13d
movq 0x5839(%rip), %rax      # 0x8fd0
movq (%rax), %rdi
incl %r13d
leaq 0x2a0b(%rip), %rsi      # 0x61af
movl %r13d, %edx
xorl %eax, %eax
callq 0x21f0
movq 0x40(%rsp), %r15
movq 0x48(%rsp), %rbx
cmpq %rbx, %r15
je 0x38a7
movq %r12, %rdi
movq %r15, %rsi
callq 0x4258
movzwl 0x18(%r15), %eax
movw %ax, 0x38(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2b38
movss %xmm0, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movss 0x295b(%rip), %xmm1     # 0x6154
cmpq %rcx, %rax
je 0x381c
movss 0x294e(%rip), %xmm1     # 0x6154
movss 0x4(%rax), %xmm0
mulss %xmm0, %xmm0
addss %xmm0, %xmm1
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x3806
movss %xmm1, 0x18(%rsp)
movswl 0x38(%rsp), %ebp
movss 0x8(%r14), %xmm0
movss %xmm0, 0x14(%rsp)
movq 0x18(%r14), %rdx
subq 0x10(%r14), %rdx
shrq $0x2, %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x402c
xorps %xmm1, %xmm1
cvtsi2ss %ebp, %xmm1
mulss 0x1c(%rsp), %xmm1
movss 0x28f5(%rip), %xmm0     # 0x6154
subss %xmm1, %xmm0
maxss 0x27e5(%rip), %xmm0     # 0x6050
divss 0x18(%rsp), %xmm0
minss 0x14(%rsp), %xmm0
movswl 0x38(%rsp), %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x40ba
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x389e
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
addq $0x20, %r15
jmp 0x37b8
cmpl 0x10(%rsp), %r13d
jne 0x3790
movq %r14, %rdi
callq 0x22df
movb 0xf(%rsp), %bl
jmp 0x375d
jmp 0x38d6
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2ae0
jmp 0x38f5
jmp 0x38db
movq %rax, %rbx
jmp 0x38f5
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x38f5
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0x40(%rsp), %rdi
callq 0x4130
movq %rbx, %rdi
callq 0x2270
nop