// File: /workspace/github_c_makefile_star2_O1/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 0x22a42(%rip), %rax     # 0x292e8
movq (%rax), %rsi
movq %r12, %rdi
callq 0x173d9
movq %rax, %rbx
testq %rax, %rax
je 0x68ec
cmpw $0x3, 0x18(%rbx)
jne 0x68ec
cmpb $0x53, 0x1a(%rbx)
je 0x6938
movq 0x20(%rbx), %rsi
movq %r15, %rdi
movl $0x1, %edx
callq 0x192a9
testl %eax, %eax
je 0x6938
movq 0x20(%rbx), %rsi
movq %r15, %rdi
callq 0x18d3a
movq %rax, %r15
jmp 0x694e
cmpl $0x51, %ebp
jne 0x69bf
cmpl $0xf, (%r15)
movq %r15, %rax
jb 0x6902
movq 0x10(%r15), %rax
cmpl $0xb, (%rax)
je 0x69bf
cmpl $0x0, 0x8(%r15)
jne 0x69bf
leaq 0x250c3(%rip), %rax     # 0x2b9e0
cmpl $0x3d, (%rax)
je 0x69bf
leaq 0x17f24(%rip), %rdi     # 0x1e851
movq %r15, %rsi
movq %r12, %rdx
jmp 0x69b8
movq 0x10(%rbx), %rsi
leaq 0x28(%rbx), %rdx
leaq 0x17b7f(%rip), %rdi     # 0x1e4c6
xorl %eax, %eax
callq 0x9720
cmpl $0xf, (%r15)
movq %r15, %rax
jb 0x695b
movq 0x10(%r15), %rax
cmpl $0xb, (%rax)
je 0x6988
testb $0x1, 0x1b(%rbx)
je 0x6988
leaq 0x25073(%rip), %rax     # 0x2b9e0
cmpl $0x3d, (%rax)
jne 0x6988
movq 0x10(%rbx), %rsi
leaq 0x28(%rbx), %rdx
leaq 0x17d12(%rip), %rdi     # 0x1e693
xorl %eax, %eax
callq 0x9720
movb 0x1a(%rbx), %al
cmpb $0x51, %al
sete %cl
cmpl $0x43, %ebp
sete %dl
testb %cl, %dl
jne 0x69a9
cmpb $0x51, %al
sete %al
cmpl $0x51, %ebp
setne %cl
orb %al, %cl
jne 0x69bf
movq 0x10(%rbx), %rsi
leaq 0x28(%rbx), %rdx
leaq 0x17e60(%rip), %rdi     # 0x1e818
xorl %eax, %eax
callq 0x9be3
testq %rbx, %rbx
je 0x69cb
cmpw $0x3, 0x18(%rbx)
je 0x69e2
leaq 0x2291e(%rip), %rsi     # 0x292f0
movq %r12, %rdi
movl $0x1, %edx
callq 0x17429
movq %rax, %rbx
movq %r15, 0x20(%rbx)
movb 0x1a(%rbx), %al
testb %al, %al
je 0x69f6
cmpl $0x4a, %ebp
je 0x69fa
cmpb $0x51, %al
je 0x69fa
movb %bpl, 0x1a(%rbx)
cmpb $0x51, 0x1a(%rbx)
je 0x6a37
movl 0x22ea2(%rip), %eax     # 0x298a8
incl %eax
movl %eax, 0x22e9a(%rip)     # 0x298a8
leaq 0x25043(%rip), %rcx     # 0x2ba58
cmpl $0x2, (%rcx)
setge %cl
cmpl $0x200, %eax            # imm = 0x200
sete %al
andb %cl, %al
cmpb $0x1, %al
jne 0x6a37
leaq 0x17e44(%rip), %rdi     # 0x1e874
xorl %eax, %eax
callq 0x9be3
movups (%r14), %xmm0
movups %xmm0, 0x28(%rbx)
testb $0x1, 0x1b(%rbx)
jne 0x6a4d
movq %rbx, %rdi
callq 0x1a687
movq 0x10(%rbx), %rdi
leaq 0x22470(%rip), %rax     # 0x28ec8
movq (%rax), %rsi
callq 0x173d9
testq %rax, %rax
je 0x6ab2
movq %rax, %r14
movzbl 0x1a(%rbx), %eax
cmpb $0x43, %al
movl $0x4a, %ecx
cmovnel %eax, %ecx
cmpb 0x1a(%r14), %cl
jne 0x6a92
movq 0x20(%rbx), %rdi
movq 0x20(%r14), %rsi
movl $0x1, %edx
callq 0x192a9
testl %eax, %eax
jne 0x6aab
movq 0x10(%rbx), %rsi
movq %r14, %rdx
addq $0x28, %rdx
leaq 0x17aa1(%rip), %rdi     # 0x1e545
xorl %eax, %eax
callq 0x9be3
movl 0x1c(%r14), %eax
addl %eax, 0x1c(%rbx)
movq 0x20(%rbx), %rax
cmpl $0xf, (%rax)
jb 0x6abf
movq 0x10(%rax), %rax
cmpl $0xb, (%rax)
jne 0x6af8
leaq 0x24f15(%rip), %r14     # 0x2b9e0
cmpl $0x3d, (%r14)
jne 0x6b02
movq 0x10(%rbx), %rsi
leaq 0x17dbc(%rip), %rdi     # 0x1e898
xorl %eax, %eax
callq 0x9720
callq 0xe1c6
movl %eax, (%r14)
movq 0x20(%rbx), %rdi
xorl %esi, %esi
callq 0xcd39
jmp 0x6b02
movq %rbx, %rdi
xorl %esi, %esi
callq 0xcc77
movq %rbx, %rax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq