// File: /workspace/github_cpp_makefile_star2_O2/luooofan[P]hblzbd_compiler/src/Pass/simplify_cfg.cpp
// Function: SimplifyCFG::Run4IRFunc(IRFunction*)
void SimplifyCFG::Run4IRFunc(IRFunction* func) {
#ifdef DEBUG_SIMPLIFY_CFG_PROCESS
  std::cout << "========Before Simplyfy:========" << std::endl;
  func->EmitCode(std::cout);
#endif
  std::unordered_set<IRBasicBlock*> worklist;
  std::unordered_set<IRBasicBlock*> wait;
  for (auto bb : func->bb_list_) {
    if (bb->pred_.size() == 0) worklist.insert(bb);
  }
  if (func->bb_list_.size() > 0) worklist.erase(func->bb_list_[0]);
  while (!worklist.empty()) {
    auto bb = *worklist.begin();
    worklist.erase(bb);
    wait.insert(bb);
    for (auto succ : bb->succ_) {
      succ->pred_.erase(std::find(succ->pred_.begin(), succ->pred_.end(), bb));
      if (succ->pred_.size() == 0) worklist.insert(succ);
    }
  }
  for (auto it = func->bb_list_.begin(); it != func->bb_list_.end();) {
    if (wait.count(*it))
      it = func->bb_list_.erase(it);
    else
      ++it;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rsi, %r13
leaq 0x58(%rsp), %rax
movq %rax, -0x30(%rax)
pushq $0x1
popq %rcx
movq %rcx, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, %edx       # imm = 0x3F800000
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x90(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x30(%rsi), %rbp
movq 0x30(%rsi), %rbx
movq 0x38(%rsi), %r14
leaq 0x28(%rsp), %r15
leaq 0x8(%rsp), %r12
cmpq %r14, %rbx
je 0x54294
movq (%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x30(%rax), %rcx
cmpq 0x28(%rax), %rcx
jne 0x5428e
movq %r15, %rdi
movq %r12, %rsi
callq 0x38a9a
addq $0x8, %rbx
jmp 0x5426c
movq %rbp, 0x18(%rsp)
movq 0x30(%r13), %rsi
movq %r13, 0x20(%rsp)
cmpq %rsi, 0x38(%r13)
je 0x542b2
leaq 0x28(%rsp), %rdi
callq 0x543de
leaq 0x28(%rsp), %r15
leaq 0x8(%rsp), %r12
leaq 0x10(%rsp), %rbp
cmpq $0x0, 0x40(%rsp)
je 0x5434d
movq 0x38(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x543de
leaq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x38a9a
movq 0x8(%rsp), %rax
movq 0x40(%rax), %r13
movq 0x48(%rax), %rbx
cmpq %rbx, %r13
je 0x542c1
movq (%r13), %r14
movq %r14, 0x10(%rsp)
movq 0x28(%r14), %rdi
movq 0x30(%r14), %rsi
movq %r12, %rdx
callq 0x200f5
addq $0x28, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x4b952
movq 0x10(%rsp), %rax
movq 0x30(%rax), %rcx
cmpq 0x28(%rax), %rcx
jne 0x54347
movq %r15, %rdi
movq %rbp, %rsi
callq 0x38a9a
addq $0x8, %r13
jmp 0x54300
movq 0x18(%rsp), %r14
movq (%r14), %r12
leaq 0x60(%rsp), %r15
movq 0x20(%rsp), %rbx
cmpq 0x38(%rbx), %r12
je 0x5438b
movq %r15, %rdi
movq %r12, %rsi
callq 0x5442c
testq %rax, %rax
je 0x54385
movq %r14, %rdi
movq %r12, %rsi
callq 0x4b952
movq %rax, %r12
jmp 0x5435f
addq $0x8, %r12
jmp 0x5435f
leaq 0x60(%rsp), %rdi
callq 0x1fe2c
leaq 0x28(%rsp), %rdi
callq 0x1fe2c
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x543bd
jmp 0x543bd
jmp 0x543bd
jmp 0x543bd
jmp 0x543bd
jmp 0x543bd
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x1fe2c
leaq 0x28(%rsp), %rdi
callq 0x1fe2c
movq %rbx, %rdi
callq 0x84d0