// File: /workspace/github_c_makefile_star2_O3/michaelforney[P]cproc/qbe.c
// Function: convert
static struct value *
convert(struct func *f, struct type *dst, struct type *src, struct value *l)
{
	enum instkind op;
	struct value *r = NULL;
	int class;

	if (src->kind == TYPEPOINTER)
		src = &typeulong;
	if (dst->kind == TYPEPOINTER)
		dst = &typeulong;
	if (dst->kind == TYPEVOID)
		return NULL;
	if (!(src->prop & PROPREAL) || !(dst->prop & PROPREAL))
		fatal("internal error; unsupported conversion");
	if (dst->kind == TYPEBOOL) {
		class = 'w';
		if (src->prop & PROPINT) {
			r = mkintconst(0);
			switch (src->size) {
			case 1: op = ICNEW, l = funcinst(f, IEXTUB, 'w', l, NULL); break;
			case 2: op = ICNEW, l = funcinst(f, IEXTUH, 'w', l, NULL); break;
			case 4: op = ICNEW; break;
			case 8: op = ICNEL; break;
			default:
				fatal("internal error; unknown integer conversion");
				return NULL;  /* unreachable */
			}
		} else {
			assert(src->prop & PROPFLOAT);
			switch (src->size) {
			case 4: op = ICNES, r = mkfltconst(VALUE_FLTCONST, 0); break;
			case 8: op = ICNED, r = mkfltconst(VALUE_DBLCONST, 0); break;
			default:
				fatal("internal error; unknown floating point conversion");
				return NULL;  /* unreachable */
			}
		}
	} else if (dst->prop & PROPINT) {
		class = dst->size == 8 ? 'l' : 'w';
		if (src->prop & PROPINT) {
			if (dst->size <= src->size)
				return l;
			switch (src->size) {
			case 4: op = src->u.basic.issigned ? IEXTSW : IEXTUW; break;
			case 2: op = src->u.basic.issigned ? IEXTSH : IEXTUH; break;
			case 1: op = src->u.basic.issigned ? IEXTSB : IEXTUB; break;
			default:
				fatal("internal error; unknown integer conversion");
				return NULL;  /* unreachable */
			}
		} else {
			if (dst->u.basic.issigned)
				op = src->size == 8 ? IDTOSI : ISTOSI;
			else
				op = src->size == 8 ? IDTOUI : ISTOUI;
		}
	} else {
		class = dst->size == 8 ? 'd' : 's';
		if (src->prop & PROPINT) {
			if (src->u.basic.issigned)
				op = src->size == 8 ? ISLTOF : ISWTOF;
			else
				op = src->size == 8 ? IULTOF : IUWTOF;
		} else {
			assert(src->prop & PROPFLOAT);
			if (src->size == dst->size)
				return l;
			op = src->size < dst->size ? IEXTS : ITRUNCD;
		}
	}

	return funcinst(f, op, class, l, r);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rdx, %r12
movq %rsi, %r15
cmpl $0xc, (%rdx)
leaq 0xce69(%rip), %rax      # 0x1bd08
cmoveq %rax, %r12
cmpl $0xc, (%rsi)
cmoveq %rax, %r15
movl (%r15), %eax
cmpl $0x1, %eax
jne 0xeec0
xorl %ebx, %ebx
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rcx, %rbx
movq %rdi, %r14
testb $0x4, 0x4(%r12)
je 0xeed5
testb $0x4, 0x4(%r15)
jne 0xeee6
leaq 0x6eda(%rip), %rdi      # 0x15db6
xorl %eax, %eax
callq 0xe058
movl (%r15), %eax
cmpl $0x2, %eax
jne 0xef44
movl 0x4(%r12), %eax
testb $0x2, %al
jne 0xef95
testb $0x20, %al
je 0xf146
movq 0x10(%r12), %rax
cmpq $0x8, %rax
je 0xf081
cmpq $0x4, %rax
jne 0xf0a9
movl $0x10, %edi
callq 0xe142
movq %rax, %r15
movl $0x3, (%rax)
movq $0x0, 0x8(%rax)
movl $0x77, %ebp
movl $0x35, %r12d
jmp 0xf113
testb $0x2, 0x4(%r15)
movq 0x10(%r15), %rax
movl 0x4(%r12), %ecx
jne 0xefea
cmpq $0x8, %rax
movl $0x64, %edx
movl $0x73, %ebp
cmovel %edx, %ebp
testb $0x2, %cl
jne 0xf026
testb $0x20, %cl
je 0xf165
cmpq %rax, 0x10(%r12)
je 0xeeb4
movl $0x4b, %r12d
sbbl $0x0, %r12d
jmp 0xf0eb
movl $0x10, %edi
callq 0xe142
movq %rax, %r15
movl $0x2, (%rax)
movq $0x0, 0x8(%rax)
movq 0x10(%r12), %rax
decq %rax
cmpq $0x7, %rax
ja 0xf0b2
movl $0x77, %ebp
movl $0x21, %r12d
leaq 0x67bc(%rip), %rcx      # 0x15790
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
movl $0x49, %esi
jmp 0xf0f8
cmpq $0x8, %rax
movl $0x6c, %edx
movl $0x77, %ebp
cmovel %edx, %ebp
testb $0x2, %cl
jne 0xf04d
movq 0x10(%r12), %rax
cmpb $0x1, 0x40(%r15)
jne 0xf0c7
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x4c(,%rcx,2), %r12d
jmp 0xf0eb
movq 0x10(%r12), %rax
cmpb $0x1, 0x40(%r12)
jne 0xf0da
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x50(,%rcx,2), %r12d
jmp 0xf0eb
movq 0x10(%r12), %rcx
cmpq %rcx, %rax
jbe 0xeeb4
cmpq $0x1, %rcx
je 0xf13a
cmpq $0x2, %rcx
je 0xf12e
cmpq $0x4, %rcx
jne 0xf0b2
movzbl 0x40(%r12), %r12d
xorl $0x45, %r12d
jmp 0xf0eb
movl $0x10, %edi
callq 0xe142
movq %rax, %r15
movl $0x4, (%rax)
movq $0x0, 0x8(%rax)
movl $0x77, %ebp
movl $0x3d, %r12d
jmp 0xf113
leaq 0x6dc1(%rip), %rdi      # 0x15e71
jmp 0xf0b9
leaq 0x6d24(%rip), %rdi      # 0x15ddd
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xe058
jmp 0xeeb4
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x4d(,%rcx,2), %r12d
jmp 0xf0eb
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x51(,%rcx,2), %r12d
xorl %r15d, %r15d
jmp 0xf113
movq %r14, %rdi
movl $0x47, %esi
movl $0x77, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x10201
movq %rax, %rbx
jmp 0xf113
movl $0x2b, %r12d
movq %r14, %rdi
movl %r12d, %esi
movl %ebp, %edx
movq %rbx, %rcx
movq %r15, %r8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x10201
movzbl 0x40(%r12), %r12d
xorl $0x47, %r12d
jmp 0xf0eb
movzbl 0x40(%r12), %r12d
xorl $0x49, %r12d
jmp 0xf0eb
leaq 0x6cbb(%rip), %rdi      # 0x15e08
leaq 0x67a0(%rip), %rsi      # 0x158f4
leaq 0x6cc3(%rip), %rcx      # 0x15e1e
movl $0x11f, %edx            # imm = 0x11F
callq 0x30e0
leaq 0x6c9c(%rip), %rdi      # 0x15e08
leaq 0x6781(%rip), %rsi      # 0x158f4
leaq 0x6ca4(%rip), %rcx      # 0x15e1e
movl $0x143, %edx            # imm = 0x143
callq 0x30e0