// File: /workspace/github_c_makefile_star2_O2/lucvoo[P]sparse-dev/liveness.c
// Function: track_instruction_usage
static void track_instruction_usage(struct basic_block *bb, struct instruction *insn,
	void (*def)(struct basic_block *, pseudo_t),
	void (*use)(struct basic_block *, pseudo_t))
{
	pseudo_t pseudo;

	#define USES(x)		use(bb, insn->x)
	#define DEFINES(x)	def(bb, insn->x)

	switch (insn->opcode) {
	case OP_RET:
	case OP_COMPUTEDGOTO:
		USES(src);
		break;

	case OP_CBR:
	case OP_SWITCH:
		USES(cond);
		break;

	/* Binary */
	case OP_BINARY ... OP_BINARY_END:
	case OP_FPCMP ... OP_FPCMP_END:
	case OP_BINCMP ... OP_BINCMP_END:
		USES(src1); USES(src2); DEFINES(target);
		break;

	/* Uni */
	case OP_UNOP ... OP_UNOP_END:
	case OP_SYMADDR:
	case OP_SLICE:
		USES(src); DEFINES(target);
		break;

	case OP_SEL:
		USES(src1); USES(src2); USES(src3); DEFINES(target);
		break;
	
	/* Memory */
	case OP_LOAD:
		USES(src); DEFINES(target);
		break;

	case OP_STORE:
		USES(src); USES(target);
		break;

	case OP_LABEL:
	case OP_SETVAL:
	case OP_SETFVAL:
		DEFINES(target);
		break;

	/* Other */
	case OP_PHI:
		/* Phi-nodes are "backwards" nodes. Their def doesn't matter */
		phi_defines(insn, insn->target, def);
		break;

	case OP_PHISOURCE:
		/*
		 * We don't care about the phi-source define, they get set
		 * up and expanded by the OP_PHI
		 */
		USES(phi_src);
		break;

	case OP_CALL:
		USES(func);
		if (insn->target != VOID)
			DEFINES(target);
		FOR_EACH_PTR(insn->arguments, pseudo) {
			use(bb, pseudo);
		} END_FOR_EACH_PTR(pseudo);
		break;

	case OP_ASM:
		asm_liveness(bb, insn, def, use);
		break;

	case OP_RANGE:
		USES(src1); USES(src2); USES(src3);
		break;

	case OP_BADOP:
	case OP_NOP:
	case OP_CONTEXT:
		break;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl (%rsi), %eax
andl $0x7f, %eax
addl $-0x2, %eax
cmpl $0x4e, %eax
ja 0x37194
movq %rdx, %rbp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0xd781(%rip), %rdx      # 0x44714
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
movq %rcx, %r14
jmpq *%rax
movq 0x30(%r15), %rsi
movq %rbx, %rdi
movq %rcx, %r14
callq *%rcx
movq 0x38(%r15), %rsi
movq %rbx, %rdi
callq *%r14
jmp 0x36fc0
movq 0x30(%r15), %rsi
movq %rbx, %rdi
callq *%rcx
pushq $0x20
popq %rax
movq %rbp, %rcx
movq (%r15,%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rcx
pushq $0x30
popq %rax
jmp 0x36fc6
movq 0x30(%r15), %rsi
movq %rbx, %rdi
callq *%rcx
movq 0x20(%r15), %rsi
cmpq 0x22f9a(%rip), %rsi     # 0x59f90
je 0x36ffd
movq %rbx, %rdi
callq *%rbp
movq 0x38(%r15), %r13
testq %r13, %r13
je 0x37194
movq %r13, %r15
xorl %r12d, %r12d
movl (%r15), %eax
movsbq %al, %rcx
cmpq %rcx, %r12
jge 0x37037
movq 0x18(%r15,%r12,8), %rsi
cmpw $0x100, %ax             # imm = 0x100
jb 0x3702c
testq %rsi, %rsi
je 0x37032
movq %rbx, %rdi
callq *%r14
incq %r12
jmp 0x37010
movq 0x10(%r15), %r15
cmpq %r13, %r15
jne 0x3700d
jmp 0x37194
movq 0x30(%r15), %rsi
movq %rbx, %rdi
callq *%r14
movq 0x38(%r15), %rsi
movq %rbx, %rdi
callq *%r14
movq %r14, %rcx
pushq $0x40
jmp 0x36fdf
movq 0x30(%r15), %rsi
movq %rbx, %rdi
callq *%r14
movq %r14, %rcx
pushq $0x20
jmp 0x36fdf
movq 0x38(%r15), %r12
testq %r12, %r12
je 0x37194
movq 0x20(%r15), %rbx
leaq 0x28941(%rip), %r15     # 0x5f9d0
movq %r12, %r13
movq %rbp, %r14
xorl %ebp, %ebp
movl (%r13), %ecx
movsbq %cl, %rax
cmpq %rax, %rbp
jge 0x370dd
movq 0x18(%r13,%rbp,8), %rax
cmpw $0x100, %cx             # imm = 0x100
setae %cl
testq %rax, %rax
sete %dl
testb %dl, %cl
jne 0x370d8
cmpq %r15, %rax
je 0x370d8
movq 0x18(%rax), %rax
testq %rax, %rax
je 0x370d8
movq 0x8(%rax), %rdi
testq %rdi, %rdi
je 0x370d8
movq %rbx, %rsi
callq *%r14
incq %rbp
jmp 0x37097
movq 0x10(%r13), %r13
cmpq %r12, %r13
movq %r14, %rbp
jne 0x37092
jmp 0x37194
movq 0x38(%r15), %rax
movq (%rax), %r12
testq %r12, %r12
je 0x37142
movq %rbp, (%rsp)
movq %r12, %r13
xorl %ebp, %ebp
movl (%r13), %eax
movsbq %al, %rdx
cmpq %rdx, %rbp
jge 0x37131
movq 0x18(%r13,%rbp,8), %rdx
cmpw $0x100, %ax             # imm = 0x100
jb 0x37120
testq %rdx, %rdx
je 0x3712c
movq (%rdx), %rsi
movq %rbx, %rdi
callq *%r14
movq %r14, %rcx
incq %rbp
jmp 0x37103
movq 0x10(%r13), %r13
cmpq %r12, %r13
jne 0x37101
movq 0x38(%r15), %rax
movq (%rsp), %rbp
movq 0x8(%rax), %r15
testq %r15, %r15
je 0x37194
movq %r15, %r12
xorl %r13d, %r13d
movl (%r12), %edx
movsbq %dl, %rax
cmpq %rax, %r13
jge 0x3718a
movq 0x18(%r12,%r13,8), %rax
cmpw $0x100, %dx             # imm = 0x100
jb 0x3716f
testq %rax, %rax
je 0x37185
testb $0x1, 0x18(%rax)
movq (%rax), %rsi
movq %rcx, %rax
cmoveq %rbp, %rax
movq %rbx, %rdi
callq *%rax
movq %r14, %rcx
incq %r13
jmp 0x37151
movq 0x10(%r12), %r12
cmpq %r15, %r12
jne 0x3714e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30(%r15), %rsi
movq %rbx, %rdi
movq %rcx, %r14
callq *%rcx
movq 0x38(%r15), %rsi
movq %rbx, %rdi
callq *%r14
movq 0x40(%r15), %rsi
jmp 0x36faf