// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1c25a
leaq 0x6fb5f(%rip), %rax     # 0x8bdb0
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1c287
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x1c287
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x4(%rcx), %rcx
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq 0x4(%rax), %rax
movq %rax, 0x70eb2(%rip)     # 0x8d148
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq %rax, -0xa8(%rbp)
subq $0xd, %rax
ja 0x1c736
movq -0xa8(%rbp), %rax
leaq 0x467d1(%rip), %rcx     # 0x62a8c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x1c738
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1dfb0
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1e080
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1e0f0
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x1bb90
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1b1d0
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1e1c0
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x1e260
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x1c230
jmp 0x1c738
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0x11, %eax
andl $0x1, %eax
cmpb $0x0, %al
je 0x1c3a1
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x1e260
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x1c230
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x1b9d0
cmpl $0x0, %eax
jne 0x1c3da
jmp 0x1c738
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1c415
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x1e310
movq -0xb0(%rbp), %rdi
movq %rax, %rsi
callq 0x1b930
jmp 0x1c738
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x1c42d
jmp 0x1c738
movq -0x38(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x17, %eax
jne 0x1c46d
movq -0x10(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x1e310
movq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x1b930
jmp 0x1c738
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x1bb90
movq %rax, -0x50(%rbp)
movl $0x7, %edi
xorl %esi, %esi
callq 0x1afb0
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x40(%rbp), %rdx
addq $0x30, %rdx
callq 0x1a290
movq -0x10(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x1b5b0
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x58(%rbp)
jne 0x1c4d8
jmp 0x1c5b1
jmp 0x1c4da
movl $0x0, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movq -0x60(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jge 0x1c599
movq -0x60(%rbp), %rax
movslq -0x6c(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x30(%rbp)
movq -0x60(%rbp), %rax
movw (%rax), %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
je 0x1c529
cmpq $0x0, -0x30(%rbp)
jne 0x1c529
jmp 0x1c58b
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x1e310
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movl $0x1, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x1e370
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rdi
addq $0x30, %rdi
addq $0x8, %rdi
movq -0x80(%rbp), %rsi
callq 0x1e3c0
movq -0x78(%rbp), %rdi
addq $0x18, %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x1b9f0
movq -0x48(%rbp), %rdi
addq $0x20, %rdi
movq -0x78(%rbp), %rsi
callq 0x1b9f0
movl -0x6c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x6c(%rbp)
jmp 0x1c4e1
jmp 0x1c59b
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq -0x58(%rbp), %rax
jne 0x1c4da
movq -0x10(%rbp), %rdi
callq 0x1e3f0
jmp 0x1c738
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1c5e0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1e430
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1e5c0
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x4(%rax), %rsi
callq 0x1b110
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x4(%rax), %rsi
callq 0x1b110
movq %rax, -0x98(%rbp)
movq %rax, -0x90(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0x1c65b
movq -0xa0(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1bf60
cmpl $0x0, %eax
jne 0x1c66b
leaq 0x6f74e(%rip), %rax     # 0x8bdb0
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rdi
movq -0xa0(%rbp), %rsi
movq -0x88(%rbp), %rdx
movq -0x90(%rbp), %rcx
callq 0x1e690
movq -0x10(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x1b170
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x1c230
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x1c6fe
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x4(%rax), %rsi
callq 0x1b110
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x1b930
movq -0x10(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x1b170
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x1c230
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x1b170
jmp 0x1c738
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1e830
movq %rax, -0x8(%rbp)
jmp 0x1c743
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x1ebb0
movq %rax, -0x8(%rbp)
jmp 0x1c743
jmp 0x1c738
leaq 0x6f671(%rip), %rax     # 0x8bdb0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xc0, %rsp
popq %rbp
retq