// File: /workspace/github_cpp_makefile_star2_O3/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 0x4a450
movq 0x8(%rbx), %rdi
movq %rbx, 0x70(%rsp)
movq 0x10(%rbx), %rsi
movq %r14, %rdx
callq 0x4a58e
movq %rax, %r14
leaq 0x10(%rsp), %rbx
movq %rbx, -0x10(%rbx)
movq 0x8(%r15), %rsi
movq 0x10(%r15), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0xc6dc
leaq 0x27ac9(%rip), %rsi     # 0x717cc
movq %rsp, %rdi
callq 0x8590
movl 0x28(%r15), %r15d
movl %r15d, %ebp
negl %ebp
cmovsl %r15d, %ebp
movl $0x1, %r12d
cmpl $0xa, %ebp
jb 0x49d6c
movl $0x4, %r12d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %ebp, %ecx
cmpl $0x63, %ecx
jbe 0x49d63
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x49d69
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x49d6c
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r12d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x49d30
addl $-0x3, %r12d
jmp 0x49d6c
addl $-0x2, %r12d
jmp 0x49d6c
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 0xc35d
movq (%rsp), %rcx
movq 0x8(%rsp), %r8
movq 0x58(%rsp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
movq %rbx, %r15
cmpq %rbx, %rcx
je 0x49dc2
movq 0x10(%rsp), %rdi
movq 0x50(%rsp), %rsi
cmpq %rdi, %rax
jbe 0x49de0
movl $0xf, %edi
cmpq %r13, %rsi
je 0x49ddb
movq 0x60(%rsp), %rdi
cmpq %rdi, %rax
jbe 0x49dea
movq %rsp, %rdi
callq 0x8120
jmp 0x49df8
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 0x49e1c
movq %rsi, 0x30(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x40(%rsp)
jmp 0x49e22
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 0x49e56
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x82a0
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x49e6c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x18(%rsp), %r15
addq $0x8, %r14
movq %rsp, %r12
leaq 0x30(%rsp), %r13
movq 0x70(%rsp), %rax
cmpq 0x10(%rax), %r14
je 0x49ef2
movq (%r14), %rsi
movq %r12, %rdi
movl $0x1, %edx
callq 0x58895
movq (%rsp), %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
callq 0x4a639
cmpq 0x8(%rsp), %rax
je 0x49eb6
xorl %ebx, %ebx
xorl %ebp, %ebp
jmp 0x49ed8
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movq %r13, %rdx
callq 0x4a639
cmpq 0x20(%rsp), %rax
sete %bl
setne %al
orb %bpl, %al
movl %eax, %ebp
movq %r15, %rdi
callq 0x45cd2
movq %r12, %rdi
callq 0x45cd2
addq $0x8, %r14
testb %bl, %bl
jne 0x49e7d
jmp 0x49f0b
leaq 0x80(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x4826a
testq %rax, %rax
setne %bpl
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x49f26
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x80(%rsp), %rdi
callq 0x25b24
andb $0x1, %bpl
movl %ebp, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x49f9c
movq %rax, %r14
movq 0x50(%rsp), %rdi
cmpq %r13, %rdi
je 0x49f6e
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x82a0
jmp 0x49f6e
jmp 0x49f6b
movq %rax, %r14
movq (%rsp), %rdi
cmpq %rbx, %rdi
je 0x49fba
movq 0x10(%rsp), %rsi
jmp 0x49fb2
jmp 0x49f80
movq %rax, %r14
jmp 0x49fba
jmp 0x49f87
movq %rax, %r14
movq %r15, %rdi
callq 0x45cd2
movq %rsp, %rdi
callq 0x45cd2
jmp 0x49f9f
movq %rax, %r14
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x49fba
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x82a0
leaq 0x80(%rsp), %rdi
callq 0x25b24
movq %r14, %rdi
callq 0x8540
nop