// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/frontend/parser_loops.c
// Function: prv_for_step_generic_var
static void prv_for_step_generic_var(subtilis_parser_t *p, subtilis_token_t *t,
				     subtilis_exp_t *to, subtilis_exp_t *step,
				     const subtilis_for_context_t *for_ctx,
				     subtilis_error_t *err)
{
	subtilis_ir_operand_t start_label;
	subtilis_ir_operand_t true_label;
	subtilis_ir_operand_t true_label2;
	subtilis_ir_operand_t inc_label;
	subtilis_ir_operand_t dec_label;
	subtilis_exp_t *step_dup = NULL;
	subtilis_exp_t *var = NULL;
	subtilis_exp_t *var_dup = NULL;
	subtilis_exp_t *to_dup = NULL;
	subtilis_exp_t *conde = NULL;
	subtilis_exp_t *zero = NULL;

	prv_for_loop_start(p, t, &start_label, &true_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	step_dup = subtilis_type_if_dup(step, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	var = prv_increment_var(p, step, for_ctx, err);
	step = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (!subtilis_type_if_is_numeric(&var->type)) {
		subtilis_error_set_assertion_failed(err);
		goto cleanup;
	}

	var_dup = subtilis_type_if_dup(var, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	to_dup = subtilis_type_if_dup(to, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	zero = subtilis_type_if_zero(p, &step_dup->type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	conde = subtilis_exp_gt(p, step_dup, zero, err);
	step_dup = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	inc_label.reg = subtilis_ir_section_new_label(p->current);
	dec_label.reg = subtilis_ir_section_new_label(p->current);

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  conde->exp.ir_op, inc_label,
					  dec_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, inc_label.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_exp_delete(conde);
	conde = subtilis_exp_gt(p, var, to, err);
	var = NULL;
	to = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  conde->exp.ir_op, true_label,
					  start_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, dec_label.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_exp_delete(conde);
	conde = subtilis_exp_lt(p, var_dup, to_dup, err);
	var_dup = NULL;
	to_dup = NULL;
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	true_label2.reg = subtilis_ir_section_new_label(p->current);

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  conde->exp.ir_op, true_label2,
					  start_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, true_label.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_label(p->current, true_label2.reg, err);

cleanup:

	subtilis_exp_delete(conde);
	subtilis_exp_delete(var_dup);
	subtilis_exp_delete(to_dup);
	subtilis_exp_delete(var);
	subtilis_exp_delete(to);
	subtilis_exp_delete(step_dup);
	subtilis_exp_delete(step);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r14
movq %r8, %r12
movq %rcx, %rbp
movq %rdx, %r13
movq %rdi, %r15
leaq 0x20(%rsp), %rdx
leaq 0x18(%rsp), %rcx
movq %r9, %r8
callq 0x23be8
cmpl $0x0, (%r14)
movq %r13, (%rsp)
je 0x226fb
xorl %ebx, %ebx
jmp 0x2270f
movq %rbp, %rdi
movq %r14, %rsi
callq 0x362d2
movq %rax, %rbx
cmpl $0x0, (%r14)
je 0x22762
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
movq %r12, %rdi
callq 0x2b4c3
movq %r14, %rdi
callq 0x2b4c3
movq %r13, %rdi
callq 0x2b4c3
movq %r15, %rdi
callq 0x2b4c3
movq (%rsp), %rdi
callq 0x2b4c3
movq %rbx, %rdi
callq 0x2b4c3
movq %rbp, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b4c3
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x23c62
cmpl $0x0, (%r14)
je 0x22789
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
movq %rax, %r15
jmp 0x2271b
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x37676
testb %al, %al
je 0x227b9
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x362d2
movq %rax, 0x8(%rsp)
cmpl $0x0, (%r14)
je 0x227df
xorl %ebp, %ebp
xorl %r13d, %r13d
jmp 0x22809
leaq 0x511aa(%rip), %rdx     # 0x7396a
movq %r14, %rdi
movl $0xf, %esi
movl $0x20d, %ecx            # imm = 0x20D
callq 0x145f4
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
jmp 0x22811
movq %r13, %rdi
movq %r14, %rsi
callq 0x362d2
movq %rax, %r13
cmpl $0x0, (%r14)
jne 0x22807
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x35f70
cmpl $0x0, (%r14)
je 0x2281b
xorl %ebp, %ebp
xorl %r12d, %r12d
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r15
jmp 0x2271b
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x2bdc0
movq %rax, %r12
cmpl $0x0, (%r14)
jne 0x22887
movq 0x48(%r15), %rdi
callq 0x2d00a
movq %rax, %rbx
movq 0x48(%r15), %rdi
callq 0x2d00a
movq %rax, %rbp
movq 0x48(%r15), %rdi
movq 0x148(%r12), %rdx
movl $0x43, %esi
movq %rbx, %rcx
movq %rax, %r8
movq %r14, %r9
callq 0x2c0c2
cmpl $0x0, (%r14)
jne 0x22887
movq 0x48(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2d017
cmpl $0x0, (%r14)
je 0x22890
xorl %ebp, %ebp
xorl %ebx, %ebx
jmp 0x2280c
movq %r12, %rdi
callq 0x2b4c3
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rdx
movq %r14, %rcx
callq 0x2bdc0
movq %rax, %r12
cmpl $0x0, (%r14)
jne 0x228fa
movq 0x48(%r15), %rdi
movq 0x148(%r12), %rdx
movq 0x18(%rsp), %rcx
movq 0x20(%rsp), %rbx
movl $0x43, %esi
movq %rcx, (%rsp)
movq %rbx, %r8
movq %r14, %r9
callq 0x2c0c2
cmpl $0x0, (%r14)
jne 0x228fa
movq 0x48(%r15), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x2d017
cmpl $0x0, (%r14)
je 0x22913
xorl %ebp, %ebp
movq $0x0, (%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x8(%rsp), %r14
jmp 0x2271b
movq %r12, %rdi
callq 0x2b4c3
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x2bdca
movq %rax, %r12
cmpl $0x0, (%r14)
jne 0x2298d
movq 0x48(%r15), %rdi
callq 0x2d00a
movq %rax, %r13
movq 0x48(%r15), %rdi
movq 0x148(%r12), %rdx
movl $0x43, %esi
movq %rax, %rcx
movq %rbx, %r8
movq %r14, %r9
callq 0x2c0c2
cmpl $0x0, (%r14)
jne 0x2298d
movq 0x48(%r15), %rdi
movq (%rsp), %rsi
movq %r14, %rdx
callq 0x2d017
cmpl $0x0, (%r14)
jne 0x2298d
movq 0x48(%r15), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2d017
xorl %ebp, %ebp
movq $0x0, (%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %r13d, %r13d
jmp 0x2271b