// File: /workspace/github_c_makefile_star2_O1/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 0xce76(%rip), %rax      # 0x1bd08
cmoveq %rax, %r12
cmpl $0xc, (%rsi)
cmoveq %rax, %r15
cmpl $0x1, (%r15)
jne 0xeeb1
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 0xeec6
testb $0x4, 0x4(%r15)
jne 0xeed4
leaq 0x6e49(%rip), %rdi      # 0x15d16
xorl %eax, %eax
callq 0xe054
cmpl $0x2, (%r15)
jne 0xef33
movl 0x4(%r12), %eax
testb $0x2, %al
jne 0xef84
testb $0x20, %al
je 0xf135
movq 0x10(%r12), %rax
cmpq $0x8, %rax
je 0xf070
cmpq $0x4, %rax
jne 0xf098
movl $0x10, %edi
callq 0xe13e
movq %rax, %r15
movl $0x3, (%rax)
movq $0x0, 0x8(%rax)
movl $0x77, %ebp
movl $0x35, %r12d
jmp 0xf102
testb $0x2, 0x4(%r15)
movq 0x10(%r15), %rax
movl 0x4(%r12), %ecx
jne 0xefd9
cmpq $0x8, %rax
movl $0x64, %edx
movl $0x73, %ebp
cmovel %edx, %ebp
testb $0x2, %cl
jne 0xf015
testb $0x20, %cl
je 0xf154
cmpq %rax, 0x10(%r12)
je 0xeea5
movl $0x4b, %r12d
sbbl $0x0, %r12d
jmp 0xf0da
movl $0x10, %edi
callq 0xe13e
movq %rax, %r15
movl $0x2, (%rax)
movq $0x0, 0x8(%rax)
movq 0x10(%r12), %rax
decq %rax
cmpq $0x7, %rax
ja 0xf0a1
movl $0x77, %ebp
movl $0x21, %r12d
leaq 0x672d(%rip), %rcx      # 0x156f0
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
movl $0x49, %esi
jmp 0xf0e7
cmpq $0x8, %rax
movl $0x6c, %edx
movl $0x77, %ebp
cmovel %edx, %ebp
testb $0x2, %cl
jne 0xf03c
movq 0x10(%r12), %rax
cmpb $0x1, 0x40(%r15)
jne 0xf0b6
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x4c(,%rcx,2), %r12d
jmp 0xf0da
movq 0x10(%r12), %rax
cmpb $0x1, 0x40(%r12)
jne 0xf0c9
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x50(,%rcx,2), %r12d
jmp 0xf0da
movq 0x10(%r12), %rcx
cmpq %rcx, %rax
jbe 0xeea5
cmpq $0x1, %rcx
je 0xf129
cmpq $0x2, %rcx
je 0xf11d
cmpq $0x4, %rcx
jne 0xf0a1
movzbl 0x40(%r12), %r12d
xorl $0x45, %r12d
jmp 0xf0da
movl $0x10, %edi
callq 0xe13e
movq %rax, %r15
movl $0x4, (%rax)
movq $0x0, 0x8(%rax)
movl $0x77, %ebp
movl $0x3d, %r12d
jmp 0xf102
leaq 0x6d32(%rip), %rdi      # 0x15dd1
jmp 0xf0a8
leaq 0x6c95(%rip), %rdi      # 0x15d3d
xorl %ebx, %ebx
xorl %eax, %eax
callq 0xe054
jmp 0xeea5
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x4d(,%rcx,2), %r12d
jmp 0xf0da
xorl %ecx, %ecx
cmpq $0x8, %rax
sete %cl
leal 0x51(,%rcx,2), %r12d
xorl %r15d, %r15d
jmp 0xf102
movq %r14, %rdi
movl $0x47, %esi
movl $0x77, %edx
movq %rbx, %rcx
xorl %r8d, %r8d
callq 0x101fd
movq %rax, %rbx
jmp 0xf102
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 0x101fd
movzbl 0x40(%r12), %r12d
xorl $0x47, %r12d
jmp 0xf0da
movzbl 0x40(%r12), %r12d
xorl $0x49, %r12d
jmp 0xf0da
leaq 0x6c2c(%rip), %rdi      # 0x15d68
leaq 0x6711(%rip), %rsi      # 0x15854
leaq 0x6c34(%rip), %rcx      # 0x15d7e
movl $0x11f, %edx            # imm = 0x11F
callq 0x30e0
leaq 0x6c0d(%rip), %rdi      # 0x15d68
leaq 0x66f2(%rip), %rsi      # 0x15854
leaq 0x6c15(%rip), %rcx      # 0x15d7e
movl $0x143, %edx            # imm = 0x143
callq 0x30e0