// File: /workspace/github_c_makefile_star2_O0/Oric4ever[P]lcc65/6502/build/../src/stmt.c
// Function: swgen
static void swgen(swp) struct swtch *swp; {
	int *buckets, k, n, *v;

	if (swp->ncases == 0)
		return;
	buckets = (int *) talloc((swp->ncases + 1)*sizeof *buckets);
	v = swp->values;
	n = 0;
	for (k = 0; k < swp->ncases; k++, n++) {
		buckets[n] = k;
		while (n > 0) {
			float d = den(k, n-1);
			if (d < density || (k < swp->ncases - 1 && d < den(k+1, n)))
				break;
			n--;
		}
	}
	buckets[n--] = swp->ncases;
	swcode(swp, buckets, 0, n, n);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jne 0x22c3b
jmp 0x22e5d
movq -0x8(%rbp), %rax
movl 0x18(%rax), %eax
addl $0x1, %eax
cltq
shlq $0x2, %rax
addq $0x7, %rax
andq $-0x8, %rax
movl %eax, %ecx
leaq 0x189ec(%rip), %rax     # 0x3b648
movq (%rax), %rax
movl %ecx, (%rax)
leaq 0x189e0(%rip), %rax     # 0x3b648
movq (%rax), %rax
movq 0x8(%rax), %rax
leaq 0x189d2(%rip), %rcx     # 0x3b648
movq (%rcx), %rcx
movslq (%rcx), %rcx
addq %rcx, %rax
leaq 0x189c2(%rip), %rcx     # 0x3b648
movq (%rcx), %rcx
cmpq 0x10(%rcx), %rax
jb 0x22cad
leaq 0x189b2(%rip), %rax     # 0x3b648
movq (%rax), %rax
movl (%rax), %edi
leaq 0x189a6(%rip), %rsi     # 0x3b648
callq 0x253d0
movq %rax, -0x30(%rbp)
jmp 0x22cf8
leaq 0x18994(%rip), %rax     # 0x3b648
movq (%rax), %rax
movl (%rax), %edx
leaq 0x18988(%rip), %rax     # 0x3b648
movq (%rax), %rax
movq 0x8(%rax), %rcx
movslq %edx, %rdx
addq %rdx, %rcx
movq %rcx, 0x8(%rax)
leaq 0x18970(%rip), %rax     # 0x3b648
movq (%rax), %rax
movq 0x8(%rax), %rax
leaq 0x18962(%rip), %rcx     # 0x3b648
movq (%rcx), %rcx
movslq (%rcx), %rdx
xorl %ecx, %ecx
subq %rdx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x18(%rbp)
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x18(%rcx), %eax
jge 0x22e2b
movl -0x14(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
cmpl $0x0, -0x18(%rbp)
jle 0x22e12
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
movl -0x18(%rbp), %edx
subl $0x1, %edx
movslq %edx, %rdx
subl (%rcx,%rdx,4), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm0
movq -0x20(%rbp), %rax
movslq -0x14(%rbp), %rcx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rdx
movl -0x18(%rbp), %esi
subl $0x1, %esi
movslq %esi, %rsi
movslq (%rdx,%rsi,4), %rdx
subl (%rcx,%rdx,4), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x24(%rbp), %xmm1
movss 0x17214(%rip), %xmm0    # 0x39fb0
ucomiss %xmm1, %xmm0
ja 0x22e02
movl -0x14(%rbp), %eax
movq -0x8(%rbp), %rcx
movl 0x18(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jge 0x22e04
movss -0x24(%rbp), %xmm1
movl -0x14(%rbp), %eax
addl $0x1, %eax
movq -0x10(%rbp), %rcx
movslq -0x18(%rbp), %rdx
subl (%rcx,%rdx,4), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm0
movq -0x20(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rdx
movslq -0x18(%rbp), %rsi
movslq (%rdx,%rsi,4), %rdx
subl (%rcx,%rdx,4), %eax
addl $0x1, %eax
cvtsi2ss %eax, %xmm2
divss %xmm2, %xmm0
ucomiss %xmm1, %xmm0
jbe 0x22e04
jmp 0x22e12
movl -0x18(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x22d38
jmp 0x22e14
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x22d1a
movq -0x8(%rbp), %rax
movl 0x18(%rax), %edx
movq -0x10(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, %esi
addl $-0x1, %esi
movl %esi, -0x18(%rbp)
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x18(%rbp), %ecx
movl -0x18(%rbp), %r8d
xorl %edx, %edx
callq 0x22e70
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)