// File: /workspace/github_c_makefile_star2_O1/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 %rdi, %rbx
leaq 0x50(%rsp), %r14
leaq 0x8(%rsp), %r13
movq %r13, (%r13)
movq %r13, 0x8(%r13)
testq %rcx, %rcx
je 0x4ae1
movq $0x0, (%rcx)
movzbl %r8b, %r8d
movq %rsi, %rdi
movq %r13, %rsi
callq 0x5cd2
movq 0x8(%rsp), %rbp
movq (%r14), %r12
cmpq %r13, %rbp
je 0x4c64
movq %rbx, (%rsp)
movl 0x8(%r14), %ebx
leaq 0x175f8(%rip), %r15     # 0x1c108
addq $0x8, %r15
movq %r12, %r14
movq %rbp, %r12
movl %ebx, %eax
movq (%rbp), %rbp
movl 0x10(%r12), %ebx
movq %r14, -0x8(%r12)
movl %eax, 0x10(%r12)
movl 0x4(%r14), %eax
andl $0x40, %eax
orl %eax, -0x24(%r12)
movl -0x28(%r12), %eax
cmpl $0xd, %eax
je 0x4b85
cmpl $0xe, %eax
jne 0x4c4a
cmpl $0xe, (%r14)
jne 0x4b65
movq %r15, %rdi
leaq 0xe0cd(%rip), %rsi      # 0x12c2b
xorl %eax, %eax
callq 0xd56a
cmpl $0xd, (%r14)
jne 0x4c4a
movq %r15, %rdi
leaq 0xe0e5(%rip), %rsi      # 0x12c5e
xorl %eax, %eax
callq 0xd56a
jmp 0x4c4a
cmpb $0x1, 0x3c(%r14)
jne 0x4b9d
movq %r15, %rdi
leaq 0xe0f8(%rip), %rsi      # 0x12c8e
xorl %eax, %eax
callq 0xd56a
cmpl $0xe, (%r14)
jne 0x4bb4
movq %r15, %rdi
leaq 0xe103(%rip), %rsi      # 0x12cb0
xorl %eax, %eax
callq 0xd56a
movl 0x8(%r14), %eax
movl %eax, -0x20(%r12)
movq $0x0, -0x18(%r12)
movq 0x18(%r12), %rdi
testq %rdi, %rdi
je 0x4c4a
callq 0x61cc
movq %rax, %r13
cmpl $0x1, (%rax)
jne 0x4c31
cmpq $0x0, 0x10(%r14)
je 0x4c31
movq 0x8(%r13), %rax
cmpb $0x1, 0x40(%rax)
jne 0x4c06
cmpq $0x0, 0x30(%r13)
jns 0x4c06
movq %r15, %rdi
leaq 0xe0d1(%rip), %rsi      # 0x12cd0
xorl %eax, %eax
callq 0xd56a
movq 0x10(%r14), %rax
mulq 0x30(%r13)
jno 0x4c21
movq %r15, %rdi
leaq 0xe0d8(%rip), %rsi      # 0x12cf2
xorl %eax, %eax
callq 0xd56a
movq 0x30(%r13), %rax
imulq 0x10(%r14), %rax
movq %rax, -0x18(%r12)
jmp 0x4c45
orb $0x40, -0x24(%r12)
movq %r13, 0x18(%r12)
movq $0x0, 0x28(%r12)
leaq 0x8(%rsp), %r13
addq $-0x28, %r12
cmpq %r13, %rbp
jne 0x4b14
leaq 0x50(%rsp), %r14
movl %ebx, 0x8(%r14)
movq (%rsp), %rbx
movq %r12, (%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)
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq