// File: /workspace/github_cpp_makefile_star2_O1/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 0x64f05
movq %rdx, %r14
movq 0x8(%rbx), %rax
cmpq 0x10(%rbx), %rax
je 0x64d1c
movq %rsi, (%rax)
addq $0x8, 0x8(%rbx)
jmp 0x64d2c
leaq 0x48(%rsp), %rdx
movq %rbx, %rdi
movq %rax, %rsi
callq 0x5aaf2
addq $0x8, %r14
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x61468
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
cmpq %rcx, %rax
setne %dl
addq $-0x8, %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x64d83
addq $0x8, %rax
movq -0x8(%rax), %rdx
movq (%rcx), %rsi
movq %rsi, -0x8(%rax)
movq %rdx, (%rcx)
addq $-0x8, %rcx
leaq 0x8(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x64d65
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %r12
cmpq %r12, %r15
je 0x64e24
leaq 0x50(%rsp), %r14
movq (%r15), %r13
movl (%r13), %eax
addl $-0x7, %eax
cmpl $0x5, %eax
jb 0x64e17
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5ac2e
addq $0x88, %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x64c7c
movl %eax, %ebp
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x64de0
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x82a0
testb %bpl, %bpl
je 0x64e17
movq (%r15), %rax
addq $0x8, %rax
movq %rax, 0x20(%rsp)
movq %rbx, %rdi
leaq 0x20(%rsp), %rsi
callq 0x6908c
movq (%r15), %rax
addq $0x48, %rax
movq %rax, 0x40(%rsp)
movq %rbx, %rdi
leaq 0x40(%rsp), %rsi
callq 0x6908c
addq $0x8, %r15
cmpq %r12, %r15
jne 0x64d9b
movq (%rbx), %rdi
movq 0x8(%rbx), %rdx
leaq 0x8(%rdi), %rsi
cmpq %rdx, %rsi
je 0x64e3c
subq %rsi, %rdx
callq 0x84c0
movq (%rbx), %r14
movq 0x8(%rbx), %rax
addq $-0x8, %rax
movq %rax, 0x8(%rbx)
cmpq %rax, %r14
je 0x64eee
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 0xca10
movq 0x28(%rsp), %rax
testq %rax, %rax
je 0x64ec9
movq 0x20(%rsp), %rcx
xorl %esi, %esi
xorl %edx, %edx
xorl %edi, %edi
cmpb $0x2d, (%rcx,%rsi)
sete %dil
addq %rdi, %rdx
incq %rsi
cmpq %rsi, %rax
jne 0x64e8c
cmpq $0x1, %rdx
jne 0x64ec9
movq %r14, %rsi
addq $0x8, %rsi
movq 0x8(%rbx), %rdx
cmpq %rdx, %rsi
je 0x64ec2
subq %rsi, %rdx
movq %r14, %rdi
callq 0x84c0
addq $-0x8, 0x8(%rbx)
jmp 0x64ecd
addq $0x8, %r14
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x64ee4
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x82a0
cmpq 0x8(%rbx), %r14
jne 0x64e5e
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x64f05
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 0x64f19
movq %rax, %r14
jmp 0x64f3e
jmp 0x64f24
jmp 0x64f24
jmp 0x64f24
movq %rax, %r14
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x64f3e
movq 0x18(%rsp), %rsi
subq %rdi, %rsi
callq 0x82a0
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x64f52
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x82a0
movq %r14, %rdi
callq 0x8540