// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movl %edx, %ebp
movq %rsi, %r15
movq %rdi, %r14
xorps %xmm0, %xmm0
leaq 0x30(%rsp), %rdx
movaps %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
leaq 0x50(%rsp), %rcx
andq $0x0, (%rcx)
callq 0x2bd2
movl %eax, %ebx
testb %al, %al
jne 0x2fb6
movl $0x2, 0x10(%rsp)
movq 0x50db(%rip), %rdi      # 0x7ff0
leaq 0x211f(%rip), %rsi      # 0x503b
callq 0x2130
leaq 0x2118(%rip), %rsi      # 0x5040
movq %rax, %rdi
callq 0x2130
leaq 0x210f(%rip), %rsi      # 0x5046
movq %rax, %rdi
callq 0x2130
leaq 0x2204(%rip), %rsi      # 0x514a
movq %rax, %rdi
callq 0x2130
leaq 0x20e9(%rip), %rsi      # 0x503e
movq %rax, %rdi
callq 0x2130
pushq $0x2f
popq %rsi
movq %rax, %rdi
callq 0x2240
leaq 0x20f1(%rip), %rsi      # 0x5060
movq %rax, %rdi
callq 0x2130
leaq 0x21e6(%rip), %rsi      # 0x5164
movq %rax, %rdi
callq 0x2130
movq %rax, %rdi
movq %r15, %rsi
callq 0x2130
leaq 0x10(%rsp), %rdi
callq 0x2858
leaq 0x30(%rsp), %rdi
callq 0x3796
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb %bl, 0xb(%rsp)
xorl %eax, %eax
testl %ebp, %ebp
cmovlel %eax, %ebp
leaq 0x10(%rsp), %r12
xorl %r13d, %r13d
movq 0x5000(%rip), %rax      # 0x7fd0
movq (%rax), %rdi
cmpl %ebp, %r13d
je 0x3085
incl %r13d
leaq 0x2199(%rip), %rsi      # 0x517f
movl %r13d, %edx
xorl %eax, %eax
callq 0x21c0
movq 0x30(%rsp), %r15
movq 0x38(%rsp), %rbx
cmpq %rbx, %r15
je 0x2fc9
movq %r12, %rdi
movq %r15, %rsi
callq 0x368c
movq %r14, %rdi
movq %r12, %rsi
callq 0x28a0
movswl 0x28(%rsp), %eax
cvtsi2ss %eax, %xmm1
mulss %xmm0, %xmm1
movss 0x20f6(%rip), %xmm0     # 0x5120
subss %xmm1, %xmm0
maxss 0x20ee(%rip), %xmm0     # 0x5124
movq %r14, %rdi
movq %r12, %rsi
callq 0x36ac
movss %xmm0, 0xc(%rsp)
movq 0x18(%r14), %rdx
subq 0x10(%r14), %rdx
shrq $0x2, %rdx
movq %r14, %rdi
movq %r12, %rsi
callq 0x36da
movswl 0x28(%rsp), %edx
movq %r14, %rdi
movq %r12, %rsi
movss 0xc(%rsp), %xmm0
callq 0x375a
movq %r12, %rdi
callq 0x2b28
addq $0x20, %r15
jmp 0x2ffa
movq 0x48(%r14), %rdx
subq 0x40(%r14), %rdx
sarq $0x2, %rdx
leaq 0x20f2(%rip), %rsi      # 0x518a
xorl %eax, %eax
callq 0x21c0
movb 0xb(%rsp), %bl
jmp 0x2f9b
jmp 0x30b9
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2858
jmp 0x30cd
movq %rax, %rbx
jmp 0x30cd
jmp 0x30c0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x2b28
leaq 0x30(%rsp), %rdi
callq 0x3796
movq %rbx, %rdi
callq 0x2250
nop