// File: luooofan[P]hblzbd_compiler/src/Pass/loop_unroll.cpp
// Function: find_back(std::vector<IRBasicBlock*, std::allocator<IRBasicBlock*>>)
vector<pair<IRBasicBlock*, IRBasicBlock*> > find_back(vector<IRBasicBlock*> bb_list) {
  // 计算必经节点集
  map<IRBasicBlock*, vector<IRBasicBlock*> > dom;
  dom[bb_list[0]] = {bb_list[0]};
  for (int i = 1; i < bb_list.size(); i++) {
    for (int j = 0; j < bb_list.size(); j++) dom[bb_list[i]].push_back(bb_list[j]);
  }
  bool flag = true;
  while (flag) {
    flag = false;
    for (auto& bb : bb_list) {
      int last = dom[bb].size();
      if (bb->pred_.size() == 0) dom[bb].clear();
      for (auto& pred : bb->pred_) dom[bb] = cross(dom[bb], dom[pred]);
      if (bb != bb_list[0]) dom[bb].push_back(bb);
      flag |= (last != dom[bb].size());
    }
  }

  // 计算回边
  vector<pair<IRBasicBlock*, IRBasicBlock*> > back;
  for (auto& bb : bb_list) {
    for (auto& suc : bb->succ_) {
      if (have(suc, dom[bb])) back.push_back(make_pair(bb, suc));
    }
  }
  return back;
}

