// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/show-parse.c
// Function: show_switch_statement
static void show_switch_statement(struct statement *stmt)
{
	int val = show_expression(stmt->switch_expression);
	struct symbol *sym;
	printf("\tswitch v%d\n", val);

	/*
	 * Debugging only: Check that the case list is correct
	 * by printing it out.
	 *
	 * This is where a _real_ back-end would go through the
	 * cases to decide whether to use a lookup table or a
	 * series of comparisons etc
	 */
	printf("# case table:\n");
	FOR_EACH_PTR(stmt->switch_case->symbol_list, sym) {
		struct statement *case_stmt = sym->stmt;
		struct expression *expr = case_stmt->case_expression;
		struct expression *to = case_stmt->case_to;

		if (!expr) {
			printf("    default");
		} else {
			if (expr->type == EXPR_VALUE) {
				printf("    case %lld", expr->value);
				if (to) {
					if (to->type == EXPR_VALUE) {
						printf(" .. %lld", to->value);
					} else {
						printf(" .. what?");
					}
				}
			} else
				printf("    what?");
		}
		printf(": .L%p\n", sym);
	} END_FOR_EACH_PTR(sym);
	printf("# end case table\n");

	show_statement(stmt->switch_statement);

	if (stmt->switch_break->used)
		printf(".L%p:\n", stmt->switch_break);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x33a40
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %esi
leaq 0x344ef(%rip), %rdi     # 0x684b5
movb $0x0, %al
callq 0x110f0
leaq 0x344ee(%rip), %rdi     # 0x684c2
movb $0x0, %al
callq 0x110f0
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x98(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x3400a
jmp 0x3414b
jmp 0x3400c
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
movw (%rcx), %cx
shlw $0x8, %cx
sarw $0x8, %cx
movswl %cx, %ecx
cmpl %ecx, %eax
jge 0x34133
movq -0x28(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq 0x18(%rax,%rcx,8), %rax
movq %rax, -0x18(%rbp)
movq -0x28(%rbp), %rax
movw (%rax), %ax
sarw $0x8, %ax
cwtl
cmpl $0x0, %eax
je 0x3405e
cmpq $0x0, -0x18(%rbp)
jne 0x3405e
jmp 0x34125
movq -0x18(%rbp), %rax
movq 0x90(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x3409c
leaq 0x3443e(%rip), %rdi     # 0x684d1
movb $0x0, %al
callq 0x110f0
jmp 0x34113
movq -0x48(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x34103
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x34422(%rip), %rdi     # 0x684dd
movb $0x0, %al
callq 0x110f0
cmpq $0x0, -0x50(%rbp)
je 0x34101
movq -0x50(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x340f1
movq -0x50(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x34403(%rip), %rdi     # 0x684eb
movb $0x0, %al
callq 0x110f0
jmp 0x340ff
leaq 0x343fc(%rip), %rdi     # 0x684f4
movb $0x0, %al
callq 0x110f0
jmp 0x34101
jmp 0x34111
leaq 0x343f4(%rip), %rdi     # 0x684fe
movb $0x0, %al
callq 0x110f0
jmp 0x34113
movq -0x18(%rbp), %rsi
leaq 0x343ea(%rip), %rdi     # 0x68508
movb $0x0, %al
callq 0x110f0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x34013
jmp 0x34135
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq -0x20(%rbp), %rax
jne 0x3400c
leaq 0x343be(%rip), %rdi     # 0x68510
movb $0x0, %al
callq 0x110f0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x33400
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movl (%rax), %eax
shrl $0x11, %eax
andl $0x1, %eax
cmpb $0x0, %al
je 0x34190
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rsi
leaq 0x33ebf(%rip), %rdi     # 0x68048
movb $0x0, %al
callq 0x110f0
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)