// File: 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:
subq $0x1e8, %rsp            # imm = 0x1E8
movq %r9, 0x58(%rsp)
movq %r8, 0x60(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x1f0(%rsp), %rax
movl %edi, 0x1e0(%rsp)
movq %rsi, 0x1d8(%rsp)
movq %rdx, 0x1d0(%rsp)
movl %ecx, 0x1cc(%rsp)
movq %r8, 0x1c0(%rsp)
movq %r9, 0x1b8(%rsp)
leaq 0x168(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0xd4d70
leaq 0x138(%rsp), %rdi
callq 0x6eec0
movq 0x70(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0xd4da0
jmp 0xccfff
jmp 0xcd001
leaq 0x168(%rsp), %rdi
callq 0xd4dd0
movb %al, 0x57(%rsp)
jmp 0xcd014
movb 0x57(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0xcd023
jmp 0xcd421
leaq 0x168(%rsp), %rdi
callq 0xd4df0
movq %rax, 0x48(%rsp)
jmp 0xcd037
movq 0x48(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x128(%rsp)
leaq 0x168(%rsp), %rdi
callq 0xd4e00
jmp 0xcd054
movl 0x128(%rsp), %eax
cmpl 0x1cc(%rsp), %eax
jne 0xcd07f
jmp 0xcd001
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0xcd45f
leaq 0x138(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x80a70
movq %rax, 0x40(%rsp)
jmp 0xcd09b
movq 0x40(%rsp), %rax
movq %rax, 0x120(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x80ab0
movq %rax, 0x118(%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x80a50
testb $0x1, %al
jne 0xcd0d8
jmp 0xcd0dd
jmp 0xcd001
movq 0x58(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0xd4c10
movq %rax, 0x38(%rsp)
jmp 0xcd0f6
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x110(%rsp)
movl $0x0, 0x10c(%rsp)
movslq 0x10c(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x110(%rsp), %rdi
addq $0x8, %rdi
callq 0x18440
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0xcd2f2
movq 0x110(%rsp), %rdi
addq $0x8, %rdi
movslq 0x10c(%rsp), %rsi
callq 0x18460
movq (%rax), %rsi
addq $0x10, %rsi
leaq 0xe8(%rsp), %rdi
callq 0x81a0
jmp 0xcd16f
movq 0x110(%rsp), %rdi
addq $0x8, %rdi
movslq 0x10c(%rsp), %rsi
callq 0x18460
movq (%rax), %rsi
addq $0x50, %rsi
leaq 0xc8(%rsp), %rdi
callq 0x81a0
jmp 0xcd19e
movq 0x110(%rsp), %rdi
addq $0x8, %rdi
movslq 0x10c(%rsp), %rsi
callq 0x18460
movq (%rax), %rsi
addq $0x90, %rsi
leaq 0xa8(%rsp), %rdi
callq 0x81a0
jmp 0xcd1d0
movq 0x60(%rsp), %rsi
leaq 0xe8(%rsp), %rdi
callq 0x1a650
testb $0x1, %al
jne 0xcd1fe
movq 0x60(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0x1a650
testb $0x1, %al
jne 0xcd1fe
jmp 0xcd252
movb $0x0, 0x1e7(%rsp)
movl $0x1, 0xa4(%rsp)
jmp 0xcd282
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
jmp 0xcd2e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x130(%rsp)
movl %eax, 0x12c(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x8728
jmp 0xcd2e0
movq 0x60(%rsp), %rsi
leaq 0xa8(%rsp), %rdi
callq 0x1a650
testb $0x1, %al
jne 0xcd26a
jmp 0xcd277
movl $0x4, 0xa4(%rsp)
jmp 0xcd282
movl $0x0, 0xa4(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0x8728
leaq 0xc8(%rsp), %rdi
callq 0x8728
leaq 0xe8(%rsp), %rdi
callq 0x8728
movl 0xa4(%rsp), %eax
movl %eax, 0x2c(%rsp)
testl %eax, %eax
je 0xcd2c8
jmp 0xcd2ba
movl 0x2c(%rsp), %eax
subl $0x4, %eax
je 0xcd2f2
jmp 0xcd434
jmp 0xcd2ca
movl 0x10c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x10c(%rsp)
jmp 0xcd111
leaq 0xe8(%rsp), %rdi
callq 0x8728
jmp 0xcd45f
leaq 0x138(%rsp), %rdi
leaq 0x128(%rsp), %rsi
callq 0x75710
movb %dl, 0x1f(%rsp)
movq %rax, 0x20(%rsp)
jmp 0xcd312
movb 0x1f(%rsp), %al
movq 0x20(%rsp), %rcx
movq %rcx, 0x90(%rsp)
movb %al, 0x98(%rsp)
movl $0x0, 0x8c(%rsp)
movq 0x68(%rsp), %rdi
movslq 0x8c(%rsp), %rax
movq %rax, 0x10(%rsp)
movslq 0x128(%rsp), %rsi
callq 0x36bb0
movq %rax, %rdi
callq 0x10a40
movq %rax, %rcx
movq 0x10(%rsp), %rax
cmpq %rcx, %rax
jae 0xcd41c
movq 0x68(%rsp), %rdi
movslq 0x128(%rsp), %rsi
callq 0x36bb0
movq %rax, %rdi
movslq 0x8c(%rsp), %rsi
callq 0x10a60
movl (%rax), %eax
movl %eax, 0x88(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x80a70
movq %rax, 0x8(%rsp)
jmp 0xcd3b4
movq 0x8(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x80ab0
movq %rax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x80a50
testb $0x1, %al
jne 0xcd3eb
jmp 0xcd3ed
jmp 0xcd406
leaq 0x168(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xd4da0
jmp 0xcd404
jmp 0xcd406
movl 0x8c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x8c(%rsp)
jmp 0xcd335
jmp 0xcd001
movb $0x1, 0x1e7(%rsp)
movl $0x1, 0xa4(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x6f180
leaq 0x168(%rsp), %rdi
callq 0xd4e10
movb 0x1e7(%rsp), %al
andb $0x1, %al
addq $0x1e8, %rsp            # imm = 0x1E8
retq
leaq 0x138(%rsp), %rdi
callq 0x6f180
leaq 0x168(%rsp), %rdi
callq 0xd4e10
movq 0x130(%rsp), %rdi
callq 0x8670
nopw %cs:(%rax,%rax)