// File: /workspace/github_c_makefile_star2_O3/Oric4ever[P]lcc65/6502/build/../src/enode.c
// Function: asgnnode
Tree asgnnode(int op, Tree l, Tree r) {
	Type aty, ty;

	r = pointer(r);
	if ((ty = assign(l->type, r)) == 0) {
		typeerror(ASGN, l, r);
		if (r->type == voidtype)
			r = retype(r, inttype);
		ty = r->type;
	}
	if (l->op != FIELD)
		l = lvalue(l);
	aty = l->type;
	if (isptr(aty))
		aty = unqual(aty)->type;
	if (isconst(aty) || (isstruct(aty) && unqual(aty)->u.sym->u.s.cfields)) {
		if (isaddrop(l->op) && !l->u.sym->computed && !l->u.sym->generated)
			error("assignment to const identifier `%s'\n", l->u.sym->name);
		else
			error("assignment to const location\n");
    }
	r = cast(r, ty);
	if (l->op == FIELD && fieldsize(l->u.field) < 8*l->u.field->type->size) {
		if (isunsigned(l->u.field->type))
			r = bitnode(BAND, r,
				constnode(fieldmask(l->u.field), unsignedtype));
		else {
			int n = 8*l->u.field->type->size - fieldsize(l->u.field);
			/*
			 * The value of assignment is the value of the left
			 * operand (sec. 3.3.16), which for bit fields is the
			 * same as extracting the field. When r is a constant,
			 * the explicit left shift below avoids overflow that
			 * would occur if shnode(LSH, ...) were used. The
			 * subsequent shnode(RSH, ...) will be signed and thus
			 * extend the sign bit correctly.
			 */
			if (r->op == CNST+I)
				r = constnode(r->u.v.i<<n, inttype);
			else
				r = shnode(LSH, r, constnode(n, inttype));
			r = shnode(RSH, r, constnode(n, inttype));
		}
	}
	if (isstruct(ty)) {
		if (r->op == RIGHT && r->kids[0] && r->kids[0]->op == CALL+B
		&& isaddrop(l->op)) {
			/*
			 * When x=f() where f returns a struct and x is a simple
			 * address, release the temporary generated to hold f's
			 * return value and use x in its place. The RIGHT tree
			 * assigned to r below returns x's address, and
			 * rvalue(r) hangs that tree under an INDIR+B,
			 * thus identifying the result as an lvalue.
			 */
			r = r->kids[0];	/* CALL+B node */
			release(r->kids[1]->u.sym);
			r = tree(RIGHT, l->type,
				tree(CALL+B, r->kids[0]->type, r->kids[0], l),
				retype(isarray(l->u.sym->type) ? idnode(l->u.sym) : addrof(idnode(l->u.sym)), l->type));
			return rvalue(r);
		}
		return tree(ASGN+B, ty, l, r);
	}
	return tree(op + (isunsigned(ty) ? I : ttob(ty)), ty, l, r);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rsi, %rbx
movl %edi, %ebp
movq %rdx, %rdi
callq 0xac23
movq %rax, %r15
movq 0x8(%rbx), %rdi
movq %rax, %rsi
callq 0x9ff1
testq %rax, %rax
je 0x8d1c
movq %rax, %r14
jmp 0x8d55
movl $0x30, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x9016
movq 0x8(%r15), %r14
leaq 0x2a2a9(%rip), %rax     # 0x32fe0
cmpq (%rax), %r14
jne 0x8d55
leaq 0x2a255(%rip), %rax     # 0x32f98
movq (%rax), %rsi
movq %r15, %rdi
callq 0x17b29
movq %rax, %r15
movq 0x8(%rax), %r14
cmpl $0x2b0, (%rbx)          # imm = 0x2B0
je 0x8d68
movq %rbx, %rdi
callq 0xb318
movq %rax, %rbx
movq 0x8(%rbx), %rax
movl (%rax), %ecx
cmpl $0xf, %ecx
jb 0x8d7e
movq 0x10(%rax), %rdx
cmpl $0x7, (%rdx)
je 0x8d86
jmp 0x8d8c
movq %rax, %rdx
cmpl $0x7, %ecx
jne 0x8d8c
movq 0x10(%rdx), %rax
movl (%rax), %ecx
movl %ecx, %edx
orl $0x10, %edx
cmpl $0x1f, %edx
jne 0x8dcc
movl $0xfffffef9, %eax       # imm = 0xFFFFFEF9
addl (%rbx), %eax
cmpl $0x20, %eax
ja 0x8dbc
movabsq $0x100010001, %rcx      # imm = 0x100010001
btq %rax, %rcx
jae 0x8dbc
movq 0x28(%rbx), %rax
testb $0xc, 0x1b(%rax)
je 0x8de5
leaq 0x15e52(%rip), %rdi     # 0x1ec15
xorl %eax, %eax
callq 0x974c
jmp 0x8e0b
cmpl $0xf, %ecx
jb 0x8df9
movq 0x10(%rax), %rcx
movl (%rcx), %ecx
addl $-0x9, %ecx
cmpl $0x2, %ecx
jae 0x8e0b
movq 0x10(%rax), %rax
jmp 0x8e01
movq 0x10(%rax), %rsi
leaq 0x15e00(%rip), %rdi     # 0x1ebf0
xorl %eax, %eax
callq 0x974c
jmp 0x8e0b
addl $-0x9, %ecx
cmpl $0x2, %ecx
jae 0x8e0b
movq 0x18(%rax), %rax
testb $0x1, 0x48(%rax)
jne 0x8d96
movq %r15, %rdi
movq %r14, %rsi
callq 0xa2f7
movq %rax, %r15
cmpl $0x2b0, (%rbx)          # imm = 0x2B0
jne 0x8ef5
movq 0x28(%rbx), %rsi
movswl 0x16(%rsi), %edx
movswl 0x14(%rsi), %eax
movl %edx, %ecx
subl %eax, %ecx
movq 0x8(%rsi), %rsi
movl 0x8(%rsi), %r12d
shll $0x3, %r12d
cmpl %r12d, %ecx
jge 0x8ef5
movl (%rsi), %edi
cmpl $0xf, %edi
jb 0x8e57
movq 0x10(%rsi), %rsi
movl (%rsi), %edi
cmpl $0x6, %edi
jne 0x8e86
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shll %cl, %edi
notl %edi
leaq 0x2a16c(%rip), %rax     # 0x32fd8
movq (%rax), %rsi
callq 0x908f
movl $0x180, %edi            # imm = 0x180
movq %r15, %rsi
movq %rax, %rdx
callq 0x83cc
jmp 0x8ef2
subl %edx, %eax
addl %eax, %r12d
cmpl $0x15, (%r15)
jne 0x8eab
movl 0x28(%r15), %edi
movl %r12d, %ecx
shll %cl, %edi
leaq 0x2a0f7(%rip), %rax     # 0x32f98
movq (%rax), %rsi
callq 0x908f
jmp 0x8ecd
leaq 0x2a0e6(%rip), %rax     # 0x32f98
movq (%rax), %rsi
movl %r12d, %edi
callq 0x908f
movl $0x150, %edi            # imm = 0x150
movq %r15, %rsi
movq %rax, %rdx
callq 0x8c43
movq %rax, %r15
leaq 0x2a0c1(%rip), %rax     # 0x32f98
movq (%rax), %rsi
movl %r12d, %edi
callq 0x908f
movl $0x170, %edi            # imm = 0x170
movq %r15, %rsi
movq %rax, %rdx
callq 0x8c43
movq %rax, %r15
movl (%r14), %eax
cmpl $0xf, %eax
jb 0x8f26
movq 0x10(%r14), %rax
movl (%rax), %eax
leal -0x9(%rax), %ecx
cmpl $0x2, %ecx
jb 0x8f2e
movl $0x5, %edi
cmpl $0x6, %eax
je 0x8f1f
movq %r14, %rdi
callq 0x1a1c9
movl %eax, %edi
addl %ebp, %edi
jmp 0x9000
leal -0x9(%rax), %ecx
cmpl $0x1, %ecx
ja 0x8f0b
cmpl $0x2a0, (%r15)          # imm = 0x2A0
jne 0x8ffb
movq 0x10(%r15), %r12
testq %r12, %r12
je 0x8ffb
cmpl $0xd9, (%r12)
jne 0x8ffb
movl $0xfffffef9, %eax       # imm = 0xFFFFFEF9
addl (%rbx), %eax
cmpl $0x20, %eax
ja 0x8ffb
movabsq $0x100010001, %rcx      # imm = 0x100010001
btq %rax, %rcx
jae 0x8ffb
movq 0x18(%r12), %rax
movq 0x28(%rax), %rdi
callq 0x17731
movq 0x8(%rbx), %r14
movq 0x10(%r12), %rdx
movq 0x8(%rdx), %rsi
movl $0xd9, %edi
movq %rbx, %rcx
callq 0x179e5
movq %rax, %r15
movq 0x28(%rbx), %rdi
movq 0x20(%rdi), %rax
movl (%rax), %ebp
cmpl $0xf, %ebp
jb 0x8fba
movq 0x10(%rax), %rax
movl (%rax), %ebp
callq 0x9d8b
cmpl $0xc, %ebp
je 0x8fcc
movq %rax, %rdi
callq 0x9cb4
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x17b29
movl $0x2a0, %edi            # imm = 0x2A0
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x179e5
movq %rax, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xaaaa
movl $0x39, %edi
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x179e5