// File: /workspace/github_c_makefile_star2_O1/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 0xac81
movq %rax, %r15
movq 0x8(%rbx), %rdi
movq %rax, %rsi
callq 0x9fe1
testq %rax, %rax
je 0x8cbb
movq %rax, %r14
jmp 0x8cf4
movl $0x30, %edi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x8fcb
movq 0x8(%r15), %rax
leaq 0x2930a(%rip), %rcx     # 0x31fe0
cmpq (%rcx), %rax
jne 0x8cf0
leaq 0x292b6(%rip), %rax     # 0x31f98
movq (%rax), %rsi
movq %r15, %rdi
callq 0x17ca2
movq %rax, %r15
movq 0x8(%r15), %r14
cmpl $0x2b0, (%rbx)          # imm = 0x2B0
je 0x8d07
movq %rbx, %rdi
callq 0xb339
movq %rax, %rbx
movq 0x8(%rbx), %rax
movl (%rax), %ecx
movq %rax, %rdx
cmpl $0xf, %ecx
jb 0x8d19
movq 0x10(%rax), %rdx
cmpl $0x7, (%rdx)
jne 0x8d2b
cmpl $0xf, %ecx
jb 0x8d27
movq 0x10(%rax), %rax
movq 0x10(%rax), %rax
movl (%rax), %ecx
movl %ecx, %edx
orl $0x10, %edx
cmpl $0x1f, %edx
jne 0x8d6d
movl $0xfffffef9, %eax       # imm = 0xFFFFFEF9
addl (%rbx), %eax
cmpl $0x20, %eax
ja 0x8d5d
movabsq $0x100010001, %rcx      # imm = 0x100010001
btq %rax, %rcx
jae 0x8d5d
movq 0x28(%rbx), %rax
testb $0xc, 0x1b(%rax)
je 0x8da4
leaq 0x15e98(%rip), %rdi     # 0x1ebfc
xorl %eax, %eax
callq 0x9720
jmp 0x8db6
movq %rax, %rdx
cmpl $0xf, %ecx
jb 0x8d79
movq 0x10(%rax), %rdx
cmpl $0x9, (%rdx)
je 0x8d8f
movq %rax, %rdx
cmpl $0xf, %ecx
jb 0x8d8a
movq 0x10(%rax), %rdx
cmpl $0xa, (%rdx)
jne 0x8db6
cmpl $0xf, %ecx
jb 0x8d98
movq 0x10(%rax), %rax
movq 0x18(%rax), %rax
testb $0x1, 0x48(%rax)
jne 0x8d37
jmp 0x8db6
movq 0x10(%rax), %rsi
leaq 0x15e28(%rip), %rdi     # 0x1ebd7
xorl %eax, %eax
callq 0x9720
movq %r15, %rdi
movq %r14, %rsi
callq 0xa341
movq %rax, %r15
cmpl $0x2b0, (%rbx)          # imm = 0x2B0
jne 0x8e9c
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 0x8e9c
cmpl $0xf, (%rsi)
jb 0x8dfe
movq 0x10(%rsi), %rsi
cmpl $0x6, (%rsi)
jne 0x8e2d
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
shll %cl, %edi
notl %edi
leaq 0x291c5(%rip), %rax     # 0x31fd8
movq (%rax), %rsi
callq 0x9044
movl $0x180, %edi            # imm = 0x180
movq %r15, %rsi
movq %rax, %rdx
callq 0x8378
jmp 0x8e99
subl %edx, %eax
addl %eax, %r12d
cmpl $0x15, (%r15)
jne 0x8e52
movl 0x28(%r15), %edi
movl %r12d, %ecx
shll %cl, %edi
leaq 0x29150(%rip), %rax     # 0x31f98
movq (%rax), %rsi
callq 0x9044
jmp 0x8e74
leaq 0x2913f(%rip), %rax     # 0x31f98
movq (%rax), %rsi
movl %r12d, %edi
callq 0x9044
movl $0x150, %edi            # imm = 0x150
movq %r15, %rsi
movq %rax, %rdx
callq 0x8bd9
movq %rax, %r15
leaq 0x2911a(%rip), %rax     # 0x31f98
movq (%rax), %rsi
movl %r12d, %edi
callq 0x9044
movl $0x170, %edi            # imm = 0x170
movq %r15, %rsi
movq %rax, %rdx
callq 0x8bd9
movq %rax, %r15
movl (%r14), %eax
movq %r14, %rcx
cmpl $0xf, %eax
jb 0x8eab
movq 0x10(%r14), %rcx
cmpl $0x9, (%rcx)
je 0x8ec5
movq %r14, %rcx
cmpl $0xf, %eax
jb 0x8ebc
movq 0x10(%r14), %rcx
cmpl $0xa, (%rcx)
jne 0x8f93
cmpl $0x2a0, (%r15)          # imm = 0x2A0
jne 0x8f8c
movq 0x10(%r15), %r12
testq %r12, %r12
je 0x8f8c
cmpl $0xd9, (%r12)
jne 0x8f8c
movl $0xfffffef9, %eax       # imm = 0xFFFFFEF9
addl (%rbx), %eax
cmpl $0x20, %eax
ja 0x8f8c
movabsq $0x100010001, %rcx      # imm = 0x100010001
btq %rax, %rcx
jae 0x8f8c
movq 0x18(%r12), %rax
movq 0x28(%rax), %rdi
callq 0x178a9
movq 0x8(%rbx), %r14
movq 0x10(%r12), %rdx
movq 0x8(%rdx), %rsi
movl $0xd9, %edi
movq %rbx, %rcx
callq 0x17b61
movq %rax, %r15
movq 0x28(%rbx), %rdi
movq 0x20(%rdi), %rax
cmpl $0xf, (%rax)
jb 0x8f49
movq 0x10(%rax), %rax
movl (%rax), %ebp
callq 0x9d77
cmpl $0xc, %ebp
je 0x8f5d
movq %rax, %rdi
callq 0x9c98
movq 0x8(%rbx), %rsi
movq %rax, %rdi
callq 0x17ca2
movl $0x2a0, %edi            # imm = 0x2A0
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x17b61
movq %rax, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xab00
movl $0x39, %edi
jmp 0x8fb5
movq %r14, %rcx
cmpl $0xf, %eax
jb 0x8f9f
movq 0x10(%r14), %rcx
movl $0x5, %edi
cmpl $0x6, (%rcx)
je 0x8fb3
movq %r14, %rdi
callq 0x1a3e6
movl %eax, %edi
addl %ebp, %edi
movq %r14, %rsi
movq %rbx, %rdx
movq %r15, %rcx
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x17b61