// File: tetsuok[P]kernel-pa/learner.cc
// Function: kernel::Learner::Save(char const*) const
bool Learner::Save(const char* filename) const {
  std::ofstream bofs;
  bofs.open(filename, ios::out | ios::binary);
  if (!bofs) {
    LOG(ERROR) << "no such file or directory: " << filename;
    return false;
  }

  bofs.write(reinterpret_cast<const char *>(&C_), sizeof(C_));
  bofs.write(reinterpret_cast<const char *>(&d_), sizeof(d_));

  const std::size_t alpha_size = alpha_.size();
  bofs.write(reinterpret_cast<const char *>(&alpha_size), sizeof(alpha_size));
  bofs.write(reinterpret_cast<const char *>(&alpha_[0]), alpha_.size() * sizeof(float));

  const std::size_t sv_size = sv_index_.size();
  bofs.write(reinterpret_cast<const char *>(&sv_size), sizeof(sv_size));

  for (const fv& x : sv_index_) {
    const std::size_t x_size = x.size();
    bofs.write(reinterpret_cast<const char *>(&x_size), sizeof(x_size));

    for (const auto& p : x) {
      bofs.write(reinterpret_cast<const char *>(&p.first), sizeof(p.first));
      bofs.write(reinterpret_cast<const char *>(&p.second), sizeof(p.second));
    }
  }

  bofs.close();
  return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x310, %rsp            # imm = 0x310
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x2a0(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x2290
movq -0x18(%rbp), %rax
movq %rax, -0x298(%rbp)
movl $0x10, %edi
movl $0x4, %esi
callq 0x5e50
movl %eax, -0x28c(%rbp)
jmp 0x517c
movl -0x28c(%rbp), %edx
movq -0x298(%rbp), %rsi
leaq -0x218(%rbp), %rdi
callq 0x2040
jmp 0x5197
movq -0x218(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x218(%rbp,%rax), %rdi
callq 0x20e0
movb %al, -0x2a1(%rbp)
jmp 0x51b7
movb -0x2a1(%rbp), %al
testb $0x1, %al
jne 0x51c6
jmp 0x534c
leaq -0x228(%rbp), %rdi
movl $0x2, %esi
callq 0x2e30
jmp 0x51d9
callq 0x2e60
movq %rax, -0x2b0(%rbp)
jmp 0x51e7
movq -0x2b0(%rbp), %rdi
leaq 0x5e36(%rip), %rsi      # 0xb02b
callq 0x2150
movq %rax, -0x2b8(%rbp)
jmp 0x5203
movq -0x2b8(%rbp), %rdi
leaq 0x5e1f(%rip), %rsi      # 0xb030
callq 0x2150
movq %rax, -0x2c0(%rbp)
jmp 0x521f
movq -0x2c0(%rbp), %rdi
leaq 0x5e09(%rip), %rsi      # 0xb036
callq 0x2150
movq %rax, -0x2c8(%rbp)
jmp 0x523b
movq -0x2c8(%rbp), %rdi
leaq 0x5ecb(%rip), %rsi      # 0xb114
callq 0x2150
movq %rax, -0x2d0(%rbp)
jmp 0x5257
movq -0x2d0(%rbp), %rdi
leaq 0x5dc9(%rip), %rsi      # 0xb02e
callq 0x2150
movq %rax, -0x2d8(%rbp)
jmp 0x5273
movq -0x2d8(%rbp), %rdi
movl $0x6e, %esi
callq 0x22a0
movq %rax, -0x2e0(%rbp)
jmp 0x528d
movq -0x2e0(%rbp), %rdi
leaq 0x5db5(%rip), %rsi      # 0xb050
callq 0x2150
movq %rax, -0x2e8(%rbp)
jmp 0x52a9
movq -0x2e8(%rbp), %rdi
leaq 0x5ed8(%rip), %rsi      # 0xb18f
callq 0x2150
movq %rax, -0x2f0(%rbp)
jmp 0x52c5
movq -0x2f0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2150
movq %rax, -0x2f8(%rbp)
jmp 0x52de
movq -0x2f8(%rbp), %rsi
leaq -0x228(%rbp), %rdi
callq 0x2e50
jmp 0x52f3
leaq -0x228(%rbp), %rdi
callq 0x2e70
movb $0x0, -0x1(%rbp)
movl $0x1, -0x22c(%rbp)
jmp 0x559f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
jmp 0x55b9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x220(%rbp)
movl %eax, -0x224(%rbp)
leaq -0x228(%rbp), %rdi
callq 0x2e70
jmp 0x55b9
movq -0x2a0(%rbp), %rsi
addq $0x8, %rsi
leaq -0x218(%rbp), %rdi
movl $0x4, %edx
callq 0x21e0
jmp 0x536a
movq -0x2a0(%rbp), %rsi
addq $0xc, %rsi
leaq -0x218(%rbp), %rdi
movl $0x4, %edx
callq 0x21e0
jmp 0x5388
movq -0x2a0(%rbp), %rdi
addq $0x10, %rdi
callq 0x3220
movq %rax, -0x238(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0x238(%rbp), %rsi
movl $0x8, %edx
callq 0x21e0
jmp 0x53b9
movq -0x2a0(%rbp), %rdi
addq $0x10, %rdi
movq %rdi, -0x308(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x6290
movq -0x308(%rbp), %rdi
movq %rax, -0x300(%rbp)
callq 0x3220
movq -0x300(%rbp), %rsi
movq %rax, %rdx
shlq $0x2, %rdx
leaq -0x218(%rbp), %rdi
callq 0x21e0
jmp 0x5403
movq -0x2a0(%rbp), %rdi
addq $0x28, %rdi
callq 0x3300
movq %rax, -0x240(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0x240(%rbp), %rsi
movl $0x8, %edx
callq 0x21e0
jmp 0x5434
movq -0x2a0(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x248(%rbp)
movq -0x248(%rbp), %rdi
callq 0x62b0
movq %rax, -0x250(%rbp)
movq -0x248(%rbp), %rdi
callq 0x62e0
movq %rax, -0x258(%rbp)
leaq -0x250(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x6310
testb $0x1, %al
jne 0x5488
jmp 0x5583
leaq -0x250(%rbp), %rdi
callq 0x6350
movq %rax, -0x260(%rbp)
movq -0x260(%rbp), %rdi
callq 0x6370
movq %rax, -0x268(%rbp)
leaq -0x218(%rbp), %rdi
leaq -0x268(%rbp), %rsi
movl $0x8, %edx
callq 0x21e0
jmp 0x54c8
movq -0x260(%rbp), %rax
movq %rax, -0x270(%rbp)
movq -0x270(%rbp), %rdi
callq 0x3240
movq %rax, -0x278(%rbp)
movq -0x270(%rbp), %rdi
callq 0x3270
movq %rax, -0x280(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0x32a0
testb $0x1, %al
jne 0x5515
jmp 0x5570
leaq -0x278(%rbp), %rdi
callq 0x32e0
movq %rax, -0x288(%rbp)
movq -0x288(%rbp), %rsi
leaq -0x218(%rbp), %rdi
movl $0x4, %edx
callq 0x21e0
jmp 0x5542
movq -0x288(%rbp), %rsi
addq $0x4, %rsi
leaq -0x218(%rbp), %rdi
movl $0x4, %edx
callq 0x21e0
jmp 0x5560
jmp 0x5562
leaq -0x278(%rbp), %rdi
callq 0x3370
jmp 0x54fc
jmp 0x5572
leaq -0x250(%rbp), %rdi
callq 0x6390
jmp 0x546c
leaq -0x218(%rbp), %rdi
callq 0x2200
jmp 0x5591
movb $0x1, -0x1(%rbp)
movl $0x1, -0x22c(%rbp)
leaq -0x218(%rbp), %rdi
callq 0x2230
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x218(%rbp), %rdi
callq 0x2230
movq -0x220(%rbp), %rdi
callq 0x22b0
nopw %cs:(%rax,%rax)