// File: 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:
subq $0x168, %rsp            # imm = 0x168
movq %rdi, 0x38(%rsp)
movq %rdi, %rax
movq %rax, 0x40(%rsp)
movq %rdi, 0x160(%rsp)
movq %rsi, 0x158(%rsp)
movq %rdx, 0x150(%rsp)
movb $0x0, 0x14f(%rsp)
callq 0xc9eb0
movq 0x158(%rsp), %rax
cmpl $0x1, (%rax)
jne 0xe45de
movb $0x1, 0x14f(%rsp)
movl $0x1, 0x148(%rsp)
jmp 0xe49c7
movq 0x38(%rsp), %rdi
leaq 0x158(%rsp), %rsi
callq 0xca1c0
jmp 0xe45f2
movq 0x150(%rsp), %rsi
addq $0x8, %rsi
leaq 0x120(%rsp), %rdi
callq 0xd5170
jmp 0xe460d
leaq 0x120(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x1b070
movq 0x30(%rsp), %rdi
movq %rax, 0x118(%rsp)
callq 0x1aeb0
movq %rax, 0x110(%rsp)
movq 0x118(%rsp), %rdi
movq 0x110(%rsp), %rsi
callq 0xea010
jmp 0xe4650
leaq 0x120(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x108(%rsp), %rdi
callq 0x1b070
movq %rax, 0x100(%rsp)
movq 0x108(%rsp), %rdi
callq 0x1aeb0
movq %rax, 0xf8(%rsp)
leaq 0x100(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x493c0
testb $0x1, %al
jne 0xe46a8
jmp 0xe4817
leaq 0x100(%rsp), %rdi
callq 0x1b4d0
movq %rax, 0xf0(%rsp)
movq 0xf0(%rsp), %rax
movq (%rax), %rax
cmpl $0x7, (%rax)
je 0xe470d
movq 0xf0(%rsp), %rax
movq (%rax), %rax
cmpl $0x8, (%rax)
je 0xe470d
movq 0xf0(%rsp), %rax
movq (%rax), %rax
cmpl $0x9, (%rax)
je 0xe470d
movq 0xf0(%rsp), %rax
movq (%rax), %rax
cmpl $0xa, (%rax)
je 0xe470d
movq 0xf0(%rsp), %rax
movq (%rax), %rax
cmpl $0xb, (%rax)
jne 0xe4744
jmp 0xe4805
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0xe49e8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0xe49b8
movq 0x38(%rsp), %rsi
movq 0xf0(%rsp), %rax
movq (%rax), %rax
addq $0x88, %rax
movq %rax, 0xe8(%rsp)
movq 0xe8(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0xca900
jmp 0xe477e
movq 0x28(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
callq 0xe44e0
movb %al, 0x27(%rsp)
leaq 0xd0(%rsp), %rdi
callq 0x92a70
movb 0x27(%rsp), %al
testb $0x1, %al
jne 0xe47ab
jmp 0xe4803
movq 0x38(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq (%rax), %rax
addq $0x8, %rax
movq %rax, 0xc8(%rsp)
leaq 0xc8(%rsp), %rsi
callq 0xe99f0
jmp 0xe47d6
movq 0x38(%rsp), %rdi
movq 0xf0(%rsp), %rax
movq (%rax), %rax
addq $0x48, %rax
movq %rax, 0xc0(%rsp)
leaq 0xc0(%rsp), %rsi
callq 0xe99f0
jmp 0xe4801
jmp 0xe4803
jmp 0xe4805
leaq 0x100(%rsp), %rdi
callq 0x49460
jmp 0xe468a
movq 0x38(%rsp), %rdi
callq 0xca5a0
movq %rax, 0xb0(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0xea0c0
movq 0x38(%rsp), %rdi
movq 0xb8(%rsp), %rsi
callq 0xea050
movq %rax, 0x18(%rsp)
jmp 0xe4857
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rax
movq %rax, 0xa8(%rsp)
callq 0xca5a0
movq %rax, 0xa0(%rsp)
movq 0x38(%rsp), %rdi
callq 0xca420
movq %rax, 0x98(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0xe9a20
testb $0x1, %al
jne 0xe48a6
jmp 0xe4996
leaq 0xa0(%rsp), %rdi
callq 0xe9a60
movq (%rax), %rsi
addq $0x8, %rsi
leaq 0x78(%rsp), %rdi
callq 0x81a0
jmp 0xe48c6
leaq 0x78(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x82f0
movq 0x8(%rsp), %rdi
movq %rax, 0x70(%rsp)
callq 0x8230
movq %rax, 0x68(%rsp)
movb $0x2d, 0x67(%rsp)
movq 0x70(%rsp), %rdi
movq 0x68(%rsp), %rsi
leaq 0x67(%rsp), %rdx
callq 0xea100
movq %rax, 0x10(%rsp)
jmp 0xe4909
movq 0x10(%rsp), %rax
cmpq $0x1, %rax
jne 0xe4973
leaq 0x50(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0xea0c0
movq 0x38(%rsp), %rdi
movq 0x50(%rsp), %rsi
callq 0xea050
movq %rax, (%rsp)
jmp 0xe493b
movq (%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0xa0(%rsp)
jmp 0xe4987
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x8728
jmp 0xe49b8
leaq 0xa0(%rsp), %rdi
xorl %esi, %esi
callq 0xea150
movq %rax, 0x48(%rsp)
leaq 0x78(%rsp), %rdi
callq 0x8728
jmp 0xe4876
movb $0x1, 0x14f(%rsp)
movl $0x1, 0x148(%rsp)
leaq 0x120(%rsp), %rdi
callq 0x49500
jmp 0xe49c7
leaq 0x120(%rsp), %rdi
callq 0x49500
jmp 0xe49e8
testb $0x1, 0x14f(%rsp)
jne 0xe49db
movq 0x38(%rsp), %rdi
callq 0x92a70
movq 0x40(%rsp), %rax
addq $0x168, %rsp            # imm = 0x168
retq
movq 0x38(%rsp), %rdi
callq 0x92a70
movq 0x140(%rsp), %rdi
callq 0x8670
nop