// File: /workspace/github_cpp_makefile_star2_O1/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 0x2e08
movl %eax, %ebx
testb %al, %al
jne 0x3364
movl $0x2, 0x20(%rsp)
movq 0x4d95(%rip), %rdi      # 0x7ff0
leaq 0x1dd9(%rip), %rsi      # 0x503b
movl $0x4, %edx
callq 0x2180
movq 0x4d7d(%rip), %rdi      # 0x7ff0
leaq 0x1dc6(%rip), %rsi      # 0x5040
movl $0x5, %edx
callq 0x2180
movq 0x4d65(%rip), %rdi      # 0x7ff0
leaq 0x1db4(%rip), %rsi      # 0x5046
movl $0x3, %edx
callq 0x2180
movq 0x4d4d(%rip), %rdi      # 0x7ff0
leaq 0x1ea0(%rip), %rsi      # 0x514a
movl $0xa, %edx
callq 0x2180
movq 0x4d35(%rip), %rdi      # 0x7ff0
leaq 0x1d7c(%rip), %rsi      # 0x503e
movl $0x1, %edx
callq 0x2180
movq 0x4d1d(%rip), %rdi      # 0x7ff0
movl $0x2f, %esi
callq 0x2260
movq %rax, %r14
leaq 0x1d79(%rip), %rsi      # 0x5060
movl $0x2, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x1e69(%rip), %rsi      # 0x5164
movl $0x1a, %edx
movq %r14, %rdi
callq 0x2180
testq %r15, %r15
je 0x3325
movq %r15, %rdi
callq 0x20d0
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x2180
jmp 0x333f
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 0x2ad8
leaq 0x40(%rsp), %rdi
callq 0x3d12
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 0x349e
leaq 0x20(%rsp), %r12
xorl %r13d, %r13d
movq 0x4c4d(%rip), %rax      # 0x7fd0
movq (%rax), %rdi
incl %r13d
leaq 0x1def(%rip), %rsi      # 0x517f
movl %r13d, %edx
xorl %eax, %eax
callq 0x21f0
movq 0x40(%rsp), %r15
movq 0x48(%rsp), %rbx
cmpq %rbx, %r15
je 0x3493
movq %r12, %rdi
movq %r15, %rsi
callq 0x3e34
movzwl 0x18(%r15), %eax
movw %ax, 0x38(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x2b30
movss %xmm0, 0x1c(%rsp)
movq 0x20(%rsp), %rax
movq 0x28(%rsp), %rcx
movss 0x1d3b(%rip), %xmm1     # 0x5120
cmpq %rcx, %rax
je 0x3408
movss 0x1d2e(%rip), %xmm1     # 0x5120
movss 0x4(%rax), %xmm0
mulss %xmm0, %xmm0
addss %xmm0, %xmm1
addq $0x8, %rax
cmpq %rcx, %rax
jne 0x33f2
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 0x3c12
xorps %xmm1, %xmm1
cvtsi2ss %ebp, %xmm1
mulss 0x1c(%rsp), %xmm1
movss 0x1cd5(%rip), %xmm0     # 0x5120
subss %xmm1, %xmm0
maxss 0x1ccd(%rip), %xmm0     # 0x5124
divss 0x18(%rsp), %xmm0
minss 0x14(%rsp), %xmm0
movswl 0x38(%rsp), %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x3c9c
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x348a
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
addq $0x20, %r15
jmp 0x33a4
cmpl 0x10(%rsp), %r13d
jne 0x337c
movq %r14, %rdi
callq 0x22df
movb 0xf(%rsp), %bl
jmp 0x3349
jmp 0x34c2
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x2ad8
jmp 0x34e1
jmp 0x34c7
movq %rax, %rbx
jmp 0x34e1
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x34e1
movq 0x30(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0x40(%rsp), %rdi
callq 0x3d12
movq %rbx, %rdi
callq 0x2270
nop