// File: /workspace/github_c_makefile_star2_O1/michaelforney[P]cproc/expr.c
// Function: castexpr
static struct expr *
castexpr(struct scope *s)
{
	struct type *t, *ct;
	struct decl *d;
	enum typequal tq;
	struct expr *r, *e, **end, *toeval;

	ct = NULL;
	end = &r;
	while (consume(TLPAREN)) {
		tq = QUALNONE;
		t = typename(s, &tq, &toeval);
		if (!t) {
			e = expr(s);
			expect(TRPAREN, "after expression to match '('");
			e = postfixexpr(s, e);
			goto done;
		}
		expect(TRPAREN, "after type name");
		if (tok.kind == TLBRACE) {
			e = mkexpr(EXPRCOMPOUND, t, NULL);
			e->toeval = toeval;
			e->qual = tq;
			e->lvalue = true;
			d = mkdecl(NULL, DECLOBJECT, t, tq, LINKNONE);
			d->u.obj.storage = s == &filescope ? SDSTATIC : SDAUTO;
			e->u.compound.decl = d;
			e->u.compound.init = parseinit(s, t);
			e = postfixexpr(s, decay(e));
			goto done;
		}
		if (t != &typevoid && !(t->prop & PROPSCALAR))
			error(&tok.loc, "cast type must be scalar");
		e = mkexpr(EXPRCAST, t, NULL);
		e->toeval = toeval;
		*end = e;
		end = &e->base;
		ct = t;
	}
	e = unaryexpr(s);

done:
	if (ct && ct != &typevoid && !(e->type->prop & PROPSCALAR))
		error(&tok.loc, "cast operand must have scalar type");
	*end = e;
	return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
movl $0x42, %edi
callq 0xb099
testb %al, %al
je 0x8049
leaq 0x18(%rsp), %r12
leaq 0x1418a(%rip), %r15     # 0x1c108
leaq 0x8(%r15), %rax
movq %rax, 0x20(%rsp)
xorl %r14d, %r14d
movq %r14, %r13
movl $0x0, 0xc(%rsp)
movq %rbx, %rdi
leaq 0xc(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x3875
testq %rax, %rax
je 0x8067
movq %rax, %r14
movl $0x43, %edi
leaq 0xb7be(%rip), %rsi      # 0x1377d
callq 0xb07a
cmpl $0x44, (%r15)
je 0x808e
cmpq 0x12fcb(%rip), %r14     # 0x1afa0
je 0x7ff1
testb $0x10, 0x4(%r14)
jne 0x7ff1
movq 0x20(%rsp), %rdi
leaq 0xb7a3(%rip), %rsi      # 0x1378d
xorl %eax, %eax
callq 0xd56a
movl $0x40, %edi
callq 0xe13e
movl $0x0, 0x10(%rax)
movq %r14, 0x8(%rax)
movw $0x0, 0x4(%rax)
movl $0x8, (%rax)
leaq 0x18(%rax), %rbp
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq $0x0, 0x28(%rax)
movq 0x10(%rsp), %rcx
movq %rcx, 0x28(%rax)
movq %rax, (%r12)
movl $0x42, %edi
callq 0xb099
movq %rbp, %r12
testb %al, %al
jne 0x7f8a
jmp 0x8051
leaq 0x18(%rsp), %rbp
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x94a0
movq %rax, %rbx
movq %r14, %r13
movq %rbp, %r12
jmp 0x8123
movq %rbx, %rdi
callq 0x73a2
movq %rax, %r14
leaq 0xb6e6(%rip), %rsi      # 0x1375f
movl $0x43, %edi
callq 0xb07a
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x811b
movl $0x40, %edi
callq 0xe13e
movq %rax, %r15
movl $0x0, 0x10(%rax)
movq %r14, 0x8(%rax)
movw $0x0, 0x4(%rax)
movl $0x6, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movq $0x0, 0x28(%rax)
movq 0x10(%rsp), %rax
movq %rax, 0x28(%r15)
movl 0xc(%rsp), %ecx
movl %ecx, 0x10(%r15)
movb $0x1, 0x4(%r15)
xorl %edi, %edi
movl $0x1, %esi
movq %r14, %rdx
xorl %r8d, %r8d
callq 0x3808
xorl %ecx, %ecx
cmpq 0x12ee6(%rip), %rbx     # 0x1afd8
setne %cl
addl %ecx, %ecx
movl %ecx, 0x44(%rax)
movq %rax, 0x30(%r15)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x9b1d
movq %rax, 0x38(%r15)
movq %r15, %rdi
callq 0x9444
movq %rbx, %rdi
movq %rax, %rsi
callq 0x818c
movq %rax, %rbx
testq %r13, %r13
sete %al
cmpq 0x12e70(%rip), %r13     # 0x1afa0
sete %cl
orb %al, %cl
jne 0x815a
movq 0x8(%rbx), %rax
testb $0x10, 0x4(%rax)
jne 0x815a
leaq 0x13fc0(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xb653(%rip), %rsi      # 0x137a6
xorl %eax, %eax
callq 0xd56a
movq %rbx, (%r12)
movq 0x18(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq