// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/mi/flatten.c
// Function: flattentraititer
static void
flattentraititer(Flattenctx *s, Node *n)
{
	Loop l;
	Node *lbody, *lclean, *lstep, *lmatch, *lend;
	Node *done, *val, *iter, *valptr, *iterptr;
	Node *func, *call, *seq;
	Trait *tr;

	val = temp(s, n->iterstmt.elt);
	valptr = mkexpr(val->loc, Oaddr, val, NULL);
	valptr->expr.type = mktyptr(n->loc, exprtype(val));
	iter = temp(s, n->iterstmt.seq);
	iterptr = mkexpr(val->loc, Oaddr, iter, NULL);
	iterptr->expr.type = mktyptr(n->loc, exprtype(iter));
	tr = traittab[Tciter];

	/* create labels */
	lbody = genlbl(n->loc);
	lclean = genlbl(n->loc);
	lstep = genlbl(n->loc);
	lmatch = genlbl(n->loc);
	lend = genlbl(n->loc);

	s->inloop++;
	l = s->loop;
	s->loop.lcnt = lstep;
	s->loop.lbrk = lend;
	s->loop.body = n->iterstmt.body->block.scope;

	seq = rval(s, n->iterstmt.seq);
	append(s, asn(iter, seq));
	jmp(s, lstep);
	flatten(s, lbody);
	/* body */
	flatten(s, n->iterstmt.body);
	flatten(s, lclean);

	/* call iterator cleanup */
	func = traitfn(n->loc, tr, "__iterfin__", exprtype(iter));
	call = mkexpr(n->loc, Ocall, func, iterptr, valptr, NULL);
	call->expr.type = mktype(n->loc, Tyvoid);
	append(s, call);

	flatten(s, lstep);
	/* call iterator step */
	func = traitfn(n->loc, tr, "__iternext__", exprtype(iter));
	call = mkexpr(n->loc, Ocall, func, iterptr, valptr, NULL);
	done = gentemp(n->loc, mktype(n->loc, Tybool), NULL);
	call->expr.type = exprtype(done);
	append(s, asn(done, call));
	cjmp(s, done, lmatch, lend);

	/* pattern match */
	flatten(s, lmatch);
	flattenloopmatch(s, n->iterstmt.elt, val, lbody, lclean);
	jmp(s, lbody);
	flatten(s, lend);

	s->inloop--;
	s->loop = l;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x43230
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq -0x60(%rbp), %rdx
movq (%rax), %rdi
movl $0x12, %esi
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x2f400
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x60(%rbp), %rdi
callq 0x30340
movq %rax, %rsi
movq -0xe0(%rbp), %rax
movq (%rax), %rdi
callq 0x37430
movq %rax, %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x43230
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rdx
movq (%rax), %rdi
movl $0x12, %esi
xorl %eax, %eax
movl %eax, %ecx
movb $0x0, %al
callq 0x2f400
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x68(%rbp), %rdi
callq 0x30340
movq %rax, %rsi
movq -0xd8(%rbp), %rax
movq (%rax), %rdi
callq 0x37430
movq %rax, %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x20(%rax)
leaq 0x3b17c(%rip), %rax     # 0x7dd10
movq (%rax), %rax
movq 0x30(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2fd00
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2fd00
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2fd00
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2fd00
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0x2fd00
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movl 0x48(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x48(%rax)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rcx
movq %rcx, -0x28(%rbp)
movq 0x38(%rax), %rcx
movq %rcx, -0x20(%rbp)
movq 0x40(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x40(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x50(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x18(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x41a40
movq %rax, -0x90(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x68(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x42ef0
movq -0xd0(%rbp), %rdi
movq %rax, %rsi
callq 0x419f0
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x42420
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x41220
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rsi
callq 0x41220
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x41220
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0x68(%rbp), %rdi
callq 0x30340
movq -0xc8(%rbp), %rsi
movq %rax, %rcx
movq -0xc0(%rbp), %rax
movq (%rax), %rdi
leaq 0x1141e(%rip), %rdx     # 0x5411c
callq 0x42480
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq -0x80(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x70(%rbp), %r8
movq (%rax), %rdi
movl $0x2d, %esi
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x2f400
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x1, %esi
callq 0x36c10
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x419f0
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x41220
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x68(%rbp), %rdi
callq 0x30340
movq -0xb8(%rbp), %rsi
movq %rax, %rcx
movq -0xb0(%rbp), %rax
movq (%rax), %rdi
leaq 0x11360(%rip), %rdx     # 0x5410b
callq 0x42480
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq -0x80(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x70(%rbp), %r8
movq (%rax), %rdi
movl $0x2d, %esi
xorl %eax, %eax
movl %eax, %r9d
movb $0x0, %al
callq 0x2f400
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x2, %esi
callq 0x36c10
movq %rax, %rsi
movq -0xa8(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %edx
callq 0x2ffd0
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
callq 0x30340
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x58(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x42ef0
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x419f0
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
callq 0x42730
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x41220
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x60(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %r8
callq 0x430d0
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x42420
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x41220
movq -0x8(%rbp), %rax
movl 0x48(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x48(%rax)
movq -0x8(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq -0x20(%rbp), %rcx
movq %rcx, 0x38(%rax)
movq -0x18(%rbp), %rcx
movq %rcx, 0x40(%rax)
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)