// File: /workspace/github_c_makefile_star2_O3/michaelforney[P]cproc/decl.c
// Function: declcommon
static struct decl *
declcommon(struct scope *s, enum declkind kind, char *name, char *asmname, struct type *t, enum typequal tq, enum storageclass sc, struct decl *prior)
{
	struct decl *d;
	enum linkage linkage;
	const char *kindstr = kind == DECLFUNC ? "function" : "object";

	if (prior) {
		if (prior->linkage == LINKNONE)
			error(&tok.loc, "%s '%s' with no linkage redeclared", kindstr, name);
		linkage = getlinkage(kind, sc, prior, s == &filescope);
		if (prior->linkage != linkage)
			error(&tok.loc, "%s '%s' redeclared with different linkage", kindstr, name);
		if (!typecompatible(t, prior->type) || tq != prior->qual)
			error(&tok.loc, "%s '%s' redeclared with incompatible type", kindstr, name);
		if (asmname && (!prior->asmname || strcmp(prior->asmname, asmname) != 0))
			error(&tok.loc, "%s '%s' redeclared with different assembler name", kindstr, name);
		prior->type = typecomposite(t, prior->type);
		return prior;
	}
	if (s->parent)
		prior = scopegetdecl(s->parent, name, true);
	linkage = getlinkage(kind, sc, prior, s == &filescope);
	if (linkage != LINKNONE && s->parent) {
		/* XXX: should maintain map of identifiers with linkage to their declaration, and use that */
		if (s->parent != &filescope)
			prior = scopegetdecl(&filescope, name, false);
		if (prior && prior->linkage != LINKNONE) {
			if (prior->kind != kind)
				error(&tok.loc, "'%s' redeclared with different kind", name);
			if (prior->linkage != linkage)
				error(&tok.loc, "%s '%s' redeclared with different linkage", kindstr, name);
			if (!typecompatible(t, prior->type) || tq != prior->qual)
				error(&tok.loc, "%s '%s' redeclared with incompatible type", kindstr, name);
			if (!asmname)
				asmname = prior->asmname;
			else if (!prior->asmname || strcmp(prior->asmname, asmname) != 0)
				error(&tok.loc, "%s '%s' redeclared with different assembler name", kindstr, name);
			t = typecomposite(t, prior->type);
		}
	}
	d = mkdecl(name, kind, t, tq, linkage);
	d->asmname = asmname;
	scopeputdecl(s, d);
	return d;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, 0x14(%rsp)
movq %r8, %rbx
movq %rcx, 0x8(%rsp)
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %rdx
movq 0x58(%rsp), %r15
movl 0x50(%rsp), %r13d
cmpl $0x2, %esi
leaq 0xe694(%rip), %rax      # 0x138d7
leaq 0x10a4c(%rip), %r12     # 0x15c96
cmoveq %rax, %r12
testq %r15, %r15
je 0x52a7
cmpl $0x0, 0xc(%r15)
jne 0x528a
leaq 0x16ea7(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xdcbb(%rip), %rsi      # 0x12f27
movl %ebp, %r13d
movq %rdx, %rbp
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd55c
movq %rbp, %rdx
movl %r13d, %ebp
movl 0x50(%rsp), %r13d
testb $0x8, %r13b
jne 0x52cf
cmpl $0x2, %ebp
setne %al
testb $0x4, %r13b
sete %cl
testb %cl, %al
jne 0x52dd
movl 0xc(%r15), %eax
jmp 0x52eb
movq 0x58(%rdx), %rdi
testq %rdi, %rdi
je 0x539c
movq %r14, %rsi
movq %rdx, %r15
movl $0x1, %edx
callq 0xc70d
movq %r15, %rdx
movq %rax, %r15
jmp 0x539f
xorl %eax, %eax
cmpq 0x15d00(%rip), %rdx     # 0x1afd8
sete %al
jmp 0x52eb
xorl %eax, %eax
cmpq 0x15cf2(%rip), %rdx     # 0x1afd8
sete %al
addl %eax, %eax
movq 0x8(%rsp), %r13
cmpl %eax, 0xc(%r15)
je 0x5315
leaq 0x16e0b(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xdc42(%rip), %rsi      # 0x12f4a
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd55c
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xd8b8
testb %al, %al
je 0x532f
movl 0x14(%rsp), %eax
cmpl %eax, 0x18(%r15)
je 0x534e
leaq 0x16dd2(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xdc33(%rip), %rsi      # 0x12f74
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd55c
testq %r13, %r13
je 0x5387
movq 0x28(%r15), %rdi
testq %rdi, %rdi
je 0x5368
movq %r13, %rsi
callq 0x3140
testl %eax, %eax
je 0x5387
leaq 0x16d99(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xdc24(%rip), %rsi      # 0x12f9e
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd55c
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xd9c5
movq %rax, 0x10(%r15)
jmp 0x5571
xorl %r15d, %r15d
testb $0x8, %r13b
jne 0x53c1
cmpl $0x2, %ebp
setne %al
testb $0x4, %r13b
sete %cl
testb %cl, %al
jne 0x53d3
testq %r15, %r15
je 0x53e7
movl 0xc(%r15), %eax
jmp 0x53cd
xorl %eax, %eax
cmpq 0x15c0e(%rip), %rdx     # 0x1afd8
sete %al
testl %eax, %eax
jne 0x53ec
jmp 0x53dc
cmpq 0x15bfe(%rip), %rdx     # 0x1afd8
je 0x53e7
movq %rdx, %r13
xorl %r12d, %r12d
jmp 0x551a
movl $0x2, %eax
movl %eax, 0x4(%rsp)
movq 0x58(%rdx), %rax
testq %rax, %rax
je 0x54fc
cmpq 0x15bd4(%rip), %rax     # 0x1afd8
je 0x5420
leaq 0x16c93(%rip), %rdi     # 0x1c0a0
movq %r14, %rsi
movq %rdx, %r15
xorl %edx, %edx
callq 0xc70d
movq %r15, %rdx
movq %rax, %r15
testq %r15, %r15
je 0x54fc
movq %rdx, %r13
movl 0xc(%r15), %eax
testl %eax, %eax
je 0x5515
cmpl %ebp, 0x8(%r15)
je 0x545e
leaq 0x16cc3(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xce70(%rip), %rsi      # 0x122c0
movq %r14, %rdx
xorl %eax, %eax
callq 0xd55c
movl 0xc(%r15), %eax
cmpl 0x4(%rsp), %eax
je 0x5483
leaq 0x16c9d(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xdad4(%rip), %rsi      # 0x12f4a
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd55c
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xd8b8
testb %al, %al
je 0x549d
movl 0x14(%rsp), %eax
cmpl %eax, 0x18(%r15)
je 0x54bc
leaq 0x16c64(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xdac5(%rip), %rsi      # 0x12f74
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd55c
movq 0x28(%r15), %rdi
cmpq $0x0, 0x8(%rsp)
je 0x5501
testq %rdi, %rdi
je 0x54db
movq 0x8(%rsp), %rsi
callq 0x3140
testl %eax, %eax
je 0x5506
leaq 0x16c26(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xdab1(%rip), %rsi      # 0x12f9e
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd55c
jmp 0x5506
movq %rdx, %r13
jmp 0x5515
movq %rdi, 0x8(%rsp)
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xd9c5
movq %rax, %rbx
movl 0x4(%rsp), %r12d
movl $0x48, %edi
callq 0xe142
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x38(%rax)
movq %r14, (%rax)
movl %ebp, 0x8(%rax)
movl %r12d, 0xc(%rax)
movq %rbx, 0x10(%rax)
movl 0x14(%rsp), %eax
movl %eax, 0x18(%r15)
cmpl $0x1, %ebp
jne 0x555d
testq %rbx, %rbx
je 0x555d
movl 0x8(%rbx), %eax
movl %eax, 0x40(%r15)
movq 0x8(%rsp), %rax
movq %rax, 0x28(%r15)
movq %r13, %rdi
movq %r15, %rsi
callq 0xc644
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq