// File: /workspace/github_cpp_makefile_star2_O2/luooofan[P]hblzbd_compiler/src/Pass/reach_define.cpp
// Function: ReachDefine::Run()
void ReachDefine::Run() {
  auto m = dynamic_cast<IRModule *>(*m_);

  MyAssert(nullptr != m);

  for (auto func : m->func_list_) {
    for (auto bb : func->bb_list_) {
      for (auto ir : bb->ir_list_) {
        if (ir->res_.type_ == ir::Opn::Type::Var && ir->res_.scope_id_ != 0) {
          std::string var_name = ir->res_.name_ + "_#" + std::to_string(ir->res_.scope_id_);
          if (0 == func->def_pre_var_.count(var_name)) {
            std::unordered_set<ir::IR *> temp_set;
            temp_set.insert(ir);
            func->def_pre_var_.emplace(var_name, temp_set);
          } else {
            func->def_pre_var_[var_name].insert(ir);
          }
        }
      }
      // print_map(func->def_pre_var_);
    }
  }

  for (auto func : m->func_list_) {
    // std::cout << "analysis func:" << func->name_ << std::endl;
    Run4Func(func);
  }

  // 计算每个程序点处的使用-定值链
  GetUseDefChain(m);

#ifdef PRINT_USE_DEF_CHAIN
  print_use_def_chain(m);
#endif

#ifdef PRINT_SET
  print_set(m);
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, 0x18(%rsp)
movq 0x8(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x521af
leaq 0x2d669(%rip), %rsi     # 0x7f648
leaq 0x2e08a(%rip), %rdx     # 0x80070
xorl %ecx, %ecx
callq 0x82c0
testq %rax, %rax
je 0x521af
movq 0x28(%rax), %rcx
movq %rax, 0x10(%rsp)
movq 0x30(%rax), %rax
movq %rax, 0x20(%rsp)
leaq 0x40(%rsp), %r12
leaq 0x78(%rsp), %r13
leaq 0x98(%rsp), %rbp
cmpq 0x20(%rsp), %rcx
je 0x5216b
movq %rcx, 0x28(%rsp)
movq (%rcx), %rbx
movq 0x30(%rbx), %rax
movq 0x38(%rbx), %rcx
movq %rcx, 0x30(%rsp)
addq $0x60, %rbx
cmpq 0x30(%rsp), %rax
je 0x5215d
movq %rax, 0x38(%rsp)
movq (%rax), %rax
movq 0x8(%rax), %r15
movq 0x10(%rax), %r14
cmpq %r14, %r15
je 0x5214f
movq (%r15), %rsi
movq %rsi, 0x8(%rsp)
cmpl $0x0, 0x88(%rsi)
jne 0x52146
cmpl $0x0, 0xb0(%rsi)
je 0x52146
addq $0x90, %rsi
movq %r12, %rdi
leaq 0x7936(%rip), %rdx      # 0x599cb
callq 0xa334
movq 0x8(%rsp), %rax
movl 0xb0(%rax), %esi
movq %r13, %rdi
callq 0xa36c
movq %rbp, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0xa2cd
movq %r13, %rdi
callq 0x8578
movq %r12, %rdi
callq 0x8578
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x531d6
testq %rax, %rax
je 0x520f5
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x538ce
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
callq 0x532ba
jmp 0x5213e
leaq 0x70(%rsp), %rax
movq %rax, 0x40(%rsp)
movq $0x1, 0x48(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, 0x60(%rsp) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
callq 0x532ba
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x53566
movq %r12, %rdi
callq 0x1fed4
movq %rbp, %rdi
callq 0x8578
addq $0x8, %r15
jmp 0x52059
movq 0x38(%rsp), %rax
addq $0x8, %rax
jmp 0x5203e
movq 0x28(%rsp), %rcx
addq $0x8, %rcx
jmp 0x5201a
movq 0x10(%rsp), %r12
movq 0x28(%r12), %rbx
movq 0x30(%r12), %r14
movq 0x18(%rsp), %r15
cmpq %r14, %rbx
je 0x52195
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x5223e
addq $0x8, %rbx
jmp 0x5217f
movq %r12, %rsi
callq 0x524f2
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x2ee32(%rip), %rdi     # 0x80fe8
leaq 0x3f2b(%rip), %rsi      # 0x560e8
callq 0x8240
leaq 0x7994(%rip), %rsi      # 0x59b5d
movq %rax, %rdi
callq 0x8240
leaq 0x5148(%rip), %rsi      # 0x57320
movq %rax, %rdi
callq 0x8240
pushq $0x41
popq %rsi
movq %rax, %rdi
callq 0x84b0
movq %rax, %rdi
callq 0x8170
movl $0xff, %edi
callq 0x8300
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
callq 0x1fed4
jmp 0x52228
movq %rax, %rbx
jmp 0x5221e
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x8578
leaq 0x40(%rsp), %rdi
jmp 0x52230
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x8578
movq %rbx, %rdi
callq 0x84d0
nop