// File: /workspace/github_cpp_makefile_star2_O1/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 0x69fbb
leaq 0x2466d(%rip), %rsi     # 0x8e618
leaq 0x250c6(%rip), %rdx     # 0x8f078
xorl %ecx, %ecx
callq 0x8320
jmp 0x69fbd
xorl %eax, %eax
movq %rbx, 0x90(%rsp)
testq %rax, %rax
je 0x6a369
movq 0x28(%rax), %rcx
movq %rax, 0x88(%rsp)
movq 0x30(%rax), %rax
movq %rax, 0x98(%rsp)
cmpq %rax, %rcx
je 0x6a31c
leaq 0x60(%rsp), %r14
leaq 0x40(%rsp), %r15
leaq 0x50(%rsp), %rbx
movq %rcx, 0xa0(%rsp)
movq (%rcx), %r13
movq 0x30(%r13), %rax
movq 0x38(%r13), %rcx
movq %rcx, 0xa8(%rsp)
cmpq %rcx, %rax
je 0x6a302
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 0x6a2e8
movq (%rbp), %rax
movq %rax, 0x28(%rsp)
cmpl $0x0, 0x88(%rax)
jne 0x6a2db
cmpl $0x0, 0xb0(%rax)
je 0x6a2db
movq %r14, 0x50(%rsp)
movq 0x90(%rax), %rsi
movq 0x98(%rax), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xca10
movq %rbx, %rdi
leaq 0x89ca(%rip), %rsi      # 0x72a67
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 0x6a111
movl $0x4, %r13d
movl %r14d, %eax
movl $0xd1b71759, %edx       # imm = 0xD1B71759
cmpl $0x63, %eax
jbe 0x6a108
cmpl $0x3e7, %eax            # imm = 0x3E7
jbe 0x6a10e
cmpl $0x2710, %eax           # imm = 0x2710
jb 0x6a111
movl %eax, %ecx
imulq %rdx, %rcx
shrq $0x2d, %rcx
addl $0x4, %r13d
cmpl $0x1869f, %eax          # imm = 0x1869F
movl %ecx, %eax
ja 0x6a0d8
addl $-0x3, %r13d
jmp 0x6a111
addl $-0x2, %r13d
jmp 0x6a111
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 0xc65b
movq 0x50(%rsp), %rcx
movl $0xf, %esi
movq %r15, %r14
cmpq %r15, %rcx
je 0x6a15c
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %r8
movq 0x10(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
movq %rbx, %r15
leaq 0x50(%rsp), %rbx
leaq 0x30(%rsp), %r12
movq 0xb8(%rsp), %r13
jbe 0x6a19f
movl $0xf, %esi
leaq 0x18(%rsp), %rdi
cmpq %rdi, 0x8(%rsp)
je 0x6a19a
movq 0x18(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x6a1ae
movq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x8120
jmp 0x6a1bc
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 0x6a1dc
movq %rdx, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x6a1e3
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 0x6a21c
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x6a233
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %r13, %rdi
movq %r12, %rsi
callq 0x6bf0a
testq %rax, %rax
je 0x6a265
movq %r13, %rdi
movq %r12, %rsi
callq 0x6c67e
movq %rax, 0x50(%rsp)
movq %rax, %rdi
leaq 0x28(%rsp), %rsi
movq %rbx, %rdx
callq 0x6c006
jmp 0x6a2bc
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 0x6c006
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x6c2cc
movq %rbx, %rdi
callq 0x2bade
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a2d3
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0xc0(%rsp), %rcx
addq $0x8, %rbp
cmpq %rcx, %rbp
jne 0x6a052
movq 0xb0(%rsp), %rax
addq $0x8, %rax
cmpq 0xa8(%rsp), %rax
jne 0x6a02e
movq 0xa0(%rsp), %rcx
addq $0x8, %rcx
cmpq 0x98(%rsp), %rcx
jne 0x69ffe
movq 0x88(%rsp), %r12
movq 0x28(%r12), %rbx
movq 0x30(%r12), %r14
cmpq %r14, %rbx
movq 0x90(%rsp), %r15
je 0x6a34f
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x6a428
addq $0x8, %rbx
cmpq %r14, %rbx
jne 0x6a33b
movq %r12, %rsi
callq 0x6a85e
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x25c80(%rip), %rdi     # 0x8fff0
leaq 0x4df1(%rip), %rsi      # 0x6f168
callq 0x8280
leaq 0x8892(%rip), %rsi      # 0x72c15
movq %rax, %rdi
callq 0x8280
leaq 0x602e(%rip), %rsi      # 0x703c0
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 0x2bade
jmp 0x6a408
movq %rax, %rbx
movq %r15, %r14
jmp 0x6a3f4
movq %rax, %rbx
jmp 0x6a3f4
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6a3f4
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x82a0
movq 0x50(%rsp), %rdi
cmpq %r14, %rdi
je 0x6a41f
movq 0x60(%rsp), %rsi
jmp 0x6a417
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x6a41f
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
movq %rbx, %rdi
callq 0x8540
nop