// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x20(%rbp), %rax
cmpl $0xc, (%rax)
jne 0x13aa4
leaq 0xe308(%rip), %rax      # 0x21da8
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpl $0xc, (%rax)
jne 0x13ab8
leaq 0xe2f4(%rip), %rax      # 0x21da8
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x1, (%rax)
jne 0x13ace
movq $0x0, -0x8(%rbp)
jmp 0x13ec9
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x13aec
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0x13afa
leaq 0x8a57(%rip), %rdi      # 0x1c54a
movb $0x0, %al
callq 0x12650
movq -0x18(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x13c81
movl $0x77, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x13bdb
xorl %eax, %eax
movl %eax, %edi
callq 0x12cc0
movq %rax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
decq %rax
movq %rax, -0x48(%rbp)
subq $0x7, %rax
ja 0x13bbb
movq -0x48(%rbp), %rax
leaq 0x82e2(%rip), %rcx      # 0x1be30
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x21, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rcx
movl $0x49, %esi
movl $0x77, %edx
xorl %eax, %eax
movl %eax, %r8d
callq 0x15860
movq %rax, -0x28(%rbp)
jmp 0x13bd6
movl $0x21, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rcx
movl $0x47, %esi
movl $0x77, %edx
xorl %eax, %eax
movl %eax, %r8d
callq 0x15860
movq %rax, -0x28(%rbp)
jmp 0x13bd6
movl $0x21, -0x2c(%rbp)
jmp 0x13bd6
movl $0x2b, -0x2c(%rbp)
jmp 0x13bd6
leaq 0x89af(%rip), %rdi      # 0x1c571
movb $0x0, %al
callq 0x12650
movq $0x0, -0x8(%rbp)
jmp 0x13ec9
jmp 0x13c7c
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x13bec
jmp 0x13c0b
leaq 0x89a9(%rip), %rdi      # 0x1c59c
leaq 0x848e(%rip), %rsi      # 0x1c088
movl $0x11f, %edx            # imm = 0x11F
leaq 0x89ac(%rip), %rcx      # 0x1c5b2
callq 0x30f0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
subq $0x4, %rax
je 0x13c2b
jmp 0x13c1f
movq -0x50(%rbp), %rax
subq $0x8, %rax
je 0x13c45
jmp 0x13c5f
movl $0x35, -0x2c(%rbp)
movl $0x3, %edi
xorps %xmm0, %xmm0
callq 0x15610
movq %rax, -0x38(%rbp)
jmp 0x13c7a
movl $0x3d, -0x2c(%rbp)
movl $0x4, %edi
xorps %xmm0, %xmm0
callq 0x15610
movq %rax, -0x38(%rbp)
jmp 0x13c7a
leaq 0x899f(%rip), %rdi      # 0x1c605
movb $0x0, %al
callq 0x12650
movq $0x0, -0x8(%rbp)
jmp 0x13ec9
jmp 0x13c7c
jmp 0x13eae
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x13dca
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
movl $0x77, %eax
movl $0x6c, %ecx
cmpq $0x8, %rdx
cmovel %ecx, %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x13d7f
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x20(%rbp), %rcx
cmpq 0x10(%rcx), %rax
ja 0x13ce2
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x13ec9
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
subq $0x1, %rax
je 0x13d46
jmp 0x13cf6
movq -0x58(%rbp), %rax
subq $0x2, %rax
je 0x13d2a
jmp 0x13d02
movq -0x58(%rbp), %rax
subq $0x4, %rax
jne 0x13d62
jmp 0x13d0e
movq -0x20(%rbp), %rax
movb 0x40(%rax), %dl
movl $0x45, %eax
movl $0x44, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x13d7d
movq -0x20(%rbp), %rax
movb 0x40(%rax), %dl
movl $0x47, %eax
movl $0x46, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x13d7d
movq -0x20(%rbp), %rax
movb 0x40(%rax), %dl
movl $0x49, %eax
movl $0x48, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x13d7d
leaq 0x8808(%rip), %rdi      # 0x1c571
movb $0x0, %al
callq 0x12650
movq $0x0, -0x8(%rbp)
jmp 0x13ec9
jmp 0x13dc5
movq -0x18(%rbp), %rax
testb $0x1, 0x40(%rax)
je 0x13da7
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
movl $0x4c, %eax
movl $0x4e, %ecx
cmpq $0x8, %rdx
cmovel %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x13dc3
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
movl $0x4d, %eax
movl $0x4f, %ecx
cmpq $0x8, %rdx
cmovel %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x13dc5
jmp 0x13eac
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
movl $0x73, %eax
movl $0x64, %ecx
cmpq $0x8, %rdx
cmovel %ecx, %eax
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x13e3b
movq -0x20(%rbp), %rax
testb $0x1, 0x40(%rax)
je 0x13e1d
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
movl $0x50, %eax
movl $0x52, %ecx
cmpq $0x8, %rdx
cmovel %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x13e39
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
movl $0x51, %eax
movl $0x53, %ecx
cmpq $0x8, %rdx
cmovel %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x13eaa
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x13e4c
jmp 0x13e6b
leaq 0x8749(%rip), %rdi      # 0x1c59c
leaq 0x822e(%rip), %rsi      # 0x1c088
movl $0x143, %edx            # imm = 0x143
leaq 0x874c(%rip), %rcx      # 0x1c5b2
callq 0x30f0
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x13e87
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x13ec9
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rsi
movl $0x4b, %eax
movl $0x4a, %ecx
cmpq %rsi, %rdx
cmovbl %ecx, %eax
movl %eax, -0x2c(%rbp)
jmp 0x13eac
jmp 0x13eae
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %esi
movl -0x3c(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x15860
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)