// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/array_string_type.c
// Function: prv_set
static void prv_set(subtilis_parser_t *p, const char *var_name,
		    const subtilis_type_t *type, size_t mem_reg, size_t loc,
		    subtilis_exp_t *e, bool check_size, subtilis_error_t *err)
{
	subtilis_ir_operand_t sizee;
	subtilis_ir_operand_t ptr;
	subtilis_ir_operand_t end_ptr;
	subtilis_ir_operand_t string_size;
	subtilis_ir_operand_t start_label;
	subtilis_ir_operand_t loop_label;
	subtilis_ir_operand_t end_label;
	subtilis_ir_operand_t gt_zero;
	subtilis_ir_operand_t condee;
	subtilis_exp_t *e_dup;

	start_label.label = subtilis_ir_section_new_label(p->current);
	end_label.label = subtilis_ir_section_new_label(p->current);
	loop_label.label = subtilis_ir_section_new_label(p->current);

	e = subtilis_type_if_coerce_type(p, e, &subtilis_type_string, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	sizee.reg = subtilis_reference_type_get_size(p, mem_reg, loc, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (check_size) {
		gt_zero.label = subtilis_ir_section_new_label(p->current);
		subtilis_ir_section_add_instr_reg(p->current,
						  SUBTILIS_OP_INSTR_JMPC, sizee,
						  gt_zero, end_label, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;

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

	ptr.reg = subtilis_reference_get_data(p, mem_reg, loc, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	string_size.integer = subtilis_type_if_size(&subtilis_type_string, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	/*
	 * TODO: Pointer arithmetic here.
	 */

	end_ptr.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADD_I32, ptr, sizee, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	condee.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LT_I32, ptr, end_ptr, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  condee, loop_label, end_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	e_dup = subtilis_type_if_dup(e, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_string_type_assign_ref(p, &subtilis_type_string, ptr.reg, 0,
					e_dup, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_ADDI_I32, ptr, ptr, string_size, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_ir_section_add_label(p->current, end_label.label, err);

cleanup:

	subtilis_exp_delete(e);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq 0x18(%rbp), %rax
movb 0x10(%rbp), %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
andb $0x1, %al
movb %al, -0x31(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x60(%rbp)
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, -0x68(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq 0x18(%rbp), %rcx
leaq 0x53e0b(%rip), %rdx     # 0xabb60
callq 0x4a2e0
movq %rax, -0x30(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57d6c
jmp 0x57fda
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x6dc00
movq %rax, -0x40(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57d93
jmp 0x57fd1
testb $0x1, -0x31(%rbp)
je 0x57dff
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %r9
movq -0x40(%rbp), %rdx
movq -0x78(%rbp), %rcx
movq -0x70(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57dda
jmp 0x57fd1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x78(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x39960
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57dfd
jmp 0x57fd1
jmp 0x57dff
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq 0x18(%rbp), %rcx
callq 0x6d1e0
movq %rax, -0x48(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57e26
jmp 0x57fd1
movq 0x18(%rbp), %rsi
leaq 0x53d2f(%rip), %rdi     # 0xabb60
callq 0x47420
movl %eax, -0x58(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57e47
jmp 0x57fd1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %r8
movq -0x48(%rbp), %rdx
movq -0x40(%rbp), %rcx
xorl %esi, %esi
callq 0x38230
movq %rax, -0x50(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57e74
jmp 0x57fd1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x60(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x39960
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57e97
jmp 0x57fd1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %r8
movq -0x48(%rbp), %rdx
movq -0x50(%rbp), %rcx
movl $0x3b, %esi
callq 0x38230
movq %rax, -0x80(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57ec7
jmp 0x57fd1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %r9
movq -0x80(%rbp), %rdx
movq -0x68(%rbp), %rcx
movq -0x70(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57ef7
jmp 0x57fd1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x68(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x39960
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57f1a
jmp 0x57fd1
movq -0x30(%rbp), %rdi
movq 0x18(%rbp), %rsi
callq 0x47d20
movq %rax, -0x88(%rbp)
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57f3c
jmp 0x57fd1
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq -0x88(%rbp), %r8
movq 0x18(%rbp), %r9
leaq 0x53c0a(%rip), %rsi     # 0xabb60
xorl %eax, %eax
movl %eax, %ecx
callq 0x67210
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57f6a
jmp 0x57fd1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %r9
movq -0x48(%rbp), %rdx
movq -0x48(%rbp), %rcx
movq -0x58(%rbp), %r8
movl $0x9, %esi
callq 0x38360
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57f97
jmp 0x57fd1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x18(%rbp), %rcx
movq -0x60(%rbp), %rdx
movl $0x45, %esi
callq 0x38540
movq 0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x57fbc
jmp 0x57fd1
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x70(%rbp), %rsi
movq 0x18(%rbp), %rdx
callq 0x39960
movq -0x30(%rbp), %rdi
callq 0x36ee0
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)