// Assembly:
subq $0x228, %rsp            # imm = 0x228
movq %rsi, 0x98(%rsp)
movq %rdi, 0x88(%rsp)
movq %rdi, %rax
movq %rax, 0x90(%rsp)
movq %rdi, 0x220(%rsp)
movq %rsi, 0x218(%rsp)
leaq 0x1e8(%rsp), %rdi
movq %rdi, 0xa8(%rsp)
callq 0xe9b30
movq 0x98(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
movq %rsi, 0xa0(%rsp)
callq 0x8ee50
movq 0x98(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq (%rax), %rax
movq %rax, 0x1d0(%rsp)
leaq 0x1d0(%rsp), %rax
movq %rax, 0x1d8(%rsp)
movq $0x1, 0x1e0(%rsp)
callq 0x8ee50
movq 0xa8(%rsp), %rdi
movq %rax, %rsi
callq 0xe9b40
movq %rax, 0xb0(%rsp)
jmp 0xe3b06
movq 0xb0(%rsp), %rdi
movq 0x1d8(%rsp), %rsi
movq 0x1e0(%rsp), %rdx
callq 0xe9c40
jmp 0xe3b25
movl $0x1, 0x1c0(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x1c0(%rsp), %rax
movq %rax, 0x80(%rsp)
callq 0x1cd80
movq %rax, %rcx
movq 0x80(%rsp), %rax
cmpq %rcx, %rax
jae 0xe3c30
movl $0x0, 0x1bc(%rsp)
movq 0x98(%rsp), %rdi
movslq 0x1bc(%rsp), %rax
movq %rax, 0x78(%rsp)
callq 0x1cd80
movq %rax, %rcx
movq 0x78(%rsp), %rax
cmpq %rcx, %rax
jae 0xe3c18
movq 0x98(%rsp), %rdi
movslq 0x1c0(%rsp), %rsi
callq 0x8ee50
movq %rax, %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xe9b40
movq %rax, 0x70(%rsp)
jmp 0xe3bc3
movq 0x98(%rsp), %rdi
movslq 0x1bc(%rsp), %rsi
callq 0x8ee50
movq 0x70(%rsp), %rdi
movq %rax, %rsi
callq 0x186f0
jmp 0xe3be7
jmp 0xe3be9
movl 0x1bc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1bc(%rsp)
jmp 0xe3b6c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
jmp 0xe422f
jmp 0xe3c1a
movl 0x1c0(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x1c0(%rsp)
jmp 0xe3b30
movb $0x1, 0x1bb(%rsp)
testb $0x1, 0x1bb(%rsp)
je 0xe3fc8
movq 0x98(%rsp), %rax
movb $0x0, 0x1bb(%rsp)
movq %rax, 0x1b0(%rsp)
movq 0x1b0(%rsp), %rdi
callq 0x1cc40
movq %rax, 0x1a8(%rsp)
movq 0x1b0(%rsp), %rdi
callq 0x1cac0
movq %rax, 0x1a0(%rsp)
leaq 0x1a8(%rsp), %rdi
leaq 0x1a0(%rsp), %rsi
callq 0x492e0
testb $0x1, %al
jne 0xe3ca6
jmp 0xe3fc3
leaq 0x1a8(%rsp), %rdi
callq 0x49320
movq %rax, 0x198(%rsp)
movq 0x198(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xe9b40
movq %rax, 0x68(%rsp)
jmp 0xe3cd7
movq 0x68(%rsp), %rdi
callq 0x1cd80
movl %eax, 0x194(%rsp)
movq 0x198(%rsp), %rax
movq (%rax), %rdi
addq $0x28, %rdi
callq 0x1cd80
cmpq $0x0, %rax
jne 0xe3d28
movq 0x198(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xe9b40
movq %rax, 0x60(%rsp)
jmp 0xe3d1e
movq 0x60(%rsp), %rdi
callq 0xa6090
movq 0x198(%rsp), %rax
movq (%rax), %rax
addq $0x28, %rax
movq %rax, 0x188(%rsp)
movq 0x188(%rsp), %rdi
callq 0x1cc40
movq %rax, 0x180(%rsp)
movq 0x188(%rsp), %rdi
callq 0x1cac0
movq %rax, 0x178(%rsp)
leaq 0x180(%rsp), %rdi
leaq 0x178(%rsp), %rsi
callq 0x492e0
testb $0x1, %al
jne 0xe3d87
jmp 0xe3eee
leaq 0x180(%rsp), %rdi
callq 0x49320
movq %rax, 0x170(%rsp)
movq 0x198(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xe9b40
movq %rax, 0x58(%rsp)
jmp 0xe3db8
movq 0x58(%rsp), %rsi
leaq 0x140(%rsp), %rdi
callq 0xe9ca0
jmp 0xe3dcc
movq 0x170(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xe9b40
movq %rax, 0x50(%rsp)
jmp 0xe3de8
movq 0x50(%rsp), %rsi
leaq 0x128(%rsp), %rdi
callq 0xe9ca0
jmp 0xe3dfc
leaq 0x158(%rsp), %rdi
leaq 0x140(%rsp), %rsi
leaq 0x128(%rsp), %rdx
callq 0xe2a80
jmp 0xe3e1b
movq 0x198(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xe9b40
movq %rax, 0x48(%rsp)
jmp 0xe3e37
movq 0x48(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xe9da0
leaq 0x158(%rsp), %rdi
callq 0x49360
leaq 0x128(%rsp), %rdi
callq 0x49360
leaq 0x140(%rsp), %rdi
callq 0x49360
leaq 0x180(%rsp), %rdi
callq 0x49330
jmp 0xe3d69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
jmp 0xe3edc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
jmp 0xe3ecf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x49360
leaq 0x128(%rsp), %rdi
callq 0x49360
leaq 0x140(%rsp), %rdi
callq 0x49360
jmp 0xe422f
movq 0x98(%rsp), %rdi
movq 0x198(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
xorl %eax, %eax
movl %eax, %esi
callq 0x8ee50
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq (%rcx), %rax
je 0xe3f4e
movq 0x198(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xe9b40
movq %rax, 0x38(%rsp)
jmp 0xe3f38
movq 0x38(%rsp), %rdi
movq 0x198(%rsp), %rsi
callq 0x186f0
jmp 0xe3f4c
jmp 0xe3f4e
movslq 0x194(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x198(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xe9b40
movq %rax, 0x30(%rsp)
jmp 0xe3f77
movq 0x30(%rsp), %rdi
callq 0x1cd80
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
setne %al
andb $0x1, %al
movzbl %al, %ecx
movb 0x1bb(%rsp), %al
andb $0x1, %al
movzbl %al, %eax
orl %ecx, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movb %al, 0x1bb(%rsp)
leaq 0x1a8(%rsp), %rdi
callq 0x49330
jmp 0xe3c88
jmp 0xe3c38
movq 0x88(%rsp), %rdi
movb $0x0, 0x127(%rsp)
callq 0xe9de0
movq 0x98(%rsp), %rax
movq %rax, 0x118(%rsp)
movq 0x118(%rsp), %rdi
callq 0x1cc40
movq %rax, 0x110(%rsp)
movq 0x118(%rsp), %rdi
callq 0x1cac0
movq %rax, 0x108(%rsp)
leaq 0x110(%rsp), %rdi
leaq 0x108(%rsp), %rsi
callq 0x492e0
testb $0x1, %al
jne 0xe4035
jmp 0xe41e6
leaq 0x110(%rsp), %rdi
callq 0x49320
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq (%rax), %rax
addq $0x40, %rax
movq %rax, 0xf8(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x1cc40
movq %rax, 0xf0(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x1cac0
movq %rax, 0xe8(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x492e0
testb $0x1, %al
jne 0xe40a9
jmp 0xe41d2
leaq 0xf0(%rsp), %rdi
callq 0x49320
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x18(%rsp)
movq 0x100(%rsp), %rsi
leaq 0x1e8(%rsp), %rdi
callq 0xe9b40
movq %rax, 0x20(%rsp)
jmp 0xe40ea
movq 0x20(%rsp), %rsi
leaq 0xc8(%rsp), %rdi
callq 0xe9ca0
jmp 0xe40fe
movq 0x18(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xe9df0
movb %al, 0x17(%rsp)
jmp 0xe4116
leaq 0xc8(%rsp), %rdi
callq 0x49360
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0xe4130
jmp 0xe41be
movq 0x100(%rsp), %rdi
movq 0xe0(%rsp), %rsi
callq 0xe9eb0
movq %rdx, (%rsp)
movq %rax, 0x8(%rsp)
jmp 0xe4150
movq 0x88(%rsp), %rdi
movq (%rsp), %rax
movq 0x8(%rsp), %rcx
movq %rcx, 0xb8(%rsp)
movq %rax, 0xc0(%rsp)
leaq 0xb8(%rsp), %rsi
callq 0xe9e80
jmp 0xe4180
jmp 0xe41be
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
jmp 0xe4222
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x1c8(%rsp)
movl %eax, 0x1c4(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x49360
jmp 0xe4222
jmp 0xe41c0
leaq 0xf0(%rsp), %rdi
callq 0x49330
jmp 0xe408b
jmp 0xe41d4
leaq 0x110(%rsp), %rdi
callq 0x49330
jmp 0xe4017
movb $0x1, 0x127(%rsp)
testb $0x1, 0x127(%rsp)
jne 0xe4205
movq 0x88(%rsp), %rdi
callq 0xe9ef0
leaq 0x1e8(%rsp), %rdi
callq 0xe9f50
movq 0x90(%rsp), %rax
addq $0x228, %rsp            # imm = 0x228
retq
movq 0x88(%rsp), %rdi
callq 0xe9ef0
leaq 0x1e8(%rsp), %rdi
callq 0xe9f50
movq 0x1c8(%rsp), %rdi
callq 0x8670
nopl (%rax)