// File: /workspace/github_c_makefile_star2_O3/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
testq %rdi, %rdi
je 0x23dd0
movq %rdi, %rbx
xorl %ebp, %ebp
leaq 0x22cfa(%rip), %r15     # 0x46510
leaq 0x22e09(%rip), %r14     # 0x46626
movl (%rbx), %ecx
decl %ecx
cmpl $0xc, %ecx
ja 0x23dc7
movl $0x10, %eax
movslq (%r15,%rcx,4), %rcx
addq %r15, %rcx
jmpq *%rcx
movl $0x28, %eax
movq (%rbx,%rax), %rsi
movq %r14, %rdi
xorl %eax, %eax
callq 0xe0f0
movq 0x20(%rbx), %rbx
movb $0x1, %bpl
testq %rbx, %rbx
jne 0x2381d
jmp 0x23dd0
movl %ebp, 0x14(%rsp)
movq 0x10(%rbx), %rdi
callq 0x23ded
leaq 0x23219(%rip), %rdi     # 0x46a89
movl %eax, %esi
xorl %eax, %eax
callq 0xe0f0
leaq 0x23462(%rip), %rdi     # 0x46ce2
callq 0xe0a0
movq 0x28(%rbx), %rax
movq 0x98(%rax), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x2396b
leaq 0x23228(%rip), %r12     # 0x46acd
movq 0x8(%rsp), %rbp
movzwl (%rbp), %eax
testb %al, %al
jle 0x2395c
xorl %r15d, %r15d
movq 0x18(%rbp,%r15,8), %r13
movzwl %ax, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0x238ce
testq %r13, %r13
je 0x23949
movq 0x90(%r13), %rcx
movq 0x10(%rcx), %rax
testq %rax, %rax
je 0x23918
cmpb $0x1, (%rax)
jne 0x23921
movq 0x18(%rcx), %r14
movq 0x20(%rax), %rsi
leaq 0x231b0(%rip), %rdi     # 0x46aa2
xorl %eax, %eax
callq 0xe0f0
testq %r14, %r14
je 0x23938
cmpb $0x1, (%r14)
jne 0x2392a
movq 0x20(%r14), %rsi
leaq 0x231a1(%rip), %rdi     # 0x46ab0
xorl %eax, %eax
callq 0xe0f0
jmp 0x23938
leaq 0x23177(%rip), %rdi     # 0x46a96
jmp 0x23931
leaq 0x2319b(%rip), %rdi     # 0x46ac3
jmp 0x23931
leaq 0x23188(%rip), %rdi     # 0x46ab9
xorl %eax, %eax
callq 0xe0f0
movq %r12, %rdi
movq %r13, %rsi
xorl %eax, %eax
callq 0xe0f0
movzwl (%rbp), %eax
incq %r15
movzwl %ax, %ecx
movsbq %cl, %rcx
cmpq %rcx, %r15
jl 0x238b9
movq 0x10(%rbp), %rbp
cmpq 0x8(%rsp), %rbp
jne 0x238aa
leaq 0x2337e(%rip), %rdi     # 0x46cf0
callq 0xe0a0
movq 0x18(%rbx), %rdi
callq 0x237f3
movq 0x20(%rbx), %rsi
testb $0x2, 0x2(%rsi)
movl 0x14(%rsp), %ebp
movl $0x0, %r14d
je 0x23dca
leaq 0x22c87(%rip), %rdi     # 0x46626
jmp 0x23cbf
movq 0x10(%rbx), %rdi
callq 0x23ded
leaq 0x22cfa(%rip), %rdi     # 0x466ae
jmp 0x239cf
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0x23cb4
callq 0x23ded
leaq 0x22cc5(%rip), %rdi     # 0x46694
movl %eax, %esi
jmp 0x23dc0
movq 0x10(%rbx), %r14
movq 0x18(%rbx), %rbx
testq %r14, %r14
je 0x23a1b
cmpq $0x0, 0x10(%r14)
je 0x23a1b
movq %r14, %rdi
callq 0x23ded
movl %eax, %r15d
movq 0x10(%r14), %rax
movl 0x50(%rax), %r14d
movq %rbx, %rdi
callq 0x24204
leaq 0x2306a(%rip), %rdi     # 0x46a76
movl %r14d, %esi
movl %r15d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe0f0
leaq 0x230b3(%rip), %rdi     # 0x46ad5
movq %rbx, %rsi
jmp 0x23cbf
movq 0x10(%rbx), %rdi
callq 0x23ded
movl 0x46faa(%rip), %r12d    # 0x6a9e4
incl %r12d
movl %r12d, 0x46fa0(%rip)    # 0x6a9e4
leaq 0x22c06(%rip), %rdi     # 0x46651
movl %eax, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0xe0f0
movq 0x18(%rbx), %rdi
callq 0x237f3
cmpq $0x0, 0x20(%rbx)
je 0x23aa6
movl 0x46f76(%rip), %r15d    # 0x6a9e4
incl %r15d
movl %r15d, 0x46f6c(%rip)    # 0x6a9e4
leaq 0x22be1(%rip), %rdi     # 0x46660
movl %r15d, %esi
xorl %eax, %eax
callq 0xe0f0
leaq 0x22bdc(%rip), %rdi     # 0x4666c
movl %r12d, %esi
xorl %eax, %eax
callq 0xe0f0
movq 0x20(%rbx), %rdi
callq 0x237f3
movl %r15d, %r12d
leaq 0x22bbf(%rip), %rdi     # 0x4666c
movl %r12d, %esi
xorl %eax, %eax
callq 0xe0f0
testb $0x1, %bpl
movl $0x0, %r14d
jne 0x23dd0
jmp 0x23dd3
movq 0x10(%rbx), %rdi
callq 0x24164
jmp 0x23cab
movq 0x10(%rbx), %rdi
callq 0x23ded
testb $0x1, %bpl
jne 0x23dd0
movl %eax, %r14d
jmp 0x23dd3
cmpq $0x0, 0x20(%rbx)
je 0x23b23
movq 0x28(%rbx), %rdi
callq 0x237f3
movq 0x20(%rbx), %rax
movq 0x18(%rax), %rdi
callq 0x2de35
leaq 0x22afa(%rip), %rdi     # 0x46613
movq %rax, %rsi
xorl %eax, %eax
callq 0xe0f0
movq 0x10(%rbx), %r15
xorl %r14d, %r14d
testq %r15, %r15
je 0x23b79
movq %r15, %r12
movzwl (%r12), %edx
testb %dl, %dl
jle 0x23b6f
xorl %r13d, %r13d
movq 0x18(%r12,%r13,8), %rdi
movzwl %dx, %ecx
cmpl $0x100, %ecx            # imm = 0x100
jb 0x23b53
testq %rdi, %rdi
je 0x23b60
callq 0x237f3
movl %eax, %r14d
movzwl (%r12), %edx
incq %r13
movzwl %dx, %ecx
movsbq %cl, %rcx
cmpq %rcx, %r13
jl 0x23b3e
movq 0x10(%r12), %r12
cmpq %r15, %r12
jne 0x23b32
movq 0x18(%rbx), %rsi
testq %rsi, %rsi
je 0x23bc4
leaq 0x22a9d(%rip), %rdi     # 0x46626
xorl %eax, %eax
callq 0xe0f0
movq 0x18(%rbx), %rdi
callq 0x24204
movq 0x18(%rbx), %rcx
movl 0x50(%rcx), %esi
movl 0x46e39(%rip), %r14d    # 0x6a9e0
incl %r14d
movl %r14d, 0x46e2f(%rip)    # 0x6a9e0
leaq 0x22a75(%rip), %rdi     # 0x4662d
movl %r14d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe0f0
movq 0x20(%rbx), %rcx
testq %rcx, %rcx
je 0x23dca
movq 0x18(%rcx), %rdi
callq 0x2de35
leaq 0x22a5f(%rip), %rdi     # 0x46640
movq %rax, %rsi
xorl %eax, %eax
callq 0xe0f0
jmp 0x23dca
movq 0x20(%rbx), %rdi
movq 0x28(%rbx), %r15
movq 0x30(%rbx), %r13
movq 0x38(%rbx), %r12
movq 0x40(%rbx), %rax
movq %rax, 0x8(%rsp)
movq 0x48(%rbx), %r14
callq 0x24164
movq %r15, %rdi
callq 0x237f3
xorl %r15d, %r15d
testq %r13, %r13
je 0x23cf7
cmpb $0x1, (%r13)
jne 0x23ccb
cmpq $0x0, 0x20(%r13)
jne 0x23cf7
movl 0x46da1(%rip), %r15d    # 0x6a9e4
incl %r15d
movl %r15d, 0x46d97(%rip)    # 0x6a9e4
leaq 0x22a0c(%rip), %rdi     # 0x46660
movl %r15d, %esi
xorl %eax, %eax
callq 0xe0f0
jmp 0x23cf7
movq 0x10(%rbx), %rdi
callq 0x23ded
movl %eax, %r12d
movq 0x18(%rbx), %rdi
callq 0x23ded
movl %eax, %r15d
movq 0x20(%rbx), %rdi
callq 0x23ded
leaq 0x22a33(%rip), %rdi     # 0x466be
movl %r12d, %esi
movl %r15d, %edx
movl %eax, %ecx
xorl %eax, %eax
callq 0xe0f0
jmp 0x23dc7
leaq 0x2302f(%rip), %rdi     # 0x46cd5
callq 0xe0a0
testb $0x1, %bpl
jmp 0x23dd0
movq 0x10(%rbx), %rsi
leaq 0x229e2(%rip), %rdi     # 0x466a1
xorl %eax, %eax
callq 0xe0f0
jmp 0x23dc7
movl 0x46d12(%rip), %r15d    # 0x6a9e4
incl %r15d
movl %r15d, 0x46d08(%rip)    # 0x6a9e4
movq %r13, %rdi
callq 0x23ded
leaq 0x22988(%rip), %rdi     # 0x46673
movl %eax, %esi
movl %r15d, %edx
xorl %eax, %eax
callq 0xe0f0
testq %r14, %r14
je 0x23d0d
cmpb $0x1, (%r14)
jne 0x23d0d
cmpq $0x0, 0x20(%r14)
je 0x23de5
movl 0x46cd0(%rip), %r13d    # 0x6a9e4
incl %r13d
movl %r13d, 0x46cc6(%rip)    # 0x6a9e4
leaq 0x22947(%rip), %rdi     # 0x4666c
movl %r13d, %esi
xorl %eax, %eax
callq 0xe0f0
movq %r12, %rdi
callq 0x237f3
movq 0x18(%rbx), %rsi
testb $0x2, 0x2(%rsi)
je 0x23d4f
leaq 0x228de(%rip), %rdi     # 0x46626
xorl %eax, %eax
callq 0xe0f0
movq 0x8(%rsp), %rdi
callq 0x237f3
testq %r14, %r14
je 0x23d6b
cmpb $0x1, (%r14)
jne 0x23d7e
cmpq $0x0, 0x20(%r14)
je 0x23d99
leaq 0x228ee(%rip), %rdi     # 0x46660
movl %r13d, %esi
xorl %eax, %eax
callq 0xe0f0
jmp 0x23d99
movq %r14, %rdi
callq 0x23ded
leaq 0x228f6(%rip), %rdi     # 0x46683
movl %eax, %esi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe0f0
movq 0x10(%rbx), %rsi
testb $0x2, 0x2(%rsi)
je 0x23db1
leaq 0x2287c(%rip), %rdi     # 0x46626
xorl %eax, %eax
callq 0xe0f0
testl %r15d, %r15d
je 0x23dc7
leaq 0x228af(%rip), %rdi     # 0x4666c
movl %r15d, %esi
xorl %eax, %eax
callq 0xe0f0
xorl %r14d, %r14d
testb $0x1, %bpl
je 0x23dd3
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
jmp 0x23d2f