// File: /workspace/github_c_makefile_star2_O0/oridb[P]mc/mi/flatten.c
// Function: flattenidxiter
static void
flattenidxiter(Flattenctx *s, Node *n)
{
	Loop l;
	Node *lbody, *lstep, *lcond, *lmatch, *lend;
	Node *idx, *len, *dcl, *seq, *val, *done;
	Node *zero;
        Type *idxtype;

	lbody = genlbl(n->loc);
	lstep = genlbl(n->loc);
	lcond = 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;

        /* FIXME: pass this in from main() */
        idxtype = mktype(n->loc, Tyuint64);
	zero = mkintlit(n->loc, 0);
	zero->expr.type = idxtype;

	seq = rval(s, n->iterstmt.seq);
	idx = gentemp(n->loc, idxtype, &dcl);

	/* setup */
	append(s, asn(idx, zero));
	jmp(s, lcond);
	flatten(s, lbody);

	/* body */
	flatten(s, n->iterstmt.body);
	/* step */
	flatten(s, lstep);
	flatten(s, asn(idx, addk(idx, 1)));
	/* condition */
	flatten(s, lcond);
	len = seqlen(s, seq, idxtype);
	done = mkexpr(n->loc, Olt, idx, len, NULL);
	done->expr.type = mktype(n->loc, Tybool);
	cjmp(s, done, lmatch, lend);
	flatten(s, lmatch);
	val = mkexpr(n->loc, Oidx, seq, idx, NULL);
	val->expr.type = tybase(exprtype(seq))->sub[0];

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

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%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 -0x38(%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 -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0xe, %esi
callq 0x36c10
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x2f3c0
movq %rax, -0x88(%rbp)
movq -0x90(%rbp), %rcx
movq -0x88(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x41a40
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rax
movq -0x90(%rbp), %rsi
movq (%rax), %rdi
leaq -0x68(%rbp), %rdx
callq 0x2ffd0
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x58(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x42ef0
movq -0xa8(%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 -0x8(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x58(%rbp), %rdi
movl $0x1, %esi
callq 0x42fa0
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
callq 0x42ef0
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x41220
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x41220
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rsi
movq -0x90(%rbp), %rdx
callq 0x42ff0
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq (%rax), %rdi
movl $0x1b, %esi
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x2f400
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl $0x2, %esi
callq 0x36c10
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
callq 0x42730
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x41220
movq -0x10(%rbp), %rax
movq -0x70(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq (%rax), %rdi
movl $0x28, %esi
xorl %eax, %eax
movl %eax, %r8d
movb $0x0, %al
callq 0x2f400
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x30340
movq %rax, %rdi
callq 0x36a30
movq 0x68(%rax), %rax
movq (%rax), %rcx
movq -0x78(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x78(%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 $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)