// File: /workspace/github_c_makefile_star2_O2/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 0xe066(%rip), %rax      # 0x1bd08
cmoveq %rax, %r12
cmpl $0xc, (%rsi)
cmoveq %rax, %r15
movl (%r15), %eax
cmpl $0x1, %eax
jne 0xdcc3
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 0xdcd8
testb $0x4, 0x4(%r15)
jne 0xdce9
leaq 0x709b(%rip), %rdi      # 0x14d7a
xorl %eax, %eax
callq 0xcffb
movl (%r15), %eax
cmpl $0x2, %eax
jne 0xdd34
movl 0x4(%r12), %eax
testb $0x2, %al
jne 0xdd7b
testb $0x20, %al
je 0xdef3
movq 0x10(%r12), %rax
cmpq $0x8, %rax
je 0xde48
cmpq $0x4, %rax
jne 0xde5d
pushq $0x3
popq %rdi
xorps %xmm0, %xmm0
callq 0xebeb
movq %rax, %r15
pushq $0x77
popq %rbp
pushq $0x35
jmp 0xdebe
testb $0x2, 0x4(%r15)
movq 0x10(%r15), %rax
movl 0x4(%r12), %ecx
jne 0xddb5
cmpq $0x8, %rax
pushq $0x64
popq %rdx
pushq $0x73
popq %rbp
cmovel %edx, %ebp
testb $0x2, %cl
jne 0xdded
testb $0x20, %cl
je 0xdf12
cmpq %rax, 0x10(%r12)
je 0xdcb7
pushq $0x4b
popq %r12
sbbl $0x0, %r12d
jmp 0xde9f
xorl %edi, %edi
callq 0xd317
movq %rax, %r15
movq 0x10(%r12), %rax
decq %rax
cmpq $0x7, %rax
ja 0xde66
pushq $0x77
popq %rbp
pushq $0x21
popq %r12
leaq 0x697b(%rip), %rcx      # 0x14720
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
pushq $0x49
jmp 0xdea6
cmpq $0x8, %rax
pushq $0x6c
popq %rdx
pushq $0x77
popq %rbp
cmovel %edx, %ebp
testb $0x2, %cl
jne 0xde14
movq 0x10(%r12), %rax
cmpb $0x1, 0x40(%r15)
jne 0xde7b
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x4c(,%rcx,2), %r12d
jmp 0xde9f
movq 0x10(%r12), %rax
cmpb $0x1, 0x40(%r12)
jne 0xde8e
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x50(,%rcx,2), %r12d
jmp 0xde9f
movq 0x10(%r12), %rcx
cmpq %rcx, %rax
jbe 0xdcb7
cmpq $0x1, %rcx
je 0xdee7
cmpq $0x2, %rcx
je 0xdedb
cmpq $0x4, %rcx
jne 0xde66
movzbl 0x40(%r12), %r12d
xorl $0x45, %r12d
jmp 0xde9f
pushq $0x4
popq %rdi
xorps %xmm0, %xmm0
callq 0xebeb
movq %rax, %r15
pushq $0x77
popq %rbp
pushq $0x3d
jmp 0xdebe
leaq 0x6fd1(%rip), %rdi      # 0x14e35
jmp 0xde6d
leaq 0x6f34(%rip), %rdi      # 0x14da1
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xcffb
jmp 0xdcb7
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x4d(,%rcx,2), %r12d
jmp 0xde9f
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x51(,%rcx,2), %r12d
xorl %r15d, %r15d
jmp 0xdec0
pushq $0x47
popq %rsi
movq %r14, %rdi
movl %ebp, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0xed68
movq %rax, %rbx
jmp 0xdec0
pushq $0x2b
popq %r12
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 0xed68
movzbl 0x40(%r12), %r12d
xorl $0x47, %r12d
jmp 0xde9f
movzbl 0x40(%r12), %r12d
xorl $0x49, %r12d
jmp 0xde9f
leaq 0x6ed2(%rip), %rdi      # 0x14dcc
leaq 0x69b7(%rip), %rsi      # 0x148b8
leaq 0x6eda(%rip), %rcx      # 0x14de2
movl $0x11f, %edx            # imm = 0x11F
callq 0x30e0
leaq 0x6eb3(%rip), %rdi      # 0x14dcc
leaq 0x6998(%rip), %rsi      # 0x148b8
leaq 0x6ebb(%rip), %rcx      # 0x14de2
movl $0x143, %edx            # imm = 0x143
callq 0x30e0