// File: luooofan[P]hblzbd_compiler/src/Pass/allocate_register.cpp
// Function: RegAlloc::ValidAdjacentSet(int, std::unordered_map<int, std::unordered_set<int, std::hash<int>, std::equal_to<int>, std::allocator<int>>, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, std::unordered_set<int, std::hash<int>, std::equal_to<int>, std::allocator<int>>>>>&, std::vector<int, std::allocator<int>>&, std::unordered_set<int, std::hash<int>, std::equal_to<int>, std::allocator<int>>&)
RegAlloc::WorkList RegAlloc::ValidAdjacentSet(RegId reg, AdjList &adj_list, std::vector<RegId> &select_stack,
                                              WorkList &coalesced_nodes) {
  WorkList valid_adjacent = adj_list[reg];
  // outfile << valid_adjacent.size() << std::endl;
  for (auto iter = valid_adjacent.begin(); iter != valid_adjacent.end();) {
    // outfile << *iter << std::endl;
    // NOTE: erase
    if (std::find(select_stack.begin(), select_stack.end(), *iter) == select_stack.end() &&
        coalesced_nodes.find(*iter) == coalesced_nodes.end()) {
      ++iter;
    } else {
      iter = valid_adjacent.erase(iter);
    }
    // dbg_print_worklist(valid_adjacent, outfile);
  }
  return valid_adjacent;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0x38(%rsp)
movq %rdi, %rax
movq %rax, 0x30(%rsp)
movq %rdi, 0xd0(%rsp)
movq %rsi, 0xc8(%rsp)
movl %edx, 0xc4(%rsp)
movq %rcx, 0xb8(%rsp)
movq %r8, 0xb0(%rsp)
movq %r9, 0xa8(%rsp)
movb $0x0, 0xa7(%rsp)
movq 0xb8(%rsp), %rdi
leaq 0xc4(%rsp), %rsi
callq 0x6ed60
movq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x6ed90
movq 0x38(%rsp), %rdi
callq 0x6ec90
movq %rax, 0x98(%rsp)
movq 0x38(%rsp), %rdi
callq 0x6ecc0
movq %rax, 0x90(%rsp)
leaq 0x98(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x6ecf0
testb $0x1, %al
jne 0x69a7f
jmp 0x69bde
movq 0xb0(%rsp), %rdi
callq 0x1fc30
movq %rax, 0x80(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x1f470
movq %rax, 0x78(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x6ed10
movq %rax, %rdx
movq 0x80(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x6edc0
movq %rax, 0x28(%rsp)
jmp 0x69acf
movq 0x28(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x1f470
movq %rax, 0x60(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x3a3f0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x27(%rsp)
jne 0x69b0f
jmp 0x69b6c
movq 0xa8(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x6ed10
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x6ee40
movq %rax, 0x18(%rsp)
jmp 0x69b3d
movq 0x18(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x6ecc0
movq %rax, 0x50(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x6ee20
movb %al, 0x27(%rsp)
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0x69b76
jmp 0x69b9f
leaq 0x98(%rsp), %rdi
callq 0x6ed30
jmp 0x69bd9
movq 0x38(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x70(%rsp)
movl %eax, 0x6c(%rsp)
callq 0x6eeb0
jmp 0x69c07
movq 0x38(%rsp), %rdi
movq 0x98(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rsi
callq 0x6ee70
movq %rax, 0x8(%rsp)
jmp 0x69bc2
movq 0x8(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
movq %rax, 0x98(%rsp)
jmp 0x69a4f
movb $0x1, 0xa7(%rsp)
testb $0x1, 0xa7(%rsp)
jne 0x69bfa
movq 0x38(%rsp), %rdi
callq 0x6eeb0
movq 0x30(%rsp), %rax
addq $0xd8, %rsp
retq
movq 0x70(%rsp), %rdi
callq 0x8670
nopw %cs:(%rax,%rax)