// File: /workspace/github_c_makefile_star2_O0/lucvoo[P]sparse-dev/compile-i386.c
// Function: emit_loop
static void emit_loop(struct statement *stmt)
{
	struct statement  *pre_statement = stmt->iterator_pre_statement;
	struct expression *pre_condition = stmt->iterator_pre_condition;
	struct statement  *statement = stmt->iterator_statement;
	struct statement  *post_statement = stmt->iterator_post_statement;
	struct expression *post_condition = stmt->iterator_post_condition;
	int loop_top = 0, loop_bottom, loop_continue;
	int have_bottom = 0;
	struct storage *val;

	loop_bottom = new_label();
	loop_continue = new_label();
	loopstk_push(loop_continue, loop_bottom);

	x86_symbol_decl(stmt->iterator_syms);
	x86_statement(pre_statement);
	if (!post_condition || post_condition->type != EXPR_VALUE || post_condition->value) {
		loop_top = new_label();
		emit_label(loop_top, "loop top");
	}
	if (pre_condition) {
		if (pre_condition->type == EXPR_VALUE) {
			if (!pre_condition->value) {
				struct storage *lbv;
				lbv = new_storage(STOR_LABEL);
				lbv->label = loop_bottom;
				lbv->flags = STOR_WANTS_FREE;
				insn("jmp", lbv, NULL, "go to loop bottom");
				have_bottom = 1;
			}
		} else {
			struct storage *lbv = new_storage(STOR_LABEL);
			lbv->label = loop_bottom;
			lbv->flags = STOR_WANTS_FREE;
			have_bottom = 1;

			val = x86_expression(pre_condition);

			emit_move(val, REG_EAX, NULL, "loop pre condition");
			insn("test", REG_EAX, REG_EAX, NULL);
			insn("jz", lbv, NULL, NULL);
		}
	}
	x86_statement(statement);
	if (stmt->iterator_continue->used)
		emit_label(loop_continue, "'continue' iterator");
	x86_statement(post_statement);
	if (!post_condition) {
		struct storage *lbv = new_storage(STOR_LABEL);
		lbv->label = loop_top;
		lbv->flags = STOR_WANTS_FREE;
		insn("jmp", lbv, NULL, "go to loop top");
	} else if (post_condition->type == EXPR_VALUE) {
		if (post_condition->value) {
			struct storage *lbv = new_storage(STOR_LABEL);
			lbv->label = loop_top;
			lbv->flags = STOR_WANTS_FREE;
			insn("jmp", lbv, NULL, "go to loop top");
		}
	} else {
		struct storage *lbv = new_storage(STOR_LABEL);
		lbv->label = loop_top;
		lbv->flags = STOR_WANTS_FREE;

		val = x86_expression(post_condition);

		emit_move(val, REG_EAX, NULL, "loop post condition");
		insn("test", REG_EAX, REG_EAX, NULL);
		insn("jnz", lbv, NULL, NULL);
	}
	if (have_bottom || stmt->iterator_break->used)
		emit_label(loop_bottom, "loop bottom");

	loopstk_pop();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x40(%rbp)
callq 0x62b30
movl %eax, -0x38(%rbp)
callq 0x62b30
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %edi
movl -0x38(%rbp), %esi
callq 0x64350
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x62c40
movq -0x10(%rbp), %rdi
callq 0x61d70
cmpq $0x0, -0x30(%rbp)
je 0x631c9
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x631c9
movq -0x30(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x631e0
callq 0x62b30
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %edi
leaq 0xf7b9(%rip), %rsi      # 0x72994
callq 0x63bd0
cmpq $0x0, -0x18(%rbp)
je 0x632e5
movq -0x18(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x63251
movq -0x18(%rbp), %rax
cmpq $0x0, 0x20(%rax)
jne 0x6324c
movl $0x5, %edi
callq 0x63490
movq %rax, -0x50(%rbp)
movl -0x38(%rbp), %ecx
movq -0x50(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x50(%rbp), %rax
movq $0x2, 0x8(%rax)
movq -0x50(%rbp), %rsi
leaq 0x9f84(%rip), %rdi      # 0x6d1b9
xorl %eax, %eax
movl %eax, %edx
leaq 0xf730(%rip), %rcx      # 0x72970
callq 0x63500
movl $0x1, -0x40(%rbp)
jmp 0x632e3
movl $0x5, %edi
callq 0x63490
movq %rax, -0x58(%rbp)
movl -0x38(%rbp), %ecx
movq -0x58(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x58(%rbp), %rax
movq $0x2, 0x8(%rax)
movl $0x1, -0x40(%rbp)
movq -0x18(%rbp), %rdi
callq 0x62220
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x2f5fc(%rip), %rsi     # 0x92890
addq $0x330, %rsi            # imm = 0x330
xorl %eax, %eax
movl %eax, %edx
leaq 0xf939(%rip), %rcx      # 0x72bdf
callq 0x63640
leaq 0xf7ff(%rip), %rdi      # 0x72ab1
leaq 0x2f5d7(%rip), %rdx     # 0x92890
addq $0x330, %rdx            # imm = 0x330
xorl %eax, %eax
movl %eax, %ecx
movq %rdx, %rsi
callq 0x63500
movq -0x58(%rbp), %rsi
leaq 0xf7df(%rip), %rdi      # 0x72ab6
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x63500
jmp 0x632e5
movq -0x20(%rbp), %rdi
callq 0x61d70
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movl (%rax), %eax
shrl $0x11, %eax
andl $0x1, %eax
cmpb $0x0, %al
je 0x63311
movl -0x3c(%rbp), %edi
leaq 0xf8e6(%rip), %rsi      # 0x72bf2
callq 0x63bd0
movq -0x28(%rbp), %rdi
callq 0x61d70
cmpq $0x0, -0x30(%rbp)
jne 0x63365
movl $0x5, %edi
callq 0x63490
movq %rax, -0x60(%rbp)
movl -0x34(%rbp), %ecx
movq -0x60(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x60(%rbp), %rax
movq $0x2, 0x8(%rax)
movq -0x60(%rbp), %rsi
leaq 0x9e69(%rip), %rdi      # 0x6d1b9
xorl %eax, %eax
movl %eax, %edx
leaq 0xf633(%rip), %rcx      # 0x7298e
callq 0x63500
jmp 0x63451
movq -0x30(%rbp), %rax
movl (%rax), %eax
andl $0xff, %eax
cmpl $0x1, %eax
jne 0x633c4
movq -0x30(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x633bf
movl $0x5, %edi
callq 0x63490
movq %rax, -0x68(%rbp)
movl -0x34(%rbp), %ecx
movq -0x68(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x68(%rbp), %rax
movq $0x2, 0x8(%rax)
movq -0x68(%rbp), %rsi
leaq 0x9e0a(%rip), %rdi      # 0x6d1b9
xorl %eax, %eax
movl %eax, %edx
leaq 0xf5d4(%rip), %rcx      # 0x7298e
callq 0x63500
jmp 0x6344f
movl $0x5, %edi
callq 0x63490
movq %rax, -0x70(%rbp)
movl -0x34(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x70(%rbp), %rax
movq $0x2, 0x8(%rax)
movq -0x30(%rbp), %rdi
callq 0x62220
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
leaq 0x2f490(%rip), %rsi     # 0x92890
addq $0x330, %rsi            # imm = 0x330
xorl %eax, %eax
movl %eax, %edx
leaq 0xf7f4(%rip), %rcx      # 0x72c06
callq 0x63640
leaq 0xf693(%rip), %rdi      # 0x72ab1
leaq 0x2f46b(%rip), %rdx     # 0x92890
addq $0x330, %rdx            # imm = 0x330
xorl %eax, %eax
movl %eax, %ecx
movq %rdx, %rsi
callq 0x63500
movq -0x70(%rbp), %rsi
leaq 0xf7d7(%rip), %rdi      # 0x72c1a
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x63500
jmp 0x63451
cmpl $0x0, -0x40(%rbp)
jne 0x6346f
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %eax
shrl $0x11, %eax
andl $0x1, %eax
movzbl %al, %eax
cmpl $0x0, %eax
je 0x6347e
movl -0x38(%rbp), %edi
leaq 0xf4fd(%rip), %rsi      # 0x72976
callq 0x63bd0
callq 0x643b0
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)