// File: /workspace/github_c_makefile_star2_O2/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
xorl %r14d, %r14d
pushq $0x10
popq %r12
leaq 0x1e9cc(%rip), %r13     # 0x3f570
pushq $0x28
popq %rbp
leaq 0x1ead8(%rip), %r15     # 0x3f686
xorl %ecx, %ecx
testq %rdi, %rdi
je 0x2115d
movq %rdi, 0x8(%rsp)
movl (%rdi), %eax
decl %eax
cmpl $0xc, %eax
ja 0x2115d
movl %ecx, 0x4(%rsp)
movslq (%r13,%rax,4), %rcx
addq %r13, %rcx
movq %r12, %rax
jmpq *%rcx
movq %rbp, %rax
movq 0x8(%rsp), %rbx
movq (%rbx,%rax), %rsi
movq %r15, %rdi
xorl %eax, %eax
callq 0xe0f0
movq 0x20(%rbx), %rdi
movb $0x1, %cl
jmp 0x20bb0
movq 0x8(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x21182
leaq 0x1eeda(%rip), %rdi     # 0x3fae9
xorl %r14d, %r14d
movl %eax, %esi
xorl %eax, %eax
callq 0xe0f0
leaq 0x1f10c(%rip), %rdi     # 0x3fd2e
callq 0xe0a0
movq 0x28(%rbx), %rax
movq 0x98(%rax), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x20cfc
leaq 0x1eee6(%rip), %r12     # 0x3fb2d
movq 0x10(%rsp), %rbp
xorl %r15d, %r15d
movl (%rbp), %eax
movsbq %al, %rcx
cmpq %rcx, %r15
jge 0x20ced
movq 0x18(%rbp,%r15,8), %r13
cmpw $0x100, %ax             # imm = 0x100
jb 0x20c6f
testq %r13, %r13
je 0x20ce5
movq 0x90(%r13), %rcx
movq 0x10(%rcx), %rax
testq %rax, %rax
je 0x20cb8
cmpb $0x1, (%rax)
jne 0x20cc1
movq 0x18(%rcx), %rbx
movq 0x20(%rax), %rsi
leaq 0x1ee6f(%rip), %rdi     # 0x3fb02
xorl %eax, %eax
callq 0xe0f0
testq %rbx, %rbx
je 0x20cd8
cmpb $0x1, (%rbx)
jne 0x20cca
movq 0x20(%rbx), %rsi
leaq 0x1ee61(%rip), %rdi     # 0x3fb10
xorl %eax, %eax
callq 0xe0f0
jmp 0x20cd8
leaq 0x1ee37(%rip), %rdi     # 0x3faf6
jmp 0x20cd1
leaq 0x1ee5b(%rip), %rdi     # 0x3fb23
jmp 0x20cd1
leaq 0x1ee48(%rip), %rdi     # 0x3fb19
xorl %eax, %eax
callq 0xe0f0
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0xe0f0
incq %r15
jmp 0x20c4f
movq 0x10(%rbp), %rbp
cmpq 0x10(%rsp), %rbp
jne 0x20c4c
leaq 0x1f039(%rip), %rdi     # 0x3fd3c
callq 0xe0a0
movq 0x8(%rsp), %rbx
movq 0x18(%rbx), %rdi
callq 0x20b88
movq 0x20(%rbx), %rsi
testb $0x2, 0x2(%rsi)
movl 0x4(%rsp), %ecx
je 0x2115d
leaq 0x1e957(%rip), %rdi     # 0x3f686
jmp 0x21049
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
testq %rdi, %rdi
je 0x2103e
callq 0x21182
leaq 0x1e9a2(%rip), %rdi     # 0x3f6f4
jmp 0x20d69
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x21182
leaq 0x1e9a5(%rip), %rdi     # 0x3f70e
xorl %r14d, %r14d
movl %eax, %esi
jmp 0x21152
movq 0x8(%rsp), %rax
movq 0x10(%rax), %r14
movq 0x18(%rax), %rbx
testq %r14, %r14
je 0x20dbb
cmpq $0x0, 0x10(%r14)
je 0x20dbb
movq %r14, %rdi
callq 0x21182
movl %eax, %ebp
movq 0x10(%r14), %rax
movl 0x50(%rax), %r14d
movq %rbx, %rdi
callq 0x2176a
leaq 0x1ed29(%rip), %rdi     # 0x3fad6
movl %r14d, %esi
movl %ebp, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe0f0
leaq 0x1ed73(%rip), %rdi     # 0x3fb35
xorl %r14d, %r14d
movq %rbx, %rsi
jmp 0x2104c
movq 0x8(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x21182
movl 0x43c03(%rip), %ebp     # 0x649e4
incl %ebp
movl %ebp, 0x43bfb(%rip)     # 0x649e4
leaq 0x1e8c1(%rip), %rdi     # 0x3f6b1
xorl %r14d, %r14d
movl %eax, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe0f0
movq 0x18(%rbx), %rdi
callq 0x20b88
cmpq $0x0, 0x20(%rbx)
je 0x20e4c
movl 0x43bcf(%rip), %r15d    # 0x649e4
incl %r15d
movl %r15d, 0x43bc5(%rip)    # 0x649e4
leaq 0x1e89a(%rip), %rdi     # 0x3f6c0
movl %r15d, %esi
xorl %eax, %eax
callq 0xe0f0
leaq 0x1e895(%rip), %rdi     # 0x3f6cc
movl %ebp, %esi
xorl %eax, %eax
callq 0xe0f0
movq 0x20(%rbx), %rdi
callq 0x20b88
movl %r15d, %ebp
leaq 0x1e879(%rip), %rdi     # 0x3f6cc
jmp 0x21150
movq 0x8(%rsp), %rbx
movq 0x10(%rbx), %rdi
callq 0x21182
movl %eax, %ebp
movq 0x18(%rbx), %rdi
callq 0x21182
movl %eax, %r15d
movq 0x20(%rbx), %rdi
callq 0x21182
leaq 0x1e89a(%rip), %rdi     # 0x3f71e
xorl %r14d, %r14d
movl %ebp, %esi
movl %r15d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe0f0
jmp 0x21159
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x21182
movl %eax, %r14d
jmp 0x21159
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x216da
jmp 0x21159
movq 0x8(%rsp), %rax
cmpq $0x0, 0x20(%rax)
je 0x20f00
movq 0x28(%rax), %rdi
callq 0x20b88
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x2936d
leaq 0x1e782(%rip), %rdi     # 0x3f673
movq %rax, %rsi
xorl %eax, %eax
callq 0xe0f0
movq 0x8(%rsp), %rax
movq 0x10(%rax), %r15
xorl %r14d, %r14d
testq %r15, %r15
je 0x20f46
movq %r15, %r12
xorl %r13d, %r13d
movl (%r12), %eax
movsbq %al, %rcx
cmpq %rcx, %r13
jge 0x20f3c
movq 0x18(%r12,%r13,8), %rdi
cmpw $0x100, %ax             # imm = 0x100
jb 0x20f2f
testq %rdi, %rdi
je 0x20f37
callq 0x20b88
movl %eax, %r14d
incq %r13
jmp 0x20f12
movq 0x10(%r12), %r12
cmpq %r15, %r12
jne 0x20f0f
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
testq %rsi, %rsi
je 0x20fa5
leaq 0x1e72b(%rip), %rdi     # 0x3f686
xorl %eax, %eax
callq 0xe0f0
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x2176a
movq 0x8(%rsp), %rcx
movq 0x18(%rcx), %rcx
movl 0x50(%rcx), %esi
movl 0x43a5d(%rip), %r14d    # 0x649e0
incl %r14d
movl %r14d, 0x43a53(%rip)    # 0x649e0
leaq 0x1e6f9(%rip), %rdi     # 0x3f68d
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe0f0
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
testq %rax, %rax
je 0x21159
movq 0x18(%rax), %rdi
callq 0x2936d
leaq 0x1e6de(%rip), %rdi     # 0x3f6a0
movq %rax, %rsi
jmp 0x2104c
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rdi
movq 0x28(%rax), %rbp
movq 0x30(%rax), %r13
movq 0x38(%rax), %r12
movq 0x40(%rax), %r15
movq 0x48(%rax), %r14
callq 0x216da
movq %rbp, %rdi
callq 0x20b88
xorl %ebp, %ebp
testq %r13, %r13
je 0x21080
cmpb $0x1, (%r13)
jne 0x21058
cmpq $0x0, 0x20(%r13)
jne 0x21080
movl 0x439d1(%rip), %ebp     # 0x649e4
incl %ebp
movl %ebp, 0x439c9(%rip)     # 0x649e4
leaq 0x1e69e(%rip), %rdi     # 0x3f6c0
movl %ebp, %esi
xorl %eax, %eax
callq 0xe0f0
jmp 0x21080
leaq 0x1eced(%rip), %rdi     # 0x3fd21
callq 0xe0a0
jmp 0x21159
movq 0x10(%rax), %rsi
leaq 0x1e6b8(%rip), %rdi     # 0x3f701
xorl %r14d, %r14d
xorl %eax, %eax
callq 0xe0f0
jmp 0x21159
movl 0x43986(%rip), %ebp     # 0x649e4
incl %ebp
movl %ebp, 0x4397e(%rip)     # 0x649e4
movq %r13, %rdi
callq 0x21182
leaq 0x1e65e(%rip), %rdi     # 0x3f6d3
movl %eax, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0xe0f0
testq %r14, %r14
je 0x21096
cmpb $0x1, (%r14)
jne 0x21096
cmpq $0x0, 0x20(%r14)
je 0x2117a
movl 0x43947(%rip), %r13d    # 0x649e4
incl %r13d
movl %r13d, 0x4393d(%rip)    # 0x649e4
leaq 0x1e61e(%rip), %rdi     # 0x3f6cc
movl %r13d, %esi
xorl %eax, %eax
callq 0xe0f0
movq %r12, %rdi
callq 0x20b88
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rsi
testb $0x2, 0x2(%rsi)
je 0x210dd
leaq 0x1e5b0(%rip), %rdi     # 0x3f686
xorl %eax, %eax
callq 0xe0f0
movq %r15, %rdi
callq 0x20b88
testq %r14, %r14
je 0x210f7
cmpb $0x1, (%r14)
jne 0x2110a
cmpq $0x0, 0x20(%r14)
je 0x21125
leaq 0x1e5c2(%rip), %rdi     # 0x3f6c0
movl %r13d, %esi
xorl %eax, %eax
callq 0xe0f0
jmp 0x21125
movq %r14, %rdi
callq 0x21182
leaq 0x1e5ca(%rip), %rdi     # 0x3f6e3
movl %eax, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe0f0
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rsi
testb $0x2, 0x2(%rsi)
je 0x21142
leaq 0x1e54b(%rip), %rdi     # 0x3f686
xorl %eax, %eax
callq 0xe0f0
testl %ebp, %ebp
je 0x21175
leaq 0x1e57f(%rip), %rdi     # 0x3f6cc
xorl %r14d, %r14d
movl %ebp, %esi
xorl %eax, %eax
callq 0xe0f0
movl 0x4(%rsp), %ecx
xorl %eax, %eax
testb $0x1, %cl
cmovel %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
jmp 0x21159
xorl %r13d, %r13d
jmp 0x210b8