// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/array_type.c
// Function: subtilis_array_type_ref_els
void subtilis_array_type_ref_els(subtilis_parser_t *p,
				 const subtilis_type_t *type, size_t data_reg,
				 size_t size_reg, subtilis_error_t *err)
{
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;
	subtilis_ir_operand_t data_end;
	subtilis_ir_operand_t counter;
	subtilis_ir_operand_t conde;
	subtilis_ir_operand_t start;
	subtilis_ir_operand_t end;

	start.label = subtilis_ir_section_new_label(p->current);
	end.label = subtilis_ir_section_new_label(p->current);

	/* size_reg must be > 0 */

	op0.reg = data_reg;
	counter.reg = subtilis_ir_section_add_instr2(
	    p->current, SUBTILIS_OP_INSTR_MOV, op0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.reg = size_reg;
	data_end.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADD_I32, counter, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_label(p->current, start.label, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (type->type == SUBTILIS_TYPE_REC) {
		if (!subtilis_type_rec_need_deref(type)) {
			subtilis_error_set_assertion_failed(err);
			return;
		}
		subtilis_rec_type_ref(p, type, counter.reg, 0, err);
	} else {
		if (!subtilis_type_if_is_reference(type)) {
			subtilis_error_set_assertion_failed(err);
			return;
		}
		subtilis_reference_type_ref(
		    p, counter.reg, 0, type->type == SUBTILIS_TYPE_STRING, err);
	}
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op2.integer = subtilis_type_if_size(type, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_ADDI_I32, counter, counter, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	conde.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LT_I32, counter, data_end, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  conde, start, end, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%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, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rdx
movl $0x1d, %esi
callq 0x38490
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x60232
jmp 0x603f5
movq -0x20(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x50(%rbp), %rdx
movq -0x38(%rbp), %rcx
xorl %esi, %esi
callq 0x38230
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x60267
jmp 0x603f5
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x60(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6028a
jmp 0x603f5
movq -0x10(%rbp), %rax
cmpl $0x16, (%rax)
jne 0x602da
movq -0x10(%rbp), %rdi
callq 0x3f560
testb $0x1, %al
jne 0x602bf
movq -0x28(%rbp), %rdi
movl $0xf, %esi
leaq 0x4c6cd(%rip), %rdx     # 0xac97d
movl $0x928, %ecx            # imm = 0x928
callq 0x158e0
jmp 0x603f5
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x28(%rbp), %r8
xorl %eax, %eax
movl %eax, %ecx
callq 0x62a70
jmp 0x6032d
movq -0x10(%rbp), %rdi
callq 0x4a090
testb $0x1, %al
jne 0x60306
movq -0x28(%rbp), %rdi
movl $0xf, %esi
leaq 0x4c686(%rip), %rdx     # 0xac97d
movl $0x92e, %ecx            # imm = 0x92E
callq 0x158e0
jmp 0x603f5
movq -0x8(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x10(%rbp), %rax
cmpl $0x7, (%rax)
sete %al
movq -0x28(%rbp), %r8
xorl %ecx, %ecx
movzbl %al, %ecx
andl $0x1, %ecx
xorl %eax, %eax
movl %eax, %edx
callq 0x6d350
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6033b
jmp 0x603f5
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x47420
movl %eax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x60359
jmp 0x603f5
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x50(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x9, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x60386
jmp 0x603f5
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x50(%rbp), %rdx
movq -0x48(%rbp), %rcx
movl $0x3b, %esi
callq 0x38230
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x603b3
jmp 0x603f5
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x68(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x603e0
jmp 0x603f5
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x68(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x39960
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)