// File: VanAndelInstitute[P]intent/src/seq_tools.cpp
// Function: v2_corrected_bc(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, int)
std::string v2_corrected_bc(std::string bc, std::set<std::string> whitelist, int maxdist) {
  int mindist = 999;
  std::string best_candidate = "";
  bool ambig = false;
  for(auto cand : whitelist) {
    int dist = 999;
    if(((bc.length() - cand.length())^2) < 4)
      dist = levenshteinDistance(bc, cand, maxdist);
    if(dist < mindist) {
      mindist = dist;
      best_candidate = cand;
      ambig = false;
    } else if (dist == mindist) {
      ambig = true;
    }
  }
  if(mindist <= maxdist) {
    return(best_candidate);
  } else {
    return("");
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdx, -0xc8(%rbp)
movq %rsi, -0xc0(%rbp)
movq %rdi, -0xb8(%rbp)
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl $0x3e7, -0x20(%rbp)     # imm = 0x3E7
leaq -0x41(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x8980
movq -0xa8(%rbp), %rdx
leaq 0x421b(%rip), %rsi      # 0x6f4d9
leaq -0x40(%rbp), %rdi
callq 0x35e90
jmp 0x6b2c9
leaq -0x41(%rbp), %rdi
callq 0x85e0
movq -0xc8(%rbp), %rax
movb $0x0, -0x55(%rbp)
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rdi
callq 0x6c730
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
callq 0x6c430
movq %rax, -0x70(%rbp)
leaq -0x68(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x6c400
testb $0x1, %al
jne 0x6b311
jmp 0x6b437
leaq -0x68(%rbp), %rdi
callq 0x6c760
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x8280
jmp 0x6b32b
movq -0xc0(%rbp), %rdi
movl $0x3e7, -0x94(%rbp)     # imm = 0x3E7
callq 0x8850
movq %rax, -0xd0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x8850
movq %rax, %rcx
movq -0xd0(%rbp), %rax
subq %rcx, %rax
xorq $0x2, %rax
cmpq $0x4, %rax
jae 0x6b3e0
movq -0xc0(%rbp), %rdi
movslq -0x1c(%rbp), %rdx
leaq -0x90(%rbp), %rsi
callq 0x6b4f0
movl %eax, -0xd4(%rbp)
jmp 0x6b38a
movl -0xd4(%rbp), %eax
movl %eax, -0x94(%rbp)
jmp 0x6b3e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x85e0
jmp 0x6b4de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x6b4d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x8a98
jmp 0x6b4d5
movl -0x94(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x6b40c
movl -0x94(%rbp), %eax
movl %eax, -0x20(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x8070
jmp 0x6b406
movb $0x0, -0x55(%rbp)
jmp 0x6b41d
movl -0x94(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x6b41b
movb $0x1, -0x55(%rbp)
jmp 0x6b41d
leaq -0x90(%rbp), %rdi
callq 0x8a98
leaq -0x68(%rbp), %rdi
callq 0x6c780
jmp 0x6b2fb
movl -0x20(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jg 0x6b45b
movq -0xb8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x8370
movl $0x1, -0x98(%rbp)
jmp 0x6b4bc
leaq -0x99(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x8980
movq -0xb8(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x4056(%rip), %rsi      # 0x6f4d9
callq 0x35e90
jmp 0x6b48a
leaq -0x99(%rbp), %rdi
callq 0x85e0
movl $0x1, -0x98(%rbp)
jmp 0x6b4bc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x99(%rbp), %rdi
callq 0x85e0
jmp 0x6b4d5
leaq -0x40(%rbp), %rdi
callq 0x8a98
movq -0xb0(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x8a98
movq -0x50(%rbp), %rdi
callq 0x8970
nopw (%rax,%rax)