// File: epfml[P]Bi-Sent2Vec/src/fasttext.cc
// Function: fasttext::FastText::test(std::istream&, int)
void FastText::test(std::istream& in, int32_t k) {
  int32_t nexamples = 0, nlabels = 0;
  double precision = 0.0;
  std::vector<int32_t> line, labels;

  while (in.peek() != EOF) {
    dict_->getLine(in, line, labels, model_->rng);
    if (labels.size() > 0 && line.size() > 0) {
      std::vector<std::pair<real, int32_t>> modelPredictions;
      model_->predict(line, k, modelPredictions);
      for (auto it = modelPredictions.cbegin(); it != modelPredictions.cend(); it++) {
        if (std::find(labels.begin(), labels.end(), it->second) != labels.end()) {
          precision += 1.0;
        }
      }
      nexamples++;
      nlabels += labels.size();
    }
  }
  std::cout << "N" << "\t" << nexamples << std::endl;
  std::cout << std::setprecision(3);
  std::cout << "P@" << k << "\t" << precision / (k * nexamples) << std::endl;
  std::cout << "R@" << k << "\t" << precision / nlabels << std::endl;
  std::cerr << "Number of examples: " << nexamples << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
leaq -0x40(%rbp), %rdi
callq 0xe440
leaq -0x58(%rbp), %rdi
callq 0xe440
movq -0x10(%rbp), %rdi
callq 0x5190
movl %eax, -0xcc(%rbp)
jmp 0x2be6a
movl -0xcc(%rbp), %eax
cmpl $-0x1, %eax
je 0x2c084
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
callq 0x34050
movq -0xc8(%rbp), %rdi
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
addq $0x60, %rdi
callq 0x34630
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movq %rax, %r8
addq $0x110, %r8             # imm = 0x110
leaq -0x40(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0xac80
jmp 0x2bed2
leaq -0x58(%rbp), %rdi
callq 0xed50
cmpq $0x0, %rax
jbe 0x2c07f
leaq -0x40(%rbp), %rdi
callq 0xed50
cmpq $0x0, %rax
jbe 0x2c07f
leaq -0x80(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x34cf0
movq -0xc8(%rbp), %rdi
addq $0x60, %rdi
callq 0x34630
movq -0xe8(%rbp), %rcx
movq %rax, %rdi
movl -0x14(%rbp), %edx
leaq -0x40(%rbp), %rsi
callq 0x22950
jmp 0x2bf30
leaq -0x80(%rbp), %rdi
callq 0x34d10
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x34d80
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x34d40
testb $0x1, %al
jne 0x2bf6c
jmp 0x2c057
leaq -0x58(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0xea10
movq -0xf8(%rbp), %rdi
movq %rax, -0xa0(%rbp)
callq 0xea40
movq %rax, -0xa8(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x34e00
movq %rax, %rdx
addq $0x4, %rdx
movq -0xa0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x34db0
movq %rax, -0xf0(%rbp)
jmp 0x2bfc5
movq -0xf0(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xea40
movq %rax, -0xb0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xf6e0
testb $0x1, %al
jne 0x2bffc
jmp 0x2c03b
movsd 0x168b4(%rip), %xmm0    # 0x428b8
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x2c03b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x2c297
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x34e60
jmp 0x2c297
jmp 0x2c03d
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
callq 0x34e20
movq %rax, -0xb8(%rbp)
jmp 0x2bf40
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xed50
movq %rax, %rcx
movslq -0x1c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x1c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x34e60
jmp 0x2be59
movq 0x32f2d(%rip), %rdi     # 0x5efb8
leaq 0x17751(%rip), %rsi     # 0x437e3
callq 0x5420
movq %rax, -0x100(%rbp)
jmp 0x2c0a0
movq -0x100(%rbp), %rdi
leaq 0x17737(%rip), %rsi     # 0x437e5
callq 0x5420
movq %rax, -0x108(%rbp)
jmp 0x2c0bc
movq -0x108(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x5770
movq %rax, -0x110(%rbp)
jmp 0x2c0d4
movq -0x110(%rbp), %rdi
movq 0x32eae(%rip), %rsi     # 0x5ef90
callq 0x5460
jmp 0x2c0e9
movl $0x3, %edi
callq 0x214f0
movl %eax, -0x114(%rbp)
jmp 0x2c0fb
movl -0x114(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %esi
movq 0x32ea4(%rip), %rdi     # 0x5efb8
callq 0x56a0
jmp 0x2c11b
movq 0x32e96(%rip), %rdi     # 0x5efb8
leaq 0x176be(%rip), %rsi     # 0x437e7
callq 0x5420
movq %rax, -0x120(%rbp)
jmp 0x2c137
movq -0x120(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x5770
movq %rax, -0x128(%rbp)
jmp 0x2c14f
movq -0x128(%rbp), %rdi
leaq 0x17688(%rip), %rsi     # 0x437e5
callq 0x5420
movq %rax, -0x130(%rbp)
jmp 0x2c16b
movq -0x130(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
movl -0x14(%rbp), %eax
movl -0x18(%rbp), %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x5840
movq %rax, -0x138(%rbp)
jmp 0x2c196
movq -0x138(%rbp), %rdi
movq 0x32dec(%rip), %rsi     # 0x5ef90
callq 0x5460
jmp 0x2c1ab
movq 0x32e06(%rip), %rdi     # 0x5efb8
leaq 0x17631(%rip), %rsi     # 0x437ea
callq 0x5420
movq %rax, -0x140(%rbp)
jmp 0x2c1c7
movq -0x140(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x5770
movq %rax, -0x148(%rbp)
jmp 0x2c1df
movq -0x148(%rbp), %rdi
leaq 0x175f8(%rip), %rsi     # 0x437e5
callq 0x5420
movq %rax, -0x150(%rbp)
jmp 0x2c1fb
movq -0x150(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x5840
movq %rax, -0x158(%rbp)
jmp 0x2c21e
movq -0x158(%rbp), %rdi
movq 0x32d64(%rip), %rsi     # 0x5ef90
callq 0x5460
jmp 0x2c233
movq 0x32db6(%rip), %rdi     # 0x5eff0
leaq 0x175ac(%rip), %rsi     # 0x437ed
callq 0x5420
movq %rax, -0x160(%rbp)
jmp 0x2c24f
movq -0x160(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x5770
movq %rax, -0x168(%rbp)
jmp 0x2c267
movq -0x168(%rbp), %rdi
movq 0x32d1b(%rip), %rsi     # 0x5ef90
callq 0x5460
jmp 0x2c27c
leaq -0x58(%rbp), %rdi
callq 0xe530
leaq -0x40(%rbp), %rdi
callq 0xe530
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0xe530
leaq -0x40(%rbp), %rdi
callq 0xe530
movq -0x60(%rbp), %rdi
callq 0x57a0
nopw %cs:(%rax,%rax)