// File: /workspace/github_c_makefile_star2_O2/lucvoo[P]sparse-dev/linearize.c
// Function: linearize_statement
static pseudo_t linearize_statement(struct entrypoint *ep, struct statement *stmt)
{
	struct basic_block *bb;

	if (!stmt)
		return VOID;

	bb = ep->active;
	if (bb && !bb->insns)
		bb->pos = stmt->pos;
	current_pos = stmt->pos;

	switch (stmt->type) {
	case STMT_NONE:
		break;

	case STMT_DECLARATION:
		return linearize_declaration(ep, stmt);

	case STMT_CONTEXT:
		return linearize_context(ep, stmt);

	case STMT_RANGE:
		return linearize_range(ep, stmt);

	case STMT_EXPRESSION:
		return linearize_expression(ep, stmt->expression);

	case STMT_ASM:
		return linearize_asm_statement(ep, stmt);

	case STMT_RETURN:
		return linearize_return(ep, stmt);

	case STMT_CASE: {
		add_label(ep, stmt->case_label);
		linearize_statement(ep, stmt->case_statement);
		break;
	}

	case STMT_LABEL: {
		struct symbol *label = stmt->label_identifier;

		if (label->used) {
			add_label(ep, label);
		}
		return linearize_statement(ep, stmt->label_statement);
	}

	case STMT_GOTO: {
		struct symbol *sym;
		struct expression *expr;
		struct instruction *goto_ins;
		struct basic_block *active;
		pseudo_t pseudo;

		active = ep->active;
		if (!bb_reachable(active))
			break;

		if (stmt->goto_label) {
			add_goto(ep, get_bound_block(ep, stmt->goto_label));
			break;
		}

		expr = stmt->goto_expression;
		if (!expr)
			break;

		/* This can happen as part of simplification */
		if (expr->type == EXPR_LABEL) {
			add_goto(ep, get_bound_block(ep, expr->label_symbol));
			break;
		}

		pseudo = linearize_expression(ep, expr);
		goto_ins = alloc_instruction(OP_COMPUTEDGOTO, 0);
		use_pseudo(goto_ins, pseudo, &goto_ins->src);
		add_one_insn(ep, goto_ins);

		FOR_EACH_PTR(stmt->target_list, sym) {
			struct basic_block *bb_computed = get_bound_block(ep, sym);
			struct multijmp *jmp = alloc_multijmp(bb_computed, 1, 0);
			add_multijmp(&goto_ins->multijmp_list, jmp);
			add_bb(&bb_computed->parents, ep->active);
			add_bb(&active->children, bb_computed);
		} END_FOR_EACH_PTR(sym);

		finish_block(ep);
		break;
	}

	case STMT_COMPOUND:
		if (stmt->inline_fn)
			return linearize_inlined_call(ep, stmt);
		return linearize_compound_statement(ep, stmt);

	/*
	 * This could take 'likely/unlikely' into account, and
	 * switch the arms around appropriately..
	 */
	case STMT_IF: {
		struct basic_block *bb_true, *bb_false, *endif;
 		struct expression *cond = stmt->if_conditional;

		bb_true = alloc_basic_block(ep, stmt->pos);
		bb_false = endif = alloc_basic_block(ep, stmt->pos);

		// If the condition is invalid, the following
		// statement(s) are not evaluated.
		if (!cond || !valid_type(cond->ctype))
			return VOID;
 		linearize_cond_branch(ep, cond, bb_true, bb_false);

		set_activeblock(ep, bb_true);
 		linearize_statement(ep, stmt->if_true);
 
 		if (stmt->if_false) {
			endif = alloc_basic_block(ep, stmt->pos);
			add_goto(ep, endif);
			set_activeblock(ep, bb_false);
 			linearize_statement(ep, stmt->if_false);
		}
		set_activeblock(ep, endif);
		break;
	}

	case STMT_SWITCH:
		return linearize_switch(ep, stmt);

	case STMT_ITERATOR:
		return linearize_iterator(ep, stmt);

	default:
		break;
	}
	return VOID;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
xorl %ebp, %ebp
leaq 0x4b3b3(%rip), %r13     # 0x5f9d0
leaq 0x25498(%rip), %r15     # 0x39abc
movl %ebp, 0x8(%rsp)
testq %r14, %r14
je 0x14dd4
movq 0x20(%rbx), %rax
testq %rax, %rax
je 0x14648
cmpq $0x0, 0x28(%rax)
jne 0x14648
movq 0x4(%r14), %rcx
movq %rcx, (%rax)
movq 0x4(%r14), %rsi
movq %rsi, 0x4c715(%rip)     # 0x60d68
movl (%r14), %eax
decl %eax
cmpl $0xc, %eax
ja 0x14dd4
movslq (%r15,%rax,4), %rax
addq %r15, %rax
jmpq *%rax
movq 0x10(%r14), %rsi
testb $0x2, 0x2(%rsi)
je 0x1467c
movq %rbx, %rdi
callq 0x153ec
movq 0x20(%r14), %r14
jmp 0x14628
movq 0x28(%r14), %rsi
movq %rbx, %rdi
callq 0x153ec
movq 0x20(%r14), %r14
movb $0x1, %bpl
jmp 0x14624
movq 0x20(%r14), %r12
movq 0x28(%r14), %r15
movq 0x30(%r14), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%r14), %rax
movq %rax, 0x18(%rsp)
movq 0x40(%r14), %rax
movq %rax, 0x20(%rsp)
movq 0x48(%r14), %rax
movq %rax, (%rsp)
testq %r12, %r12
je 0x14be0
movq %r12, %r13
xorl %ebp, %ebp
movl (%r13), %eax
movsbq %al, %rcx
cmpq %rcx, %rbp
jge 0x146fa
movq 0x18(%r13,%rbp,8), %rsi
cmpw $0x100, %ax             # imm = 0x100
jb 0x146ed
testq %rsi, %rsi
je 0x146f5
movq %rbx, %rdi
callq 0x144b3
incq %rbp
jmp 0x146d0
movq 0x10(%r13), %r13
cmpq %r12, %r13
jne 0x146ce
movq 0x20(%r14), %rdi
jmp 0x14be2
movq %rbx, %rdi
callq 0x134b2
movq 0x10(%r14), %r15
movq %r13, %r12
testq %r15, %r15
je 0x14dd7
cmpq $0x0, 0x10(%r15)
movq %r13, %r12
je 0x14dd7
movq %rax, 0x30(%rsp)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x13895
movq %rax, %r13
movq 0x20(%rbx), %rax
movq %rax, (%rsp)
testq %rax, %rax
jne 0x1476d
movq 0x4(%r14), %rsi
movq %rbx, %rdi
callq 0x134b2
movq %rbx, %rdi
movq %rax, (%rsp)
movq %rax, %rsi
callq 0x134e4
movq 0x10(%r15), %rsi
pushq $0x5
popq %rdi
callq 0x12bbd
movq %rax, %r15
leaq 0x30(%rax), %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x12bdf
movq %rbx, %rdi
movq %r15, %rsi
callq 0x13783
cmpq $0x0, 0x20(%rbx)
je 0x147a2
andq $0x0, 0x20(%rbx)
movq 0x28(%r14), %rax
movq 0x98(%rax), %rcx
testq %rcx, %rcx
movq %r15, 0x28(%rsp)
je 0x14d30
leaq 0x38(%r15), %rax
movq %rax, 0x20(%rsp)
movq (%rsp), %rax
addq $0x20, %rax
movq %rax, 0x18(%rsp)
movq $0x0, 0x8(%rsp)
movq %rcx, %rbp
movq %rcx, 0x10(%rsp)
xorl %r15d, %r15d
movl (%rbp), %eax
movsbq %al, %rcx
cmpq %rcx, %r15
jge 0x1489b
movq 0x18(%rbp,%r15,8), %rsi
cmpw $0x100, %ax             # imm = 0x100
jb 0x14809
testq %rsi, %rsi
je 0x14893
movq 0x90(%rsi), %r12
movq %rbx, %rdi
callq 0x1544a
movq %rax, %r13
movq 0x10(%r12), %rax
testq %rax, %rax
je 0x14857
cmpb $0x1, (%rax)
jne 0x14893
movq 0x18(%r12), %rcx
movq 0x20(%rax), %rax
movq %rax, %rdx
testq %rcx, %rcx
je 0x1485e
cmpb $0x1, (%rcx)
movq %rax, %rdx
jne 0x1485e
movq 0x20(%rcx), %rdx
cmpq %rdx, %rax
jle 0x1485e
movq %r13, %rdi
movq %rdx, %rsi
movq %rax, %rdx
jmp 0x14864
movq %r13, 0x8(%rsp)
jmp 0x14893
movq %r13, %rdi
movq %rax, %rsi
callq 0x1546d
movq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x1fae9
movq %r13, %rdi
addq $0x18, %rdi
movq (%rsp), %rsi
callq 0x1fae9
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x1fae9
incq %r15
jmp 0x147e5
movq 0x10(%rbp), %rbp
movq 0x10(%rsp), %rcx
cmpq %rcx, %rbp
jne 0x147e2
jmp 0x14d39
movq 0x10(%r14), %r12
movq 0x18(%r14), %r15
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1544a
movq %rax, %r14
movq %rbx, %rdi
movq %r12, %rsi
callq 0x13895
cmpq $0x0, 0x20(%rbx)
je 0x14901
cmpb $0x3, (%r15)
movq %r15, %rcx
jne 0x148e7
movq 0x60(%r15), %rcx
cmpq 0x4565a(%rip), %rcx     # 0x59f48
je 0x14901
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x15642
movq %rbx, %rdi
movq %r14, %rsi
callq 0x13830
jmp 0x14dd4
cmpq $0x0, 0x20(%r14)
je 0x14ced
pushq $0x4b
popq %rdi
xorl %esi, %esi
callq 0x1347f
movq %rax, (%rsp)
movq 0x28(%r14), %r15
testq %r15, %r15
je 0x14994
movq 0x10(%r15), %rdi
leaq 0x8(%rbx), %rsi
callq 0x1fe0b
movq 0x10(%r15), %r13
testq %r13, %r13
je 0x14994
movq (%rsp), %r12
addq $0x38, %r12
movq %r13, %rbp
xorl %r15d, %r15d
movl (%rbp), %eax
movsbq %al, %rcx
cmpq %rcx, %r15
jge 0x1498b
movq 0x18(%rbp,%r15,8), %rsi
cmpw $0x100, %ax             # imm = 0x100
jb 0x14973
testq %rsi, %rsi
je 0x14986
movq %rbx, %rdi
callq 0x144b3
movq %r12, %rdi
movq %rax, %rsi
callq 0x1fae9
incq %r15
jmp 0x14957
movq 0x10(%rbp), %rbp
cmpq %r13, %rbp
jne 0x14954
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1379a
movq %rax, %r12
movq (%rsp), %r15
movq %rax, 0x20(%r15)
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x14f2d
movq %rax, 0x30(%r15)
movq 0x20(%rbx), %rax
cmpq $0x0, 0x28(%rax)
jne 0x149cc
movq 0x4(%r14), %rcx
movq %rcx, (%rax)
movq %rbx, %rdi
movq %r15, %rsi
callq 0x13783
jmp 0x14cfb
movq 0x20(%rbx), %r15
movq %r13, %r12
testq %r15, %r15
je 0x14dd7
movq 0x10(%r14), %rsi
testq %rsi, %rsi
je 0x14d07
movq %rbx, %rdi
callq 0x1544a
movq %rbx, %rdi
movq %rax, %rsi
callq 0x13830
leaq 0x4afbd(%rip), %r13     # 0x5f9d0
jmp 0x14dd4
movq 0x10(%r14), %rdi
leaq 0x8(%rbx), %rsi
callq 0x1fe0b
movq 0x10(%r14), %r14
movq %r13, %r12
testq %r14, %r14
je 0x14dd7
movq %r14, %r15
xorl %r12d, %r12d
movl (%r15), %eax
movsbq %al, %rcx
cmpq %rcx, %r12
jge 0x14a64
movq 0x18(%r15,%r12,8), %rsi
cmpw $0x100, %ax             # imm = 0x100
jb 0x14a57
testq %rsi, %rsi
je 0x14a5f
movq %rbx, %rdi
callq 0x144b3
incq %r12
jmp 0x14a3b
movq 0x10(%r15), %r15
cmpq %r14, %r15
jne 0x14a38
jmp 0x14dd4
pushq $0x4f
popq %rdi
xorl %esi, %esi
callq 0x1347f
movq %rax, %r15
movq 0x10(%r14), %rdi
callq 0xfe1b
movl %eax, 0x30(%r15)
movq 0x18(%r14), %rax
movq %rax, 0x38(%r15)
jmp 0x14bd0
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x13895
movq %rax, %r12
jmp 0x14dd7
movq 0x10(%r14), %rbp
movq %rbx, %rdi
callq 0x134b2
movq %rax, %r15
movq 0x4(%r14), %rsi
movq %rbx, %rdi
callq 0x134b2
movq %r13, %r12
testq %rbp, %rbp
je 0x14dd7
movq 0x10(%rbp), %rdx
testq %rdx, %rdx
sete %cl
cmpq 0x4547b(%rip), %rdx     # 0x59f60
sete %dl
orb %cl, %dl
movq %r13, %r12
jne 0x14dd7
movq %rbx, %rdi
movq %rbp, %rsi
movq %r15, %rdx
movq %rax, %rcx
movq %rax, %rbp
callq 0x154fc
movq %rbx, %rdi
movq %r15, %rsi
callq 0x134e4
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x14600
cmpq $0x0, 0x20(%r14)
je 0x14dc9
movq 0x4(%r14), %rsi
movq %rbx, %rdi
callq 0x134b2
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x13830
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x134e4
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x14600
movq %r12, %rsi
jmp 0x14dcc
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1352d
jmp 0x14dd4
pushq $0x50
popq %rdi
xorl %esi, %esi
callq 0x1347f
movq %rax, %r15
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0x13895
leaq 0x30(%r15), %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x12bdf
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x13895
leaq 0x38(%r15), %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x12bdf
movq 0x20(%r14), %rsi
movq %rbx, %rdi
callq 0x13895
leaq 0x40(%r15), %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x12bdf
movq %rbx, %rdi
movq %r15, %rsi
callq 0x13783
jmp 0x14dd4
xorl %edi, %edi
leaq 0x8(%rbx), %rsi
callq 0x1fe0b
movq %rbx, %rdi
movq %r15, %rsi
callq 0x14600
movq 0x4(%r14), %rsi
movq %rbx, %rdi
callq 0x134b2
movq %rax, %r13
movq 0x4(%r14), %rsi
movq %rbx, %rdi
callq 0x134b2
movq %rax, %rbp
movq 0x4(%r14), %rsi
movq %rbx, %rdi
callq 0x134b2
movq %rax, %r12
movq %r13, %r15
cmpq $0x0, (%rsp)
jne 0x14c47
movq 0x4(%r14), %rsi
movq %rbx, %rdi
callq 0x134b2
movq %rax, %r15
movq %rbx, %rdi
movq %rax, %rsi
callq 0x134e4
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x14c5f
movq %rbx, %rdi
movq %r13, %rdx
movq %r12, %rcx
callq 0x154fc
movq 0x4(%r14), %rdx
movq 0x18(%r14), %rdi
movq %rbp, %rsi
callq 0x158da
movq 0x4(%r14), %rdx
movq 0x10(%r14), %rdi
movq %r12, %rsi
callq 0x158da
movq %rbx, %rdi
movq %r13, %rsi
callq 0x134e4
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x14600
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x13830
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x134e4
movq %rbx, %rdi
movq 0x20(%rsp), %rsi
callq 0x14600
movq (%rsp), %rsi
movq %rbx, %rdi
testq %rsi, %rsi
je 0x14cd3
movq %r15, %rdx
movq %r12, %rcx
callq 0x154fc
jmp 0x14cdb
movq %r15, %rsi
callq 0x13830
leaq 0x4acee(%rip), %r13     # 0x5f9d0
movq %rbx, %rdi
movq %r12, %rsi
jmp 0x14dcf
movq %rbx, %rdi
movq %r14, %rsi
callq 0x15493
movq %rax, %r12
leaq 0x4acce(%rip), %r13     # 0x5f9d0
jmp 0x14dd7
movq 0x18(%r14), %rsi
leaq 0x4acbe(%rip), %r13     # 0x5f9d0
movq %r13, %r12
testq %rsi, %rsi
je 0x14dd7
cmpb $0x17, (%rsi)
jne 0x14df2
movq 0x20(%rsi), %rsi
jmp 0x149f9
movq $0x0, 0x8(%rsp)
movq 0x4(%r14), %rdx
movq 0x20(%r14), %rdi
movq 0x30(%rsp), %r15
movq %r15, %rsi
callq 0x158da
movq 0x18(%r14), %rsi
movq %rbx, %rdi
callq 0x14600
movq %rbx, %rdi
movq %r15, %rsi
callq 0x134e4
movq 0x8(%rsp), %rax
testq %rax, %rax
cmovneq %rax, %r15
pushq $0x1
popq %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x1546d
movq 0x28(%rsp), %r14
addq $0x38, %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x1fae9
leaq 0x18(%r15), %rdi
movq (%rsp), %rbx
movq %rbx, %rsi
callq 0x1fae9
addq $0x20, %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x1fae9
leaq 0xb64(%rip), %rsi       # 0x1591c
movq %r14, %rdi
callq 0x257d4
leaq 0x4ac09(%rip), %r12     # 0x5f9d0
jmp 0x14de0
movq %rbp, %rsi
movq %rbx, %rdi
callq 0x134e4
movq %r13, %r12
testb $0x1, 0x8(%rsp)
cmovneq %r13, %r12
movq %r12, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbx, %rdi
callq 0x13895
movq %rax, %r13
pushq $0x7
popq %rdi
xorl %esi, %esi
callq 0x1347f
movq %rax, %r12
leaq 0x30(%rax), %rdx
movq %rax, %rdi
movq %r13, %rsi
callq 0x12bdf
movq %rbx, %rdi
movq %r12, %rsi
callq 0x13783
movq 0x20(%r14), %rax
movq %rax, (%rsp)
testq %rax, %rax
je 0x14ea6
addq $0x38, %r12
addq $0x20, %r15
movq (%rsp), %rbp
xorl %r14d, %r14d
movl (%rbp), %eax
movsbq %al, %rcx
cmpq %rcx, %r14
jge 0x14e9c
movq 0x18(%rbp,%r14,8), %rsi
cmpw $0x100, %ax             # imm = 0x100
jb 0x14e5c
testq %rsi, %rsi
je 0x14e97
movq %rbx, %rdi
callq 0x1544a
movq %rax, %r13
movq %rax, %rdi
pushq $0x1
popq %rsi
xorl %edx, %edx
callq 0x1546d
movq %r12, %rdi
movq %rax, %rsi
callq 0x1fae9
leaq 0x18(%r13), %rdi
movq 0x20(%rbx), %rsi
callq 0x1fae9
movq %r15, %rdi
movq %r13, %rsi
callq 0x1fae9
incq %r14
jmp 0x14e40
movq 0x10(%rbp), %rbp
cmpq (%rsp), %rbp
jne 0x14e3d
cmpq $0x0, 0x20(%rbx)
leaq 0x4ab1e(%rip), %r13     # 0x5f9d0
movq %r13, %r12
je 0x14dd7
andq $0x0, 0x20(%rbx)
jmp 0x14dd4