// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x33422
movl $0x0, -0x4(%rbp)
jmp 0x33a2b
movq -0x10(%rbp), %rax
movl (%rax), %eax
movq %rax, -0xb0(%rbp)
subq $0xd, %rax
ja 0x33a24
movq -0xb0(%rbp), %rax
leaq 0x34ad9(%rip), %rcx     # 0x67f20
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x33cf0
movl $0x0, -0x4(%rbp)
jmp 0x33a2b
movq -0x10(%rbp), %rdi
callq 0x33da0
movl %eax, -0x4(%rbp)
jmp 0x33a2b
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x334bb
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x33400
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x44150
movq %rax, %rsi
leaq 0x34b81(%rip), %rdi     # 0x68035
movb $0x0, %al
callq 0x110f0
jmp 0x334bd
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x334e2
jmp 0x3355a
jmp 0x334e4
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x30(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jge 0x33546
movq -0x30(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movq -0x30(%rbp), %rax
movw (%rax), %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
je 0x3352f
cmpq $0x0, -0x18(%rbp)
jne 0x3352f
jmp 0x3353b
movq -0x18(%rbp), %rdi
callq 0x33400
movl %eax, -0x1c(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x334eb
jmp 0x33548
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq -0x28(%rbp), %rax
jne 0x334e4
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x335b8
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
leaq 0x34ad4(%rip), %rdi     # 0x68048
movb $0x0, %al
callq 0x110f0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x33e30
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl 0x50(%rax), %eax
movl %eax, -0x44(%rbp)
callq 0x33f60
movl %eax, -0x1c(%rbp)
movl -0x44(%rbp), %esi
movl -0x1c(%rbp), %edx
movl -0x40(%rbp), %ecx
leaq 0x34a9e(%rip), %rdi     # 0x6804f
movb $0x0, %al
callq 0x110f0
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x335e5
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x18(%rax), %rdi
callq 0x44150
movq %rax, %rsi
leaq 0x34a84(%rip), %rdi     # 0x68062
movb $0x0, %al
callq 0x110f0
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x33a2b
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x33a40
movl %eax, -0x4(%rbp)
jmp 0x33a2b
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x33a40
movl %eax, -0x48(%rbp)
callq 0x33f80
movl %eax, -0x4c(%rbp)
movl -0x48(%rbp), %esi
movl -0x4c(%rbp), %edx
leaq 0x34a41(%rip), %rdi     # 0x68073
movb $0x0, %al
callq 0x110f0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x33400
movq -0x10(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x3368e
callq 0x33f80
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %esi
leaq 0x34a1f(%rip), %rdi     # 0x68082
movb $0x0, %al
callq 0x110f0
movl -0x4c(%rbp), %esi
leaq 0x34a1a(%rip), %rdi     # 0x6808e
movb $0x0, %al
callq 0x110f0
movl -0x5c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x33400
movl -0x4c(%rbp), %esi
leaq 0x349f6(%rip), %rdi     # 0x6808e
movb $0x0, %al
callq 0x110f0
jmp 0x33a24
movq -0x10(%rbp), %rdi
callq 0x33fa0
jmp 0x33a24
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
leaq 0x34987(%rip), %rdi     # 0x68048
movb $0x0, %al
callq 0x110f0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x33400
jmp 0x33a24
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x90(%rbp)
movl $0x0, -0x94(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x33cf0
movq -0x68(%rbp), %rdi
callq 0x33400
cmpq $0x0, -0x70(%rbp)
je 0x337bc
movq -0x70(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x33786
movq -0x70(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x33784
callq 0x33f80
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %esi
leaq 0x34905(%rip), %rdi     # 0x68082
movb $0x0, %al
callq 0x110f0
jmp 0x337ba
callq 0x33f80
movl %eax, -0x94(%rbp)
movq -0x70(%rbp), %rdi
callq 0x33a40
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %esi
movl -0x94(%rbp), %edx
leaq 0x348e2(%rip), %rdi     # 0x68095
movb $0x0, %al
callq 0x110f0
jmp 0x337bc
cmpq $0x0, -0x88(%rbp)
je 0x337e7
movq -0x88(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x337e7
movq -0x88(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x33806
callq 0x33f80
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %esi
leaq 0x3488f(%rip), %rdi     # 0x6808e
movb $0x0, %al
callq 0x110f0
movq -0x78(%rbp), %rdi
callq 0x33400
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
shrl $0x11, %eax
andl $0x1, %eax
cmpb $0x0, %al
je 0x33839
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
leaq 0x34816(%rip), %rdi     # 0x68048
movb $0x0, %al
callq 0x110f0
movq -0x80(%rbp), %rdi
callq 0x33400
cmpq $0x0, -0x88(%rbp)
jne 0x33862
movl -0x90(%rbp), %esi
leaq 0x34829(%rip), %rdi     # 0x68082
movb $0x0, %al
callq 0x110f0
jmp 0x338c7
movq -0x88(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x33899
movq -0x88(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x33897
movl -0x90(%rbp), %esi
leaq 0x347f2(%rip), %rdi     # 0x68082
movb $0x0, %al
callq 0x110f0
jmp 0x338c5
movq -0x88(%rbp), %rdi
callq 0x33a40
movl %eax, -0x8c(%rbp)
movl -0x8c(%rbp), %esi
movl -0x90(%rbp), %edx
leaq 0x347e7(%rip), %rdi     # 0x680a5
movb $0x0, %al
callq 0x110f0
jmp 0x338c7
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %eax
shrl $0x11, %eax
andl $0x1, %eax
cmpb $0x0, %al
je 0x338f1
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x3475e(%rip), %rdi     # 0x68048
movb $0x0, %al
callq 0x110f0
cmpl $0x0, -0x94(%rbp)
je 0x3390e
movl -0x94(%rbp), %esi
leaq 0x34787(%rip), %rdi     # 0x6808e
movb $0x0, %al
callq 0x110f0
jmp 0x33a24
jmp 0x33a24
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x34721(%rip), %rdi     # 0x68048
movb $0x0, %al
callq 0x110f0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x33400
jmp 0x33a24
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x33974
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x33a40
movl %eax, -0x98(%rbp)
movl -0x98(%rbp), %esi
leaq 0x3474b(%rip), %rdi     # 0x680b6
movb $0x0, %al
callq 0x110f0
jmp 0x3398a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
leaq 0x34740(%rip), %rdi     # 0x680c3
movb $0x0, %al
callq 0x110f0
jmp 0x33a24
leaq 0x3473a(%rip), %rdi     # 0x680d0
movb $0x0, %al
callq 0x110f0
jmp 0x33a24
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x33a40
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %esi
leaq 0x3471c(%rip), %rdi     # 0x680de
movb $0x0, %al
callq 0x110f0
jmp 0x33a24
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x33a40
movl %eax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x33a40
movl %eax, -0xa4(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x33a40
movl %eax, -0xa8(%rbp)
movl -0xa0(%rbp), %esi
movl -0xa4(%rbp), %edx
movl -0xa8(%rbp), %ecx
leaq 0x346d1(%rip), %rdi     # 0x680ee
movb $0x0, %al
callq 0x110f0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw (%rax,%rax)