// File: /workspace/github_c_makefile_star2_O2/Oric4ever[P]lcc65/6502/build/../src/enode.c
// Function: condnode
Tree condnode(Tree e, Tree l, Tree r) {
	Symbol t1 = 0;
	Type ty = 0, lty = l->type, rty = r->type;
	Tree p;

	if (isarith(lty) && isarith(rty)) {
		ty = binary(lty, rty);
		l = cast(l, ty);
		r = cast(r, ty);
	} else if (eqtype(lty, rty, 1)
	|| (isptr(lty) && isint(rty) && assign(lty, r)))
		ty = unqual(lty);
	else if (isptr(rty) && isint(lty) && assign(rty, l))
		ty = unqual(rty);
	else if (isptr(lty) && isptr(rty)) {
		lty = lty->type;
		rty = rty->type;
		if (unqual(lty) == voidtype || unqual(rty) == voidtype)
			ty = voidtype;
		else if (eqtype(unqual(lty), unqual(rty), 1))
			ty = unqual(lty);
		if (ty) {
			if (isconst(lty) || isconst(rty))
				ty = qual(CONST, ty);
			if (isvolatile(lty) || isvolatile(rty))
				ty = qual(VOLATILE, ty);
			ty = ptr(ty);
		}
	}
	if (ty == 0) {
		typeerror(COND, l, r);
		ty = inttype;
	} else if (e->op == CNST+D || e->op == CNST+F) {
		e = cast(e, doubletype);
		return retype(e->u.v.d != 0.0 ? l : r, ty);
	} else if (generic(e->op) == CNST) {
		e = cast(e, unsignedtype);
		return retype(e->u.v.u ? l : r, ty);
	} else if (ty != voidtype && ty->size > 0) {
		Opcode op = generic(e->op);
		t1 = temporary(REGISTER, ty);
		l = root(asgn(t1, l));
		if (op != AND && op != OR && op != NOT && op != EQ && op != NE
		&&  op !=  LE && op != LT && op !=  GE && op != GT && op != RIGHT
		&& r->op == CNST+I && r->u.v.i == 0
		&& assign(e->type, r)) {
			/* e1?e2:0 => ((t1=e1)?(t1=e2): ) */
			e = asgn(t1, cast(e, ty));
			r = 0;
		} else
			r = root(asgn(t1, r));
	}
	p = tree(COND, ty, cond(e), tree(RIGHT, ty, l, r));
	p->u.sym = t1;
	return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, %r15
movq 0x8(%rsi), %r12
movl (%r12), %eax
cmpl $0xf, %eax
jb 0x8953
movq 0x10(%r12), %rax
movl (%rax), %eax
movq 0x8(%r14), %r13
cmpl $0x6, %eax
ja 0x899c
movl (%r13), %eax
cmpl $0xf, %eax
jb 0x896b
movq 0x10(%r13), %rax
movl (%rax), %eax
cmpl $0x6, %eax
ja 0x899c
movq %r12, %rdi
movq %r13, %rsi
callq 0x8773
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0x9912
movq %rax, %rbx
movq %r14, %rdi
movq %r12, %rsi
callq 0x9912
movq %rax, %r14
jmp 0x89be
pushq $0x1
popq %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x17b46
testl %eax, %eax
je 0x8a3f
cmpl $0xf, (%r12)
jb 0x89c7
movq 0x10(%r12), %r12
testq %r12, %r12
je 0x8c6f
movl (%r15), %ebp
leal -0x11(%rbp), %eax
cmpl $0x1, %eax
ja 0x89fa
leaq 0x295af(%rip), %rax     # 0x31f88
movq (%rax), %rsi
movq %r15, %rdi
callq 0x9912
xorpd %xmm0, %xmm0
ucomisd 0x28(%rax), %xmm0
cmovneq %rbx, %r14
cmovpq %rbx, %r14
movq %r14, %rdi
jmp 0x8a29
movq %r15, (%rsp)
movl %ebp, %r15d
andl $-0x10, %r15d
cmpl $0x10, %r15d
jne 0x8a7b
leaq 0x295c6(%rip), %rax     # 0x31fd8
movq (%rax), %rsi
movq (%rsp), %rdi
callq 0x9912
cmpl $0x0, 0x28(%rax)
cmoveq %r14, %rbx
movq %rbx, %rdi
movq %r12, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16727
movl (%r12), %eax
movl %eax, %edx
cmpl $0xf, %eax
jb 0x8a51
movq 0x10(%r12), %rcx
movl (%rcx), %edx
movl (%r13), %ecx
cmpl $0x7, %edx
jne 0x8b74
cmpl $0xf, %ecx
jb 0x8b50
movq 0x10(%r13), %rax
movl (%rax), %edx
cmpl $0x2, %edx
ja 0x8b57
jmp 0x8b79
leaq 0x2955e(%rip), %rax     # 0x31fe0
cmpq (%rax), %r12
je 0x8b44
cmpl $0x0, 0x8(%r12)
jle 0x8b44
pushq $0x4e
popq %rdi
movq %r12, %rsi
callq 0x16311
movq %rax, %r13
movq %rax, %rdi
movq %rbx, %rsi
callq 0x952e
movq %rax, %rdi
callq 0x16750
movq %rax, %rbx
cmpl $0x280, %r15d           # imm = 0x280
setne %al
movl %ebp, %ecx
andl $-0x20, %ecx
cmpl $0x260, %ecx            # imm = 0x260
setne %cl
cmpl $0x1e0, %r15d           # imm = 0x1E0
setne %dl
andl $-0x30, %ebp
cmpl $0x210, %ebp            # imm = 0x210
sete %sil
movd %r15d, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pcmpeqd 0x140e4(%rip), %xmm0    # 0x1cbe0
movmskps %xmm0, %edi
testl %edi, %edi
sete %dil
andb %al, %dl
andb %cl, %dl
andb %dil, %dl
xorb $0x1, %dl
orb %sil, %dl
movq (%rsp), %r15
jne 0x8b29
cmpl $0x15, (%r14)
jne 0x8b29
cmpl $0x0, 0x28(%r14)
je 0x8d32
movq %r13, %rdi
movq %r14, %rsi
callq 0x952e
movq %rax, %rdi
callq 0x16750
movq %rax, %r14
jmp 0x8c8c
xorl %r13d, %r13d
movq (%rsp), %r15
jmp 0x8c8c
movl %ecx, %edx
cmpl $0x3, %ecx
jb 0x8bd3
cmpl $0x6, %edx
ja 0x8b74
movq %r12, %rdi
movq %r14, %rsi
callq 0x9610
testq %rax, %rax
jne 0x89b2
movl (%r13), %ecx
cmpl $0xf, %ecx
jb 0x8b7f
movq 0x10(%r13), %rax
movl (%rax), %ecx
movl (%r12), %eax
cmpl $0x7, %ecx
jne 0x8bd3
cmpl $0xf, %eax
jb 0x8b9b
movq 0x10(%r12), %rcx
movl (%rcx), %ecx
cmpl $0x2, %ecx
ja 0x8ba6
jmp 0x8bd8
movl %eax, %ecx
cmpl $0x3, %eax
jb 0x8c6f
cmpl $0x6, %ecx
ja 0x8bd3
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9610
testq %rax, %rax
je 0x8bcf
cmpl $0xf, (%r13)
jb 0x8cd0
movq 0x10(%r13), %r12
jmp 0x89be
movl (%r12), %eax
cmpl $0xf, %eax
jb 0x8bdf
movq 0x10(%r12), %rax
movl (%rax), %eax
cmpl $0x7, %eax
jne 0x8c6f
movl (%r13), %eax
cmpl $0xf, %eax
jb 0x8bf7
movq 0x10(%r13), %rax
movl (%rax), %eax
cmpl $0x7, %eax
jne 0x8c6f
movq 0x10(%r12), %rbp
movl (%rbp), %ecx
movq %rbp, %rdx
cmpl $0xf, %ecx
jb 0x8c10
movq 0x10(%rbp), %rdx
movq 0x10(%r13), %r12
leaq 0x293c5(%rip), %rax     # 0x31fe0
movq (%rax), %rax
cmpq %rax, %rdx
je 0x8c6a
movl (%r12), %edx
movq %r12, %rsi
cmpl $0xf, %edx
jb 0x8c34
movq 0x10(%r12), %rsi
cmpq %rax, %rsi
je 0x8c6a
movq %rbp, %rdi
cmpl $0xf, %ecx
jb 0x8c45
movq 0x10(%rbp), %rdi
movq %r12, %rsi
cmpl $0xf, %edx
jb 0x8c52
movq 0x10(%r12), %rsi
pushq $0x1
popq %rdx
callq 0x17b46
testl %eax, %eax
je 0x8c6f
movl (%rbp), %ecx
cmpl $0xf, %ecx
jb 0x8cd8
movq 0x10(%rbp), %rax
testq %rax, %rax
jne 0x8cdb
movl $0x290, %edi            # imm = 0x290
movq %rbx, %rsi
movq %r14, %rdx
callq 0x86ad
leaq 0x29312(%rip), %rax     # 0x31f98
movq (%rax), %r12
xorl %r13d, %r13d
movq %r15, %rdi
callq 0xa110
movq %rax, %r15
movl $0x2a0, %edi            # imm = 0x2A0
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x165eb
movl $0x290, %edi            # imm = 0x290
movq %r12, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x165eb
movq %r13, 0x28(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %r12
jmp 0x89c7
movq %rbp, %rax
movl %ecx, %edx
orl $0x10, %edx
cmpl $0x1f, %edx
je 0x8cf1
movl (%r12), %edx
orl $0x10, %edx
cmpl $0x1f, %edx
jne 0x8cff
pushq $0xf
popq %rdi
movq %rax, %rsi
callq 0x178ba
movl (%rbp), %ecx
cmpl $0x10, %ecx
je 0x8d17
cmpl $0x1f, %ecx
je 0x8d17
movl (%r12), %ecx
cmpl $0x1f, %ecx
je 0x8d17
cmpl $0x10, %ecx
jne 0x8d22
pushq $0x10
popq %rdi
movq %rax, %rsi
callq 0x178ba
movq %rax, %rdi
callq 0x1736a
movq %rax, %r12
jmp 0x89be
movq 0x8(%r15), %rdi
movq %r14, %rsi
callq 0x9610
testq %rax, %rax
je 0x8b29
movq %r15, %rdi
movq %r12, %rsi
callq 0x9912
movq %r13, %rdi
movq %rax, %rsi
callq 0x952e
movq %rax, %r15
xorl %r14d, %r14d
jmp 0x8c8c