// File: /workspace/github_c_makefile_star2_O3/michaelforney[P]cproc/decl.c
// Function: declarator
static struct qualtype
declarator(struct scope *s, struct qualtype base, char **name, struct scope **funcscope, bool allowabstract)
{
	struct type *t;
	enum typequal tq;
	struct expr *e;
	struct list result = {&result, &result}, *l, *prev;

	if (funcscope)
		*funcscope = NULL;
	declaratortypes(s, &result, name, funcscope, allowabstract);
	for (l = result.prev; l != &result; l = prev) {
		prev = l->prev;
		t = listelement(l, struct type, link);
		tq = t->qual;
		t->base = base.type;
		t->qual = base.qual;
		t->prop |= base.type->prop & PROPVM;
		switch (t->kind) {
		case TYPEFUNC:
			if (base.type->kind == TYPEFUNC)
				error(&tok.loc, "function declarator specifies function return type");
			if (base.type->kind == TYPEARRAY)
				error(&tok.loc, "function declarator specifies array return type");
			break;
		case TYPEARRAY:
			if (base.type->incomplete)
				error(&tok.loc, "array element has incomplete type");
			if (base.type->kind == TYPEFUNC)
				error(&tok.loc, "array element has function type");
			t->align = base.type->align;
			t->size = 0;
			if (t->u.array.length) {
				e = eval(t->u.array.length);
				if (e->kind == EXPRCONST && base.type->size) {
					if (e->type->u.basic.issigned && e->u.constant.u >> 63)
						error(&tok.loc, "array length must be non-negative");
					if (e->u.constant.u > ULLONG_MAX / base.type->size)
						error(&tok.loc, "array length is too large");
					t->size = base.type->size * e->u.constant.u;
				} else {
					t->prop |= PROPVM;
					t->u.array.length = e;
					t->u.array.size = NULL;
				}
			}
			break;
		}
		base.type = t;
		base.qual = tq;
	}

	return base;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rax
movq %rdi, %rbx
leaq 0x50(%rsp), %r14
movq %rsp, %r15
movq %r15, (%r15)
movq %r15, 0x8(%r15)
testq %rcx, %rcx
je 0x4939
movq $0x0, (%rcx)
movzbl %r8b, %r8d
movq %rsp, %rsi
movq %rax, %rdi
jmp 0x4945
movzbl %r8b, %r8d
movq %rsp, %rsi
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x5b4a
movq (%rsp), %r12
movq (%r14), %rbp
cmpq %r15, %r12
je 0x4abd
movq %rbx, 0x10(%rsp)
movl 0x8(%r14), %ebx
leaq 0x1779e(%rip), %r14     # 0x1c108
addq $0x8, %r14
movq %rbp, %r13
movq %r12, %rbp
movl %ebx, %eax
movq (%r12), %r12
movl 0x10(%rbp), %ebx
movq %r13, -0x8(%rbp)
movl %eax, 0x10(%rbp)
movl 0x4(%r13), %eax
andl $0x40, %eax
orl %eax, -0x24(%rbp)
movl -0x28(%rbp), %eax
cmpl $0xd, %eax
je 0x49dc
cmpl $0xe, %eax
jne 0x4aa2
movl (%r13), %eax
cmpl $0xe, %eax
jne 0x49bd
movq %r14, %rdi
leaq 0xe2d9(%rip), %rsi      # 0x12c8b
xorl %eax, %eax
callq 0xd55c
movl (%r13), %eax
cmpl $0xd, %eax
jne 0x4aa2
movq %r14, %rdi
leaq 0xe2ee(%rip), %rsi      # 0x12cbe
xorl %eax, %eax
callq 0xd55c
jmp 0x4aa2
cmpb $0x1, 0x3c(%r13)
jne 0x49f4
movq %r14, %rdi
leaq 0xe301(%rip), %rsi      # 0x12cee
xorl %eax, %eax
callq 0xd55c
cmpl $0xe, (%r13)
jne 0x4a0c
movq %r14, %rdi
leaq 0xe30b(%rip), %rsi      # 0x12d10
xorl %eax, %eax
callq 0xd55c
movl 0x8(%r13), %eax
movl %eax, -0x20(%rbp)
movq $0x0, -0x18(%rbp)
movq 0x18(%rbp), %rdi
testq %rdi, %rdi
je 0x4aa2
callq 0x603c
movq %rax, %r15
cmpl $0x1, (%rax)
jne 0x4a8f
movq 0x10(%r13), %rcx
testq %rcx, %rcx
je 0x4a8f
movq 0x8(%r15), %rax
cmpb $0x1, 0x40(%rax)
jne 0x4a60
cmpq $0x0, 0x30(%r15)
jns 0x4a60
movq %r14, %rdi
leaq 0xe2db(%rip), %rsi      # 0x12d30
xorl %eax, %eax
callq 0xd55c
movq 0x10(%r13), %rcx
movq 0x30(%r15), %rsi
movq %rcx, %rax
mulq %rsi
jno 0x4a85
movq %r14, %rdi
leaq 0xe2dc(%rip), %rsi      # 0x12d52
xorl %eax, %eax
callq 0xd55c
movq 0x10(%r13), %rcx
movq 0x30(%r15), %rsi
imulq %rcx, %rsi
movq %rsi, -0x18(%rbp)
jmp 0x4a9f
orb $0x40, -0x24(%rbp)
movq %r15, 0x18(%rbp)
movq $0x0, 0x28(%rbp)
movq %rsp, %r15
addq $-0x28, %rbp
cmpq %r15, %r12
jne 0x496e
leaq 0x50(%rsp), %r14
movl %ebx, 0x8(%r14)
movq 0x10(%rsp), %rbx
movq %rbp, (%r14)
movq 0x10(%r14), %rax
movq %rax, 0x10(%rbx)
movq (%r14), %rax
movq %rax, (%rbx)
movl 0x8(%r14), %eax
movl %eax, 0x8(%rbx)
movl 0xc(%r14), %eax
movl %eax, 0xc(%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq