// File: /workspace/github_c_makefile_star2_O2/lucvoo[P]sparse-dev/cse.c
// Function: cse_collect
void cse_collect(struct instruction *insn)
{
	unsigned long hash;

	hash = (insn->opcode << 3) + (insn->size >> 3);
	switch (insn->opcode) {
	case OP_SEL:
		hash += hashval(insn->src3);
		/* Fall through */	

	/* Binary arithmetic */
	case OP_ADD: case OP_SUB:
	case OP_MUL:
	case OP_DIVU: case OP_DIVS:
	case OP_MODU: case OP_MODS:
	case OP_SHL:
	case OP_LSR: case OP_ASR:
	case OP_AND: case OP_OR:

	/* Binary logical */
	case OP_XOR:

	/* Binary comparison */
	case OP_SET_EQ: case OP_SET_NE:
	case OP_SET_LE: case OP_SET_GE:
	case OP_SET_LT: case OP_SET_GT:
	case OP_SET_B:  case OP_SET_A:
	case OP_SET_BE: case OP_SET_AE:

	/* floating-point arithmetic & comparison */
	case OP_FPCMP ... OP_FPCMP_END:
	case OP_FADD:
	case OP_FSUB:
	case OP_FMUL:
	case OP_FDIV:
		hash += hashval(insn->src2);
		/* Fall through */
	
	/* Unary */
	case OP_NOT: case OP_NEG:
	case OP_FNEG:
	case OP_SYMADDR:
		hash += hashval(insn->src1);
		break;

	case OP_LABEL:
		hash += hashval(insn->bb_true);
		break;

	case OP_SETVAL:
		hash += hashval(insn->val);
		break;

	case OP_SETFVAL:
		hash += hashval(insn->fvalue);
		break;

	case OP_SEXT: case OP_ZEXT:
	case OP_TRUNC:
	case OP_PTRCAST:
	case OP_UTPTR: case OP_PTRTU:
		if (!insn->orig_type || insn->orig_type->bit_size < 0)
			return;
		hash += hashval(insn->src);

		// Note: see corresponding line in insn_compare()
		hash += hashval(insn->orig_type->bit_size);
		break;

	/* Other */
	case OP_PHI: {
		pseudo_t phi;
		FOR_EACH_PTR(insn->phi_list, phi) {
			struct instruction *def;
			if (phi == VOID || !phi->def)
				continue;
			def = phi->def;
			hash += hashval(def->src1);
			hash += hashval(def->bb);
		} END_FOR_EACH_PTR(phi);
		break;
	}

	default:
		/*
		 * Nothing to do, don't even bother hashing them,
		 * we're not going to try to CSE them
		 */
		return;
	}
	hash += hash >> 16;
	hash &= INSN_HASH_SIZE-1;
	add_instruction(insn_hash_table + hash, insn);
}

// Assembly:
pushq %rbp
pushq %rbx
movl (%rdi), %eax
movl %eax, %edx
andl $0x7f, %edx
leal -0x8(%rdx), %ecx
cmpl $0x41, %ecx
ja 0x2be81
movq %rdi, %rsi
shrl $0xb, %eax
leal (%rax,%rdx,8), %eax
leaq 0x16b2b(%rip), %rdx     # 0x42964
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
addq 0x38(%rsi), %rax
addq 0x30(%rsi), %rax
movl %eax, %ecx
shrl $0x10, %ecx
addl %eax, %ecx
movzbl %cl, %eax
leaq 0x5d8a5(%rip), %rcx     # 0x89700
leaq (%rcx,%rax,8), %rdi
popq %rbx
popq %rbp
jmp 0x1fae9
movq 0x40(%rsi), %rcx
testq %rcx, %rcx
je 0x2be81
movl 0x50(%rcx), %ecx
testl %ecx, %ecx
js 0x2be81
addl %eax, %ecx
addq 0x30(%rsi), %rcx
movq %rcx, %rax
jmp 0x2be4a
popq %rbx
popq %rbp
retq
movq 0x38(%rsi), %rcx
testq %rcx, %rcx
je 0x2be4a
leaq 0x33b3c(%rip), %rdx     # 0x5f9d0
movq %rcx, %rdi
movzwl (%rdi), %r8d
movsbl %r8b, %r9d
testw %r9w, %r9w
movl $0x0, %r10d
cmovgl %r9d, %r10d
movzwl %r10w, %r9d
xorl %r10d, %r10d
cmpq %r10, %r9
je 0x2beee
cmpw $0x100, %r8w            # imm = 0x100
setae %bl
movq 0x18(%rdi,%r10,8), %r11
testq %r11, %r11
sete %bpl
testb %bpl, %bl
jne 0x2bee9
cmpq %rdx, %r11
je 0x2bee9
movq 0x18(%r11), %r11
testq %r11, %r11
je 0x2bee9
addq 0x30(%r11), %rax
addq 0x8(%r11), %rax
incq %r10
jmp 0x2beb4
movq 0x10(%rdi), %rdi
cmpq %rcx, %rdi
jne 0x2be97
jmp 0x2be4a
addq 0x38(%rsi), %rax
jmp 0x2be4a
fldt 0x30(%rsi)
flds 0x16a52(%rip)           # 0x42960
xorl %ecx, %ecx
fucomi %st(1), %st
setbe %cl
fldz
fcmovbe %st(1), %st
fstp %st(1)
fsubrp %st, %st(1)
fnstcw -0xc(%rsp)
movzwl -0xc(%rsp), %edx
orl $0xc00, %edx            # imm = 0xC00
movw %dx, -0xa(%rsp)
fldcw -0xa(%rsp)
fistpll -0x8(%rsp)
fldcw -0xc(%rsp)
shlq $0x3f, %rcx
xorq -0x8(%rsp), %rcx
addq %rcx, %rax
jmp 0x2be4a
addq 0x40(%rsi), %rax
jmp 0x2be42