// File: /workspace/github_c_makefile_star2_O1/Oric4ever[P]lcc65/6502/build/../src/expr.c
// Function: cast
Tree cast(p, type) Tree p; Type type; {
	Field q;
	Type pty, ty = unqual(type);

	p = value(p);
	if (p->type == type)
		return p;
	pty = unqual(p->type);
	if (pty == ty)
		return retype(p, type);
	if (pty == signedchar || pty == chartype)
		p = simplify(CVC, inttype, p, 0);
	else if (pty == shorttype)
		p = simplify(CVS, inttype, p, 0);
	else if (pty == longtype)
		p = retype(p, inttype);
	else if (pty == floattype)
		p = simplify(CVF, doubletype, p, 0);
	else if (pty == longdouble)
		p = retype(p, doubletype);
	else if (pty == unsignedchar)
		p = simplify(CVC, unsignedtype, p, 0);
	else if (pty == unsignedshort)
		p = simplify(CVS, unsignedtype, p, 0);
	else if (pty == unsignedlong)
		p = retype(p, unsignedtype);
	else if (isptr(pty)) {
		if (isstruct(pty->type) && isptr(ty) && isstruct(ty->type)
		&& (q = extends(pty->type, ty->type)))
			return simplify(ADD+P, ty, p, constnode(q->offset, inttype));
		if (isptr(ty)) {
			if (isfunc(pty->type) && !isfunc(ty->type)
			|| !isfunc(pty->type) &&  isfunc(ty->type))
				warning("conversion from `%t' to `%t' is compiler-dependent\n",
					p->type, ty);
			return retype(p, type);
		}
		p = simplify(CVP, unsignedtype, p, 0);
	}
	else if (isstruct(pty) && isstruct(ty) && (q = extends(pty, ty)))
		return rvalue(simplify(ADD+P, ptr(ty), addrof(p),
			constnode(q->offset, inttype)));
	pty = unqual(p->type);
	if (pty == inttype || isenum(pty)) {
		if (ty == floattype || ty == doubletype || ty == longdouble)
			p = simplify(CVI, doubletype, p, 0);
		else if (ty == unsignedtype  || ty == unsignedchar
		     ||  ty == unsignedshort || ty == unsignedlong || isptr(ty))
			p = simplify(CVI, unsignedtype, p, 0);
	} else if (pty == doubletype) {
		if (ty == signedchar || ty == chartype || isenum(ty)
		||  ty == shorttype  || ty == inttype  || ty == longtype)
			p = simplify(CVD, inttype, p, 0);
		else if (ty == unsignedtype  || ty == unsignedchar
		     ||  ty == unsignedshort || ty == unsignedlong || isptr(ty)) {
			/*
			 * For (unsigned)d for double d, build
			 * d >= INT_MAX+1 ? (unsigned)(int)(d-(INT_MAX+1)) + INT_MAX+1 :
			 *		    (unsigned)(int)d
			 */
			Tree c = tree(CNST+D, doubletype, 0, 0);
			c->u.v.d = (double)INT_MAX + 1;
			p = condnode(
				simplify(GE, doubletype, p, c),
				(*opnode['+'])(ADD,
					cast(cast(simplify(SUB, doubletype, p, c), inttype), unsignedtype),
					constnode((unsigned)INT_MAX + 1, unsignedtype)),
				simplify(CVD, inttype, p, 0));
		}
	} else if (pty == unsignedtype) {
		if (ty == signedchar || ty == chartype || isenum(ty)
		||  ty == shorttype  || ty == inttype  || ty == longtype)
			p = simplify(CVU, inttype, p, 0);
		else if (ty == floattype || ty == doubletype || ty == longdouble) {
			/*
			 * For (double)u for unsigned u, build
			 * (int)u >= 0 ? (double)(int)u : (double)(int)u + UINT_MAX + 1
			 */
			Tree u = simplify(CVU, inttype, p, 0);
			p = tree(CNST+D, doubletype, 0, 0);
			p->u.v.d = utod(UINT_MAX) + 1;
			p = condnode(
				simplify(GE, inttype, u, constnode(0, inttype)),
				simplify(CVI, doubletype, u, 0),
				(*opnode['+'])(ADD, simplify(CVI, doubletype, u, 0), p));
		}
	} else
		assert(0);
	if (ty == signedchar || ty == chartype || ty == shorttype)
		p = simplify(CVI, type, p, 0);
	else if (ty == floattype)
		p = simplify(CVD, type, p, 0);
	else if (ty == unsignedchar || ty == unsignedshort || isptr(ty))
		p = simplify(CVU, type, p, 0);
	else
		p = retype(p, type);
	return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
cmpl $0xf, (%rsi)
movq %rsi, %r14
jb 0xa35e
movq 0x10(%rbx), %r14
callq 0x9e6f
movq %rax, %r15
movq 0x8(%rax), %r12
cmpq %rbx, %r12
je 0xa4d6
cmpl $0xf, (%r12)
jb 0xa37f
movq 0x10(%r12), %r12
cmpq %r14, %r12
je 0xaab4
leaq 0x27c29(%rip), %rbp     # 0x31fb8
leaq 0x27bea(%rip), %r13     # 0x31f80
cmpq (%rbp), %r12
je 0xa4e8
cmpq (%r13), %r12
je 0xa4e8
leaq 0x27bff(%rip), %rax     # 0x31fb0
cmpq (%rax), %r12
je 0xa4f9
leaq 0x27be7(%rip), %rax     # 0x31fa8
cmpq (%rax), %r12
je 0xa50a
leaq 0x27bbf(%rip), %rax     # 0x31f90
cmpq (%rax), %r12
je 0xa516
leaq 0x27bbf(%rip), %rax     # 0x31fa0
cmpq (%rax), %r12
je 0xa950
leaq 0x27bcf(%rip), %rax     # 0x31fc0
cmpq (%rax), %r12
je 0xa967
leaq 0x27bcf(%rip), %rax     # 0x31fd0
cmpq (%rax), %r12
je 0xa973
leaq 0x27bb7(%rip), %rax     # 0x31fc8
cmpq (%rax), %r12
je 0xa97f
movl (%r12), %eax
movq %r12, %rcx
cmpl $0xf, %eax
jb 0xa42b
movq 0x10(%r12), %rcx
cmpl $0x7, (%rcx)
jne 0xa988
movq 0x10(%r12), %rdi
movl (%rdi), %eax
movq %rdi, %rcx
cmpl $0xf, %eax
jb 0xa447
movq 0x10(%rdi), %rcx
cmpl $0x9, (%rcx)
je 0xa461
movq %rdi, %rcx
cmpl $0xf, %eax
jb 0xa458
movq 0x10(%rdi), %rcx
cmpl $0xa, (%rcx)
jne 0xaa43
cmpl $0xf, (%r14)
movq %r14, %rax
jb 0xa46e
movq 0x10(%r14), %rax
cmpl $0x7, (%rax)
jne 0xaa43
movq 0x10(%r14), %rsi
movl (%rsi), %eax
movq %rsi, %rcx
cmpl $0xf, %eax
jb 0xa489
movq 0x10(%rsi), %rcx
cmpl $0x9, (%rcx)
je 0xa4a3
movq %rsi, %rcx
cmpl $0xf, %eax
jb 0xa49a
movq 0x10(%rsi), %rcx
cmpl $0xa, (%rcx)
jne 0xaa43
callq 0x19489
testq %rax, %rax
je 0xaa43
movl 0x10(%rax), %edi
leaq 0x27add(%rip), %rax     # 0x31f98
movq (%rax), %rsi
callq 0x9044
movl $0x137, %edi            # imm = 0x137
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
jmp 0xa7ab
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x27aa9(%rip), %rax     # 0x31f98
movq (%rax), %rsi
movl $0x50, %edi
jmp 0xa525
leaq 0x27a98(%rip), %rax     # 0x31f98
movq (%rax), %rsi
movl $0xa0, %edi
jmp 0xa525
leaq 0x27a87(%rip), %rax     # 0x31f98
jmp 0xa957
leaq 0x27a6b(%rip), %rax     # 0x31f88
movq (%rax), %rsi
movl $0x70, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12653
movq %rax, %r15
movq 0x8(%r15), %rcx
cmpl $0xf, (%rcx)
jb 0xa53f
movq 0x10(%rcx), %rcx
leaq 0x27a52(%rip), %r12     # 0x31f98
movq (%r12), %rsi
cmpq %rsi, %rcx
je 0xa564
cmpl $0xf, (%rcx)
movq %rcx, %rax
jb 0xa55b
movq 0x10(%rcx), %rax
cmpl $0xd, (%rax)
jne 0xa64a
leaq 0x27a25(%rip), %rax     # 0x31f90
leaq 0x27a16(%rip), %rcx     # 0x31f88
movq (%rcx), %rsi
cmpq (%rax), %r14
je 0xa5d0
cmpq %rsi, %r14
je 0xa5d0
leaq 0x27a1a(%rip), %rax     # 0x31fa0
cmpq (%rax), %r14
je 0xa5d0
leaq 0x27a46(%rip), %rax     # 0x31fd8
movq (%rax), %rsi
cmpq %rsi, %r14
je 0xa5d0
leaq 0x27a1f(%rip), %rax     # 0x31fc0
cmpq (%rax), %r14
je 0xa5d0
leaq 0x27a23(%rip), %rax     # 0x31fd0
cmpq (%rax), %r14
je 0xa5d0
leaq 0x27a0f(%rip), %rax     # 0x31fc8
cmpq (%rax), %r14
je 0xa5d0
cmpl $0xf, (%r14)
movq %r14, %rax
jb 0xa5cb
movq 0x10(%r14), %rax
cmpl $0x7, (%rax)
jne 0xa5e2
movl $0x80, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12653
movq %rax, %r15
cmpq (%rbp), %r14
je 0xa640
cmpq (%r13), %r14
je 0xa640
leaq 0x279bb(%rip), %rax     # 0x31fb0
cmpq (%rax), %r14
je 0xa640
leaq 0x2798f(%rip), %rax     # 0x31f90
cmpq (%rax), %r14
je 0xa79e
leaq 0x279af(%rip), %rax     # 0x31fc0
cmpq (%rax), %r14
je 0xa636
leaq 0x279b3(%rip), %rax     # 0x31fd0
cmpq (%rax), %r14
je 0xa636
cmpl $0xf, (%r14)
jb 0xa62c
movq 0x10(%r14), %r14
cmpl $0x7, (%r14)
jne 0xaab4
movl $0xb0, %edi
jmp 0xa7a3
movl $0x80, %edi
jmp 0xa7a3
leaq 0x27937(%rip), %rdi     # 0x31f88
movq (%rdi), %rax
cmpq %rax, %rcx
je 0xa7c8
leaq 0x27974(%rip), %rdx     # 0x31fd8
cmpq (%rdx), %rcx
jne 0xaae1
cmpq (%rbp), %r14
je 0xa7be
cmpq (%r13), %r14
je 0xa7be
cmpl $0xf, (%r14)
movq %r14, %rcx
jb 0xa68e
movq 0x10(%r14), %rcx
cmpl $0xd, (%rcx)
je 0xa7be
cmpq %rsi, %r14
je 0xa7be
leaq 0x27909(%rip), %rcx     # 0x31fb0
cmpq (%rcx), %r14
je 0xa7be
leaq 0x278f1(%rip), %rcx     # 0x31fa8
cmpq (%rcx), %r14
je 0xa7be
cmpq %rax, %r14
je 0xa6e1
leaq 0x278c4(%rip), %rax     # 0x31f90
cmpq (%rax), %r14
je 0xa6e1
leaq 0x278c8(%rip), %rax     # 0x31fa0
cmpq (%rax), %r14
jne 0xa5e2
movq %rdi, %r13
movl $0xb0, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12653
movq %rax, %r15
movq (%r13), %rsi
movl $0x12, %edi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x17b61
movq %rax, 0x10(%rsp)
movabsq $0x41f0000000000000, %rcx # imm = 0x41F0000000000000
movq %rcx, 0x28(%rax)
movq (%r12), %r13
xorl %edi, %edi
movq %r13, %rsi
callq 0x9044
movl $0x1f0, %edi            # imm = 0x1F0
movq %r13, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x12653
movq %rax, 0x8(%rsp)
leaq 0x27840(%rip), %rax     # 0x31f88
movq (%rax), %rsi
movl $0x80, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12653
movq %rax, %r13
leaq 0x1d9fc(%rip), %rax     # 0x28160
movq 0x158(%rax), %r12
leaq 0x27816(%rip), %rax     # 0x31f88
movq (%rax), %rsi
movl $0x80, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12653
movl $0x130, %edi            # imm = 0x130
movq %rax, %rsi
movq 0x10(%rsp), %rdx
callq *%r12
movq 0x8(%rsp), %rdi
jmp 0xa92f
movl $0x60, %edi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x12653
movl $0xb0, %edi
jmp 0xa5d5
cmpq (%rbp), %r14
je 0xa946
cmpq (%r13), %r14
je 0xa946
movl (%r14), %ecx
movq %r14, %rdx
cmpl $0xf, %ecx
jb 0xa7eb
movq 0x10(%r14), %rdx
cmpl $0xd, (%rdx)
je 0xa946
cmpq %rsi, %r14
je 0xa946
leaq 0x277ac(%rip), %rdx     # 0x31fb0
cmpq (%rdx), %r14
je 0xa946
leaq 0x27794(%rip), %rdx     # 0x31fa8
cmpq (%rdx), %r14
je 0xa946
leaq 0x277b4(%rip), %rdx     # 0x31fd8
cmpq (%rdx), %r14
je 0xa862
leaq 0x27790(%rip), %rdx     # 0x31fc0
cmpq (%rdx), %r14
je 0xa862
leaq 0x27794(%rip), %rdx     # 0x31fd0
cmpq (%rdx), %r14
je 0xa862
leaq 0x27780(%rip), %rdx     # 0x31fc8
cmpq (%rdx), %r14
je 0xa862
movq %r14, %rdx
cmpl $0xf, %ecx
jb 0xa859
movq 0x10(%r14), %rdx
cmpl $0x7, (%rdx)
jne 0xa5e2
movl $0x12, %edi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x17b61
movq %rax, %r13
movabsq $0x41e0000000000000, %rax # imm = 0x41E0000000000000
movq %rax, 0x28(%r13)
leaq 0x276fd(%rip), %rax     # 0x31f88
movq (%rax), %rsi
movl $0x1f0, %edi            # imm = 0x1F0
movq %r15, %rdx
movq %r13, %rcx
callq 0x12653
movq %rax, 0x10(%rsp)
leaq 0x1d8b6(%rip), %rax     # 0x28160
movq 0x158(%rax), %rax
movq %rax, 0x8(%rsp)
leaq 0x276cb(%rip), %rax     # 0x31f88
movq (%rax), %rsi
movl $0x140, %edi            # imm = 0x140
movq %r15, %rdx
movq %r13, %rcx
callq 0x12653
movq (%r12), %rsi
movq %rax, %rdi
callq 0xa341
leaq 0x276f5(%rip), %rcx     # 0x31fd8
movq (%rcx), %rsi
movq %rax, %rdi
callq 0xa341
movq %rax, %r13
leaq 0x276e0(%rip), %rax     # 0x31fd8
movq (%rax), %rsi
movl $0x80000000, %edi       # imm = 0x80000000
callq 0x9044
movl $0x130, %edi            # imm = 0x130
movq %r13, %rsi
movq %rax, %rdx
callq *0x8(%rsp)
movq %rax, %r13
movq (%r12), %rsi
movl $0x60, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12653
movq 0x10(%rsp), %rdi
movq %r13, %rsi
leaq 0x27647(%rip), %r13     # 0x31f80
movq %rax, %rdx
callq 0x9290
jmp 0xa5df
movl $0x60, %edi
jmp 0xa5d5
leaq 0x27631(%rip), %rax     # 0x31f88
movq (%rax), %rsi
movq %r15, %rdi
callq 0x17ca2
jmp 0xa52f
leaq 0x2766a(%rip), %rax     # 0x31fd8
jmp 0xa4ef
leaq 0x2765e(%rip), %rax     # 0x31fd8
jmp 0xa500
leaq 0x27652(%rip), %rax     # 0x31fd8
jmp 0xa957
movq %r12, %rcx
cmpl $0xf, %eax
jb 0xa995
movq 0x10(%r12), %rcx
cmpl $0x9, (%rcx)
je 0xa9b0
movq %r12, %rcx
cmpl $0xf, %eax
jb 0xa9a7
movq 0x10(%r12), %rcx
cmpl $0xa, (%rcx)
jne 0xa532
movl (%r14), %eax
movq %r14, %rcx
cmpl $0xf, %eax
jb 0xa9bf
movq 0x10(%r14), %rcx
cmpl $0x9, (%rcx)
je 0xa9d9
movq %r14, %rcx
cmpl $0xf, %eax
jb 0xa9d0
movq 0x10(%r14), %rcx
cmpl $0xa, (%rcx)
jne 0xa532
movq %r12, %rdi
movq %r14, %rsi
callq 0x19489
testq %rax, %rax
je 0xa532
movq %rax, %r12
movq %r14, %rdi
callq 0x18a44
movq %rax, %rbx
movq %r15, %rdi
callq 0x9c98
movq %rax, %r14
movl 0x10(%r12), %edi
leaq 0x27586(%rip), %rax     # 0x31f98
movq (%rax), %rsi
callq 0x9044
movl $0x137, %edi            # imm = 0x137
movq %rbx, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x12653
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xab00
cmpl $0xf, (%r14)
movq %r14, %rax
jb 0xaa50
movq 0x10(%r14), %rax
cmpl $0x7, (%rax)
jne 0xaacd
movq 0x10(%r12), %rax
movl (%rax), %ecx
movq %rax, %rdx
cmpl $0xf, %ecx
jb 0xaa68
movq 0x10(%rax), %rdx
cmpl $0xb, (%rdx)
jne 0xaa7f
movq 0x10(%r14), %rdx
cmpl $0xf, (%rdx)
jb 0xaa7a
movq 0x10(%rdx), %rdx
cmpl $0xb, (%rdx)
jne 0xaa9f
cmpl $0xf, %ecx
jb 0xaa88
movq 0x10(%rax), %rax
cmpl $0xb, (%rax)
je 0xaab4
movq 0x10(%r14), %rax
cmpl $0xf, (%rax)
jb 0xaa9a
movq 0x10(%rax), %rax
cmpl $0xb, (%rax)
jne 0xaab4
movq 0x8(%r15), %rsi
leaq 0x14680(%rip), %rdi     # 0x1f12a
movq %r14, %rdx
xorl %eax, %eax
callq 0x9be3
movq %r15, %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17ca2
leaq 0x27504(%rip), %rax     # 0x31fd8
movq (%rax), %rsi
movl $0x90, %edi
jmp 0xa525
leaq 0x136b3(%rip), %rdi     # 0x1e19b
leaq 0x145ca(%rip), %rsi     # 0x1f0b9
leaq 0x14668(%rip), %rcx     # 0x1f15e
movl $0x115, %edx            # imm = 0x115
callq 0x30d0