// File: /workspace/github_cpp_makefile_star2_O2/tetsuok[P]kernel-pa/kernel_pa_classify.cc
// Function: main
int KernelPAClassify(int argc, char** argv) {
  if (argc < 3) {
    fprintf(stderr, "usage: %s test_file model\n", argv[0]);
    return -1;
  }

  const char* test_file = argv[1];
  const char* model = argv[2];
  kernel::Learner learner;
  if (!learner.Load(model)) {
    LOG(ERROR) << "cannot load " << model;
    return -1;
  }

  std::ifstream ifs(test_file);
  if (!ifs) {
    LOG(ERROR) << "no such file or directory " << test_file;
    return -1;
  }

  Result result;
  unsigned int line_num = 0;
  std::string line;
  while (std::getline(ifs, line)) {
    if (line[0] == '#' || line.empty()) continue;       // ignore comments
    ++line_num;

    short label;
    fv x;
    size_t dummy = 0;
    if (!Tokenize(line.c_str(), &x, &label, &dummy)) {
      LOG(ERROR) << "cannot tokenize: " << line;
      return -1;
    }

    const short predict = learner.Predict(x);
    result.Add(label, predict);
  }

  result.Show();
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
cmpl $0x2, %edi
jle 0x27c3
movq 0x8(%rsi), %rbx
movq 0x10(%rsi), %r14
leaq 0x78(%rsp), %r15
movq %r15, %rdi
callq 0x2b5c
movq %r15, %rdi
movq %r14, %rsi
callq 0x30e0
testb %al, %al
je 0x24f8
leaq 0xd0(%rsp), %rdi
pushq $0x8
popq %rdx
movq %rbx, %rsi
callq 0x2260
movq 0xd0(%rsp), %rax
movq -0x18(%rax), %rax
testb $0x5, 0xf0(%rsp,%rax)
je 0x259b
movl $0x2, 0x30(%rsp)
movq 0x5b86(%rip), %rdi      # 0x7ff0
leaq 0x2bca(%rip), %rsi      # 0x503b
callq 0x2130
leaq 0x2bc3(%rip), %rsi      # 0x5040
movq %rax, %rdi
callq 0x2130
leaq 0x2bba(%rip), %rsi      # 0x5046
movq %rax, %rdi
callq 0x2130
leaq 0x2baf(%rip), %rsi      # 0x504a
movq %rax, %rdi
callq 0x2130
leaq 0x2b94(%rip), %rsi      # 0x503e
movq %rax, %rdi
callq 0x2130
pushq $0x44
popq %rsi
movq %rax, %rdi
callq 0x2240
leaq 0x2b9c(%rip), %rsi      # 0x5060
movq %rax, %rdi
callq 0x2130
leaq 0x2b9d(%rip), %rsi      # 0x5070
movq %rax, %rdi
callq 0x2130
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2130
leaq 0x30(%rsp), %rdi
callq 0x2858
pushq $-0x1
popq %rbx
jmp 0x2798
movl $0x2, 0xd0(%rsp)
movq 0x5ae6(%rip), %rdi      # 0x7ff0
leaq 0x2b2a(%rip), %rsi      # 0x503b
callq 0x2130
leaq 0x2b23(%rip), %rsi      # 0x5040
movq %rax, %rdi
callq 0x2130
leaq 0x2b1a(%rip), %rsi      # 0x5046
movq %rax, %rdi
callq 0x2130
leaq 0x2b0f(%rip), %rsi      # 0x504a
movq %rax, %rdi
callq 0x2130
leaq 0x2af4(%rip), %rsi      # 0x503e
movq %rax, %rdi
callq 0x2130
pushq $0x3e
popq %rsi
movq %rax, %rdi
callq 0x2240
leaq 0x2afc(%rip), %rsi      # 0x5060
movq %rax, %rdi
callq 0x2130
leaq 0x2af0(%rip), %rsi      # 0x5063
movq %rax, %rdi
callq 0x2130
movq %rax, %rdi
movq %r14, %rsi
callq 0x2130
pushq $-0x1
popq %rbx
leaq 0xd0(%rsp), %rdi
callq 0x2858
jmp 0x27a5
xorps %xmm0, %xmm0
andq $0x0, 0x20(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movaps %xmm0, 0x10(%rsp)
movb $0x0, (%rax)
xorl %ebp, %ebp
leaq 0xd0(%rsp), %r14
leaq 0x30(%rsp), %r15
leaq 0xa(%rsp), %r13
pushq $-0x1
popq %rbx
movq %r14, %rdi
movq %r15, %rsi
callq 0x2060
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2749
movq 0x30(%rsp), %rdi
cmpb $0x23, (%rdi)
je 0x25d1
cmpq $0x0, 0x38(%rsp)
je 0x25d1
andq $0x0, 0x60(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x50(%rsp)
andq $0x0, 0x70(%rsp)
leaq 0x50(%rsp), %rsi
movq %r13, %r12
movq %r13, %rdx
leaq 0x70(%rsp), %rcx
callq 0x44d0
movl %eax, %r13d
testb %al, %al
je 0x269c
leaq 0x78(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x2880
movzwl 0xa(%rsp), %ecx
movl %ecx, %edx
xorl $0x1, %edx
movl %eax, %esi
xorl $0x1, %esi
orw %dx, %si
pushq $0x8
popq %rdx
je 0x2689
movl %ecx, %esi
andl %eax, %esi
pushq $0xc
popq %rdx
cmpw $-0x1, %si
je 0x2689
movl %eax, %edx
xorl $0x1, %edx
movl %ecx, %esi
notl %esi
orw %dx, %si
pushq $0x10
popq %rdx
je 0x2685
notl %eax
xorl $0x1, %ecx
orw %ax, %cx
pushq $0x14
popq %rdx
jne 0x2731
incl 0x14(%rsp)
incl 0x10(%rsp,%rdx)
movl 0x10(%rsp), %ebp
incl %ebp
movl %ebp, 0x10(%rsp)
jmp 0x2731
movl $0x2, 0xc(%rsp)
movq 0x5945(%rip), %rdi      # 0x7ff0
leaq 0x2989(%rip), %rsi      # 0x503b
callq 0x2130
movq %rax, %rdi
leaq 0x297f(%rip), %rsi      # 0x5040
callq 0x2130
movq %rax, %rdi
leaq 0x2976(%rip), %rsi      # 0x5046
callq 0x2130
movq %rax, %rdi
leaq 0x296b(%rip), %rsi      # 0x504a
callq 0x2130
movq %rax, %rdi
leaq 0x2950(%rip), %rsi      # 0x503e
callq 0x2130
movq %rax, %rdi
pushq $0x53
popq %rsi
callq 0x2240
movq %rax, %rdi
leaq 0x2958(%rip), %rsi      # 0x5060
callq 0x2130
movq %rax, %rdi
leaq 0x2974(%rip), %rsi      # 0x508b
callq 0x2130
movq %rax, %rdi
movq %r15, %rsi
callq 0x2120
leaq 0xc(%rsp), %rdi
callq 0x2858
leaq 0x50(%rsp), %rdi
callq 0x2b28
testb %r13b, %r13b
movq %r12, %r13
jne 0x25d1
jmp 0x278e
movl %ebp, %esi
subl 0x14(%rsp), %esi
cvtsi2sd %rsi, %xmm0
mulsd 0x28ac(%rip), %xmm0     # 0x5008
movl %ebp, %eax
cvtsi2sd %rax, %xmm1
divsd %xmm1, %xmm0
movl 0x18(%rsp), %ecx
movl 0x1c(%rsp), %r8d
movl 0x20(%rsp), %r9d
movl 0x24(%rsp), %eax
movl %eax, (%rsp)
leaq 0x294b(%rip), %rdi      # 0x50ce
movl %ebp, %edx
movb $0x1, %al
callq 0x2030
xorl %ebx, %ebx
leaq 0x30(%rsp), %rdi
callq 0x20c0
leaq 0xd0(%rsp), %rdi
callq 0x2080
leaq 0x78(%rsp), %rdi
callq 0x2b8e
movl %ebx, %eax
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x5806(%rip), %rax      # 0x7fd0
movq (%rax), %rdi
movq (%rsi), %rdx
leaq 0x2849(%rip), %rsi      # 0x5020
xorl %eax, %eax
callq 0x21c0
pushq $-0x1
popq %rbx
jmp 0x27af
jmp 0x27e5
movq %rax, %rbx
jmp 0x27f9
jmp 0x2805
movq %rax, %rbx
leaq 0xc(%rsp), %rdi
callq 0x2858
leaq 0x50(%rsp), %rdi
callq 0x2b28
jmp 0x282e
movq %rax, %rbx
jmp 0x2845
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2858
jmp 0x2838
movq %rax, %rbx
leaq 0xd0(%rsp), %rdi
callq 0x2858
jmp 0x2845
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x20c0
leaq 0xd0(%rsp), %rdi
callq 0x2080
leaq 0x78(%rsp), %rdi
callq 0x2b8e
movq %rbx, %rdi
callq 0x2250
nop