// File: /workspace/github_cpp_makefile_star2_O1/luooofan[P]hblzbd_compiler/src/Pass/dead_function_eliminate.cpp
// Function: isLiveness(IRBasicBlock*, ir::IR*, ir::Opn)
bool isLiveness(IRBasicBlock *bb, ir::IR *end_ir, ir::Opn opn) {
  std::unordered_set<std::string> keepalive = bb->liveout_;
  auto it = find(bb->ir_list_.begin(), bb->ir_list_.end(), end_ir);
  std::string opn_str = opn.name_ + "." + std::to_string(opn.scope_id_);

  for (auto iter = it + 1; iter != bb->ir_list_.end(); ++iter) {
    auto ir = *iter;

    auto [def, use] = GetDefUse(ir);

    if (find(def.begin(), def.end(), opn_str) != def.end()) {
      return false;
    }

    if (find(use.begin(), use.end(), opn_str) != use.end()) {
      return true;
    }
  }

  if (keepalive.find(opn_str) != keepalive.end()) {
    return true;
  } else {
    return false;
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdx, %r15
movq %rdi, %rbx
leaq 0x78(%rsp), %r14
movq %rsi, (%r14)
leaq 0x100(%rdi), %rsi
xorl %eax, %eax
leaq 0x80(%rsp), %rdi
movq %rax, (%rdi)
movq 0x108(%rbx), %rcx
movq %rcx, 0x8(%rdi)
movq %rax, 0x10(%rdi)
movq 0x118(%rbx), %rcx
movq %rcx, 0x18(%rdi)
movups 0x120(%rbx), %xmm0
movups %xmm0, 0x20(%rdi)
movq %rax, 0x30(%rdi)
movq %rsp, %rdx
movq %rdi, (%rdx)
callq 0x4adf2
movq 0x8(%rbx), %rdi
movq %rbx, 0x70(%rsp)
movq 0x10(%rbx), %rsi
movq %r14, %rdx
callq 0x4af35
movq %rax, %rbx
leaq 0x10(%rsp), %r14
movq %r14, -0x10(%r14)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0xca10
leaq 0x28125(%rip), %rsi     # 0x727c8
movq %rsp, %rdi
callq 0x8590
movl 0x28(%r15), %r15d
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
movl $0x1, %r12d
cmpl $0xa, %ebp
jb 0x4a70c
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0x4a703
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x4a709
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x4a70c
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x4a6d0
addl $-0x3, %r12d
jmp 0x4a70c
addl $-0x2, %r12d
jmp 0x4a70c
decl %r12d
shrl $0x1f, %r15d
leal (%r12,%r15), %esi
leaq 0x60(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x50(%rsp), %rdi
movl $0x2d, %edx
callq 0x8350
addq 0x50(%rsp), %r15
movq %r15, %rdi
movl %r12d, %esi
movl %ebp, %edx
callq 0xc65b
movq (%rsp), %rcx
movq 0x8(%rsp), %r8
movq 0x58(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
cmpq %r14, %rcx
je 0x4a75f
movq 0x10(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x4a77a
movl $0xf, %esi
cmpq %r13, 0x50(%rsp)
je 0x4a775
movq 0x60(%rsp), %rsi
cmpq %rsi, %rax
jbe 0x4a789
movq 0x50(%rsp), %rsi
movq %rsp, %rdi
callq 0x8120
jmp 0x4a797
leaq 0x50(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x8310
leaq 0x40(%rsp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x4a7bb
movq %rsi, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x4a7c1
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x38(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x4a7f5
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x82a0
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x4a80b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x82a0
addq $0x8, %rbx
movq %rsp, %r12
movq %rbx, %r14
movq 0x70(%rsp), %rax
movq 0x10(%rax), %r15
cmpq %r15, %rbx
je 0x4a898
movq (%r14), %rsi
movq %r12, %rdi
movl $0x1, %edx
callq 0x59681
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x4afd4
cmpq 0x8(%rsp), %rax
je 0x4a854
xorl %r13d, %r13d
xorl %ebp, %ebp
jmp 0x4a879
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x4afd4
cmpq 0x20(%rsp), %rax
sete %r13b
setne %al
orb %bpl, %al
movl %eax, %ebp
leaq 0x18(%rsp), %rdi
callq 0x4643e
movq %r12, %rdi
callq 0x4643e
leaq 0x8(%r14), %rbx
testb %r13b, %r13b
jne 0x4a812
cmpq %r15, %r14
jne 0x4a8b6
leaq 0x80(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x48ae0
testq %rax, %rax
setne %bpl
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4a8d1
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x80(%rsp), %rdi
callq 0x25458
andb $0x1, %bpl
movl %ebp, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4a949
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x4a919
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x4a919
jmp 0x4a916
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x4a967
movq 0x10(%rsp), %rsi
jmp 0x4a95f
jmp 0x4a92b
movq %rax, %rbx
jmp 0x4a967
jmp 0x4a932
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x4643e
movq %rsp, %rdi
callq 0x4643e
jmp 0x4a94c
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x4a967
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x80(%rsp), %rdi
callq 0x25458
movq %rbx, %rdi
callq 0x8540