// File: /workspace/github_c_makefile_star2_O3/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, 0x10(%rsp)
movq %rsi, %r12
movq %rdi, 0x20(%rsp)
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rcx, %rsi
callq 0x1d6f5
movq %rax, %rbx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x22b29
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1e04f
movq %rax, 0x18(%rsp)
xorl %edi, %edi
callq 0x1fcd1
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rsi
callq 0x1db37
movq %rax, %r14
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x1, %esi
callq 0x2289d
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %edx, %edx
movq %rax, 0x8(%rsp)
movq %rax, %rcx
callq 0x22d97
movq %rax, %rbp
testq %r12, %r12
je 0x1fb51
movq %r12, %r15
xorl %r13d, %r13d
movq %r14, %r12
movq 0x20(%rsp), %rax
movq (%rax,%r13,8), %r14
leaq 0x4179a(%rip), %rax     # 0x61278
movq 0x90(%rax), %rdi
movq %r14, %rsi
callq 0x20250
movq %rax, %rbx
testq %rax, %rax
jne 0x1fb2f
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %r14, %rsi
movq %rbp, %rdx
callq 0x1e04f
movq %rax, %rbx
movw $0x101, 0x71(%rax)      # imm = 0x101
movb $0x1, %al
movb %al, 0x7a(%rbx)
movb %al, 0x74(%rbx)
movb %al, 0x76(%rbx)
leaq 0x41758(%rip), %rax     # 0x61278
movq 0x90(%rax), %rdi
movq %rbx, %rsi
callq 0x204de
movq %r12, %r14
movq %r12, %rdi
movq %rbx, %rsi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
callq 0x1fc08
incq %r13
cmpq %r13, %r15
jne 0x1facb
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x1fb6b
movq %r14, %rdi
movq 0x8(%rsp), %rdx
movq %rbp, %rcx
callq 0x1fc08
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x1, %esi
callq 0x2289d
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
xorl %esi, %esi
xorl %edx, %edx
movq %rax, %rcx
movq %r14, %r8
callq 0x1da2e
movq %rax, %rbx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl $0x35, %esi
movq %rax, %rdx
xorl %ecx, %ecx
xorl %eax, %eax
callq 0x1d5e2
movq %rbp, 0x20(%rax)
movq 0x18(%rsp), %rdx
movq %rax, 0x30(%rdx)
movb $0x1, 0x72(%rdx)
movq %rbp, 0x28(%rdx)
movw $0x102, 0x70(%rdx)      # imm = 0x102
leaq 0x416af(%rip), %rsi     # 0x61278
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(%r14), %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 0x2ceff