// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/string_type.c
// Function: prv_string_str_non_const_common
static void prv_string_str_non_const_common(subtilis_parser_t *p,
					    const subtilis_symbol_t *s,
					    subtilis_exp_t *count,
					    size_t str_data,
					    subtilis_exp_t *str_len,
					    bool check_for_one,
					    subtilis_error_t *err)
/* clang-format on */
{
	subtilis_ir_operand_t end;
	subtilis_ir_operand_t memcpy_loop;
	size_t dest_reg;
	size_t val_reg;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;
	subtilis_ir_operand_t end_ptr;
	subtilis_ir_operand_t eq_one_label;
	subtilis_ir_operand_t not_eq_one_label;
	subtilis_exp_t *dup = NULL;
	subtilis_exp_t *one = NULL;

	not_eq_one_label.label = SIZE_MAX;
	eq_one_label.label = SIZE_MAX;

	if (check_for_one) {
		eq_one_label.label = subtilis_ir_section_new_label(p->current);
		not_eq_one_label.label =
		    subtilis_ir_section_new_label(p->current);
	}
	memcpy_loop.label = subtilis_ir_section_new_label(p->current);
	end.label = subtilis_ir_section_new_label(p->current);

	dup = subtilis_type_if_dup(count, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	prv_string_str_check_count(p, s, dup, end, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	dup = subtilis_type_if_dup(str_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	count = subtilis_type_if_mul(p, count, dup, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;
	dup = NULL;

	dest_reg = subtilis_reference_type_alloc(
	    p, &subtilis_type_string, s->loc, SUBTILIS_IR_REG_LOCAL,
	    count->exp.ir_op.reg, true, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (check_for_one && str_len->type.type == SUBTILIS_TYPE_INTEGER) {
		op2.integer = 1;
		op1.reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_EQI_I32, str_len->exp.ir_op,
		    op2, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		subtilis_ir_section_add_instr_reg(
		    p->current, SUBTILIS_OP_INSTR_JMPC, op1, eq_one_label,
		    not_eq_one_label, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

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

		op1.reg = str_data;
		op2.integer = 0;
		val_reg = subtilis_ir_section_add_instr(
		    p->current, SUBTILIS_OP_INSTR_LOADO_I8, op1, op2, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		subtilis_builtin_memset_i8(p, dest_reg, count->exp.ir_op.reg,
					   val_reg, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		subtilis_ir_section_add_instr_no_reg(
		    p->current, SUBTILIS_OP_INSTR_JMP, end, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

		subtilis_ir_section_add_label(p->current,
					      not_eq_one_label.label, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
	}

	op1.reg = dest_reg;
	end_ptr.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADD_I32, op1, count->exp.ir_op, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	str_len = subtilis_type_if_exp_to_var(p, str_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_reference_type_memcpy_dest(p, dest_reg, str_data,
					    str_len->exp.ir_op.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.integer = dest_reg;
	op2.reg =
	    subtilis_ir_section_add_instr(p->current, SUBTILIS_OP_INSTR_ADD_I32,
					  op1, str_len->exp.ir_op, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_no_reg2(p->current, SUBTILIS_OP_INSTR_MOV,
					      op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op1.integer = dest_reg;
	op2.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_EQ_I32, op1, end_ptr, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC_NF,
					  op2, end, memcpy_loop, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_exp_delete(count);
	subtilis_exp_delete(str_len);

	return;

cleanup:

	subtilis_exp_delete(one);
	subtilis_exp_delete(dup);
	subtilis_exp_delete(count);
	subtilis_exp_delete(str_len);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movb %r9b, %al
movq 0x10(%rbp), %r9
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
andb $0x1, %al
movb %al, -0x29(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x88(%rbp)
movq $-0x1, -0x78(%rbp)
movq $-0x1, -0x70(%rbp)
testb $0x1, -0x29(%rbp)
je 0x6c716
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x70(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0x47d20
movq %rax, -0x80(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c757
jmp 0x6cb21
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq 0x10(%rbp), %r8
movq -0x38(%rbp), %rcx
callq 0x6c4f0
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c77e
jmp 0x6cb21
movq -0x28(%rbp), %rdi
movq 0x10(%rbp), %rsi
callq 0x47d20
movq %rax, -0x80(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c79d
jmp 0x6cb21
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq 0x10(%rbp), %rcx
callq 0x48fb0
movq %rax, -0x18(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c7c4
jmp 0x6cb21
movq $0x0, -0x80(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq (%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x148(%rax), %r8
movq 0x10(%rbp), %rax
leaq 0x3f373(%rip), %rsi     # 0xabb60
movl $0x2, %ecx
movl $0x1, %r9d
movq %rax, (%rsp)
callq 0x6e3e0
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c813
jmp 0x6cb21
testb $0x1, -0x29(%rbp)
je 0x6c975
movq -0x28(%rbp), %rax
cmpl $0x5, (%rax)
jne 0x6c975
movl $0x1, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rbp), %r8
movq 0x148(%rax), %rdx
movq -0x60(%rbp), %rcx
movl $0x2d, %esi
callq 0x38230
movq %rax, -0x58(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c868
jmp 0x6cb21
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r9
movq -0x58(%rbp), %rdx
movq -0x70(%rbp), %rcx
movq -0x78(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c898
jmp 0x6cb21
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x70(%rbp), %rsi
movq 0x10(%rbp), %rdx
callq 0x39960
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c8bb
jmp 0x6cb21
movq -0x20(%rbp), %rax
movq %rax, -0x58(%rbp)
movl $0x0, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r8
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movl $0x11, %esi
callq 0x38230
movq %rax, -0x50(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c8fa
jmp 0x6cb21
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x148(%rax), %rdx
movq -0x50(%rbp), %rcx
movq 0x10(%rbp), %r8
callq 0x3fc60
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c928
jmp 0x6cb21
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %rcx
movq -0x38(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c950
jmp 0x6cb21
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x78(%rbp), %rsi
movq 0x10(%rbp), %rdx
callq 0x39960
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c973
jmp 0x6cb21
jmp 0x6c975
movq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x10(%rbp), %r8
movq -0x58(%rbp), %rdx
movq 0x148(%rax), %rcx
xorl %esi, %esi
callq 0x38230
movq %rax, -0x68(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c9b1
jmp 0x6cb21
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq 0x10(%rbp), %rdx
callq 0x47c10
movq %rax, -0x28(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c9d4
jmp 0x6cb21
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x40(%rbp), %rsi
movq 0x10(%rbp), %rdx
callq 0x39960
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6c9f7
jmp 0x6cb21
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x148(%rax), %rcx
movq 0x10(%rbp), %r8
callq 0x6dad0
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ca25
jmp 0x6cb21
movq -0x48(%rbp), %rax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rax
movq 0x10(%rbp), %r8
movq -0x58(%rbp), %rdx
movq 0x148(%rax), %rcx
xorl %esi, %esi
callq 0x38230
movq %rax, -0x60(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ca60
jmp 0x6cb21
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r8
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movl $0x1d, %esi
callq 0x385a0
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ca8c
jmp 0x6cb21
movq -0x48(%rbp), %rax
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r8
movq -0x58(%rbp), %rdx
movq -0x68(%rbp), %rcx
movl $0x2b, %esi
callq 0x38230
movq %rax, -0x60(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6cac0
jmp 0x6cb21
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r9
movq -0x60(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x44, %esi
callq 0x38360
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6caed
jmp 0x6cb21
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x38(%rbp), %rsi
movq 0x10(%rbp), %rdx
callq 0x39960
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6cb0d
jmp 0x6cb21
movq -0x18(%rbp), %rdi
callq 0x36ee0
movq -0x28(%rbp), %rdi
callq 0x36ee0
jmp 0x6cb48
movq -0x88(%rbp), %rdi
callq 0x36ee0
movq -0x80(%rbp), %rdi
callq 0x36ee0
movq -0x18(%rbp), %rdi
callq 0x36ee0
movq -0x28(%rbp), %rdi
callq 0x36ee0
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)