// File: /workspace/github_c_makefile_star2_O0/Oric4ever[P]lcc65/6502/build/../src/stmt.c
// Function: swcode
static int swcode(swp, b, lb, ub, n) struct swtch *swp; int lb, ub, n, b[]; {
	int hilab, k, l, lolab, median, u, *v;

	v = swp->values;
	median = ((float)v[b[lb]] + (float)v[b[ub+1]-1] + 1)/2;
	for (l = lb, u = ub; l <= u; ) {
		k = (l + u)/2;
		if (v[b[k]] > median)
			u = k - 1;
		else if (v[b[k+1]-1] < median)
			l = k + 1;
		else
			break;
	}
	if (l > u) {	/* which of two buckets is closest to the median? */
		l = b[k];
		u = b[k+1] - 1;
		if (median < v[l] && k > lb && v[l] - median > median - v[l-1])
			k--;
		else if (median > v[u] && k < ub && median - v[u] > v[u+1] - median)
			k++;
	}
	l = b[k];
	u = b[k+1] - 1;
	lolab = hilab = swp->deflab->u.l.label;
	if (k > lb) {
		lolab = 0;
		if (k < ub)
			hilab = genlabel(1);
	} else if (k < ub)
		hilab = 0;
	if (n == 0)
		lolab = hilab = 0;
	if (u - l + 1 <= 3) {
		int i;
		for (i = l; i <= u; i++)
			cmp(EQ, swp->sym, swp->values[i], swp->labels[i]->u.l.label);
		if (lolab && lolab == hilab)
			branch(lolab);
		else {
			if (lolab)
				cmp(LT, swp->sym, swp->values[l], lolab);
			if (hilab)
				cmp(GT, swp->sym, swp->values[u], hilab);
			walk(0, 0, 0);
		}
	} else {
		int lab = genlabel(1);
		Symbol tab = genident(STATIC, array(voidptype, u - l + 1, 0), GLOBAL);
		cmp(LT, swp->sym, swp->values[l], lolab ? lolab : lab);
		cmp(GT, swp->sym, swp->values[u], hilab ? hilab : lab);
		walk(tree(JUMP, voidtype, rvalue((*opnode['+'])(ADD, pointer(idnode(tab)),
			(*opnode['-'])(SUB, cast(idnode(swp->sym), inttype),
				constnode(swp->values[l], inttype)))), 0), 0, 0);
		code(Switch);
		codelist->u.swtch.sym = swp->sym;
		codelist->u.swtch.deflab = swp->deflab;
		codelist->u.swtch.table = tab;
		codelist->u.swtch.size = u - l + 1;
		codelist->u.swtch.values = &swp->values[l];
		codelist->u.swtch.labels = &swp->labels[l];
		branch(0);
		definelab(lab);
		if (swp->values[u] - swp->values[l] + 1 >= 10000)
			warning("switch generates a huge table\n");
	}
	if (k > lb)
		n = swcode(swp, b, lb, k - 1, n - 1);
	if (k < ub) {
		if (hilab)
			definelab(hilab);
		n = swcode(swp, b, k + 1, ub, n - 1);
	}
	return n;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x14(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
cvtsi2ssl (%rax,%rcx,4), %xmm0
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movl -0x18(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
cvtsi2ssl (%rax,%rcx,4), %xmm1
addss %xmm1, %xmm0
movss 0xee03(%rip), %xmm1     # 0x31cdc
addss %xmm1, %xmm0
movss 0xedf3(%rip), %xmm1     # 0x31cd8
divss %xmm1, %xmm0
cvttss2si %xmm0, %eax
movl %eax, -0x30(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x22f6b
movl -0x28(%rbp), %eax
addl -0x34(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x24(%rbp)
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movslq (%rcx,%rdx,4), %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x30(%rbp), %eax
jle 0x22f38
movl -0x24(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x22f69
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movl -0x24(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
cmpl -0x30(%rbp), %eax
jge 0x22f65
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x22f67
jmp 0x22f6b
jmp 0x22f69
jmp 0x22efc
movl -0x28(%rbp), %eax
cmpl -0x34(%rbp), %eax
jle 0x2302d
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movl -0x30(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x28(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x22fe3
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x22fe3
movq -0x40(%rbp), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %eax
subl -0x30(%rbp), %eax
movl -0x30(%rbp), %ecx
movq -0x40(%rbp), %rdx
movl -0x28(%rbp), %esi
subl $0x1, %esi
movslq %esi, %rsi
subl (%rdx,%rsi,4), %ecx
cmpl %ecx, %eax
jle 0x22fe3
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2302b
movl -0x30(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x34(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
jle 0x23029
movl -0x24(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x23029
movl -0x30(%rbp), %eax
movq -0x40(%rbp), %rcx
movslq -0x34(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
movq -0x40(%rbp), %rcx
movl -0x34(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movl (%rcx,%rdx,4), %ecx
subl -0x30(%rbp), %ecx
cmpl %ecx, %eax
jle 0x23029
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2302b
jmp 0x2302d
movq -0x10(%rbp), %rax
movslq -0x24(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl 0x48(%rax), %eax
movl %eax, -0x20(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x23088
movl $0x0, -0x2c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x23086
movl $0x1, %edi
callq 0x24d90
movl %eax, -0x20(%rbp)
jmp 0x23099
movl -0x24(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x23097
movl $0x0, -0x20(%rbp)
jmp 0x23099
cmpl $0x0, -0x1c(%rbp)
jne 0x230ad
movl $0x0, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x34(%rbp), %eax
subl -0x28(%rbp), %eax
addl $0x1, %eax
cmpl $0x3, %eax
jg 0x23187
movl -0x28(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x34(%rbp), %eax
jg 0x2310b
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl 0x48(%rax), %ecx
movl $0x1e0, %edi            # imm = 0x1E0
callq 0x23490
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x230c5
cmpl $0x0, -0x2c(%rbp)
je 0x23123
movl -0x2c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jne 0x23123
movl -0x2c(%rbp), %edi
callq 0x21370
jmp 0x23182
cmpl $0x0, -0x2c(%rbp)
je 0x2314c
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movl -0x2c(%rbp), %ecx
movl $0x220, %edi            # imm = 0x220
callq 0x23490
cmpl $0x0, -0x20(%rbp)
je 0x23175
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movl -0x20(%rbp), %ecx
movl $0x200, %edi            # imm = 0x200
callq 0x23490
xorl %eax, %eax
movl %eax, %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x3a80
jmp 0x23420
movl $0x1, %edi
callq 0x24d90
movl %eax, -0x48(%rbp)
leaq 0x210b5(%rip), %rax     # 0x44250
movq (%rax), %rdi
movl -0x34(%rbp), %esi
subl -0x28(%rbp), %esi
addl $0x1, %esi
xorl %edx, %edx
callq 0x27160
movq %rax, %rsi
movl $0x51, %edi
movl $0x3, %edx
callq 0x24b00
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x231ef
movl -0x2c(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0x231f5
movl -0x48(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x54(%rbp), %edx
movq -0x60(%rbp), %rsi
movl -0x64(%rbp), %ecx
movl $0x220, %edi            # imm = 0x220
callq 0x23490
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movl %eax, -0x68(%rbp)
cmpl $0x0, -0x20(%rbp)
je 0x23234
movl -0x20(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x2323a
movl -0x48(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x68(%rbp), %edx
movq -0x70(%rbp), %rsi
movl -0x74(%rbp), %ecx
movl $0x200, %edi            # imm = 0x200
callq 0x23490
leaq 0x20feb(%rip), %rax     # 0x44240
movq (%rax), %rax
movq %rax, -0x80(%rbp)
leaq 0x15eed(%rip), %rax     # 0x39150
movq 0x158(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x50(%rbp), %rdi
callq 0xddf0
movq %rax, %rdi
callq 0xf9f0
movq %rax, -0x90(%rbp)
leaq 0x15ec0(%rip), %rax     # 0x39150
movq 0x168(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0xddf0
movq %rax, %rdi
leaq 0x20f44(%rip), %rax     # 0x441f8
movq (%rax), %rsi
callq 0xe9b0
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x28(%rbp), %rcx
movl (%rax,%rcx,4), %edi
leaq 0x20f1f(%rip), %rax     # 0x441f8
movq (%rax), %rsi
callq 0xc7b0
movq -0xa0(%rbp), %rsi
movq %rax, %rdx
movq -0x98(%rbp), %rax
movl $0x140, %edi            # imm = 0x140
callq *%rax
movq -0x90(%rbp), %rsi
movq %rax, %rdx
movq -0x88(%rbp), %rax
movl $0x130, %edi            # imm = 0x130
callq *%rax
movq %rax, %rdi
callq 0xf780
movq -0x80(%rbp), %rsi
movq %rax, %rdx
movl $0x240, %edi            # imm = 0x240
xorl %eax, %eax
movl %eax, %ecx
callq 0x256f0
movq %rax, %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x3a80
movl $0xa, %edi
callq 0x3300
movq -0x8(%rbp), %rax
movq (%rax), %rcx
leaq 0x15dd6(%rip), %rax     # 0x39128
movq (%rax), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rcx
leaq 0x15dc0(%rip), %rax     # 0x39128
movq (%rax), %rax
movq %rcx, 0x28(%rax)
movq -0x50(%rbp), %rcx
leaq 0x15dae(%rip), %rax     # 0x39128
movq (%rax), %rax
movq %rcx, 0x20(%rax)
movl -0x34(%rbp), %ecx
subl -0x28(%rbp), %ecx
addl $0x1, %ecx
leaq 0x15d97(%rip), %rax     # 0x39128
movq (%rax), %rax
movl %ecx, 0x30(%rax)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rcx
movslq -0x28(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rcx
leaq 0x15d77(%rip), %rax     # 0x39128
movq (%rax), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rcx
movslq -0x28(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rcx
leaq 0x15d56(%rip), %rax     # 0x39128
movq (%rax), %rax
movq %rcx, 0x40(%rax)
xorl %edi, %edi
callq 0x21370
movl -0x48(%rbp), %edi
callq 0x208b0
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x34(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x8(%rbp), %rcx
movq 0x20(%rcx), %rcx
movslq -0x28(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
addl $0x1, %eax
cmpl $0x2710, %eax           # imm = 0x2710
jl 0x2341e
leaq 0xeb60(%rip), %rdi      # 0x31f77
movb $0x0, %al
callq 0xdba0
jmp 0x23420
movl -0x24(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x23449
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movl -0x1c(%rbp), %r8d
subl $0x1, %r8d
callq 0x22e70
movl %eax, -0x1c(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x23480
cmpl $0x0, -0x20(%rbp)
je 0x2345f
movl -0x20(%rbp), %edi
callq 0x208b0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x24(%rbp), %edx
addl $0x1, %edx
movl -0x18(%rbp), %ecx
movl -0x1c(%rbp), %r8d
subl $0x1, %r8d
callq 0x22e70
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopl (%rax)