// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/ssa.c
// Function: ssa_convert_one_var
static void ssa_convert_one_var(struct entrypoint *ep, struct symbol *var)
{
	unsigned long generation = ++bb_generation;
	struct basic_block_list *alpha = NULL;
	struct basic_block_list *idf = NULL;
	struct basic_block *samebb = NULL;
	struct basic_block *bb;
	struct pseudo_user *pu;
	unsigned long mod = var->ctype.modifiers;
	bool local = true;
	int nbr_stores = 0;
	int nbr_uses   = 0;
	pseudo_t addr;

	/* Never used as a symbol? */
	addr = var->pseudo;
	if (!addr)
		return;

	/* We don't do coverage analysis of volatiles.. */
	if (mod & MOD_VOLATILE)
		return;

	/* ..and symbols with external visibility need more care */
	mod &= (MOD_NONLOCAL | MOD_STATIC | MOD_ADDRESSABLE);
	if (mod)
		goto external_visibility;

	if (!is_promotable(var))
		return;

	// 1) insert in the worklist all BBs that may modify var
	FOR_EACH_PTR(addr->users, pu) {
		struct instruction *insn = pu->insn;
		struct basic_block *bb = insn->bb;

		switch (insn->opcode) {
		case OP_STORE:
			nbr_stores++;
			if (bb->generation != generation) {
				bb->generation = generation;
				add_bb(&alpha, bb);
			}
			/* fall through */
		case OP_LOAD:
			if (local) {
				if (!samebb)
					samebb = bb;
				else if (samebb != bb)
					local = false;
			}
			nbr_uses++;
			break;
		case OP_SYMADDR:
			mod |= MOD_ADDRESSABLE;
			goto external_visibility;
		default:
			warning(var->pos, "symbol '%s' pseudo used in unexpected way",
				show_ident(var->ident));
		}
	} END_FOR_EACH_PTR(pu);

	// if all uses are local to a single block
	// they can easily be rewritten and doesn't need phi-nodes
	// FIXME: could be done for extended BB too
	if (local) {
		rewrite_local_var(samebb, addr, nbr_stores, nbr_uses);
		return;
	}

	idf_compute(ep, &idf, alpha);
	FOR_EACH_PTR(idf, bb) {
		struct instruction *node = insert_phi_node(bb, var);
		node->phi_var = var->pseudo;
	} END_FOR_EACH_PTR(bb);
	var->torename = 1;

external_visibility:
	if (mod & (MOD_NONLOCAL | MOD_STATIC))
		return;
	kill_dead_stores(ep, addr, !mod);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x7862e(%rip), %rax     # 0xb6358
movq (%rax), %rax
addq $0x1, %rax
leaq 0x78620(%rip), %rcx     # 0xb6358
movq %rax, (%rcx)
movq %rax, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rax
movq %rax, -0x48(%rbp)
movb $0x1, -0x49(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x3dd90
jmp 0x3e0f3
movq -0x48(%rbp), %rax
andq $0x400, %rax            # imm = 0x400
cmpq $0x0, %rax
je 0x3dda5
jmp 0x3e0f3
movq -0x48(%rbp), %rax
andq $0x11c, %rax            # imm = 0x11C
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x3ddbf
jmp 0x3e0c7
movq -0x10(%rbp), %rdi
callq 0x3e4f0
testb $0x1, %al
jne 0x3ddd1
jmp 0x3e0f3
jmp 0x3ddd3
movq -0x60(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x3ddfb
jmp 0x3df8e
jmp 0x3ddfd
movl $0x0, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movq -0x70(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jge 0x3df76
movq -0x70(%rbp), %rax
movslq -0x7c(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x70(%rbp), %rax
movw (%rax), %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
je 0x3de4f
cmpq $0x0, -0x40(%rbp)
jne 0x3de4f
jmp 0x3df68
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rax
movl (%rax), %eax
andl $0x7f, %eax
movl %eax, -0xbc(%rbp)
subl $0x3f, %eax
je 0x3df1f
jmp 0x3de8c
movl -0xbc(%rbp), %eax
subl $0x43, %eax
je 0x3dee5
jmp 0x3de99
movl -0xbc(%rbp), %eax
subl $0x44, %eax
jne 0x3df32
jmp 0x3deaa
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movq -0x90(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x18(%rbp), %rax
je 0x3dee3
movq -0x18(%rbp), %rcx
movq -0x90(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x90(%rbp), %rsi
leaq -0x20(%rbp), %rdi
callq 0x3e7d0
jmp 0x3dee5
testb $0x1, -0x49(%rbp)
je 0x3df14
cmpq $0x0, -0x30(%rbp)
jne 0x3deff
movq -0x90(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x3df12
movq -0x30(%rbp), %rax
cmpq -0x90(%rbp), %rax
je 0x3df10
movb $0x0, -0x49(%rbp)
jmp 0x3df12
jmp 0x3df14
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x3df66
movq -0x48(%rbp), %rax
orq $0x100, %rax            # imm = 0x100
movq %rax, -0x48(%rbp)
jmp 0x3e0c7
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x44150
movq %rax, %rdx
movq -0xc8(%rbp), %rax
movq 0x4(%rax), %rdi
leaq 0x2b3ef(%rip), %rsi     # 0x6934e
movb $0x0, %al
callq 0x16d80
jmp 0x3df68
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x3de04
jmp 0x3df78
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x70(%rbp)
cmpq -0x68(%rbp), %rax
jne 0x3ddfd
testb $0x1, -0x49(%rbp)
je 0x3dfac
movq -0x30(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x50(%rbp), %edx
movl -0x54(%rbp), %ecx
callq 0x3e800
jmp 0x3e0f3
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rdx
leaq -0x28(%rbp), %rsi
callq 0x4a560
movq -0x28(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xa8(%rbp)
cmpq $0x0, -0x98(%rbp)
jne 0x3dff3
jmp 0x3e0b1
jmp 0x3dff5
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
movq -0xa0(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jge 0x3e090
movq -0xa0(%rbp), %rax
movslq -0xac(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0xa0(%rbp), %rax
movw (%rax), %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
je 0x3e052
cmpq $0x0, -0x38(%rbp)
jne 0x3e052
jmp 0x3e07c
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x1a8b0
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rcx
movq -0xb8(%rbp), %rax
movq %rcx, 0x30(%rax)
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0x3dfff
jmp 0x3e092
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
cmpq -0x98(%rbp), %rax
jne 0x3dff5
movq -0x10(%rbp), %rax
movl 0x54(%rax), %ecx
andl $0xffefffff, %ecx       # imm = 0xFFEFFFFF
orl $0x100000, %ecx         # imm = 0x100000
movl %ecx, 0x54(%rax)
movq -0x48(%rbp), %rax
andq $0x1c, %rax
cmpq $0x0, %rax
je 0x3e0d7
jmp 0x3e0f3
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
cmpq $0x0, -0x48(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %edx
callq 0x59480
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)