// File: /workspace/github_cpp_makefile_star2_O3/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 0x3cf7
movl $0x2, 0x8(%rsp)
movq 0x53ca(%rip), %rdi      # 0x8ff0
leaq 0x2442(%rip), %rsi      # 0x606f
movl $0x4, %edx
callq 0x2180
movq 0x53b2(%rip), %rdi      # 0x8ff0
leaq 0x242f(%rip), %rsi      # 0x6074
movl $0x5, %edx
callq 0x2180
movq 0x539a(%rip), %rdi      # 0x8ff0
leaq 0x241d(%rip), %rsi      # 0x607a
movl $0x3, %edx
callq 0x2180
movq 0x5382(%rip), %rdi      # 0x8ff0
leaq 0x2505(%rip), %rsi      # 0x617a
movl $0xa, %edx
callq 0x2180
movq 0x536a(%rip), %rdi      # 0x8ff0
leaq 0x23e5(%rip), %rsi      # 0x6072
movl $0x1, %edx
callq 0x2180
movq 0x5352(%rip), %rdi      # 0x8ff0
movl $0x6e, %esi
callq 0x2260
movq %rax, %r14
leaq 0x23e2(%rip), %rsi      # 0x6094
movl $0x2, %edx
movq %rax, %rdi
callq 0x2180
leaq 0x252f(%rip), %rsi      # 0x61f5
movl $0x1b, %edx
movq %r14, %rdi
callq 0x2180
testq %rbx, %rbx
je 0x3e14
movq %rbx, %rdi
callq 0x20d0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x2180
jmp 0x3e2e
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 0x3e04
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 0x3dfb
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 0x3dcc
addq $0x18, %r12
cmpq %r13, %r12
jne 0x3da1
leaq 0x28(%rsp), %rdi
callq 0x21e0
movl 0x14(%rsp), %ebp
jmp 0x3e38
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 0x2ae0
testb $0x5, %bpl
sete %bl
movq 0x5182(%rip), %rax      # 0x8fc8
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 0x3e9c
jmp 0x3e9c
jmp 0x3e9c
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x2ae0
jmp 0x3e9f
jmp 0x3e9c
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2200
movq %rbx, %rdi
callq 0x2270
nop