// File: /workspace/github_c_makefile_star2_O3/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 0x23ae5
cmpl $0x0, (%r14)
movq %r13, (%rsp)
je 0x22657
xorl %ebx, %ebx
jmp 0x2266b
movq %rbp, %rdi
movq %r14, %rsi
callq 0x36182
movq %rax, %rbx
cmpl $0x0, (%r14)
je 0x226be
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
movq %r12, %rdi
callq 0x2b166
movq %r14, %rdi
callq 0x2b166
movq %r13, %rdi
callq 0x2b166
movq %r15, %rdi
callq 0x2b166
movq (%rsp), %rdi
callq 0x2b166
movq %rbx, %rdi
callq 0x2b166
movq %rbp, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2b166
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x23b5f
cmpl $0x0, (%r14)
je 0x226e5
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
movq %rax, %r15
jmp 0x22677
movq %rax, 0x10(%rsp)
movq %rax, %rdi
callq 0x37534
testb %al, %al
je 0x22715
movq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x36182
movq %rax, 0x8(%rsp)
cmpl $0x0, (%r14)
je 0x2273b
xorl %ebp, %ebp
xorl %r13d, %r13d
jmp 0x22765
leaq 0x51270(%rip), %rdx     # 0x7398c
movq %r14, %rdi
movl $0xf, %esi
movl $0x20d, %ecx            # imm = 0x20D
callq 0x145a4
xorl %ebp, %ebp
xorl %r14d, %r14d
xorl %r13d, %r13d
xorl %r12d, %r12d
jmp 0x2276d
movq %r13, %rdi
movq %r14, %rsi
callq 0x36182
movq %rax, %r13
cmpl $0x0, (%r14)
jne 0x22763
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x35e20
cmpl $0x0, (%r14)
je 0x22777
xorl %ebp, %ebp
xorl %r12d, %r12d
movq 0x8(%rsp), %r14
movq 0x10(%rsp), %r15
jmp 0x22677
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
movq %r14, %rcx
callq 0x2ba3c
movq %rax, %r12
cmpl $0x0, (%r14)
jne 0x227e3
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, %rbx
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, %rbp
movq 0x48(%r15), %rdi
movq 0x148(%r12), %rdx
movl $0x43, %esi
movq %rbx, %rcx
movq %rax, %r8
movq %r14, %r9
callq 0x2bd42
cmpl $0x0, (%r14)
jne 0x227e3
movq 0x48(%r15), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
je 0x227ec
xorl %ebp, %ebp
xorl %ebx, %ebx
jmp 0x22768
movq %r12, %rdi
callq 0x2b166
movq %r15, %rdi
movq 0x10(%rsp), %rsi
movq (%rsp), %rdx
movq %r14, %rcx
callq 0x2ba3c
movq %rax, %r12
cmpl $0x0, (%r14)
jne 0x22856
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 0x2bd42
cmpl $0x0, (%r14)
jne 0x22856
movq 0x48(%r15), %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
je 0x2286f
xorl %ebp, %ebp
movq $0x0, (%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x8(%rsp), %r14
jmp 0x22677
movq %r12, %rdi
callq 0x2b166
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x2ba46
movq %rax, %r12
cmpl $0x0, (%r14)
jne 0x228e9
movq 0x48(%r15), %rdi
callq 0x2cc99
movq %rax, %r13
movq 0x48(%r15), %rdi
movq 0x148(%r12), %rdx
movl $0x43, %esi
movq %rax, %rcx
movq %rbx, %r8
movq %r14, %r9
callq 0x2bd42
cmpl $0x0, (%r14)
jne 0x228e9
movq 0x48(%r15), %rdi
movq (%rsp), %rsi
movq %r14, %rdx
callq 0x2cca6
cmpl $0x0, (%r14)
jne 0x228e9
movq 0x48(%r15), %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x2cca6
xorl %ebp, %ebp
movq $0x0, (%rsp)
xorl %ebx, %ebx
xorl %r15d, %r15d
xorl %r14d, %r14d
xorl %r13d, %r13d
jmp 0x22677