// File: /workspace/github_c_makefile_star2_O3/Oric4ever[P]lcc65/6502/build/../src/decl.c
// Function: dclglobal
static Symbol dclglobal(int sclass, char *id, Type ty, Coordinate *pos) {
	Symbol p, q;

	if (sclass == 0 || sclass == REGISTER)
		sclass = AUTO;
	if ((p = lookup(id, identifiers)) && p->scope == GLOBAL) {
		if (p->sclass != TYPEDEF && eqtype(ty, p->type, 1))
			ty = composite(ty, p->type);
		else
			error("redeclaration of `%s' previously declared at %w\n",
				p->name, &p->src);
		if (!isfunc(ty) && p->defined && t == '=')
			error("redefinition of `%s' previously defined at %w\n",
				p->name, &p->src);
		if (p->sclass == STATIC && sclass == AUTO
		||  p->sclass != STATIC && sclass == STATIC)
			warning("inconsistent linkage for `%s' previously declared at %w\n",
				p->name, &p->src);
	} else if (sclass == STATIC && !isfunc(ty) && ty->size == 0 && t != '=')
		warning("undefined size for static `%t %s'\n", ty, id);
	if (p == 0 || p->scope != GLOBAL)
		p = install(id, &globals, 1);
	p->type = ty;
	if (p->sclass == 0 || sclass != EXTERN && p->sclass != STATIC)
		p->sclass = sclass;
	if (p->sclass != STATIC) {
		nglobals++;
		if (Aflag >= 2 && nglobals == 512)
			warning("more than 511 external identifiers\n");
	}
	p->src = *pos;
	if (!p->defined)
		defsymbol(p);
	if (q = lookup(p->name, externals)) {
		if ((p->sclass == AUTO ? EXTERN : p->sclass) != q->sclass
		|| !eqtype(p->type, q->type, 1))
			warning("declaration of `%s' does not match previous declaration at %w\n",
				p->name, &q->src);
		p->ref += q->ref;
	}
	if (!isfunc(p->type))
		initglobal(p, 0);
	else if (t == '=') {
		error("illegal initialization for `%s'\n", p->name);
		t = gettok();
		initializer(p->type, 0);
	}
	return p;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %r12
cmpl $0x4e, %edi
movl $0x43, %eax
movl %edi, %ebp
cmovel %eax, %ebp
testl %edi, %edi
cmovel %eax, %ebp
leaq 0x23a31(%rip), %rax     # 0x2a2e8
movq (%rax), %rsi
movq %r12, %rdi
callq 0x1728e
movq %rax, %rbx
testq %rax, %rax
je 0x68fd
cmpw $0x3, 0x18(%rbx)
jne 0x68fd
cmpb $0x53, 0x1a(%rbx)
je 0x694a
movq 0x20(%rbx), %rsi
movq %r15, %rdi
movl $0x1, %edx
callq 0x190d9
testl %eax, %eax
je 0x694a
movq 0x20(%rbx), %rsi
movq %r15, %rdi
callq 0x18bc1
movq %rax, %r15
jmp 0x6960
cmpl $0x51, %ebp
jne 0x693c
movl (%r15), %eax
cmpl $0xf, %eax
jb 0x6910
movq 0x10(%r15), %rax
movl (%rax), %eax
cmpl $0xb, %eax
je 0x693c
cmpl $0x0, 0x8(%r15)
jne 0x693c
leaq 0x260bd(%rip), %rax     # 0x2c9e0
cmpl $0x3d, (%rax)
je 0x693c
leaq 0x17f22(%rip), %rdi     # 0x1e851
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x9bfd
testq %rbx, %rbx
jne 0x69d5
jmp 0x69dc
movq 0x10(%rbx), %rsi
leaq 0x28(%rbx), %rdx
leaq 0x17b6d(%rip), %rdi     # 0x1e4c6
xorl %eax, %eax
callq 0x974c
movl (%r15), %eax
cmpl $0xf, %eax
jb 0x696e
movq 0x10(%r15), %rax
movl (%rax), %eax
cmpl $0xb, %eax
je 0x699b
testb $0x1, 0x1b(%rbx)
je 0x699b
leaq 0x26060(%rip), %rax     # 0x2c9e0
cmpl $0x3d, (%rax)
jne 0x699b
movq 0x10(%rbx), %rsi
leaq 0x28(%rbx), %rdx
leaq 0x17cff(%rip), %rdi     # 0x1e693
xorl %eax, %eax
callq 0x974c
movb 0x1a(%rbx), %al
cmpb $0x51, %al
sete %cl
cmpl $0x43, %ebp
sete %dl
testb %cl, %dl
jne 0x69bc
cmpb $0x51, %al
sete %al
cmpl $0x51, %ebp
setne %cl
orb %al, %cl
jne 0x69d5
movq 0x10(%rbx), %rsi
movq %rbx, %rdx
addq $0x28, %rdx
leaq 0x17e4a(%rip), %rdi     # 0x1e818
xorl %eax, %eax
callq 0x9bfd
cmpw $0x3, 0x18(%rbx)
je 0x69f3
leaq 0x2390d(%rip), %rsi     # 0x2a2f0
movq %r12, %rdi
movl $0x1, %edx
callq 0x172de
movq %rax, %rbx
movq %r15, 0x20(%rbx)
movb 0x1a(%rbx), %al
testb %al, %al
je 0x6a07
cmpl $0x4a, %ebp
je 0x6a0d
cmpb $0x51, %al
je 0x6a0d
movb %bpl, 0x1a(%rbx)
movl %ebp, %eax
cmpb $0x51, %al
je 0x6a48
movl 0x23e91(%rip), %eax     # 0x2a8a8
incl %eax
movl %eax, 0x23e89(%rip)     # 0x2a8a8
leaq 0x26032(%rip), %rcx     # 0x2ca58
cmpl $0x2, (%rcx)
setge %cl
cmpl $0x200, %eax            # imm = 0x200
sete %al
andb %cl, %al
cmpb $0x1, %al
jne 0x6a48
leaq 0x17e33(%rip), %rdi     # 0x1e874
xorl %eax, %eax
callq 0x9bfd
movups (%r14), %xmm0
movups %xmm0, 0x28(%rbx)
testb $0x1, 0x1b(%rbx)
jne 0x6a5e
movq %rbx, %rdi
callq 0x1a458
movq 0x10(%rbx), %rdi
leaq 0x2345f(%rip), %rax     # 0x29ec8
movq (%rax), %rsi
callq 0x1728e
testq %rax, %rax
je 0x6ac3
movq %rax, %r14
movzbl 0x1a(%rbx), %eax
cmpb $0x43, %al
movl $0x4a, %ecx
cmovnel %eax, %ecx
cmpb 0x1a(%r14), %cl
jne 0x6aa3
movq 0x20(%rbx), %rdi
movq 0x20(%r14), %rsi
movl $0x1, %edx
callq 0x190d9
testl %eax, %eax
jne 0x6abc
movq 0x10(%rbx), %rsi
movq %r14, %rdx
addq $0x28, %rdx
leaq 0x17a90(%rip), %rdi     # 0x1e545
xorl %eax, %eax
callq 0x9bfd
movl 0x1c(%r14), %eax
addl %eax, 0x1c(%rbx)
movq 0x20(%rbx), %rcx
movl (%rcx), %eax
cmpl $0xf, %eax
jb 0x6ad4
movq 0x10(%rcx), %rax
movl (%rax), %eax
cmpl $0xb, %eax
jne 0x6b0d
leaq 0x25f00(%rip), %r14     # 0x2c9e0
cmpl $0x3d, (%r14)
jne 0x6b17
movq 0x10(%rbx), %rsi
leaq 0x17da7(%rip), %rdi     # 0x1e898
xorl %eax, %eax
callq 0x974c
callq 0xe195
movl %eax, (%r14)
movq 0x20(%rbx), %rdi
xorl %esi, %esi
callq 0xcd17
jmp 0x6b17
movq %rbx, %rdi
xorl %esi, %esi
callq 0xcc4e
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq