// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq $0x0, -0x18(%rbp)
leaq -0x30(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x42, %edi
callq 0xd910
testb $0x1, %al
jne 0x9dcf
jmp 0x9f7b
movl $0x0, -0x24(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x24(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x3960
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x9e26
movq -0x8(%rbp), %rdi
callq 0x8f10
movq %rax, -0x38(%rbp)
movl $0x43, %edi
leaq 0xfde4(%rip), %rsi      # 0x19bef
callq 0xd8d0
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xa080
movq %rax, -0x38(%rbp)
jmp 0x9f88
movl $0x43, %edi
leaq 0xfddb(%rip), %rsi      # 0x19c0d
callq 0xd8d0
leaq 0x1836a(%rip), %rax     # 0x221a8
cmpl $0x44, (%rax)
jne 0x9f00
movq -0x10(%rbp), %rsi
movl $0x6, %edi
xorl %eax, %eax
movl %eax, %edx
callq 0x9040
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movl -0x24(%rbp), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x38(%rbp), %rax
movb $0x1, 0x4(%rax)
movq -0x10(%rbp), %rdx
movl -0x24(%rbp), %ecx
xorl %eax, %eax
movl %eax, %edi
movl $0x1, %esi
xorl %r8d, %r8d
callq 0x38c0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdx
leaq 0x1829e(%rip), %rsi     # 0x22140
movl $0x2, %ecx
xorl %eax, %eax
cmpq %rsi, %rdx
cmovel %eax, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x44(%rax)
movq -0x20(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0xbee0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x38(%rbp), %rdi
callq 0xa660
movq -0x50(%rbp), %rdi
movq %rax, %rsi
callq 0xa080
movq %rax, -0x38(%rbp)
jmp 0x9f88
leaq 0x17b31(%rip), %rax     # 0x21a38
cmpq %rax, -0x10(%rbp)
je 0x9f35
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x9f35
leaq 0x18285(%rip), %rdi     # 0x221a8
addq $0x8, %rdi
leaq 0xfcef(%rip), %rsi      # 0x19c1d
movb $0x0, %al
callq 0x11190
movq -0x10(%rbp), %rsi
movl $0x8, %edi
xorl %eax, %eax
movl %eax, %edx
callq 0x9040
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
jmp 0x9dbc
movq -0x8(%rbp), %rdi
callq 0xa700
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x9fc8
leaq 0x17aa2(%rip), %rax     # 0x21a38
cmpq %rax, -0x18(%rbp)
je 0x9fc8
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
jne 0x9fc8
leaq 0x181f2(%rip), %rdi     # 0x221a8
addq $0x8, %rdi
leaq 0xfc75(%rip), %rsi      # 0x19c36
movb $0x0, %al
callq 0x11190
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)