// File: ddu1[P]polarizedtext/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);
    dict_->addNgrams(line, args_->wordNgrams);
    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 << std::setprecision(3);
  std::cout << "P@" << k << ": " << precision / (k * nexamples) << std::endl;
  std::cout << "R@" << k << ": " << precision / nlabels << std::endl;
  std::cout << "Number of examples: " << nexamples << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
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 0x9e40
leaq -0x58(%rbp), %rdi
callq 0x9e40
movq -0x10(%rbp), %rdi
callq 0x40e0
movl %eax, -0xcc(%rbp)
jmp 0x1d7fa
movl -0xcc(%rbp), %eax
cmpl $-0x1, %eax
je 0x1da4f
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
callq 0x1ff50
movq -0xc8(%rbp), %rdi
movq %rax, -0xe0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
addq $0x40, %rdi
callq 0x202d0
movq -0xe0(%rbp), %rdi
movq -0xd8(%rbp), %rsi
movq %rax, %r8
addq $0x108, %r8             # imm = 0x108
leaq -0x40(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x8090
jmp 0x1d862
movq -0xc8(%rbp), %rdi
addq $0x10, %rdi
callq 0x1ff50
movq -0xc8(%rbp), %rdi
movq %rax, -0xe8(%rbp)
callq 0xa170
movq -0xe8(%rbp), %rdi
movl 0x84(%rax), %edx
leaq -0x40(%rbp), %rsi
callq 0x7f70
jmp 0x1d89d
leaq -0x58(%rbp), %rdi
callq 0xad50
cmpq $0x0, %rax
jbe 0x1da4a
leaq -0x40(%rbp), %rdi
callq 0xad50
cmpq $0x0, %rax
jbe 0x1da4a
leaq -0x80(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x20500
movq -0xc8(%rbp), %rdi
addq $0x40, %rdi
callq 0x202d0
movq -0xf0(%rbp), %rcx
movq %rax, %rdi
movl -0x14(%rbp), %edx
leaq -0x40(%rbp), %rsi
callq 0x14cf0
jmp 0x1d8fb
leaq -0x80(%rbp), %rdi
callq 0x20520
movq %rax, -0x88(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x20590
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x20550
testb $0x1, %al
jne 0x1d937
jmp 0x1da22
leaq -0x58(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0xa660
movq -0x100(%rbp), %rdi
movq %rax, -0xa0(%rbp)
callq 0xa690
movq %rax, -0xa8(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x20610
movq %rax, %rdx
addq $0x4, %rdx
movq -0xa0(%rbp), %rdi
movq -0xa8(%rbp), %rsi
callq 0x205c0
movq %rax, -0xf8(%rbp)
jmp 0x1d990
movq -0xf8(%rbp), %rax
movq %rax, -0x98(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xa690
movq %rax, -0xb0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0xe8a0
testb $0x1, %al
jne 0x1d9c7
jmp 0x1da06
movsd 0xbbf9(%rip), %xmm0     # 0x295c8
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
jmp 0x1da06
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x1dbfd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x20670
jmp 0x1dbfd
jmp 0x1da08
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
callq 0x20630
movq %rax, -0xb8(%rbp)
jmp 0x1d90b
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
leaq -0x58(%rbp), %rdi
callq 0xad50
movq %rax, %rcx
movslq -0x1c(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x1c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x20670
jmp 0x1d7e9
movl $0x3, %edi
callq 0x138c0
movl %eax, -0x104(%rbp)
jmp 0x1da61
movl -0x104(%rbp), %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %esi
movq 0x1e546(%rip), %rdi     # 0x3bfc0
callq 0x44f0
jmp 0x1da81
movq 0x1e538(%rip), %rdi     # 0x3bfc0
leaq 0xc339(%rip), %rsi      # 0x29dc8
callq 0x42e0
movq %rax, -0x110(%rbp)
jmp 0x1da9d
movq -0x110(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x4580
movq %rax, -0x118(%rbp)
jmp 0x1dab5
movq -0x118(%rbp), %rdi
leaq 0xc2ff(%rip), %rsi      # 0x29dc2
callq 0x42e0
movq %rax, -0x120(%rbp)
jmp 0x1dad1
movq -0x120(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
movl -0x14(%rbp), %eax
movl -0x18(%rbp), %ecx
imull %ecx, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x4620
movq %rax, -0x128(%rbp)
jmp 0x1dafc
movq -0x128(%rbp), %rdi
movq 0x1e48e(%rip), %rsi     # 0x3bf98
callq 0x4310
jmp 0x1db11
movq 0x1e4a8(%rip), %rdi     # 0x3bfc0
leaq 0xc2ac(%rip), %rsi      # 0x29dcb
callq 0x42e0
movq %rax, -0x130(%rbp)
jmp 0x1db2d
movq -0x130(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x4580
movq %rax, -0x138(%rbp)
jmp 0x1db45
movq -0x138(%rbp), %rdi
leaq 0xc26f(%rip), %rsi      # 0x29dc2
callq 0x42e0
movq %rax, -0x140(%rbp)
jmp 0x1db61
movq -0x140(%rbp), %rdi
movsd -0x28(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
callq 0x4620
movq %rax, -0x148(%rbp)
jmp 0x1db84
movq -0x148(%rbp), %rdi
movq 0x1e406(%rip), %rsi     # 0x3bf98
callq 0x4310
jmp 0x1db99
movq 0x1e420(%rip), %rdi     # 0x3bfc0
leaq 0xc227(%rip), %rsi      # 0x29dce
callq 0x42e0
movq %rax, -0x150(%rbp)
jmp 0x1dbb5
movq -0x150(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x4580
movq %rax, -0x158(%rbp)
jmp 0x1dbcd
movq -0x158(%rbp), %rdi
movq 0x1e3bd(%rip), %rsi     # 0x3bf98
callq 0x4310
jmp 0x1dbe2
leaq -0x58(%rbp), %rdi
callq 0xa040
leaq -0x40(%rbp), %rdi
callq 0xa040
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0xa040
leaq -0x40(%rbp), %rdi
callq 0xa040
movq -0x60(%rbp), %rdi
callq 0x45b0
nopl (%rax,%rax)