// File: /workspace/github_cpp_makefile_star2_O3/luooofan[P]hblzbd_compiler/src/Pass/loop_unroll.cpp
// Function: find_basicvar(ir::Opn*, IRBasicBlock*)
vector<ir::Opn*> find_basicvar(ir::Opn* var, IRBasicBlock* bb) {
  vector<ir::Opn*> basic;
  if (var->type_ == ir::Opn::Type::Imm) return basic;
  basic.push_back(var);
  vector<ir::IR*> rev(bb->ir_list_);
  reverse(rev.begin(), rev.end());
  for (auto& ir : rev) {
    if (ir->op_ == ir::IR::OpKind::LABEL || ir->op_ == ir::IR::OpKind::PARAM || ir->op_ == ir::IR::OpKind::CALL ||
        ir->op_ == ir::IR::OpKind::RET || ir->op_ == ir::IR::OpKind::GOTO)
      continue;
    auto res = &ir->res_;
    if (have1(res, basic)) basic.push_back(&ir->opn1_), basic.push_back(&ir->opn2_);
  }
  basic.erase(basic.begin());
  auto it = basic.begin();
  while (it != basic.end()) {
    string name = (*it)->name_;
    if (count(name.begin(), name.end(), '-') == 1)
      it = basic.erase(it);  // 删除临时变量，临时变量形如temp-x
    else
      it++;
  }
  return basic;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
movq %rsi, 0x48(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
cmpl $0x1, (%rsi)
je 0x64199
movq %rdx, %r14
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x59cf0
addq $0x8, %r14
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x606d4
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %r12
cmpq %r12, %r15
setne %cl
leaq -0x8(%r12), %rax
cmpq %r15, %rax
seta %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x64017
addq $0x8, %r15
movq -0x8(%r15), %rcx
movq (%rax), %rdx
movq %rdx, -0x8(%r15)
movq %rcx, (%rax)
addq $-0x8, %rax
leaq 0x8(%r15), %rcx
cmpq %rax, %r15
movq %rcx, %r15
jb 0x63fef
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %r12
cmpq %r12, %r15
je 0x640ae
leaq 0x50(%rsp), %r14
movq (%r15), %r13
movl (%r13), %eax
addl $-0x7, %eax
cmpl $0x5, %eax
jb 0x640a1
movq %r14, %rdi
movq %rbx, %rsi
callq 0x59e2c
addq $0x88, %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x63f23
movl %eax, %ebp
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x6406a
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x640a1
movq (%r15), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x682ba
movq (%r15), %rax
addq $0x48, %rax
movq %rax, 0x40(%rsp)
movq %rbx, %rdi
leaq 0x40(%rsp), %rsi
callq 0x682ba
addq $0x8, %r15
cmpq %r12, %r15
jne 0x64025
movq (%rbx), %r14
movq 0x8(%rbx), %rdx
leaq 0x8(%r14), %rsi
cmpq %rdx, %rsi
je 0x640d0
subq %rsi, %rdx
movq %r14, %rdi
callq 0x84c0
movq (%rbx), %r14
movq 0x8(%rbx), %rdx
addq $-0x8, %rdx
movq %rdx, 0x8(%rbx)
cmpq %rdx, %r14
je 0x64182
leaq 0x30(%rsp), %r12
leaq 0x20(%rsp), %r15
movq (%r14), %rax
movq %r12, 0x20(%rsp)
movq 0x8(%rax), %rsi
movq 0x10(%rax), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0xc6dc
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x64162
xorl %edx, %edx
xorl %ecx, %ecx
xorl %esi, %esi
cmpb $0x2d, (%rdi,%rdx)
sete %sil
addq %rsi, %rcx
incq %rdx
cmpq %rdx, %rax
jne 0x64119
cmpq $0x1, %rcx
jne 0x64162
movq %r14, %rsi
addq $0x8, %rsi
movq 0x8(%rbx), %rdx
cmpq %rdx, %rsi
je 0x64158
subq %rsi, %rdx
movq %r14, %rdi
callq 0x84c0
movq 0x8(%rbx), %rdx
movq 0x20(%rsp), %rdi
addq $-0x8, %rdx
movq %rdx, 0x8(%rbx)
jmp 0x64166
addq $0x8, %r14
cmpq %r12, %rdi
je 0x64178
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x82a0
cmpq 0x8(%rbx), %r14
jne 0x640eb
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x64199
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x82a0
movq %rbx, %rax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x641ad
movq %rax, %r14
jmp 0x641d2
jmp 0x641b8
jmp 0x641b8
jmp 0x641b8
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x641d2
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x82a0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x641e6
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x82a0
movq %r14, %rdi
callq 0x8540