// File: /workspace/github_c_makefile_star2_O2/michaelforney[P]cproc/decl.c
// Function: declaratortypes
static void
declaratortypes(struct scope *s, struct list *result, char **name, struct scope **funcscope, bool allowabstract)
{
	struct list *ptr, *prev;
	struct type *t;
	struct decl *d, **paramend;
	struct expr *e;
	enum typequal tq;
	bool allowattr;

	while (consume(TMUL)) {
		attr(NULL, 0);
		tq = QUALNONE;
		while (typequal(&tq))
			;
		t = mkpointertype(NULL, tq);
		listinsert(result, &t->link);
	}
	if (name)
		*name = NULL;
	ptr = result->next;
	prev = ptr->prev;
	switch (tok.kind) {
	case TLPAREN:
		next();
		if (allowabstract) {
			switch (tok.kind) {
			case TMUL:
			case TLPAREN:
				break;
			case TIDENT:
				if (!istypename(s, tok.lit))
					break;
				/* fallthrough */
			default:
				allowattr = true;
				goto func;
			}
		}
		declaratortypes(s, result, name, funcscope, allowabstract);
		expect(TRPAREN, "after parenthesized declarator");
		allowattr = false;
		break;
	case TIDENT:
		if (!name)
			error(&tok.loc, "identifier not allowed in abstract declarator");
		*name = tok.lit;
		next();
		allowattr = true;
		break;
	default:
		if (!allowabstract)
			error(&tok.loc, "expected '(' or identifier");
		allowattr = true;
	}
	for (;;) {
		switch (tok.kind) {
		case TLPAREN:  /* function declarator */
			next();
		func:
			t = mktype(TYPEFUNC, 0);
			t->qual = QUALNONE;
			t->u.func.isvararg = false;
			t->u.func.params = NULL;
			t->u.func.nparam = 0;
			paramend = &t->u.func.params;
			s = mkscope(s);
			d = NULL;
			do {
				if (consume(TELLIPSIS)) {
					t->u.func.isvararg = true;
					break;
				}
				if (tok.kind == TRPAREN)
					break;
				d = parameter(s);
				if (d->name)
					scopeputdecl(s, d);
				*paramend = d;
				paramend = &d->next;
				++t->u.func.nparam;
			} while (consume(TCOMMA));
			expect(TRPAREN, "to close function declarator");
			if (funcscope && ptr->prev == prev) {
				/* we may need to re-open the scope later if this is a function definition */
				*funcscope = s;
				s = s->parent;
			} else {
				s = delscope(s);
			}
			if (t->u.func.nparam == 1 && !t->u.func.isvararg && d->type->kind == TYPEVOID && !d->name) {
				t->u.func.params = NULL;
				t->u.func.nparam = 0;
			}
			listinsert(ptr->prev, &t->link);
			allowattr = true;
			break;
		case TLBRACK:  /* array declarator */
			if (allowattr && attr(NULL, 0))
				goto attr;
			next();
			t = mkarraytype(NULL, QUALNONE, 0);
			while (consume(TSTATIC) || typequal(&t->u.array.ptrqual))
				;
			if (tok.kind == TMUL && peek(TRBRACK)) {
				t->prop |= PROPVM;
				t->incomplete = false;
			} else if (!consume(TRBRACK)) {
				e = assignexpr(s);
				if (!(e->type->prop & PROPINT))
					error(&tok.loc, "array length expression must have integer type");
				t->u.array.length = e;
				t->incomplete = false;
				expect(TRBRACK, "after array length");
			}
			listinsert(ptr->prev, &t->link);
			allowattr = true;
			break;
		case T__ATTRIBUTE__:
			if (!allowattr)
				error(&tok.loc, "attribute not allowed after parenthesized declarator");
			/* attribute applies to identifier if ptr->prev == result, otherwise type ptr->prev */
			gnuattr(NULL, 0);
		attr:
			break;
		default:
			return;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movl %r8d, %ebp
movq %rcx, 0x28(%rsp)
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, 0x18(%rsp)
pushq $0x4b
popq %r12
leaq 0x24(%rsp), %r13
movl %r12d, %edi
callq 0xa28d
testb %al, %al
je 0x58b5
xorl %edi, %edi
xorl %esi, %esi
callq 0x334c
andl $0x0, 0x24(%rsp)
movq %r13, %rdi
callq 0x5450
testl %eax, %eax
jne 0x5890
movl 0x24(%rsp), %esi
xorl %edi, %edi
callq 0xc7d5
leaq 0x28(%rax), %rsi
movq %r15, %rdi
callq 0xd212
jmp 0x5876
testq %rbx, %rbx
je 0x58be
andq $0x0, (%rbx)
movq 0x8(%r15), %rax
movq %rax, 0x30(%rsp)
movq (%rax), %rax
movq %rax, 0x60(%rsp)
leaq 0x16832(%rip), %r14     # 0x1c108
movl (%r14), %eax
cmpl $0x4, %eax
je 0x5953
cmpl $0x42, %eax
jne 0x5978
callq 0x9c1e
testb %bpl, %bpl
je 0x5927
movl (%r14), %eax
cmpl $0x4b, %eax
je 0x5927
cmpl $0x42, %eax
je 0x5927
cmpl $0x4, %eax
jne 0x5ab6
movq 0x20(%r14), %rsi
pushq $0x1
popq %rdx
movq 0x18(%rsp), %rdi
callq 0xb758
testq %rax, %rax
je 0x5927
cmpl $0x0, 0x8(%rax)
je 0x5ab6
movzbl %bpl, %r8d
movq 0x18(%rsp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
movq 0x28(%rsp), %rcx
callq 0x5849
leaq 0xc4e3(%rip), %rsi      # 0x11e2a
pushq $0x43
popq %rdi
callq 0xa26e
xorl %ebx, %ebx
jmp 0x5995
testq %rbx, %rbx
jne 0x596a
leaq 0x8(%r14), %rdi
leaq 0xc409(%rip), %rsi      # 0x11d6c
xorl %eax, %eax
callq 0xc536
movq 0x20(%r14), %rax
movq %rax, (%rbx)
callq 0x9c1e
jmp 0x5993
movb $0x1, %bl
testb %bpl, %bpl
jne 0x5995
leaq 0x8(%r14), %rdi
leaq 0xc410(%rip), %rsi      # 0x11d9a
xorl %eax, %eax
callq 0xc536
jmp 0x5995
movb $0x1, %bl
leaq 0x8(%r14), %r15
leaq 0xc474(%rip), %r12      # 0x11e14
pushq $0x27
popq %rbp
pushq $0x41
popq %r13
movl (%r14), %eax
cmpl $0x3f, %eax
je 0x5a1b
cmpl $0x40, %eax
jne 0x5aa8
testb $0x1, %bl
je 0x59ca
xorl %edi, %edi
xorl %esi, %esi
callq 0x334c
testb %al, %al
jne 0x59a7
callq 0x9c1e
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
callq 0xc813
movq %rax, %rbx
leaq 0x48(%rax), %r14
movl %ebp, %edi
callq 0xa28d
testb %al, %al
jne 0x59e1
movq %r14, %rdi
callq 0x5450
testl %eax, %eax
jne 0x59e1
leaq 0x16709(%rip), %r14     # 0x1c108
cmpl $0x4b, (%r14)
jne 0x5a3b
movl %r13d, %edi
callq 0xa18a
testb %al, %al
je 0x5a3b
orb $0x40, 0x4(%rbx)
movb $0x0, 0x3c(%rbx)
jmp 0x5a8d
testb $0x1, %bl
jne 0x5a2d
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xc536
xorl %edi, %edi
xorl %esi, %esi
callq 0x33db
jmp 0x59a7
movl %r13d, %edi
callq 0xa28d
testb %al, %al
jne 0x5a8d
movq 0x18(%rsp), %rdi
callq 0x6fa4
movq %rax, %r14
movq 0x8(%rax), %rax
testb $0x2, 0x4(%rax)
jne 0x5a6f
movq %r15, %rdi
leaq 0xc36a(%rip), %rsi      # 0x11dd2
xorl %eax, %eax
callq 0xc536
movq %r14, 0x40(%rbx)
movb $0x0, 0x3c(%rbx)
movl %r13d, %edi
leaq 0xc380(%rip), %rsi      # 0x11e01
callq 0xa26e
leaq 0x1667b(%rip), %r14     # 0x1c108
movq 0x30(%rsp), %rax
movq (%rax), %rdi
addq $0x28, %rbx
movq %rbx, %rsi
callq 0xd212
movb $0x1, %bl
jmp 0x59a7
cmpl $0x42, %eax
jne 0x5c2d
callq 0x9c1e
pushq $0xe
popq %rdi
xorl %esi, %esi
callq 0xc7b0
movq %rax, %r15
andl $0x0, 0x38(%rax)
movb $0x0, 0x40(%rax)
leaq 0x48(%rax), %rbp
xorps %xmm0, %xmm0
movups %xmm0, 0x48(%rax)
movq 0x18(%rsp), %rdi
callq 0xb6ed
movq %rax, %r14
leaq 0x1661e(%rip), %rax     # 0x1c108
leaq 0x8(%rax), %rbx
pushq $0x1
popq %r13
xorl %r12d, %r12d
movq %rbp, 0x58(%rsp)
pushq $0x62
popq %rdi
callq 0xa28d
testb %al, %al
jne 0x5c3f
leaq 0x165f7(%rip), %rax     # 0x1c108
cmpl $0x43, (%rax)
je 0x5c44
xorl %edi, %edi
xorl %esi, %esi
callq 0x334c
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
leaq 0x3c(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x381f
movq 0x78(%rsp), %rax
movq %rax, 0x50(%rsp)
movups 0x68(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
cmpq $0x0, 0x40(%rsp)
jne 0x5b67
movq %rbx, %rdi
leaq 0xc2e9(%rip), %rsi      # 0x11e49
xorl %eax, %eax
callq 0xc536
testl $0xffffffdf, 0x3c(%rsp) # imm = 0xFFFFFFDF
je 0x5b82
movq %rbx, %rdi
leaq 0xc2ef(%rip), %rsi      # 0x11e6a
xorl %eax, %eax
callq 0xc536
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movaps 0x40(%rsp), %xmm0
movups %xmm0, (%rsp)
leaq 0x68(%rsp), %rdi
movq %r14, %rsi
leaq 0x80(%rsp), %rdx
xorl %ecx, %ecx
movl %r13d, %r8d
callq 0x46fd
movq 0x78(%rsp), %rax
movq %rax, 0x50(%rsp)
movups 0x68(%rsp), %xmm0
movaps %xmm0, 0x40(%rsp)
movq 0x40(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xcba2
movq %rax, 0x40(%rsp)
movq 0x80(%rsp), %rdi
movl 0x48(%rsp), %ecx
movl %r13d, %esi
movq %rax, %rdx
xorl %r8d, %r8d
callq 0x3724
movq %rax, %r12
movl $0x2, 0x44(%rax)
cmpq $0x0, (%rax)
je 0x5c0c
movq %r14, %rdi
movq %r12, %rsi
callq 0xb693
movq %r12, (%rbp)
movq %r12, %rbp
addq $0x38, %rbp
incq 0x50(%r15)
pushq $0x6e
popq %rdi
callq 0xa28d
testb %al, %al
jne 0x5afa
jmp 0x5c44
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x40(%r15)
leaq 0xc16a(%rip), %rsi      # 0x11db5
pushq $0x43
popq %rdi
callq 0xa26e
cmpq $0x0, 0x28(%rsp)
je 0x5c6a
movq 0x30(%rsp), %rax
movq 0x60(%rsp), %rcx
cmpq %rcx, (%rax)
je 0x5c74
movq %r14, %rdi
callq 0xb718
jmp 0x5c80
movq 0x28(%rsp), %rax
movq %r14, (%rax)
movq 0x58(%r14), %rax
movq %rax, 0x18(%rsp)
cmpq $0x1, 0x50(%r15)
leaq 0x16477(%rip), %r14     # 0x1c108
jne 0x5cb6
cmpb $0x0, 0x40(%r15)
jne 0x5cb6
movq 0x10(%r12), %rax
cmpl $0x1, (%rax)
jne 0x5cb6
cmpq $0x0, (%r12)
jne 0x5cb6
xorps %xmm0, %xmm0
movq 0x58(%rsp), %rax
movups %xmm0, (%rax)
movq 0x30(%rsp), %rax
movq (%rax), %rdi
addq $0x28, %r15
movq %r15, %rsi
callq 0xd212
jmp 0x5993