// File: /workspace/github_c_makefile_star2_O3/michaelforney[P]cproc/qbe.c
// Function: casesearch
static void
casesearch(struct func *f, int class, struct value *v, struct switchcase *c, struct block *defaultlabel)
{
	struct value *res, *key;
	struct block *label[3];

	if (!c) {
		funcjmp(f, defaultlabel);
		return;
	}
	label[0] = mkblock("switch_ne");
	label[1] = mkblock("switch_lt");
	label[2] = mkblock("switch_gt");

	/* XXX: linear search if c->node.height < 4 */
	key = mkintconst(c->node.key);
	res = funcinst(f, class == 'w' ? ICEQW : ICEQL, 'w', v, key);
	funcjnz(f, res, NULL, c->body, label[0]);
	funclabel(f, label[0]);
	res = funcinst(f, class == 'w' ? ICULTW : ICULTL, 'w', v, key);
	funcjnz(f, res, NULL, label[1], label[2]);
	funclabel(f, label[1]);
	casesearch(f, class, v, c->node.child[0], defaultlabel);
	funclabel(f, label[2]);
	casesearch(f, class, v, c->node.child[1], defaultlabel);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r8, 0x20(%rsp)
movq %rdi, %r15
movq %rcx, 0x8(%rsp)
testq %rcx, %rcx
je 0x109b5
cmpl $0x77, %esi
movl $0x20, %eax
movl $0x2a, %ecx
cmovel %eax, %ecx
movl %ecx, 0x18(%rsp)
movl $0x27, %eax
movl $0x31, %ecx
cmovel %eax, %ecx
movl %ecx, 0x14(%rsp)
movq %rdx, 0x28(%rsp)
movl %esi, 0x1c(%rsp)
movl $0x88, %edi
callq 0xe142
movq %rax, %rbx
movl $0x7, %r12d
movl %r12d, (%rax)
leaq 0x57c2(%rip), %rax      # 0x15fb5
movq %rax, 0x8(%rbx)
movl 0xb943(%rip), %eax      # 0x1c140
incl %eax
movl %eax, 0xb93b(%rip)      # 0x1c140
movl %eax, 0x4(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbx)
xorl %r14d, %r14d
movq %r14, 0x20(%rbx)
movl %r14d, 0x60(%rbx)
movl %r14d, 0x50(%rbx)
movq %r14, 0x80(%rbx)
movl $0x88, %edi
callq 0xe142
movq %rax, %r13
movl %r12d, (%rax)
leaq 0x5783(%rip), %rax      # 0x15fbf
movq %rax, 0x8(%r13)
movl 0xb8fa(%rip), %eax      # 0x1c140
incl %eax
movl %eax, 0xb8f2(%rip)      # 0x1c140
movl %eax, 0x4(%r13)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%r13)
movq %r14, 0x20(%r13)
movl %r14d, 0x60(%r13)
movl %r14d, 0x50(%r13)
movq %r14, 0x80(%r13)
movl $0x88, %edi
callq 0xe142
movq %rax, %rbp
movl %r12d, (%rax)
leaq 0x5745(%rip), %rax      # 0x15fc9
movq %rax, 0x8(%rbp)
movl 0xb8b2(%rip), %eax      # 0x1c140
incl %eax
movl %eax, 0xb8aa(%rip)      # 0x1c140
movl %eax, 0x4(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, 0x10(%rbp)
movq %r14, 0x20(%rbp)
movl %r14d, 0x60(%rbp)
movl %r14d, 0x50(%rbp)
movq %r14, 0x80(%rbp)
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
movl $0x10, %edi
callq 0xe142
movq %rax, %r12
movl $0x2, (%rax)
movq 0x30(%rsp), %rax
movq %rax, 0x8(%r12)
movq %r15, %rdi
movl 0x18(%rsp), %esi
movl $0x77, %edx
movq 0x28(%rsp), %rcx
movq %r12, %r8
callq 0x10201
movq 0x30(%r15), %rcx
cmpl %r14d, 0x60(%rcx)
je 0x10907
movq 0x8(%rsp), %r14
jmp 0x10927
movq 0x8(%rsp), %r14
movq 0x20(%r14), %rdx
movl $0x2, 0x60(%rcx)
movq %rax, 0x68(%rcx)
movq %rdx, 0x70(%rcx)
movq %rbx, 0x78(%rcx)
movq 0x30(%r15), %rcx
movq %rbx, 0x80(%rcx)
movq %rbx, 0x30(%r15)
movq %r15, %rdi
movl 0x14(%rsp), %esi
movl $0x77, %edx
movq 0x28(%rsp), %rbx
movq %rbx, %rcx
movq %r12, %r8
callq 0x10201
movq 0x30(%r15), %rcx
cmpl $0x0, 0x60(%rcx)
jne 0x1096f
movl $0x2, 0x60(%rcx)
movq %rax, 0x68(%rcx)
movq %r13, 0x70(%rcx)
movq %rbp, 0x78(%rcx)
movq 0x30(%r15), %rcx
movq %r13, 0x80(%rcx)
movq %r13, 0x30(%r15)
movq 0x8(%r14), %rcx
movq %r15, %rdi
movl 0x1c(%rsp), %esi
movq %rbx, %rdx
movq 0x20(%rsp), %r8
callq 0x10784
movq 0x30(%r15), %rax
movq %rbp, 0x80(%rax)
movq %rbp, 0x30(%r15)
movq 0x10(%r14), %r14
movq %r14, 0x8(%rsp)
testq %r14, %r14
jne 0x107d6
jmp 0x109b9
movq 0x30(%r15), %rbp
cmpl $0x0, 0x60(%rbp)
jne 0x109cf
movl $0x1, 0x60(%rbp)
movq 0x20(%rsp), %rax
movq %rax, 0x70(%rbp)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq