// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/parse/specialize.c
// Function: genautocall
void
genautocall(Node **call, size_t ncall, Node *local, char *fn)
{
	Node *name, *decl, *func, *block, *init;
	Type *tyvoid, *tyvoidfn;
	size_t i;

	name = mkname(Zloc, fn);
	decl = mkdecl(Zloc, name, mktyvar(Zloc));
	block = mkblock(Zloc, mkstab(0));
	tyvoid = mktype(Zloc, Tyvoid);
	tyvoidfn = mktyfunc(Zloc, NULL, 0, tyvoid);

	for (i = 0; i < ncall; i++) {
		init = initdecl(call[i], tyvoidfn);
		callinit(block, init, tyvoid, tyvoidfn);
	}
	if (local)
		callinit(block, local, tyvoid, tyvoidfn);

	func = mkfunc(Zloc, NULL, 0, mktype(Zloc, Tyvoid), block);
	init = mkexpr(Zloc, Olit, func, NULL);
	init->expr.type = tyvoidfn;

	decl->decl.init = init;
	decl->decl.isconst = 1;
	decl->decl.isglobl = 1;
	decl->decl.type = tyvoidfn;
	decl->decl.vis = Vishidden;

	func->lit.fnval->func.scope->super = file.globls;
	block->block.scope->super = func->lit.fnval->func.scope->super;

	lappend(&file.stmts, &file.nstmts, decl);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, 0x8(%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, 0x18(%rsp)
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rcx, %rsi
callq 0x1b7fd
movq %rax, %rbx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2003f
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1bd5f
movq %rax, 0x10(%rsp)
xorl %r13d, %r13d
xorl %edi, %edi
callq 0x1d73b
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rsi
callq 0x1ba2f
movq %rax, %rbp
pushq $0x1
popq %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1fdc2
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %edx, %edx
movq %rax, %r12
movq %rax, %rcx
callq 0x2028c
movq %rax, %r15
cmpq %r13, 0x20(%rsp)
je 0x1d5c9
movq %rbp, %rbx
movq 0x18(%rsp), %rax
movq (%rax,%r13,8), %rbp
leaq 0x40d1f(%rip), %rax     # 0x5e278
movq 0x90(%rax), %rdi
movq %rbp, %rsi
callq 0x1dc67
movq %rax, %r14
testq %rax, %rax
jne 0x1d5ad
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbp, %rsi
movq %r15, %rdx
callq 0x1bd5f
movq %rax, %r14
movw $0x101, 0x71(%rax)      # imm = 0x101
movb $0x1, %al
movb %al, 0x7a(%r14)
movb %al, 0x74(%r14)
movb %al, 0x76(%r14)
leaq 0x40cda(%rip), %rax     # 0x5e278
movq 0x90(%rax), %rdi
movq %r14, %rsi
callq 0x1deda
movq %rbx, %rbp
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
callq 0x1d67a
incq %r13
jmp 0x1d53b
movq 0x8(%rsp), %rsi
testq %rsi, %rsi
je 0x1d5e1
movq %rbp, %rdi
movq %r12, %rdx
movq %r15, %rcx
callq 0x1d67a
pushq $0x1
popq %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1fdc2
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %edx, %edx
movq %rax, %rcx
movq %rbp, %r8
callq 0x1b987
movq %rax, %rbx
pushq $0x35
popq %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1b718
movq %r15, 0x20(%rax)
movq 0x10(%rsp), %rdx
movq %rax, 0x30(%rdx)
movb $0x1, 0x72(%rdx)
movq %r15, 0x28(%rdx)
movw $0x102, 0x70(%rdx)      # imm = 0x102
leaq 0x40c3d(%rip), %rsi     # 0x5e278
movq 0x90(%rsi), %rax
movq 0x30(%rbx), %rcx
movq 0x20(%rcx), %rcx
movq %rax, (%rcx)
movq 0x30(%rbx), %rax
movq 0x20(%rax), %rax
movq (%rax), %rax
movq 0x18(%rbp), %rcx
movq %rax, (%rcx)
leaq 0x40(%rsi), %rdi
addq $0x48, %rsi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x29b2d