// File: /workspace/github_cpp_makefile_star2_O2/luooofan[P]hblzbd_compiler/src/Pass/loop_invariant_extrapolation.cpp
// Function: check3(int, std::vector<std::vector<int, std::allocator<int>>, std::allocator<std::vector<int, std::allocator<int>>>>, std::vector<int, std::allocator<int>>, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::map<int, IRBasicBlock*, std::less<int>, std::allocator<std::pair<int const, IRBasicBlock*>>>, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>)
bool check3(int enter, vector<vector<int> > to, vector<int> out, int def, string name, map<int, IRBasicBlock*> id_bb,
            vector<pair<int, int> > use)  // 这个入口节点直接用新建的那个基本块，好写
// enter用新建的那个空基本块作为入口，to就是图，out是出口节点，不能出去，因为有check2，所以def只会有1次，
//所以这里def是int，然后x的use情况
{
  queue<int> qqq;
  set<int> vis;
  qqq.push(enter);
  while (!qqq.empty()) {
    int x = qqq.front();
    qqq.pop();
    if (x == def) continue;  // 条件2保证只有1个def。此处是遇到def则可以了
    if (vis.find(x) != vis.end()) continue;
    auto bb = id_bb[x];
    for (int i = 0; i < bb->ir_list_.size(); i++) {
      auto op1 = bb->ir_list_[i]->opn1_.name_, op2 = bb->ir_list_[i]->opn2_.name_, res = bb->ir_list_[i]->res_.name_;
      if (op1 == name || op2 == name) return false;
      if (res == name) break;
    }
    vis.insert(x);
    for (int i = 0; i < to[x].size(); i++) {
      int y = to[x][i];
      if (vis.find(y) != vis.end()) continue;
      qqq.push(y);
    }
  }
  return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %r9, 0x18(%rsp)
movq %r8, %r13
movl %ecx, %ebp
movq %rsi, %r15
leaq 0x34(%rsp), %rbx
movl %edi, (%rbx)
leaq 0xc8(%rsp), %r12
movq %r12, %rdi
callq 0x4b424
leaq 0x40(%rsp), %rax
andl $0x0, (%rax)
andq $0x0, 0x8(%rax)
movq %rax, 0x10(%rax)
movq %rax, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x1cd82
leaq 0xa8(%rsp), %rbx
movq %r13, 0x28(%rsp)
movl %ebp, 0xc(%rsp)
movq %r15, 0x10(%rsp)
movq 0xd8(%rsp), %r12
movq 0xf8(%rsp), %r14
cmpq %r12, %r14
je 0x47e01
movl (%r12), %eax
movl %eax, 0x8(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x4c3d8
cmpl %ebp, 0x8(%rsp)
je 0x47c3d
leaq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x304ea
leaq 0x40(%rsp), %rcx
cmpq %rcx, %rax
jne 0x47c3d
movq %r14, 0x20(%rsp)
movq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x4b3d6
movq (%rax), %r15
xorl %r14d, %r14d
movq 0x8(%r15), %rax
movq 0x10(%r15), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
cmpq %r14, %rcx
jbe 0x47d79
movq (%rax,%r14,8), %rsi
addq $0x10, %rsi
movq %rbx, %rdi
callq 0x8390
movq 0x8(%r15), %rax
movq (%rax,%r14,8), %rsi
addq $0x50, %rsi
leaq 0x68(%rsp), %rdi
callq 0x8390
movq 0x8(%r15), %rax
movq (%rax,%r14,8), %rsi
movl $0x90, %eax
addq %rax, %rsi
leaq 0x88(%rsp), %rdi
callq 0x8390
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe1ca
testb %al, %al
jne 0x47d1f
leaq 0x68(%rsp), %rdi
movq %r13, %rsi
callq 0xe1ca
testb %al, %al
je 0x47d27
xorl %r13d, %r13d
pushq $0x1
popq %rbp
jmp 0x47d44
leaq 0x88(%rsp), %rdi
movq %r13, %rsi
callq 0xe1ca
movl %eax, %r13d
movzbl %al, %ebp
xorb $0x1, %r13b
shll $0x2, %ebp
leaq 0x88(%rsp), %rdi
callq 0x8578
leaq 0x68(%rsp), %rdi
callq 0x8578
movq %rbx, %rdi
callq 0x8578
incq %r14
testb %r13b, %r13b
movq 0x28(%rsp), %r13
jne 0x47ca4
cmpl $0x4, %ebp
jne 0x47df0
leaq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2d45e
xorl %r14d, %r14d
movl 0xc(%rsp), %ebp
movq 0x10(%rsp), %r15
movslq 0x8(%rsp), %rax
movq (%r15), %rcx
imulq $0x18, %rax, %rdx
movq (%rcx,%rdx), %rax
movq 0x8(%rcx,%rdx), %rcx
subq %rax, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jbe 0x47c3d
movl (%rax,%r14,4), %eax
movl %eax, 0xa8(%rsp)
leaq 0x38(%rsp), %rdi
movq %rbx, %rsi
callq 0x304ea
leaq 0x40(%rsp), %rcx
cmpq %rcx, %rax
jne 0x47deb
leaq 0xc8(%rsp), %rdi
movq %rbx, %rsi
callq 0x1cd82
incq %r14
jmp 0x47d94
testl %ebp, %ebp
movl 0xc(%rsp), %ebp
movq 0x20(%rsp), %r14
je 0x47c3d
cmpq %r12, %r14
sete %bl
leaq 0x38(%rsp), %rdi
callq 0x2de44
leaq 0xc8(%rsp), %rdi
callq 0x1b604
movl %ebx, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x47e5d
jmp 0x47e5d
jmp 0x47e5d
jmp 0x47e5d
jmp 0x47e5d
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x8578
jmp 0x47e4e
movq %rax, %rbx
leaq 0xa8(%rsp), %rdi
callq 0x8578
jmp 0x47e60
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x2de44
leaq 0xc8(%rsp), %rdi
callq 0x1b604
movq %rbx, %rdi
callq 0x84d0