// File: /workspace/github_c_makefile_star2_O2/oridb[P]mc/parse/type.c
// Function: iterableinit
void
iterableinit(Stab *st, Trait *tr)
{
	Node *func, *arg, **args;
	Type *ty;
	size_t nargs;

	/* trait iter @a -> @b = ... */
	tr->param = mktyparam(Zloc, "a");
	tr->aux = malloc(sizeof(Type*));
	tr->aux[0] = mktyparam(Zloc, "b");
	tr->naux = 1;

	/* __iternext__ : (it : @a#, outval : @b# -> bool) */
	args = NULL;
	nargs = 0;
	arg = mkdecl(Zloc, mkname(Zloc, "iter"), mktyptr(Zloc, mktyparam(Zloc, "a")));
	lappend(&args, &nargs, arg);
	arg = mkdecl(Zloc, mkname(Zloc, "ret"), mktyptr(Zloc, mktyparam(Zloc, "b")));
	lappend(&args, &nargs, arg);
	ty = mktyfunc(Zloc, args, nargs, mktype(Zloc, Tybool));

	func = mkdecl(Zloc, mkname(Zloc, "__iternext__"), ty);
	func->decl.trait = tr;
	func->decl.impls = mkht(tyhash, tyeq);
	func->decl.isgeneric = 1;
	func->decl.isconst = 1;
	func->decl.isglobl = 1;
	func->decl.isextern = 1;

	lappend(&tr->proto, &tr->nproto, func);
	putdcl(st, func);

	/* __iterfin__ : (it : @a#, outval : @b# -> void) */
	args = NULL;
	nargs = 0;
	arg = mkdecl(Zloc, mkname(Zloc, "iter"), mktyptr(Zloc, mktyparam(Zloc, "a")));
	lappend(&args, &nargs, arg);
	arg = mkdecl(Zloc, mkname(Zloc, "val"), mktyptr(Zloc, mktyparam(Zloc, "b")));
	lappend(&args, &nargs, arg);
	ty = mktyfunc(Zloc, args, nargs, mktype(Zloc, Tyvoid));

	func = mkdecl(Zloc, mkname(Zloc, "__iterfin__"), ty);
	func->decl.trait = tr;
	func->decl.impls = mkht(tyhash, tyeq);
	func->decl.isgeneric = 1;
	func->decl.isconst = 1;
	func->decl.isglobl = 1;
	func->decl.isextern = 1;

	lappend(&tr->proto, &tr->nproto, func);
	putdcl(st, func);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, (%rsp)
leaq 0xfb9a(%rip), %rbp      # 0x315e2
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbp, %rsi
callq 0x20047
movq %rax, 0x18(%r14)
pushq $0x8
popq %rdi
callq 0x4280
movq %rax, 0x20(%r14)
leaq 0x9e19(%rip), %r13      # 0x2b885
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %r13, %rsi
callq 0x20047
movq 0x20(%r14), %rcx
movq %rax, (%rcx)
movq $0x1, 0x28(%r14)
leaq 0x10(%rsp), %r15
andq $0x0, (%r15)
leaq 0x8(%rsp), %r12
andq $0x0, (%r12)
leaq 0x12372(%rip), %rsi     # 0x33e14
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1b7fd
movq %rax, %rbx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbp, %rsi
callq 0x20047
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rsi
callq 0x2020c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1bd5f
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
leaq 0x1110b(%rip), %rsi     # 0x32bf9
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1b7fd
movq %rax, %rbx
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %r13, %rsi
callq 0x20047
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rsi
callq 0x2020c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
movq %rax, %rdx
callq 0x1bd5f
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
movq (%r15), %rbx
movq (%r12), %r13
pushq $0x2
popq %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1fdc2
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbx, %rsi
movq %r13, %rdx
movq %rax, %rcx
callq 0x2028c
movq %rax, %rbx
leaq 0x122b5(%rip), %rsi     # 0x33e19
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1b7fd
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rsi
movq %rbx, %rdx
callq 0x1bd5f
movq %rax, %rbp
movq %r14, 0x40(%rax)
leaq -0xb57(%rip), %rdi      # 0x21035
leaq -0x59e(%rip), %rsi      # 0x215f5
callq 0x2a188
movq %rax, 0x48(%rbp)
leaq 0x30(%r14), %r13
leaq 0x38(%r14), %rbx
movl $0x1010101, %eax        # imm = 0x1010101
movl %eax, 0x71(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x29b2d
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0x1deda
andq $0x0, (%r15)
andq $0x0, (%r12)
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x12239(%rip), %rsi     # 0x33e14
callq 0x1b7fd
movq %rax, %rbp
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0xf9f3(%rip), %rsi      # 0x315e2
callq 0x20047
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rsi
callq 0x2020c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbp, %rsi
movq %rax, %rdx
callq 0x1bd5f
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
leaq 0x12200(%rip), %rsi     # 0x33e26
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1b7fd
movq %rax, %rbp
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x9c46(%rip), %rsi      # 0x2b885
callq 0x20047
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rsi
callq 0x2020c
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rbp, %rsi
movq %rax, %rdx
callq 0x1bd5f
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x29b2d
movq (%r15), %r15
movq (%r12), %r12
pushq $0x1
popq %rsi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1fdc2
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %r15, %rsi
movq %r12, %rdx
movq %rax, %rcx
callq 0x2028c
movq %rax, %r15
leaq 0x1218a(%rip), %rsi     # 0x33e2a
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x1b7fd
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movq %rax, %rsi
movq %r15, %rdx
callq 0x1bd5f
movq %rax, %r15
movq %r14, 0x40(%rax)
leaq -0xc93(%rip), %rdi      # 0x21035
leaq -0x6da(%rip), %rsi      # 0x215f5
callq 0x2a188
movq %rax, 0x48(%r15)
movl $0x1010101, %eax        # imm = 0x1010101
movl %eax, 0x71(%r15)
movq %r13, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x29b2d
movq (%rsp), %rdi
movq %r15, %rsi
callq 0x1deda
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq