// File: tetsuok[P]kernel-pa/learner.cc
// Function: kernel::Learner::Load(char const*)
bool Learner::Load(const char* filename) {
  std::ifstream bifs(filename, std::ios::in | std::ios::binary);
  if (!bifs) {
    LOG(ERROR) << "Failed to load " << filename;
    return false;
  }

  bifs.read(reinterpret_cast<char *>(&C_), sizeof(C_));
  bifs.read(reinterpret_cast<char *>(&d_), sizeof(d_));

  std::size_t alpha_size;
  bifs.read(reinterpret_cast<char *>(&alpha_size), sizeof(alpha_size));
  alpha_.resize(alpha_size);
  bifs.read(reinterpret_cast<char *>(&alpha_[0]), alpha_.size() * sizeof(float));

  std::size_t sv_size;
  bifs.read(reinterpret_cast<char *>(&sv_size), sizeof(sv_size));
  sv_index_.resize(sv_size);

  for (fv& x : sv_index_) {
    std::size_t x_size;
    bifs.read(reinterpret_cast<char *>(&x_size), sizeof(x_size));
    x.resize(x_size);
    for (auto& p : x) {
      bifs.read(reinterpret_cast<char *>(&p.first), sizeof(p.first));
      bifs.read(reinterpret_cast<char *>(&p.second), sizeof(p.second));
    }
  }

  margin_.resize(alpha_.size(), 0.0f);

  bifs.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, -0x2a8(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x2a0(%rbp)
movl $0x8, %edi
movl $0x4, %esi
callq 0x5e50
movq -0x2a0(%rbp), %rsi
movl %eax, %edx
leaq -0x220(%rbp), %rdi
callq 0x22c0
movq -0x220(%rbp), %rax
movq -0x18(%rax), %rax
leaq -0x220(%rbp,%rax), %rdi
callq 0x20e0
movb %al, -0x295(%rbp)
jmp 0x4ccd
movb -0x295(%rbp), %al
testb $0x1, %al
jne 0x4cdc
jmp 0x4e62
leaq -0x230(%rbp), %rdi
movl $0x2, %esi
callq 0x2e30
jmp 0x4cef
callq 0x2e60
movq %rax, -0x2b0(%rbp)
jmp 0x4cfd
movq -0x2b0(%rbp), %rdi
leaq 0x6320(%rip), %rsi      # 0xb02b
callq 0x2150
movq %rax, -0x2b8(%rbp)
jmp 0x4d19
movq -0x2b8(%rbp), %rdi
leaq 0x6309(%rip), %rsi      # 0xb030
callq 0x2150
movq %rax, -0x2c0(%rbp)
jmp 0x4d35
movq -0x2c0(%rbp), %rdi
leaq 0x62f3(%rip), %rsi      # 0xb036
callq 0x2150
movq %rax, -0x2c8(%rbp)
jmp 0x4d51
movq -0x2c8(%rbp), %rdi
leaq 0x63b5(%rip), %rsi      # 0xb114
callq 0x2150
movq %rax, -0x2d0(%rbp)
jmp 0x4d6d
movq -0x2d0(%rbp), %rdi
leaq 0x62b3(%rip), %rsi      # 0xb02e
callq 0x2150
movq %rax, -0x2d8(%rbp)
jmp 0x4d89
movq -0x2d8(%rbp), %rdi
movl $0x4a, %esi
callq 0x22a0
movq %rax, -0x2e0(%rbp)
jmp 0x4da3
movq -0x2e0(%rbp), %rdi
leaq 0x629f(%rip), %rsi      # 0xb050
callq 0x2150
movq %rax, -0x2e8(%rbp)
jmp 0x4dbf
movq -0x2e8(%rbp), %rdi
leaq 0x63b2(%rip), %rsi      # 0xb17f
callq 0x2150
movq %rax, -0x2f0(%rbp)
jmp 0x4ddb
movq -0x2f0(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2150
movq %rax, -0x2f8(%rbp)
jmp 0x4df4
movq -0x2f8(%rbp), %rsi
leaq -0x230(%rbp), %rdi
callq 0x2e50
jmp 0x4e09
leaq -0x230(%rbp), %rdi
callq 0x2e70
movb $0x0, -0x1(%rbp)
movl $0x1, -0x234(%rbp)
jmp 0x50fb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
jmp 0x5115
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x228(%rbp)
movl %eax, -0x22c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x2e70
jmp 0x5115
movq -0x2a8(%rbp), %rsi
addq $0x8, %rsi
leaq -0x220(%rbp), %rdi
movl $0x4, %edx
callq 0x21d0
jmp 0x4e80
movq -0x2a8(%rbp), %rsi
addq $0xc, %rsi
leaq -0x220(%rbp), %rdi
movl $0x4, %edx
callq 0x21d0
jmp 0x4e9e
leaq -0x220(%rbp), %rdi
leaq -0x240(%rbp), %rsi
movl $0x8, %edx
callq 0x21d0
jmp 0x4eb8
movq -0x2a8(%rbp), %rdi
addq $0x10, %rdi
movq -0x240(%rbp), %rsi
callq 0x5e70
jmp 0x4ed1
movq -0x2a8(%rbp), %rdi
addq $0x10, %rdi
movq %rdi, -0x308(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x3350
movq -0x308(%rbp), %rdi
movq %rax, -0x300(%rbp)
callq 0x3220
movq -0x300(%rbp), %rsi
movq %rax, %rdx
shlq $0x2, %rdx
leaq -0x220(%rbp), %rdi
callq 0x21d0
jmp 0x4f1b
leaq -0x220(%rbp), %rdi
leaq -0x248(%rbp), %rsi
movl $0x8, %edx
callq 0x21d0
jmp 0x4f35
movq -0x2a8(%rbp), %rdi
addq $0x28, %rdi
movq -0x248(%rbp), %rsi
callq 0x5f00
jmp 0x4f4e
movq -0x2a8(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x250(%rbp)
movq -0x250(%rbp), %rdi
callq 0x5f90
movq %rax, -0x258(%rbp)
movq -0x250(%rbp), %rdi
callq 0x5fc0
movq %rax, -0x260(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x5ff0
testb $0x1, %al
jne 0x4fa2
jmp 0x509f
leaq -0x258(%rbp), %rdi
callq 0x6030
movq %rax, -0x268(%rbp)
leaq -0x220(%rbp), %rdi
leaq -0x270(%rbp), %rsi
movl $0x8, %edx
callq 0x21d0
jmp 0x4fcf
movq -0x268(%rbp), %rdi
movq -0x270(%rbp), %rsi
callq 0x6050
jmp 0x4fe4
movq -0x268(%rbp), %rax
movq %rax, -0x278(%rbp)
movq -0x278(%rbp), %rdi
callq 0x60e0
movq %rax, -0x280(%rbp)
movq -0x278(%rbp), %rdi
callq 0x6110
movq %rax, -0x288(%rbp)
leaq -0x280(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x6140
testb $0x1, %al
jne 0x5031
jmp 0x508c
leaq -0x280(%rbp), %rdi
callq 0x6180
movq %rax, -0x290(%rbp)
movq -0x290(%rbp), %rsi
leaq -0x220(%rbp), %rdi
movl $0x4, %edx
callq 0x21d0
jmp 0x505e
movq -0x290(%rbp), %rsi
addq $0x4, %rsi
leaq -0x220(%rbp), %rdi
movl $0x4, %edx
callq 0x21d0
jmp 0x507c
jmp 0x507e
leaq -0x280(%rbp), %rdi
callq 0x61a0
jmp 0x5018
jmp 0x508e
leaq -0x258(%rbp), %rdi
callq 0x61c0
jmp 0x4f86
movq -0x2a8(%rbp), %rdi
movq %rdi, %rax
addq $0x40, %rax
movq %rax, -0x310(%rbp)
addq $0x10, %rdi
callq 0x3220
movq -0x310(%rbp), %rdi
movq %rax, %rsi
movl $0x0, -0x294(%rbp)
leaq -0x294(%rbp), %rdx
callq 0x61e0
jmp 0x50df
leaq -0x220(%rbp), %rdi
callq 0x2070
jmp 0x50ed
movb $0x1, -0x1(%rbp)
movl $0x1, -0x234(%rbp)
leaq -0x220(%rbp), %rdi
callq 0x2090
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x310, %rsp            # imm = 0x310
popq %rbp
retq
leaq -0x220(%rbp), %rdi
callq 0x2090
movq -0x228(%rbp), %rdi
callq 0x22b0
nopl (%rax)