// File: /workspace/github_c_makefile_star2_O3/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 0xb00a
testb %al, %al
je 0x7efb
leaq 0x18(%rsp), %r12
leaq 0x142d0(%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 0x3846
testq %rax, %rax
je 0x7f19
movq %rax, %r14
movl $0x43, %edi
leaq 0xb964(%rip), %rsi      # 0x137dd
callq 0xafeb
cmpl $0x44, (%r15)
je 0x7f3d
cmpq 0x13111(%rip), %r14     # 0x1afa0
je 0x7eab
testb $0x10, 0x4(%r14)
jne 0x7eab
movq 0x20(%rsp), %rdi
leaq 0xb949(%rip), %rsi      # 0x137ed
xorl %eax, %eax
callq 0xd55c
movl $0x40, %edi
callq 0xe142
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 0x10(%rsp), %rcx
movq %rcx, 0x28(%rax)
movq %rax, (%r12)
movl $0x42, %edi
callq 0xb00a
movq %rbp, %r12
testb %al, %al
jne 0x7e44
jmp 0x7f03
leaq 0x18(%rsp), %rbp
xorl %r14d, %r14d
movq %rbx, %rdi
callq 0x931d
movq %rax, %rbx
movq %r14, %r13
movq %rbp, %r12
jmp 0x7fc1
movq %rbx, %rdi
callq 0x7252
movq %rax, %r14
leaq 0xb894(%rip), %rsi      # 0x137bf
movl $0x43, %edi
callq 0xafeb
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x7fb9
movl $0x40, %edi
callq 0xe142
movq %rax, %r15
movq %r14, 0x8(%rax)
movb $0x0, 0x5(%rax)
movl $0x6, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%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 0x37e4
xorl %ecx, %ecx
cmpq 0x13048(%rip), %rbx     # 0x1afd8
setne %cl
addl %ecx, %ecx
movl %ecx, 0x44(%rax)
movq %rax, 0x30(%r15)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x997d
movq %rax, 0x38(%r15)
movq %r15, %rdi
callq 0x92c1
movq %rbx, %rdi
movq %rax, %rsi
callq 0x802a
movq %rax, %rbx
testq %r13, %r13
sete %al
cmpq 0x12fd2(%rip), %r13     # 0x1afa0
sete %cl
orb %al, %cl
jne 0x7ff8
movq 0x8(%rbx), %rax
testb $0x10, 0x4(%rax)
jne 0x7ff8
leaq 0x14122(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xb815(%rip), %rsi      # 0x13806
xorl %eax, %eax
callq 0xd55c
movq %rbx, (%r12)
movq 0x18(%rsp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq