// File: /workspace/github_c_makefile_star2_O0/Oric4ever[P]lcc65/6502/build/../src/stmt.c
// Function: swstmt
static void swstmt(int loop, int lab, int lev) {
	Tree e;
	struct swtch sw;
	Code head, tail;

	t = gettok();
	expect('(');
	definept(0);
	e = expr(')');
	if (!isint(e->type)) {
		error("illegal type `%t' in switch expression\n", e->type);
		e = retype(e, inttype);
	}
	e = cast(e, promote(e->type));
	if (generic(e->op) == INDIR && isaddrop(e->kids[0]->op)
	&& e->kids[0]->u.sym->type == e->type && !isvolatile(e->kids[0]->u.sym->type)) {
		sw.sym = e->kids[0]->u.sym;
		walk(0, 0, 0);
	} else {
		sw.sym = genident(REGISTER, e->type, level);
		addlocal(sw.sym);
		walk(asgn(sw.sym, e), 0, 0);
	}
	code(Switch);
	head = codelist;
	sw.lab = lab;
	sw.deflab = 0;
	sw.ncases = 0;
	sw.size = SWITCHSIZE;
	sw.values = (int    *) talloc(SWITCHSIZE*sizeof (int));
	sw.labels = (Symbol *) talloc(SWITCHSIZE*sizeof (Symbol));
	if ((refinc /= 10) == 0)
		refinc = 1;
	statement(loop, &sw, lev);
	if (sw.deflab == 0) {
		sw.deflab = findlabel(lab);
		definelab(lab);
		if (sw.ncases == 0)
			warning("switch statement with no cases\n");
	}
	if (findlabel(lab + 1)->ref)
		definelab(lab + 1);
	tail = codelist;
	codelist = head->prev;
	swgen(&sw);
	branch(lab);
	head->next->prev = codelist;
	codelist->next = head->next;
	codelist = tail;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
callq 0x15170
movl %eax, %ecx
leaq 0x1b95e(%rip), %rax     # 0x3db80
movl %ecx, (%rax)
movl $0x28, %edi
callq 0xd670
xorl %eax, %eax
movl %eax, %edi
callq 0x20a20
movl $0x29, %edi
callq 0xfc70
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x22264
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0x22270
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
cmpl $0x3, (%rax)
jb 0x222ad
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0xf, (%rax)
jb 0x22298
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x222a4
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpl $0x6, (%rax)
jbe 0x222da
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xfc73(%rip), %rdi      # 0x31f2f
movb $0x0, %al
callq 0xd530
movq -0x18(%rbp), %rdi
leaq 0x21f2a(%rip), %rax     # 0x441f8
movq (%rax), %rsi
callq 0x25a20
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0xfae0
movq -0x70(%rbp), %rdi
movq %rax, %rsi
callq 0xe9b0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $-0x10, %eax
cmpl $0x40, %eax
jne 0x223a4
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x107, (%rax)          # imm = 0x107
je 0x22341
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x127, (%rax)          # imm = 0x127
je 0x22341
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x117, (%rax)          # imm = 0x117
jne 0x223a4
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x223a4
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rax
cmpl $0x10, (%rax)
je 0x223a4
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rax
cmpl $0x1f, (%rax)
je 0x223a4
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x48(%rbp)
xorl %eax, %eax
movl %eax, %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x3a80
jmp 0x223e5
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0x1ebdd(%rip), %rax     # 0x40f90
movl (%rax), %edx
movl $0x4e, %edi
callq 0x24b00
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3290
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xe0f0
movq %rax, %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x3a80
movl $0xa, %edi
callq 0x3300
leaq 0x16d32(%rip), %rax     # 0x39128
movq (%rax), %rax
movq %rax, -0x50(%rbp)
movl -0x8(%rbp), %eax
movl %eax, -0x40(%rbp)
movq $0x0, -0x38(%rbp)
movl $0x0, -0x30(%rbp)
movl $0x200, -0x2c(%rbp)     # imm = 0x200
leaq 0x19228(%rip), %rax     # 0x3b648
movq (%rax), %rax
movl $0x800, (%rax)          # imm = 0x800
leaq 0x19218(%rip), %rax     # 0x3b648
movq (%rax), %rax
movq 0x8(%rax), %rax
leaq 0x1920a(%rip), %rcx     # 0x3b648
movq (%rcx), %rcx
movslq (%rcx), %rcx
addq %rcx, %rax
leaq 0x191fa(%rip), %rcx     # 0x3b648
movq (%rcx), %rcx
cmpq 0x10(%rcx), %rax
jb 0x22475
leaq 0x191ea(%rip), %rax     # 0x3b648
movq (%rax), %rax
movl (%rax), %edi
leaq 0x191de(%rip), %rsi     # 0x3b648
callq 0x253d0
movq %rax, -0x78(%rbp)
jmp 0x224c0
leaq 0x191cc(%rip), %rax     # 0x3b648
movq (%rax), %rax
movl (%rax), %edx
leaq 0x191c0(%rip), %rax     # 0x3b648
movq (%rax), %rax
movq 0x8(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
leaq 0x191a8(%rip), %rax     # 0x3b648
movq (%rax), %rax
movq 0x8(%rax), %rax
leaq 0x1919a(%rip), %rcx     # 0x3b648
movq (%rcx), %rcx
movslq (%rcx), %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x28(%rbp)
leaq 0x19179(%rip), %rax     # 0x3b648
movq (%rax), %rax
movl $0x1000, (%rax)         # imm = 0x1000
leaq 0x19169(%rip), %rax     # 0x3b648
movq (%rax), %rax
movq 0x8(%rax), %rax
leaq 0x1915b(%rip), %rcx     # 0x3b648
movq (%rcx), %rcx
movslq (%rcx), %rcx
addq %rcx, %rax
leaq 0x1914b(%rip), %rcx     # 0x3b648
movq (%rcx), %rcx
cmpq 0x10(%rcx), %rax
jb 0x22524
leaq 0x1913b(%rip), %rax     # 0x3b648
movq (%rax), %rax
movl (%rax), %edi
leaq 0x1912f(%rip), %rsi     # 0x3b648
callq 0x253d0
movq %rax, -0x80(%rbp)
jmp 0x2256f
leaq 0x1911d(%rip), %rax     # 0x3b648
movq (%rax), %rax
movl (%rax), %edx
leaq 0x19111(%rip), %rax     # 0x3b648
movq (%rax), %rax
movq 0x8(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
leaq 0x190f9(%rip), %rax     # 0x3b648
movq (%rax), %rax
movq 0x8(%rax), %rax
leaq 0x190eb(%rip), %rcx     # 0x3b648
movq (%rcx), %rcx
movslq (%rcx), %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x20(%rbp)
movl 0x17a37(%rip), %eax     # 0x39fb4
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, 0x17a29(%rip)     # 0x39fb4
cmpl $0x0, %eax
jne 0x2259a
movl $0x1, 0x17a1a(%rip)     # 0x39fb4
movl -0x4(%rbp), %edi
movl -0xc(%rbp), %edx
leaq -0x48(%rbp), %rsi
callq 0x21500
cmpq $0x0, -0x38(%rbp)
jne 0x225da
movl -0x8(%rbp), %edi
callq 0x245d0
movq %rax, -0x38(%rbp)
movl -0x8(%rbp), %edi
callq 0x208b0
cmpl $0x0, -0x30(%rbp)
jne 0x225d8
leaq 0xf986(%rip), %rdi      # 0x31f57
movb $0x0, %al
callq 0xdba0
jmp 0x225da
movl -0x8(%rbp), %edi
addl $0x1, %edi
callq 0x245d0
cmpl $0x0, 0x1c(%rax)
je 0x225f6
movl -0x8(%rbp), %edi
addl $0x1, %edi
callq 0x208b0
leaq 0x16b2b(%rip), %rax     # 0x39128
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rcx
leaq 0x16b15(%rip), %rax     # 0x39128
movq %rcx, (%rax)
leaq -0x48(%rbp), %rdi
callq 0x22c20
movl -0x8(%rbp), %edi
callq 0x21370
leaq 0x16afa(%rip), %rax     # 0x39128
movq (%rax), %rcx
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rcx
leaq 0x16adc(%rip), %rax     # 0x39128
movq (%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x58(%rbp), %rcx
leaq 0x16aca(%rip), %rax     # 0x39128
movq %rcx, (%rax)
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)