// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x43
popq %rax
movl %edi, %ebp
cmovel %eax, %ebp
testl %edi, %edi
cmovel %eax, %ebp
leaq 0x23137(%rip), %rax     # 0x292e8
movq (%rax), %rsi
movq %r12, %rdi
callq 0x15ec0
movq %rax, %rbx
testq %rax, %rax
je 0x61f5
cmpw $0x3, 0x18(%rbx)
jne 0x61f5
cmpb $0x53, 0x1a(%rbx)
je 0x6242
movq 0x20(%rbx), %rsi
pushq $0x1
popq %rdx
movq %r15, %rdi
callq 0x17b46
testl %eax, %eax
je 0x6242
movq 0x20(%rbx), %rsi
movq %r15, %rdi
callq 0x1763b
movq %rax, %r15
jmp 0x6258
cmpl $0x51, %ebp
jne 0x6234
movl (%r15), %eax
cmpl $0xf, %eax
jb 0x6208
movq 0x10(%r15), %rax
movl (%rax), %eax
cmpl $0xb, %eax
je 0x6234
cmpl $0x0, 0x8(%r15)
jne 0x6234
leaq 0x257c5(%rip), %rax     # 0x2b9e0
cmpl $0x3d, (%rax)
je 0x6234
leaq 0x1662a(%rip), %rdi     # 0x1c851
movq %r15, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x9239
testq %rbx, %rbx
jne 0x62cd
jmp 0x62d4
movq 0x10(%rbx), %rsi
leaq 0x28(%rbx), %rdx
leaq 0x16275(%rip), %rdi     # 0x1c4c6
xorl %eax, %eax
callq 0x8dd4
movl (%r15), %eax
cmpl $0xf, %eax
jb 0x6266
movq 0x10(%r15), %rax
movl (%rax), %eax
cmpl $0xb, %eax
je 0x6293
testb $0x1, 0x1b(%rbx)
je 0x6293
leaq 0x25768(%rip), %rax     # 0x2b9e0
cmpl $0x3d, (%rax)
jne 0x6293
movq 0x10(%rbx), %rsi
leaq 0x28(%rbx), %rdx
leaq 0x16407(%rip), %rdi     # 0x1c693
xorl %eax, %eax
callq 0x8dd4
movb 0x1a(%rbx), %al
cmpb $0x51, %al
sete %cl
cmpl $0x43, %ebp
sete %dl
testb %cl, %dl
jne 0x62b4
cmpb $0x51, %al
sete %al
cmpl $0x51, %ebp
setne %cl
orb %al, %cl
jne 0x62cd
movq 0x10(%rbx), %rsi
movq %rbx, %rdx
addq $0x28, %rdx
leaq 0x16552(%rip), %rdi     # 0x1c818
xorl %eax, %eax
callq 0x9239
cmpw $0x3, 0x18(%rbx)
je 0x62e9
leaq 0x23015(%rip), %rsi     # 0x292f0
pushq $0x1
popq %rdx
movq %r12, %rdi
callq 0x15f13
movq %rax, %rbx
movq %r15, 0x20(%rbx)
movb 0x1a(%rbx), %al
testb %al, %al
je 0x62fd
cmpl $0x4a, %ebp
je 0x6303
cmpb $0x51, %al
je 0x6303
movb %bpl, 0x1a(%rbx)
movl %ebp, %eax
cmpb $0x51, %al
je 0x633e
movl 0x2359b(%rip), %eax     # 0x298a8
incl %eax
movl %eax, 0x23593(%rip)     # 0x298a8
leaq 0x2573c(%rip), %rcx     # 0x2ba58
cmpl $0x2, (%rcx)
setge %cl
cmpl $0x200, %eax            # imm = 0x200
sete %al
andb %cl, %al
cmpb $0x1, %al
jne 0x633e
leaq 0x1653d(%rip), %rdi     # 0x1c874
xorl %eax, %eax
callq 0x9239
movups (%r14), %xmm0
movups %xmm0, 0x28(%rbx)
testb $0x1, 0x1b(%rbx)
jne 0x6354
movq %rbx, %rdi
callq 0x18f6d
movq 0x10(%rbx), %rdi
leaq 0x22b69(%rip), %rax     # 0x28ec8
movq (%rax), %rsi
callq 0x15ec0
testq %rax, %rax
je 0x63b5
movq %rax, %r14
movzbl 0x1a(%rbx), %eax
cmpb $0x43, %al
pushq $0x4a
popq %rcx
cmovnel %eax, %ecx
cmpb 0x1a(%r14), %cl
jne 0x6395
movq 0x20(%rbx), %rdi
movq 0x20(%r14), %rsi
pushq $0x1
popq %rdx
callq 0x17b46
testl %eax, %eax
jne 0x63ae
movq 0x10(%rbx), %rsi
movq %r14, %rdx
addq $0x28, %rdx
leaq 0x1619e(%rip), %rdi     # 0x1c545
xorl %eax, %eax
callq 0x9239
movl 0x1c(%r14), %eax
addl %eax, 0x1c(%rbx)
movq 0x20(%rbx), %rcx
movl (%rcx), %eax
cmpl $0xf, %eax
jb 0x63c6
movq 0x10(%rcx), %rax
movl (%rax), %eax
cmpl $0xb, %eax
jne 0x63ff
leaq 0x2560e(%rip), %r14     # 0x2b9e0
cmpl $0x3d, (%r14)
jne 0x6409
movq 0x10(%rbx), %rsi
leaq 0x164b5(%rip), %rdi     # 0x1c898
xorl %eax, %eax
callq 0x8dd4
callq 0xd3c9
movl %eax, (%r14)
movq 0x20(%rbx), %rdi
xorl %esi, %esi
callq 0xc00d
jmp 0x6409
movq %rbx, %rdi
xorl %esi, %esi
callq 0xbf49
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq