// File: /workspace/github_cpp_makefile_star2_O2/sile[P]mphf/test_mphf.cc
// Function: main
int main(int argc, char** argv) {
  if(argc != 2) {
    std::cerr << "Usage: test_mphf <index>" << std::endl;
    return 1;
  }

  const char* index_filepath = argv[1];
  
  MPHF::Hash hash(index_filepath);
  if(!hash) {
    std::cerr << "Can't open file: " << index_filepath << std::endl;
    return 1;
  }
    
  std::string line;
  std::vector<unsigned> hash_values;

  std::cerr << "= Read keyset and calculate hash values:" << std::endl;
  while(std::getline(std::cin, line)) 
    hash_values.push_back(hash.mphf(line.c_str()));
  std::cerr << "  == read key count: " << hash_values.size() << std::endl;
  std::cerr << "DONE" << std::endl;
  
  std::cerr << "= Uniqueness check: " << std::endl;
  std::sort(hash_values.begin(), hash_values.end());
  std::vector<unsigned>::const_iterator end = std::unique(hash_values.begin(), hash_values.end());
  if(end == hash_values.end()) {
    std::cerr << "  == OK" << std::endl;
  } else {
    unsigned dup_rate = 100 - (((end-hash_values.begin())*100)/hash_values.size());
    std::cerr << "  == failure: duplicate rate is " << dup_rate << "%" << std::endl;
  }
  std::cerr << "DONE" << std::endl;

  std::cerr << "= Minimalness check: " << std::endl;
  if(hash_values.back() == hash_values.size()-1)
    std::cerr << "  == OK" << std::endl;
  else
    std::cerr << "  == failure" << std::endl;
  std::cerr << "DONE" << std::endl;

  return 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x80, %rsp
cmpl $0x2, %edi
jne 0x137d
movq 0x8(%rsi), %rbx
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x15ea
cmpq $-0x1, 0x8(%r14)
je 0x1487
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movq 0x2cd7(%rip), %rdi      # 0x3ff0
leaq 0xd0f(%rip), %rsi       # 0x202f
callq 0x1100
movq %rax, %rdi
callq 0x1090
movq 0x2ca4(%rip), %rbx      # 0x3fd8
leaq 0x28(%rsp), %r14
leaq 0x48(%rsp), %r15
movq %rsp, %r12
leaq 0x24(%rsp), %r13
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1030
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x13a0
movq 0x28(%rsp), %rsi
movq %r15, %rdi
callq 0x15c4
movl %eax, 0x24(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x1982
jmp 0x1346
movq 0x2c6c(%rip), %rdi      # 0x3ff0
leaq 0xc79(%rip), %rsi       # 0x2004
callq 0x1100
movq %rax, %rdi
callq 0x1090
pushq $0x1
popq %rbx
jmp 0x157b
movq 0x2c49(%rip), %rdi      # 0x3ff0
leaq 0xcaa(%rip), %rsi       # 0x2058
callq 0x1100
movq 0x8(%rsp), %rsi
subq (%rsp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x10c0
movq %rax, %rdi
callq 0x1090
movq 0x2c19(%rip), %rdi      # 0x3ff0
leaq 0xc90(%rip), %rsi       # 0x206e
callq 0x1100
movq %rax, %rdi
callq 0x1090
movq 0x2bfe(%rip), %rdi      # 0x3ff0
leaq 0xc7a(%rip), %rsi       # 0x2073
callq 0x1100
movq %rax, %rdi
callq 0x1090
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x1af7
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
callq 0x1ef7
movq %rax, %rbx
movq 0x8(%rsp), %r14
cmpq %r14, %rax
je 0x14b5
movq (%rsp), %r15
movq 0x2bb2(%rip), %rdi      # 0x3ff0
leaq 0xc4b(%rip), %rsi       # 0x2090
callq 0x1100
movq %rax, %rdi
subq %r15, %r14
sarq $0x2, %r14
subq %r15, %rbx
shrq $0x2, %rbx
imulq $0x64, %rbx, %rax
xorl %edx, %edx
divq %r14
pushq $0x64
popq %rsi
subl %eax, %esi
callq 0x10c0
leaq 0xc3c(%rip), %rsi       # 0x20b1
movq %rax, %rdi
callq 0x1100
movq %rax, %rdi
callq 0x1090
jmp 0x14d0
movq 0x2b62(%rip), %rdi      # 0x3ff0
leaq 0xb88(%rip), %rsi       # 0x201d
callq 0x1100
movq %rax, %rdi
movq %rbx, %rsi
callq 0x1100
movq %rax, %rdi
callq 0x1090
pushq $0x1
popq %rbx
jmp 0x1571
movq 0x2b34(%rip), %rdi      # 0x3ff0
leaq 0xbc5(%rip), %rsi       # 0x2088
callq 0x1100
movq %rax, %rdi
callq 0x1090
movq 0x2b19(%rip), %rdi      # 0x3ff0
leaq 0xb90(%rip), %rsi       # 0x206e
callq 0x1100
movq %rax, %rdi
callq 0x1090
movq 0x2afe(%rip), %rdi      # 0x3ff0
leaq 0xbba(%rip), %rsi       # 0x20b3
callq 0x1100
movq %rax, %rdi
callq 0x1090
movq 0x8(%rsp), %rax
movl -0x4(%rax), %ecx
subq (%rsp), %rax
sarq $0x2, %rax
decq %rax
cmpq %rcx, %rax
leaq 0xb65(%rip), %rax       # 0x2088
leaq 0xb9f(%rip), %rsi       # 0x20c9
cmoveq %rax, %rsi
movq 0x2abb(%rip), %rdi      # 0x3ff0
callq 0x1100
movq %rax, %rdi
callq 0x1090
movq 0x2aa7(%rip), %rdi      # 0x3ff0
leaq 0xb1e(%rip), %rsi       # 0x206e
callq 0x1100
movq %rax, %rdi
callq 0x1090
movq %rsp, %rdi
callq 0x194e
leaq 0x28(%rsp), %rdi
callq 0x1080
xorl %ebx, %ebx
leaq 0x48(%rsp), %rdi
callq 0x1910
movl %ebx, %eax
addq $0x80, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
jmp 0x159d
movq %rax, %rbx
jmp 0x15b2
jmp 0x159d
jmp 0x159d
jmp 0x159d
jmp 0x159d
movq %rax, %rbx
movq %rsp, %rdi
callq 0x194e
leaq 0x28(%rsp), %rdi
callq 0x1080
leaq 0x48(%rsp), %rdi
callq 0x1910
movq %rbx, %rdi
callq 0x1160