// File: /workspace/github_c_makefile_star2_O1/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, 0xc(%rsp)
movq %r8, (%rsp)
movq %rcx, 0x10(%rsp)
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, %r13
movq 0x58(%rsp), %r15
movl 0x50(%rsp), %ebx
cmpl $0x2, %esi
leaq 0xe48a(%rip), %rax      # 0x13877
leaq 0x10802(%rip), %r12     # 0x15bf6
cmoveq %rax, %r12
testq %r15, %r15
je 0x543e
cmpl $0x0, 0xc(%r15)
jne 0x5423
leaq 0x16cfd(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xdab1(%rip), %rsi      # 0x12ec7
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd56a
testb $0x8, %bl
jne 0x5460
cmpl $0x2, %ebp
setne %al
testb $0x4, %bl
sete %cl
testb %cl, %al
jne 0x546e
movl 0xc(%r15), %eax
jmp 0x547c
movq 0x58(%r13), %rdi
testq %rdi, %rdi
je 0x552e
movq %r14, %rsi
movl $0x1, %edx
callq 0xc6f9
movq %rax, %r15
jmp 0x5531
xorl %eax, %eax
cmpq 0x15b6f(%rip), %r13     # 0x1afd8
sete %al
jmp 0x547c
xorl %eax, %eax
cmpq 0x15b61(%rip), %r13     # 0x1afd8
sete %al
addl %eax, %eax
movq (%rsp), %rbx
cmpl %eax, 0xc(%r15)
je 0x54a5
leaq 0x16c7b(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xda52(%rip), %rsi      # 0x12eea
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd56a
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xd8c4
testb %al, %al
je 0x54bf
movl 0xc(%rsp), %eax
cmpl %eax, 0x18(%r15)
je 0x54de
leaq 0x16c42(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xda43(%rip), %rsi      # 0x12f14
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd56a
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x5519
movq 0x28(%r15), %rdi
testq %rdi, %rdi
je 0x54fa
callq 0x3140
testl %eax, %eax
je 0x5519
leaq 0x16c07(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xda32(%rip), %rsi      # 0x12f3e
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd56a
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0xd9c3
movq %rax, 0x10(%r15)
jmp 0x56f6
xorl %r15d, %r15d
testb $0x8, %bl
jne 0x5551
cmpl $0x2, %ebp
setne %al
testb $0x4, %bl
sete %cl
testb %cl, %al
jne 0x555f
testq %r15, %r15
je 0x556f
movl 0xc(%r15), %ebx
jmp 0x5574
xorl %ebx, %ebx
cmpq 0x15a7e(%rip), %r13     # 0x1afd8
sete %bl
jmp 0x5574
xorl %ebx, %ebx
cmpq 0x15a70(%rip), %r13     # 0x1afd8
sete %bl
addl %ebx, %ebx
jmp 0x5574
movl $0x2, %ebx
testl %ebx, %ebx
je 0x5691
movq 0x58(%r13), %rax
testq %rax, %rax
je 0x5691
cmpq 0x15a48(%rip), %rax     # 0x1afd8
je 0x55a6
leaq 0x16b07(%rip), %rdi     # 0x1c0a0
movq %r14, %rsi
xorl %edx, %edx
callq 0xc6f9
movq %rax, %r15
testq %r15, %r15
je 0x5691
cmpl $0x0, 0xc(%r15)
je 0x5691
cmpl %ebp, 0x8(%r15)
je 0x55dc
leaq 0x16b41(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xcc8e(%rip), %rsi      # 0x12260
movq %r14, %rdx
xorl %eax, %eax
callq 0xd56a
cmpl %ebx, 0xc(%r15)
je 0x5601
leaq 0x16b1f(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xd8f6(%rip), %rsi      # 0x12eea
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd56a
movq 0x10(%r15), %rsi
movq (%rsp), %rdi
callq 0xd8c4
testb %al, %al
je 0x561c
movl 0xc(%rsp), %eax
cmpl %eax, 0x18(%r15)
je 0x563b
leaq 0x16ae5(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xd8e6(%rip), %rsi      # 0x12f14
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd56a
movq 0x28(%r15), %rdi
cmpq $0x0, 0x10(%rsp)
je 0x567b
testq %rdi, %rdi
je 0x565a
movq 0x10(%rsp), %rsi
callq 0x3140
testl %eax, %eax
je 0x5680
leaq 0x16aa7(%rip), %rdi     # 0x1c108
addq $0x8, %rdi
leaq 0xd8d2(%rip), %rsi      # 0x12f3e
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0xd56a
jmp 0x5680
movq %rdi, 0x10(%rsp)
movq 0x10(%r15), %rsi
movq (%rsp), %rdi
callq 0xd9c3
movq %rax, (%rsp)
movl $0x48, %edi
callq 0xe13e
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movq $0x0, 0x40(%rax)
movq %r14, (%rax)
movl %ebp, 0x8(%rax)
movl %ebx, 0xc(%rax)
movq (%rsp), %rax
movq %rax, 0x10(%r15)
movl 0xc(%rsp), %ecx
movl %ecx, 0x18(%r15)
cmpl $0x1, %ebp
jne 0x56e2
testq %rax, %rax
je 0x56e2
movl 0x8(%rax), %eax
movl %eax, 0x40(%r15)
movq 0x10(%rsp), %rax
movq %rax, 0x28(%r15)
movq %r13, %rdi
movq %r15, %rsi
callq 0xc628
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq