// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/parse/specialize.c
// Function: specializedcl
Node *
specializedcl(Node *gnode, Type *param, Type *to, Node **name)
{
	Tysubst *tsmap;
	Node *g, *d, *n;
	Stab *st;

	assert(gnode->type == Ndecl);
	assert(gnode->decl.isgeneric);

	n = genericname(gnode, param, to);
	*name = n;
	if (n->name.ns)
		st = getns(n->name.ns);
	else
		st = file.globls;
	if (!st)
		fatal(n, "Can't find symbol table for %s.%s", n->name.ns, n->name.name);
	d = getdcl(st, n);
	if (d)
		return d;
	if (gnode->decl.trait) {
		g = bestimpl(gnode, to);
		if (!g)
			fatal(gnode, "type %s does not implement %s:%s",
				tystr(param), namestr(gnode->decl.name), tystr(to));
	} else {
		g = gnode;
	}
	if (debugopt['S'])
		printf("specializing [%d]%s => %s\n", g->loc.line,
			namestr(g->decl.name), namestr(n));
	/* namespaced names need to be looked up in context. */
	pushstab(st);

	/* specialize */
	tsmap = mksubst();
	fillsubst(tsmap, to, g->decl.type);

	d = mkdecl(g->loc, n, tysubst(g->decl.type, tsmap));
	d->decl.isconst = g->decl.isconst;
	d->decl.isextern = g->decl.isextern;
	d->decl.isglobl = g->decl.isglobl;
	d->decl.init = specializenode(g->decl.init, tsmap);
	putdcl(st, d);

	fixup(d);

	lappend(&file.stmts, &file.nstmts, d);
	substfree(tsmap);
	popstab();
	return d;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpl $0xb, 0x8(%rax)
jne 0x31ba7
jmp 0x31bc6
leaq 0x21626(%rip), %rdi     # 0x531d4
leaq 0x21634(%rip), %rsi     # 0x531e9
movl $0x220, %edx            # imm = 0x220
leaq 0x21635(%rip), %rcx     # 0x531f6
callq 0x6160
movq -0x10(%rbp), %rax
cmpb $0x0, 0x73(%rax)
je 0x31bd2
jmp 0x31bf1
leaq 0x21652(%rip), %rdi     # 0x5322b
leaq 0x21609(%rip), %rsi     # 0x531e9
movl $0x221, %edx            # imm = 0x221
leaq 0x2160a(%rip), %rcx     # 0x531f6
callq 0x6160
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x319c0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x31c2f
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x330b0
movq %rax, -0x50(%rbp)
jmp 0x31c41
leaq 0x4b162(%rip), %rax     # 0x7cd98
movq 0x90(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x31c6a
movq -0x48(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x18(%rax), %rdx
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rcx
leaq 0x215de(%rip), %rsi     # 0x53241
movb $0x0, %al
callq 0x1dfe0
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x334b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x31c8f
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x31e42
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x31d00
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x31e50
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x31cfe
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rdi
callq 0x38a10
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x30600
movq %rax, -0x58(%rbp)
movq -0x20(%rbp), %rdi
callq 0x38a10
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq %rax, %r8
leaq 0x2156c(%rip), %rsi     # 0x53263
movb $0x0, %al
callq 0x1dfe0
jmp 0x31d08
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
leaq 0x4aff1(%rip), %rax     # 0x7cd00
cmpb $0x0, 0x53(%rax)
je 0x31d50
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x74(%rbp)
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x30600
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rdi
callq 0x30600
movl -0x74(%rbp), %esi
movq -0x70(%rbp), %rdx
movq %rax, %rcx
leaq 0x2153b(%rip), %rdi     # 0x53284
movb $0x0, %al
callq 0x6120
movq -0x50(%rbp), %rdi
callq 0x32db0
callq 0x30990
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rdx
callq 0x31fc0
movq -0x38(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x32130
movq -0x88(%rbp), %rsi
movq %rax, %rdx
movq -0x80(%rbp), %rax
movq (%rax), %rdi
callq 0x2ff20
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movb 0x72(%rax), %cl
movq -0x40(%rbp), %rax
movb %cl, 0x72(%rax)
movq -0x38(%rbp), %rax
movb 0x74(%rax), %cl
movq -0x40(%rbp), %rax
movb %cl, 0x74(%rax)
movq -0x38(%rbp), %rax
movb 0x71(%rax), %cl
movq -0x40(%rbp), %rax
movb %cl, 0x71(%rax)
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x311d0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x50(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x33970
movq -0x40(%rbp), %rdi
callq 0x32180
movq -0x40(%rbp), %rdx
leaq 0x4af7c(%rip), %rsi     # 0x7cd98
movq %rsi, %rdi
addq $0x40, %rdi
addq $0x48, %rsi
callq 0x48290
movq -0x30(%rbp), %rdi
callq 0x30a10
callq 0x32e20
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nop