// File: /workspace/github_c_makefile_star2_O3/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 0xa314
movq 0x10(%rbx), %r14
callq 0x9e7a
movq %rax, %r15
movq 0x8(%rax), %r12
cmpq %rbx, %r12
je 0xa3fb
cmpl $0xf, (%r12)
jb 0xa335
movq 0x10(%r12), %r12
cmpq %r14, %r12
je 0xaa5e
leaq 0x28c73(%rip), %rbp     # 0x32fb8
leaq 0x28c34(%rip), %r13     # 0x32f80
cmpq (%rbp), %r12
je 0xa40d
cmpq (%r13), %r12
je 0xa40d
leaq 0x28c49(%rip), %rax     # 0x32fb0
cmpq (%rax), %r12
je 0xa41e
leaq 0x28c31(%rip), %rax     # 0x32fa8
cmpq (%rax), %r12
je 0xa42f
leaq 0x28c09(%rip), %rax     # 0x32f90
cmpq (%rax), %r12
je 0xa43b
leaq 0x28c09(%rip), %rax     # 0x32fa0
cmpq (%rax), %r12
je 0xa87b
leaq 0x28c19(%rip), %rax     # 0x32fc0
cmpq (%rax), %r12
je 0xa892
leaq 0x28c19(%rip), %rax     # 0x32fd0
cmpq (%rax), %r12
je 0xa89e
leaq 0x28c01(%rip), %rax     # 0x32fc8
cmpq (%rax), %r12
je 0xa8aa
movl (%r12), %eax
cmpl $0xf, %eax
jb 0xa8b3
movq 0x10(%r12), %rax
movl (%rax), %eax
cmpl $0x7, %eax
je 0xa9dd
cmpl $0x9, %eax
je 0xa957
jmp 0xa94e
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28b84(%rip), %rax     # 0x32f98
movq (%rax), %rsi
movl $0x50, %edi
jmp 0xa44a
leaq 0x28b73(%rip), %rax     # 0x32f98
movq (%rax), %rsi
movl $0xa0, %edi
jmp 0xa44a
leaq 0x28b62(%rip), %rax     # 0x32f98
jmp 0xa882
leaq 0x28b46(%rip), %rax     # 0x32f88
movq (%rax), %rsi
movl $0x70, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12443
movq %rax, %r15
movq 0x8(%r15), %rcx
cmpl $0xf, (%rcx)
jb 0xa464
movq 0x10(%rcx), %rcx
leaq 0x28b2d(%rip), %r12     # 0x32f98
movq (%r12), %rsi
cmpq %rsi, %rcx
je 0xa48a
movl (%rcx), %eax
cmpl $0xf, %eax
jb 0xa481
movq 0x10(%rcx), %rax
movl (%rax), %eax
cmpl $0xd, %eax
jne 0xa574
leaq 0x28aff(%rip), %rax     # 0x32f90
leaq 0x28af0(%rip), %rcx     # 0x32f88
movq (%rcx), %rsi
cmpq (%rax), %r14
je 0xa4f7
cmpq %rsi, %r14
je 0xa4f7
leaq 0x28af4(%rip), %rax     # 0x32fa0
cmpq (%rax), %r14
je 0xa4f7
leaq 0x28b20(%rip), %rax     # 0x32fd8
movq (%rax), %rsi
cmpq %rsi, %r14
je 0xa4f7
leaq 0x28af9(%rip), %rax     # 0x32fc0
cmpq (%rax), %r14
je 0xa4f7
leaq 0x28afd(%rip), %rax     # 0x32fd0
cmpq (%rax), %r14
je 0xa4f7
leaq 0x28ae9(%rip), %rax     # 0x32fc8
cmpq (%rax), %r14
je 0xa4f7
movl (%r14), %eax
cmpl $0xf, %eax
jb 0xa4f2
movq 0x10(%r14), %rax
movl (%rax), %eax
cmpl $0x7, %eax
jne 0xa509
movl $0x80, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12443
movq %rax, %r15
cmpq (%rbp), %r14
je 0xa56a
cmpq (%r13), %r14
je 0xa56a
leaq 0x28a94(%rip), %rax     # 0x32fb0
cmpq (%rax), %r14
je 0xa56a
leaq 0x28a68(%rip), %rax     # 0x32f90
cmpq (%rax), %r14
je 0xa6c9
leaq 0x28a88(%rip), %rax     # 0x32fc0
cmpq (%rax), %r14
je 0xa560
leaq 0x28a8c(%rip), %rax     # 0x32fd0
cmpq (%rax), %r14
je 0xa560
movl (%r14), %eax
cmpl $0xf, %eax
jb 0xa557
movq 0x10(%r14), %rax
movl (%rax), %eax
cmpl $0x7, %eax
jne 0xaa5e
movl $0xb0, %edi
jmp 0xa6ce
movl $0x80, %edi
jmp 0xa6ce
leaq 0x28a0d(%rip), %rdi     # 0x32f88
movq (%rdi), %rax
cmpq %rax, %rcx
je 0xa6f3
leaq 0x28a4a(%rip), %rdx     # 0x32fd8
cmpq (%rdx), %rcx
jne 0xaa8b
cmpq (%rbp), %r14
je 0xa6e9
cmpq (%r13), %r14
je 0xa6e9
movl (%r14), %ecx
cmpl $0xf, %ecx
jb 0xa5b9
movq 0x10(%r14), %rcx
movl (%rcx), %ecx
cmpl $0xd, %ecx
je 0xa6e9
cmpq %rsi, %r14
je 0xa6e9
leaq 0x289de(%rip), %rcx     # 0x32fb0
cmpq (%rcx), %r14
je 0xa6e9
leaq 0x289c6(%rip), %rcx     # 0x32fa8
cmpq (%rcx), %r14
je 0xa6e9
cmpq %rax, %r14
je 0xa60c
leaq 0x28999(%rip), %rax     # 0x32f90
cmpq (%rax), %r14
je 0xa60c
leaq 0x2899d(%rip), %rax     # 0x32fa0
cmpq (%rax), %r14
jne 0xa509
movq %rdi, %r13
movl $0xb0, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12443
movq %rax, %r15
movq (%r13), %rsi
movl $0x12, %edi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x179e5
movq %rax, 0x10(%rsp)
movabsq $0x41f0000000000000, %rcx # imm = 0x41F0000000000000
movq %rcx, 0x28(%rax)
movq (%r12), %r13
xorl %edi, %edi
movq %r13, %rsi
callq 0x908f
movl $0x1f0, %edi            # imm = 0x1F0
movq %r13, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x12443
movq %rax, 0x8(%rsp)
leaq 0x28915(%rip), %rax     # 0x32f88
movq (%rax), %rsi
movl $0x80, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12443
movq %rax, %r13
leaq 0x1ead1(%rip), %rax     # 0x29160
movq 0x158(%rax), %r12
leaq 0x288eb(%rip), %rax     # 0x32f88
movq (%rax), %rsi
movl $0x80, %edi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x12443
movl $0x130, %edi            # imm = 0x130
movq %rax, %rsi
movq 0x10(%rsp), %rdx
callq *%r12
movq 0x8(%rsp), %rdi
jmp 0xa85a
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 0x12443
movl $0xb0, %edi
jmp 0xa4fc
cmpq (%rbp), %r14
je 0xa871
cmpq (%r13), %r14
je 0xa871
movl (%r14), %ecx
movl %ecx, %edx
cmpl $0xf, %ecx
jb 0xa717
movq 0x10(%r14), %rdx
movl (%rdx), %edx
cmpl $0xd, %edx
je 0xa871
cmpq %rsi, %r14
je 0xa871
leaq 0x28880(%rip), %rdx     # 0x32fb0
cmpq (%rdx), %r14
je 0xa871
leaq 0x28868(%rip), %rdx     # 0x32fa8
cmpq (%rdx), %r14
je 0xa871
leaq 0x28888(%rip), %rdx     # 0x32fd8
cmpq (%rdx), %r14
je 0xa78d
leaq 0x28864(%rip), %rdx     # 0x32fc0
cmpq (%rdx), %r14
je 0xa78d
leaq 0x28868(%rip), %rdx     # 0x32fd0
cmpq (%rdx), %r14
je 0xa78d
leaq 0x28854(%rip), %rdx     # 0x32fc8
cmpq (%rdx), %r14
je 0xa78d
cmpl $0xf, %ecx
jb 0xa784
movq 0x10(%r14), %rcx
movl (%rcx), %ecx
cmpl $0x7, %ecx
jne 0xa509
movl $0x12, %edi
movq %rax, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x179e5
movq %rax, %r13
movabsq $0x41e0000000000000, %rax # imm = 0x41E0000000000000
movq %rax, 0x28(%r13)
leaq 0x287d2(%rip), %rax     # 0x32f88
movq (%rax), %rsi
movl $0x1f0, %edi            # imm = 0x1F0
movq %r15, %rdx
movq %r13, %rcx
callq 0x12443
movq %rax, 0x10(%rsp)
leaq 0x1e98b(%rip), %rax     # 0x29160
movq 0x158(%rax), %rax
movq %rax, 0x8(%rsp)
leaq 0x287a0(%rip), %rax     # 0x32f88
movq (%rax), %rsi
movl $0x140, %edi            # imm = 0x140
movq %r15, %rdx
movq %r13, %rcx
callq 0x12443
movq (%r12), %rsi
movq %rax, %rdi
callq 0xa2f7
leaq 0x287ca(%rip), %rcx     # 0x32fd8
movq (%rcx), %rsi
movq %rax, %rdi
callq 0xa2f7
movq %rax, %r13
leaq 0x287b5(%rip), %rax     # 0x32fd8
movq (%rax), %rsi
movl $0x80000000, %edi       # imm = 0x80000000
callq 0x908f
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 0x12443
movq 0x10(%rsp), %rdi
movq %r13, %rsi
leaq 0x2871c(%rip), %r13     # 0x32f80
movq %rax, %rdx
callq 0x9298
jmp 0xa506
movl $0x60, %edi
jmp 0xa4fc
leaq 0x28706(%rip), %rax     # 0x32f88
movq (%rax), %rsi
movq %r15, %rdi
callq 0x17b29
jmp 0xa454
leaq 0x2873f(%rip), %rax     # 0x32fd8
jmp 0xa414
leaq 0x28733(%rip), %rax     # 0x32fd8
jmp 0xa425
leaq 0x28727(%rip), %rax     # 0x32fd8
jmp 0xa882
cmpl $0x9, %eax
je 0xa957
cmpl $0x7, %eax
jne 0xa94e
movq 0x10(%r12), %rdi
movl (%rdi), %eax
cmpl $0xf, %eax
jb 0xa8d7
movq 0x10(%rdi), %rax
movl (%rax), %eax
cmpl $0x9, %eax
je 0xa8e5
cmpl $0xa, %eax
jne 0xa9dd
movl (%r14), %eax
cmpl $0xf, %eax
jb 0xa8f3
movq 0x10(%r14), %rax
movl (%rax), %eax
cmpl $0x7, %eax
jne 0xa9dd
movq 0x10(%r14), %rsi
movl (%rsi), %eax
cmpl $0xf, %eax
jb 0xa90d
movq 0x10(%rsi), %rax
movl (%rax), %eax
cmpl $0x9, %eax
je 0xa91b
cmpl $0xa, %eax
jne 0xa9dd
callq 0x1927e
testq %rax, %rax
je 0xa9dd
movl 0x10(%rax), %edi
leaq 0x28665(%rip), %rax     # 0x32f98
movq (%rax), %rsi
callq 0x908f
movl $0x137, %edi            # imm = 0x137
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
jmp 0xa6d6
cmpl $0xa, %eax
jne 0xa457
movl (%r14), %eax
cmpl $0xf, %eax
jb 0xa965
movq 0x10(%r14), %rax
movl (%rax), %eax
cmpl $0x9, %eax
je 0xa973
cmpl $0xa, %eax
jne 0xa457
movq %r12, %rdi
movq %r14, %rsi
callq 0x1927e
testq %rax, %rax
je 0xa457
movq %rax, %r12
movq %r14, %rdi
callq 0x188cc
movq %rax, %rbx
movq %r15, %rdi
callq 0x9cb4
movq %rax, %r14
movl 0x10(%r12), %edi
leaq 0x285ec(%rip), %rax     # 0x32f98
movq (%rax), %rsi
callq 0x908f
movl $0x137, %edi            # imm = 0x137
movq %rbx, %rsi
movq %r14, %rdx
movq %rax, %rcx
callq 0x12443
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xaaaa
movl (%r14), %eax
cmpl $0xf, %eax
jb 0xa9eb
movq 0x10(%r14), %rax
movl (%rax), %eax
cmpl $0x7, %eax
jne 0xaa77
movq 0x10(%r12), %rcx
movl (%rcx), %eax
movl %eax, %edx
cmpl $0xf, %eax
jb 0xaa08
movq 0x10(%rcx), %rdx
movl (%rdx), %edx
cmpl $0xb, %edx
jne 0xaa23
movq 0x10(%r14), %rsi
movl (%rsi), %edx
cmpl $0xf, %edx
jb 0xaa1e
movq 0x10(%rsi), %rdx
movl (%rdx), %edx
cmpl $0xb, %edx
jne 0xaa49
cmpl $0xf, %eax
jb 0xaa2e
movq 0x10(%rcx), %rax
movl (%rax), %eax
cmpl $0xb, %eax
je 0xaa5e
movq 0x10(%r14), %rcx
movl (%rcx), %eax
cmpl $0xf, %eax
jb 0xaa44
movq 0x10(%rcx), %rax
movl (%rax), %eax
cmpl $0xb, %eax
jne 0xaa5e
movq 0x8(%r15), %rsi
leaq 0x14726(%rip), %rdi     # 0x1f17a
movq %r14, %rdx
xorl %eax, %eax
callq 0x9bfd
movq %r15, %rdi
movq %rbx, %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x17b29
leaq 0x2855a(%rip), %rax     # 0x32fd8
movq (%rax), %rsi
movl $0x90, %edi
jmp 0xa44a
leaq 0x13709(%rip), %rdi     # 0x1e19b
leaq 0x14670(%rip), %rsi     # 0x1f109
leaq 0x1470e(%rip), %rcx     # 0x1f1ae
movl $0x115, %edx            # imm = 0x115
callq 0x30d0