// File: /workspace/github_c_makefile_star2_O2/michaelforney[P]cproc/expr.c
// Function: assignexpr
struct expr *
assignexpr(struct scope *s)
{
	struct expr *e, *l, *r, *tmp, *bit;
	enum tokenkind op;

	l = condexpr(s);
	if (l->kind == EXPRBINARY || l->kind == EXPRCOMMA || l->kind == EXPRCAST)
		return l;
	switch (tok.kind) {
	case TASSIGN:     op = TNONE; break;
	case TMULASSIGN:  op = TMUL;  break;
	case TDIVASSIGN:  op = TDIV;  break;
	case TMODASSIGN:  op = TMOD;  break;
	case TADDASSIGN:  op = TADD;  break;
	case TSUBASSIGN:  op = TSUB;  break;
	case TSHLASSIGN:  op = TSHL;  break;
	case TSHRASSIGN:  op = TSHR;  break;
	case TBANDASSIGN: op = TBAND; break;
	case TXORASSIGN:  op = TXOR;  break;
	case TBORASSIGN:  op = TBOR;  break;
	default:
		return l;
	}
	if (!l->lvalue)
		error(&tok.loc, "left side of assignment expression is not an lvalue");
	next();
	r = assignexpr(s);
	if (!op)
		return mkassignexpr(l, r);
	/* rewrite `E1 OP= E2` as `T = &E1, *T = *T OP E2`, where T is a temporary slot */
	if (l->kind == EXPRBITFIELD) {
		bit = l;
		l = l->base;
	} else {
		bit = NULL;
	}
	tmp = mkexpr(EXPRTEMP, mkpointertype(l->type, l->qual), NULL);
	tmp->lvalue = true;
	tmp->u.temp = NULL;
	e = mkassignexpr(tmp, mkunaryexpr(TBAND, l));
	l = mkunaryexpr(TMUL, tmp);
	if (bit) {
		bit->base = l;
		l = bit;
	}
	r = mkbinaryexpr(&tok.loc, op, l, r);
	e->next = mkassignexpr(l, r);
	return mkexpr(EXPRCOMMA, l->type, e);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r15
callq 0x6b87
movq %rax, %rbx
movl (%rax), %eax
cmpl $0xc, %eax
ja 0x6fdd
movl $0x1300, %ecx           # imm = 0x1300
btl %eax, %ecx
jae 0x6fdd
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x15124(%rip), %r14     # 0x1c108
movl (%r14), %eax
addl $-0x63, %eax
cmpl $0xa, %eax
ja 0x6fcb
leaq 0xb286(%rip), %rcx      # 0x1227c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %ebp, %ebp
movb $0x1, %r12b
jmp 0x7030
pushq $0x4c
jmp 0x702c
pushq $0x5a
jmp 0x702c
pushq $0x50
jmp 0x702c
pushq $0x51
jmp 0x702c
pushq $0x53
jmp 0x702c
pushq $0x4b
jmp 0x702c
pushq $0x4d
jmp 0x702c
pushq $0x52
jmp 0x702c
pushq $0x5b
jmp 0x702c
pushq $0x4a
popq %rbp
xorl %r12d, %r12d
cmpb $0x0, 0x4(%rbx)
jne 0x7048
leaq 0x8(%r14), %rdi
leaq 0xb6ba(%rip), %rsi      # 0x126fb
xorl %eax, %eax
callq 0xc536
callq 0x9c1e
movq %r15, %rdi
callq 0x6fa4
movq %rax, %r15
testb %r12b, %r12b
je 0x7076
movq %rbx, %rdi
movq %r15, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x7121
cmpl $0x4, (%rbx)
jne 0x7081
movq 0x18(%rbx), %r12
jmp 0x7086
movq %rbx, %r12
xorl %ebx, %ebx
movq 0x8(%r12), %rdi
movl 0x10(%r12), %esi
callq 0xc7d5
pushq $0xe
popq %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x6efa
movq %rax, %r13
movb $0x1, 0x4(%rax)
andq $0x0, 0x30(%rax)
pushq $0x4a
popq %rdi
movq %r12, %rsi
callq 0x715a
movq %r13, %rdi
movq %rax, %rsi
callq 0x7121
movq %rax, %r12
pushq $0x4b
popq %rdi
movq %r13, %rsi
callq 0x715a
testq %rbx, %rbx
je 0x70dd
movq %rax, 0x18(%rbx)
jmp 0x70e0
movq %rax, %rbx
addq $0x8, %r14
movq %r14, %rdi
movl %ebp, %esi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x728c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7121
movq %rax, 0x20(%r12)
movq 0x8(%rbx), %rsi
pushq $0xc
popq %rdi
movq %r12, %rdx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6efa