// File: /workspace/github_cpp_makefile_star2_O3/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 $0xc8, %rsp
movq %rdi, %rbx
movq 0x8(%rdi), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x6957d
leaq 0x24487(%rip), %rsi     # 0x8d648
leaq 0x24ea8(%rip), %rdx     # 0x8e070
xorl %ecx, %ecx
callq 0x8320
testq %rax, %rax
je 0x6957d
movq %rax, %r12
movq 0x28(%rax), %rax
movq 0x30(%r12), %rcx
movq %rcx, 0x98(%rsp)
cmpq %rcx, %rax
je 0x69563
movq %r12, 0x88(%rsp)
movq %rbx, 0x90(%rsp)
leaq 0x60(%rsp), %r14
leaq 0x40(%rsp), %r15
leaq 0x50(%rsp), %rbx
movq %rax, 0xa0(%rsp)
movq (%rax), %r13
movq 0x30(%r13), %rax
movq 0x38(%r13), %rcx
movq %rcx, 0xa8(%rsp)
cmpq %rcx, %rax
je 0x69516
addq $0x60, %r13
movq %r13, 0xb8(%rsp)
movq %rax, 0xb0(%rsp)
movq (%rax), %rax
movq 0x8(%rax), %rbp
movq 0x10(%rax), %rcx
cmpq %rcx, %rbp
movq %rcx, 0xc0(%rsp)
je 0x694fc
movq (%rbp), %rax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x88(%rax)
jne 0x694ef
cmpl $0x0, 0xb0(%rax)
je 0x694ef
movq %r14, 0x50(%rsp)
movq 0x90(%rax), %rsi
movq 0x98(%rax), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xc6dc
movq %rbx, %rdi
leaq 0x87b8(%rip), %rsi      # 0x71a6b
callq 0x8590
movq %r15, %rbx
movq %r14, %r15
movq 0x28(%rsp), %rax
movl 0xb0(%rax), %r12d
movl %r12d, %r14d
negl %r14d
cmovsl %r12d, %r14d
movl $0x1, %r13d
cmpl $0xa, %r14d
jb 0x69327
movl $0x4, %r13d
movl %r14d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x6931e
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x69324
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x69327
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x692ee
addl $-0x3, %r13d
jmp 0x69327
addl $-0x2, %r13d
jmp 0x69327
decl %r13d
shrl $0x1f, %r12d
leal (%r12,%r13), %esi
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
leaq 0x8(%rsp), %rdi
movl $0x2d, %edx
callq 0x8350
addq 0x8(%rsp), %r12
movq %r12, %rdi
movl %r13d, %esi
movl %r14d, %edx
callq 0xc35d
movq 0x50(%rsp), %rcx
movl $0xf, %edi
movq %r15, %r14
cmpq %r15, %rcx
je 0x69372
movq 0x60(%rsp), %rdi
movq 0x58(%rsp), %r8
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
movq %rbx, %r15
leaq 0x50(%rsp), %rbx
leaq 0x30(%rsp), %r12
movq 0xb8(%rsp), %r13
jbe 0x693b8
movl $0xf, %edi
leaq 0x18(%rsp), %r9
cmpq %r9, %rsi
je 0x693b3
movq 0x18(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x693c2
movq %rbx, %rdi
callq 0x8120
jmp 0x693d0
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x8310
movq %r15, 0x30(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0x693f0
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x693f7
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x69430
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x69447
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %r13, %rdi
movq %r12, %rsi
callq 0x6af70
testq %rax, %rax
je 0x69479
movq %r13, %rdi
movq %r12, %rsi
callq 0x6b6a8
movq %rax, 0x50(%rsp)
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x6b06c
jmp 0x694d0
leaq 0x80(%rsp), %rax
movq %rax, 0x50(%rsp)
movq $0x1, 0x58(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%r14)
movl $0x3f800000, 0x70(%rsp) # imm = 0x3F800000
movups %xmm0, 0x18(%r14)
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0x6b06c
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x6b2fa
movq %rbx, %rdi
callq 0x2c012
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x694e7
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0xc0(%rsp), %rcx
addq $0x8, %rbp
cmpq %rcx, %rbp
jne 0x69268
movq 0xb0(%rsp), %rax
addq $0x8, %rax
cmpq 0xa8(%rsp), %rax
jne 0x69244
movq 0xa0(%rsp), %rax
addq $0x8, %rax
cmpq 0x98(%rsp), %rax
jne 0x69214
movq 0x88(%rsp), %r12
movq 0x28(%r12), %rbx
movq 0x30(%r12), %r14
cmpq %r14, %rbx
movq 0x90(%rsp), %r15
je 0x69563
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x6963c
addq $0x8, %rbx
cmpq %r14, %rbx
jne 0x6954f
movq %r12, %rsi
callq 0x69954
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x25a64(%rip), %rdi     # 0x8efe8
leaq 0x4bdd(%rip), %rsi      # 0x6e168
callq 0x8280
leaq 0x867e(%rip), %rsi      # 0x71c15
movq %rax, %rdi
callq 0x8280
leaq 0x5e1a(%rip), %rsi      # 0x6f3c0
movq %rax, %rdi
callq 0x8280
movq %rax, %rdi
movl $0x41, %esi
callq 0x8520
movq %rax, %rdi
callq 0x8180
movl $0xff, %edi
callq 0x8380
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2c012
jmp 0x6961c
movq %rax, %rbx
movq %r15, %r14
jmp 0x69608
movq %rax, %rbx
jmp 0x69608
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x69608
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x69633
movq 0x60(%rsp), %rsi
jmp 0x6962b
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x69633
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %rbx, %rdi
callq 0x8540
nop