// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x228, %rsp            # imm = 0x228
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x2250
movq %r15, %rdi
movq %rbx, %rsi
movl $0x14, %edx
callq 0x2050
movq 0x28(%rsp), %rax
movq -0x18(%rax), %rax
movl 0x48(%rsp,%rax), %ebp
testb $0x5, %bpl
je 0x38e3
movl $0x2, 0x8(%rsp)
movq 0x47de(%rip), %rdi      # 0x7ff0
leaq 0x1822(%rip), %rsi      # 0x503b
movl $0x4, %edx
callq 0x2180
movq 0x47c6(%rip), %rdi      # 0x7ff0
leaq 0x180f(%rip), %rsi      # 0x5040
movl $0x5, %edx
callq 0x2180
movq 0x47ae(%rip), %rdi      # 0x7ff0
leaq 0x17fd(%rip), %rsi      # 0x5046
movl $0x3, %edx
callq 0x2180
movq 0x4796(%rip), %rdi      # 0x7ff0
leaq 0x18e9(%rip), %rsi      # 0x514a
movl $0xa, %edx
callq 0x2180
movq 0x477e(%rip), %rdi      # 0x7ff0
leaq 0x17c5(%rip), %rsi      # 0x503e
movl $0x1, %edx
callq 0x2180
movq 0x4766(%rip), %rdi      # 0x7ff0
movl $0x6e, %esi
callq 0x2260
movq %rax, %r14
leaq 0x17c2(%rip), %rsi      # 0x5060
movl $0x2, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x1913(%rip), %rsi      # 0x51c5
movl $0x1b, %edx
movq %r14, %rdi
callq 0x2180
testq %rbx, %rbx
je 0x3a00
movq %rbx, %rdi
callq 0x20d0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2180
jmp 0x3a1a
leaq 0x8(%r14), %rsi
leaq 0x28(%rsp), %rdi
movl $0x4, %edx
callq 0x21d0
leaq 0xc(%r14), %rsi
leaq 0x28(%rsp), %rdi
movl $0x4, %edx
callq 0x21d0
movl %ebp, 0x14(%rsp)
movq 0x18(%r14), %rax
subq 0x10(%r14), %rax
sarq $0x2, %rax
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x28(%rsp), %rdi
movl $0x8, %edx
callq 0x21d0
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
subq %rsi, %rdx
leaq 0x28(%rsp), %rdi
callq 0x21d0
movq 0x30(%r14), %rax
subq 0x28(%r14), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rax, %rcx
leaq 0x20(%rsp), %rsi
movq %rcx, (%rsi)
leaq 0x28(%rsp), %rdi
movl $0x8, %edx
callq 0x21d0
movq 0x28(%r14), %r12
movq 0x30(%r14), %r13
cmpq %r13, %r12
je 0x39f0
leaq 0x28(%rsp), %rbx
leaq 0x18(%rsp), %r14
movq 0x8(%r12), %rax
subq (%r12), %rax
sarq $0x3, %rax
movq %rax, 0x18(%rsp)
movl $0x8, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21d0
movq (%r12), %r15
movq 0x8(%r12), %rbp
cmpq %rbp, %r15
je 0x39e7
movl $0x4, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21d0
addq $0x4, %r15
movl $0x4, %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x21d0
addq $0x4, %r15
jmp 0x39b8
addq $0x18, %r12
cmpq %r13, %r12
jne 0x398d
leaq 0x28(%rsp), %rdi
callq 0x21e0
movl 0x14(%rsp), %ebp
jmp 0x3a24
movq (%r14), %rax
movq -0x18(%rax), %rax
movq %r14, %rdi
addq %rax, %rdi
movl 0x20(%r14,%rax), %esi
orl $0x1, %esi
callq 0x2240
leaq 0x8(%rsp), %rdi
callq 0x2ad8
testb $0x5, %bpl
sete %bl
movq 0x4596(%rip), %rax      # 0x7fc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x30(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x28(%rsp,%rcx)
callq 0x2130
leaq 0x120(%rsp), %rdi
callq 0x20a0
movl %ebx, %eax
addq $0x228, %rsp            # imm = 0x228
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3a88
jmp 0x3a88
jmp 0x3a88
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2ad8
jmp 0x3a8b
jmp 0x3a88
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x2270
nop