// File: /workspace/github_c_makefile_star2_O2/markdryan[P]subtilis/frontend/array_int32_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_type_t el_type;
	size_t ptr;
	size_t sizee;
	subtilis_ir_operand_t gt_zero;
	subtilis_ir_operand_t eq_zero;
	subtilis_ir_operand_t op0;

	eq_zero.label = SIZE_MAX;

	subtilis_type_if_element_type(p, type, &el_type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto free_e;

	e = subtilis_type_if_coerce_type(p, e, &el_type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	sizee = 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);
		eq_zero.label = subtilis_ir_section_new_label(p->current);
		op0.reg = sizee;
		subtilis_ir_section_add_instr_reg(p->current,
						  SUBTILIS_OP_INSTR_JMPC, op0,
						  gt_zero, eq_zero, 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 = subtilis_reference_get_data(p, mem_reg, loc, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_builtin_memset_i32(p, ptr, sizee, e->exp.ir_op.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	if (check_size)
		subtilis_ir_section_add_label(p->current, eq_zero.label, err);

cleanup:
	subtilis_type_free(&el_type);

free_e:
	subtilis_exp_delete(e);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movl %r9d, %ebp
movq %r8, %rbx
movq %rcx, %r12
movq %rdx, %r13
movq %rdi, %r15
movq 0x1a0(%rsp), %r14
leaq 0x20(%rsp), %rdx
movq %r14, %rcx
callq 0x34108
cmpl $0x0, (%r14)
jne 0x3b168
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x35977
movq %rax, %rbx
cmpl $0x0, (%r14)
jne 0x3b15e
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x4acab
movq %rax, 0x18(%rsp)
cmpl $0x0, (%r14)
je 0x3b182
leaq 0x20(%rsp), %rdi
callq 0x2dc7c
movq %rbx, %rdi
callq 0x29d88
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %bpl, %bpl
je 0x3b1de
movq 0x48(%r15), %rdi
callq 0x2b774
movq %rax, 0x10(%rsp)
movq 0x48(%r15), %rdi
callq 0x2b774
movq 0x48(%r15), %rdi
pushq $0x43
popq %rsi
movq 0x18(%rsp), %rdx
movq 0x10(%rsp), %rcx
movq %rax, 0x8(%rsp)
movq %rax, %r8
movq %r14, %r9
callq 0x2a8c1
cmpl $0x0, (%r14)
jne 0x3b15e
movq 0x48(%r15), %rdi
movq 0x10(%rsp), %rsi
movq %r14, %rdx
callq 0x2b781
cmpl $0x0, (%r14)
jne 0x3b15e
jmp 0x3b1e6
pushq $-0x1
popq %rax
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movq %r13, %rsi
movq %r12, %rdx
movq %r14, %rcx
callq 0x4a690
cmpl $0x0, (%r14)
jne 0x3b15e
movq 0x148(%rbx), %rcx
movq %r15, %rdi
movq %rax, %rsi
movq 0x18(%rsp), %rdx
movq %r14, %r8
callq 0x2ebb4
cmpl $0x0, (%r14)
setne %al
xorb $0x1, %bpl
orb %al, %bpl
jne 0x3b15e
movq 0x48(%r15), %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x2b781
jmp 0x3b15e
nopl (%rax)