// File: /workspace/github_c_makefile_star2_O1/lucvoo[P]sparse-dev/show-parse.c
// Function: show_statement
int show_statement(struct statement *stmt)
{
	if (!stmt)
		return 0;
	switch (stmt->type) {
	case STMT_DECLARATION:
		show_symbol_decl(stmt->declaration);
		return 0;
	case STMT_RETURN:
		return show_return_stmt(stmt);
	case STMT_COMPOUND: {
		struct statement *s;
		int last = 0;

		if (stmt->inline_fn) {
			show_statement(stmt->args);
			printf("\tbegin_inline \t%s\n", show_ident(stmt->inline_fn->ident));
		}
		FOR_EACH_PTR(stmt->stmts, s) {
			last = show_statement(s);
		} END_FOR_EACH_PTR(s);
		if (stmt->ret) {
			int addr, bits;
			printf(".L%p:\n", stmt->ret);
			addr = show_symbol_expr(stmt->ret);
			bits = stmt->ret->bit_size;
			last = new_pseudo();
			printf("\tld.%d\t\tv%d,[v%d]\n", bits, last, addr);
		}
		if (stmt->inline_fn)
			printf("\tend_inlined\t%s\n", show_ident(stmt->inline_fn->ident));
		return last;
	}

	case STMT_EXPRESSION:
		return show_expression(stmt->expression);
	case STMT_IF: {
		int val, target;
		struct expression *cond = stmt->if_conditional;

/* This is only valid if nobody can jump into the "dead" statement */
#if 0
		if (cond->type == EXPR_VALUE) {
			struct statement *s = stmt->if_true;
			if (!cond->value)
				s = stmt->if_false;
			show_statement(s);
			break;
		}
#endif
		val = show_expression(cond);
		target = new_label();
		printf("\tje\t\tv%d,.L%d\n", val, target);
		show_statement(stmt->if_true);
		if (stmt->if_false) {
			int last = new_label();
			printf("\tjmp\t\t.L%d\n", last);
			printf(".L%d:\n", target);
			target = last;
			show_statement(stmt->if_false);
		}
		printf(".L%d:\n", target);
		break;
	}
	case STMT_SWITCH:
		show_switch_statement(stmt);
		break;

	case STMT_CASE:
		printf(".L%p:\n", stmt->case_label);
		show_statement(stmt->case_statement);
		break;

	case STMT_ITERATOR: {
		struct statement  *pre_statement = stmt->iterator_pre_statement;
		struct expression *pre_condition = stmt->iterator_pre_condition;
		struct statement  *statement = stmt->iterator_statement;
		struct statement  *post_statement = stmt->iterator_post_statement;
		struct expression *post_condition = stmt->iterator_post_condition;
		int val, loop_top = 0, loop_bottom = 0;

		show_symbol_decl(stmt->iterator_syms);
		show_statement(pre_statement);
		if (pre_condition) {
			if (pre_condition->type == EXPR_VALUE) {
				if (!pre_condition->value) {
					loop_bottom = new_label();   
					printf("\tjmp\t\t.L%d\n", loop_bottom);
				}
			} else {
				loop_bottom = new_label();
				val = show_expression(pre_condition);
				printf("\tje\t\tv%d, .L%d\n", val, loop_bottom);
			}
		}
		if (!post_condition || post_condition->type != EXPR_VALUE || post_condition->value) {
			loop_top = new_label();
			printf(".L%d:\n", loop_top);
		}
		show_statement(statement);
		if (stmt->iterator_continue->used)
			printf(".L%p:\n", stmt->iterator_continue);
		show_statement(post_statement);
		if (!post_condition) {
			printf("\tjmp\t\t.L%d\n", loop_top);
		} else if (post_condition->type == EXPR_VALUE) {
			if (post_condition->value)
				printf("\tjmp\t\t.L%d\n", loop_top);
		} else {
			val = show_expression(post_condition);
			printf("\tjne\t\tv%d, .L%d\n", val, loop_top);
		}
		if (stmt->iterator_break->used)
			printf(".L%p:\n", stmt->iterator_break);
		if (loop_bottom)
			printf(".L%d:\n", loop_bottom);
		break;
	}
	case STMT_NONE:
		break;
	
	case STMT_LABEL:
		printf(".L%p:\n", stmt->label_identifier);
		show_statement(stmt->label_statement);
		break;

	case STMT_GOTO:
		if (stmt->goto_expression) {
			int val = show_expression(stmt->goto_expression);
			printf("\tgoto\t\t*v%d\n", val);
		} else {
			printf("\tgoto\t\t.L%p\n", stmt->goto_label);
		}
		break;
	case STMT_ASM:
		printf("\tasm( .... )\n");
		break;
	case STMT_CONTEXT: {
		int val = show_expression(stmt->expression);
		printf("\tcontext( %d )\n", val);
		break;
	}
	case STMT_RANGE: {
		int val = show_expression(stmt->range_expression);
		int low = show_expression(stmt->range_low);
		int high = show_expression(stmt->range_high);
		printf("\trange( %d %d-%d)\n", val, low, high); 
		break;
	}	
	}
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rcx
xorl %r14d, %r14d
leaq 0x23cdb(%rip), %r12     # 0x47590
leaq 0x23dea(%rip), %r15     # 0x476a6
xorl %ebp, %ebp
testq %rcx, %rcx
je 0x23e96
movl (%rcx), %eax
decl %eax
cmpl $0xc, %eax
ja 0x23e96
movslq (%r12,%rax,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x28(%rcx), %rsi
jmp 0x238e7
movq 0x10(%rcx), %rsi
movq %r15, %rdi
xorl %eax, %eax
movq %rcx, %rbx
callq 0xe0f0
movq 0x20(%rbx), %rcx
testb $0x1, %bpl
cmovel %r14d, %r13d
movb $0x1, %bpl
jmp 0x238be
movq 0x18(%rcx), %rdi
testq %rdi, %rdi
je 0x23d78
callq 0x23eb8
leaq 0x23df6(%rip), %rdi     # 0x47714
jmp 0x23930
movq 0x10(%rcx), %rdi
callq 0x23eb8
leaq 0x23dfe(%rip), %rdi     # 0x4772e
xorl %r14d, %r14d
movl %eax, %esi
xorl %eax, %eax
callq 0xe0f0
jmp 0x23e96
movq 0x10(%rcx), %r14
movq 0x18(%rcx), %rbx
testq %r14, %r14
je 0x2398a
cmpq $0x0, 0x10(%r14)
je 0x2398a
movq %r14, %rdi
callq 0x23eb8
movl %ebp, %r15d
movl %eax, %ebp
movq 0x10(%r14), %rax
movl 0x50(%rax), %r14d
movq %rbx, %rdi
callq 0x24269
leaq 0x2417d(%rip), %rdi     # 0x47af6
movl %r14d, %esi
movl %ebp, %edx
movl %r15d, %ebp
movl %eax, %ecx
xorl %eax, %eax
callq 0xe0f0
leaq 0x241c4(%rip), %rdi     # 0x47b55
xorl %r14d, %r14d
movq %rbx, %rsi
jmp 0x23d86
movl %ebp, 0x4(%rsp)
movl %r13d, (%rsp)
movq 0x20(%rcx), %rdi
movq 0x28(%rcx), %rbp
movq 0x30(%rcx), %r13
movq 0x38(%rcx), %r12
movq 0x40(%rcx), %r15
movq %rcx, %rbx
movq 0x48(%rcx), %r14
callq 0x241ce
movq %rbp, %rdi
callq 0x2389a
xorl %ebp, %ebp
testq %r13, %r13
je 0x23dba
cmpb $0x1, (%r13)
jne 0x23d92
cmpq $0x0, 0x20(%r13)
jne 0x23dba
movl 0x47ff1(%rip), %ebp     # 0x6b9e4
incl %ebp
movl %ebp, 0x47fe9(%rip)     # 0x6b9e4
leaq 0x23cde(%rip), %rdi     # 0x476e0
movl %ebp, %esi
xorl %eax, %eax
callq 0xe0f0
jmp 0x23dba
movl %ebp, %ebx
movq 0x10(%rcx), %rdi
movq %rcx, %r15
callq 0x23eb8
movl 0x47fc0(%rip), %ebp     # 0x6b9e4
incl %ebp
movl %ebp, 0x47fb8(%rip)     # 0x6b9e4
leaq 0x23c9e(%rip), %rdi     # 0x476d1
xorl %r14d, %r14d
movl %eax, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe0f0
movq 0x18(%r15), %rdi
callq 0x2389a
cmpq $0x0, 0x20(%r15)
je 0x23a96
movq %r15, %rcx
movl 0x47f89(%rip), %r15d    # 0x6b9e4
incl %r15d
movl %r15d, 0x47f7f(%rip)    # 0x6b9e4
leaq 0x23c74(%rip), %rdi     # 0x476e0
movl %r15d, %esi
xorl %eax, %eax
movq %rcx, %r12
callq 0xe0f0
leaq 0x23c6c(%rip), %rdi     # 0x476ec
movl %ebp, %esi
xorl %eax, %eax
callq 0xe0f0
movq 0x20(%r12), %rdi
callq 0x2389a
movl %r15d, %ebp
leaq 0x23c4f(%rip), %rdi     # 0x476ec
movl %ebp, %esi
xorl %eax, %eax
callq 0xe0f0
movl %ebx, %ebp
jmp 0x23e96
movq 0x10(%rcx), %rdi
callq 0x23eb8
movl %eax, %r14d
jmp 0x23e96
movq 0x10(%rcx), %rdi
callq 0x241ce
jmp 0x23e96
movq 0x10(%rcx), %rdi
movq %rcx, %r14
callq 0x23eb8
movl %ebp, %ebx
movl %eax, %ebp
movq 0x18(%r14), %rdi
callq 0x23eb8
movl %eax, %r15d
movq 0x20(%r14), %rdi
callq 0x23eb8
leaq 0x23c46(%rip), %rdi     # 0x4773e
xorl %r14d, %r14d
movl %ebp, %esi
movl %ebx, %ebp
movl %r15d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe0f0
jmp 0x23e96
movl %ebp, 0x4(%rsp)
movl %r13d, (%rsp)
movq 0x10(%rcx), %rdi
movq %rcx, %rbx
callq 0x23eb8
leaq 0x23fde(%rip), %rdi     # 0x47b09
xorl %r14d, %r14d
movl %eax, %esi
xorl %eax, %eax
callq 0xe0f0
leaq 0x24224(%rip), %rdi     # 0x47d62
callq 0xe0a0
movq %rbx, 0x10(%rsp)
movq 0x28(%rbx), %rax
movq 0x98(%rax), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x23c28
leaq 0x23fe5(%rip), %r12     # 0x47b4d
movq 0x8(%rsp), %rbp
movzwl (%rbp), %eax
testb %al, %al
jle 0x23c19
xorl %r15d, %r15d
movq 0x18(%rbp,%r15,8), %r13
movzwl %ax, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x23b90
testq %r13, %r13
je 0x23c06
movq 0x90(%r13), %rcx
movq 0x10(%rcx), %rax
testq %rax, %rax
je 0x23bd9
cmpb $0x1, (%rax)
jne 0x23be2
movq 0x18(%rcx), %rbx
movq 0x20(%rax), %rsi
leaq 0x23f6e(%rip), %rdi     # 0x47b22
xorl %eax, %eax
callq 0xe0f0
testq %rbx, %rbx
je 0x23bf9
cmpb $0x1, (%rbx)
jne 0x23beb
movq 0x20(%rbx), %rsi
leaq 0x23f60(%rip), %rdi     # 0x47b30
xorl %eax, %eax
callq 0xe0f0
jmp 0x23bf9
leaq 0x23f36(%rip), %rdi     # 0x47b16
jmp 0x23bf2
leaq 0x23f5a(%rip), %rdi     # 0x47b43
jmp 0x23bf2
leaq 0x23f47(%rip), %rdi     # 0x47b39
xorl %eax, %eax
callq 0xe0f0
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0xe0f0
incq %r15
movl (%rbp), %eax
movsbq %al, %rcx
cmpq %rcx, %r15
jl 0x23b7c
movq 0x10(%rbp), %rbp
cmpq 0x8(%rsp), %rbp
jne 0x23b6d
leaq 0x24141(%rip), %rdi     # 0x47d70
callq 0xe0a0
movq 0x10(%rsp), %rbx
movq 0x18(%rbx), %rdi
callq 0x2389a
movq 0x20(%rbx), %rsi
testb $0x2, 0x2(%rsi)
movl (%rsp), %r13d
movl 0x4(%rsp), %ebp
je 0x23e96
leaq 0x23a47(%rip), %rdi     # 0x476a6
jmp 0x23d83
cmpq $0x0, 0x20(%rcx)
je 0x23c98
movq 0x28(%rcx), %rdi
movq %rcx, %rbx
callq 0x2389a
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdi
callq 0x2e465
leaq 0x23a08(%rip), %rdi     # 0x47693
movq %rax, %rsi
xorl %eax, %eax
callq 0xe0f0
movq %rbx, %rcx
movl %r13d, (%rsp)
movq %rcx, %rbx
movq 0x10(%rcx), %r15
xorl %r14d, %r14d
testq %r15, %r15
je 0x23cf0
movq %r15, %r12
movzwl (%r12), %eax
testb %al, %al
jle 0x23ce6
xorl %r13d, %r13d
movq 0x18(%r12,%r13,8), %rdi
movzwl %ax, %eax
cmpl $0x100, %eax            # imm = 0x100
jb 0x23cce
testq %rdi, %rdi
je 0x23cd6
callq 0x2389a
movl %eax, %r14d
incq %r13
movl (%r12), %eax
movsbq %al, %rcx
cmpq %rcx, %r13
jl 0x23cba
movq 0x10(%r12), %r12
cmpq %r15, %r12
jne 0x23cae
movq %rbx, %rax
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x23d41
leaq 0x239a3(%rip), %rdi     # 0x476a6
xorl %eax, %eax
callq 0xe0f0
movq 0x18(%rbx), %rdi
callq 0x24269
movq 0x18(%rbx), %rcx
movl 0x50(%rcx), %esi
movl 0x47cbf(%rip), %r14d    # 0x6b9e0
incl %r14d
movl %r14d, 0x47cb5(%rip)    # 0x6b9e0
leaq 0x2397b(%rip), %rdi     # 0x476ad
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe0f0
movq %rbx, %rax
movq 0x20(%rax), %rax
testq %rax, %rax
movl (%rsp), %r13d
je 0x23e96
movq 0x18(%rax), %rdi
callq 0x2e465
leaq 0x2395e(%rip), %rdi     # 0x476c0
movq %rax, %rsi
jmp 0x23d86
leaq 0x23fe7(%rip), %rdi     # 0x47d55
callq 0xe0a0
jmp 0x23e96
movq 0x10(%rcx), %rsi
leaq 0x2399e(%rip), %rdi     # 0x47721
xorl %r14d, %r14d
xorl %eax, %eax
callq 0xe0f0
jmp 0x23e96
movl 0x47c4c(%rip), %ebp     # 0x6b9e4
incl %ebp
movl %ebp, 0x47c44(%rip)     # 0x6b9e4
movq %r13, %rdi
callq 0x23eb8
leaq 0x23944(%rip), %rdi     # 0x476f3
movl %eax, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe0f0
testq %r14, %r14
je 0x23dd0
cmpb $0x1, (%r14)
jne 0x23dd0
cmpq $0x0, 0x20(%r14)
je 0x23eb0
movl 0x47c0d(%rip), %r13d    # 0x6b9e4
incl %r13d
movl %r13d, 0x47c03(%rip)    # 0x6b9e4
leaq 0x23904(%rip), %rdi     # 0x476ec
movl %r13d, %esi
xorl %eax, %eax
callq 0xe0f0
movq %r12, %rdi
callq 0x2389a
movq 0x18(%rbx), %rsi
testb $0x2, 0x2(%rsi)
je 0x23e12
leaq 0x2389b(%rip), %rdi     # 0x476a6
xorl %eax, %eax
callq 0xe0f0
movq %r15, %rdi
callq 0x2389a
testq %r14, %r14
je 0x23e2c
cmpb $0x1, (%r14)
jne 0x23e3f
cmpq $0x0, 0x20(%r14)
je 0x23e5a
leaq 0x238ad(%rip), %rdi     # 0x476e0
movl %r13d, %esi
xorl %eax, %eax
callq 0xe0f0
jmp 0x23e5a
movq %r14, %rdi
callq 0x23eb8
leaq 0x238b5(%rip), %rdi     # 0x47703
movl %eax, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe0f0
movq 0x10(%rbx), %rsi
testb $0x2, 0x2(%rsi)
je 0x23e72
leaq 0x2383b(%rip), %rdi     # 0x476a6
xorl %eax, %eax
callq 0xe0f0
testl %ebp, %ebp
movl (%rsp), %r13d
je 0x23e8f
leaq 0x2386b(%rip), %rdi     # 0x476ec
xorl %r14d, %r14d
movl %ebp, %esi
xorl %eax, %eax
callq 0xe0f0
jmp 0x23e92
xorl %r14d, %r14d
movl 0x4(%rsp), %ebp
testb $0x1, %bpl
cmovnel %r13d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
jmp 0x23df2