// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/builtins_ir.c
// Function: prv_builtins_ir_deref_array_els
static void prv_builtins_ir_deref_array_els(subtilis_parser_t *p,
					    subtilis_ir_section_t *current,
					    subtilis_error_t *err)
{
	subtilis_ir_section_t *old_current;
	subtilis_ir_operand_t no_destruct_label;
	subtilis_ir_operand_t destruct_label;
	subtilis_ir_operand_t getref_label;
	subtilis_ir_operand_t deref_label;
	subtilis_ir_operand_t op2;
	subtilis_ir_operand_t ref_count;
	subtilis_ir_operand_t el_start;
	subtilis_ir_operand_t offset;
	subtilis_ir_operand_t size;
	subtilis_ir_operand_t orig_size;

	old_current = p->current;
	p->current = current;

	getref_label.label = subtilis_ir_section_new_label(p->current);
	destruct_label.label = subtilis_ir_section_new_label(p->current);
	deref_label.label = subtilis_ir_section_new_label(p->current);
	no_destruct_label.label = subtilis_ir_section_new_label(p->current);

	el_start.reg = SUBTILIS_IR_REG_TEMP_START;

	op2.integer = SUBTIILIS_REFERENCE_SIZE_OFF;
	size.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, el_start, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op2.integer = SUBTIILIS_REFERENCE_HEAP_OFF;
	offset.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, el_start, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  size, getref_label, no_destruct_label,
					  err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	ref_count.reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_GETREF, offset, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;
	op2.integer = 1;
	ref_count.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_EQI_I32, ref_count, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;
	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  ref_count, destruct_label,
					  deref_label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;
	subtilis_ir_section_add_label(p->current, destruct_label.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	op2.integer = SUBTIILIS_REFERENCE_ORIG_SIZE_OFF;
	orig_size.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, el_start, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

	subtilis_array_type_deref_els(p, offset.reg, orig_size.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	reference_type_call_deref(p, offset, err);
	if (err->type != SUBTILIS_ERROR_OK)
		goto cleanup;

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

	subtilis_ir_section_add_instr_no_arg(p->current, SUBTILIS_OP_INSTR_RET,
					     err);

cleanup:
	p->current = old_current;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x30(%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, -0x28(%rbp)
movq $0x4, -0x58(%rbp)
movl $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %r8
movq -0x58(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44b5f
jmp 0x44d68
movl $0x8, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %r8
movq -0x58(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44b96
jmp 0x44d68
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %r9
movq -0x68(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44bc6
jmp 0x44d68
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x38(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44be9
jmp 0x44d68
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rcx
movq -0x60(%rbp), %rdx
movl $0x7a, %esi
callq 0x38490
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44c15
jmp 0x44d68
movl $0x1, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %r8
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl $0x2d, %esi
callq 0x38230
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44c4c
jmp 0x44d68
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %r9
movq -0x50(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44c7c
jmp 0x44d68
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44c9f
jmp 0x44d68
movl $0xc, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %r8
movq -0x58(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x70(%rbp)
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44cd6
jmp 0x44d68
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x18(%rbp), %rcx
callq 0x60010
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44cf6
jmp 0x44d68
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x40(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44d16
jmp 0x44d68
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rdx
movq -0x60(%rbp), %rsi
callq 0x6d670
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44d32
jmp 0x44d68
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x39960
movq -0x18(%rbp), %rax
cmpl $0x0, (%rax)
je 0x44d52
jmp 0x44d68
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x18(%rbp), %rdx
movl $0x46, %esi
callq 0x385f0
movq -0x20(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)