// File: /workspace/github_c_makefile_star2_O3/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 0x92c0
movq 0x10(%r12), %rax
movl (%rax), %eax
movq 0x8(%r14), %r13
cmpl $0x6, %eax
ja 0x9309
movl (%r13), %eax
cmpl $0xf, %eax
jb 0x92d8
movq 0x10(%r13), %rax
movl (%rax), %eax
cmpl $0x6, %eax
ja 0x9309
movq %r12, %rdi
movq %r13, %rsi
callq 0x90de
movq %rax, %r12
movq %rbx, %rdi
movq %rax, %rsi
callq 0xa2f7
movq %rax, %rbx
movq %r14, %rdi
movq %r12, %rsi
callq 0xa2f7
movq %rax, %r14
jmp 0x932d
movq %r12, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0x190d9
testl %eax, %eax
je 0x93ae
cmpl $0xf, (%r12)
jb 0x9336
movq 0x10(%r12), %r12
testq %r12, %r12
je 0x95e2
movl (%r15), %ebp
leal -0x11(%rbp), %eax
cmpl $0x1, %eax
ja 0x9369
leaq 0x29c40(%rip), %rax     # 0x32f88
movq (%rax), %rsi
movq %r15, %rdi
callq 0xa2f7
xorpd %xmm0, %xmm0
ucomisd 0x28(%rax), %xmm0
cmovneq %rbx, %r14
cmovpq %rbx, %r14
movq %r14, %rdi
jmp 0x9398
movq %r15, (%rsp)
movl %ebp, %r15d
andl $-0x10, %r15d
cmpl $0x10, %r15d
jne 0x93ea
leaq 0x29c57(%rip), %rax     # 0x32fd8
movq (%rax), %rsi
movq (%rsp), %rdi
callq 0xa2f7
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 0x17b29
movl (%r12), %eax
movl %eax, %edx
cmpl $0xf, %eax
jb 0x93c0
movq 0x10(%r12), %rcx
movl (%rcx), %edx
movl (%r13), %ecx
cmpl $0x7, %edx
jne 0x94e5
cmpl $0xf, %ecx
jb 0x94c1
movq 0x10(%r13), %rax
movl (%rax), %edx
cmpl $0x2, %edx
ja 0x94c8
jmp 0x94ea
leaq 0x29bef(%rip), %rax     # 0x32fe0
cmpq (%rax), %r12
je 0x94b5
cmpl $0x0, 0x8(%r12)
jle 0x94b5
movl $0x4e, %edi
movq %r12, %rsi
callq 0x176c4
movq %rax, %r13
movq %rax, %rdi
movq %rbx, %rsi
callq 0x9f07
movq %rax, %rdi
callq 0x17b52
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 0x15773(%rip), %xmm0    # 0x1ebe0
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 0x949a
cmpl $0x15, (%r14)
jne 0x949a
cmpl $0x0, 0x28(%r14)
je 0x96a9
movq %r13, %rdi
movq %r14, %rsi
callq 0x9f07
movq %rax, %rdi
callq 0x17b52
movq %rax, %r14
jmp 0x95ff
xorl %r13d, %r13d
movq (%rsp), %r15
jmp 0x95ff
movl %ecx, %edx
cmpl $0x3, %ecx
jb 0x9544
cmpl $0x6, %edx
ja 0x94e5
movq %r12, %rdi
movq %r14, %rsi
callq 0x9ff1
testq %rax, %rax
jne 0x9321
movl (%r13), %ecx
cmpl $0xf, %ecx
jb 0x94f0
movq 0x10(%r13), %rax
movl (%rax), %ecx
movl (%r12), %eax
cmpl $0x7, %ecx
jne 0x9544
cmpl $0xf, %eax
jb 0x950c
movq 0x10(%r12), %rcx
movl (%rcx), %ecx
cmpl $0x2, %ecx
ja 0x9517
jmp 0x9549
movl %eax, %ecx
cmpl $0x3, %eax
jb 0x95e2
cmpl $0x6, %ecx
ja 0x9544
movq %r13, %rdi
movq %rbx, %rsi
callq 0x9ff1
testq %rax, %rax
je 0x9540
cmpl $0xf, (%r13)
jb 0x9643
movq 0x10(%r13), %r12
jmp 0x932d
movl (%r12), %eax
cmpl $0xf, %eax
jb 0x9550
movq 0x10(%r12), %rax
movl (%rax), %eax
cmpl $0x7, %eax
jne 0x95e2
movl (%r13), %eax
cmpl $0xf, %eax
jb 0x9568
movq 0x10(%r13), %rax
movl (%rax), %eax
cmpl $0x7, %eax
jne 0x95e2
movq 0x10(%r12), %rbp
movl (%rbp), %ecx
movq %rbp, %rdx
cmpl $0xf, %ecx
jb 0x9581
movq 0x10(%rbp), %rdx
movq 0x10(%r13), %r12
leaq 0x29a54(%rip), %rax     # 0x32fe0
movq (%rax), %rax
cmpq %rax, %rdx
je 0x95dd
movl (%r12), %edx
movq %r12, %rsi
cmpl $0xf, %edx
jb 0x95a5
movq 0x10(%r12), %rsi
cmpq %rax, %rsi
je 0x95dd
movq %rbp, %rdi
cmpl $0xf, %ecx
jb 0x95b6
movq 0x10(%rbp), %rdi
movq %r12, %rsi
cmpl $0xf, %edx
jb 0x95c3
movq 0x10(%r12), %rsi
movl $0x1, %edx
callq 0x190d9
testl %eax, %eax
je 0x95e2
movl (%rbp), %ecx
cmpl $0xf, %ecx
jb 0x964b
movq 0x10(%rbp), %rax
testq %rax, %rax
jne 0x964e
movl $0x290, %edi            # imm = 0x290
movq %rbx, %rsi
movq %r14, %rdx
callq 0x9016
leaq 0x2999f(%rip), %rax     # 0x32f98
movq (%rax), %r12
xorl %r13d, %r13d
movq %r15, %rdi
callq 0xab01
movq %rax, %r15
movl $0x2a0, %edi            # imm = 0x2A0
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %rcx
callq 0x179e5
movl $0x290, %edi            # imm = 0x290
movq %r12, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x179e5
movq %r13, 0x28(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, %r12
jmp 0x9336
movq %rbp, %rax
movl %ecx, %edx
orl $0x10, %edx
cmpl $0x1f, %edx
je 0x9664
movl (%r12), %edx
orl $0x10, %edx
cmpl $0x1f, %edx
jne 0x9674
movl $0xf, %edi
movq %rax, %rsi
callq 0x18e51
movl (%rbp), %ecx
cmpl $0x10, %ecx
je 0x968c
cmpl $0x1f, %ecx
je 0x968c
movl (%r12), %ecx
cmpl $0x1f, %ecx
je 0x968c
cmpl $0x10, %ecx
jne 0x9699
movl $0x10, %edi
movq %rax, %rsi
callq 0x18e51
movq %rax, %rdi
callq 0x188cc
movq %rax, %r12
jmp 0x932d
movq 0x8(%r15), %rdi
movq %r14, %rsi
callq 0x9ff1
testq %rax, %rax
je 0x949a
movq %r15, %rdi
movq %r12, %rsi
callq 0xa2f7
movq %r13, %rdi
movq %rax, %rsi
callq 0x9f07
movq %rax, %r15
xorl %r14d, %r14d
jmp 0x95ff