// File: /workspace/github_c_makefile_star2_O1/markdryan[P]subtilis/frontend/parser_array.c
// Function: prv_read_string_table
static void prv_read_string_table(subtilis_parser_t *p, size_t array_base,
				  size_t table_base, size_t entries,
				  size_t element_size, subtilis_error_t *err)
{
	subtilis_ir_operand_t start;
	subtilis_ir_operand_t end;
	subtilis_ir_operand_t zero_len;
	subtilis_ir_operand_t gt_zero;
	subtilis_ir_operand_t table_end;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t size;
	subtilis_ir_operand_t cond;
	subtilis_ir_operand_t skip;
	subtilis_ir_operand_t lca_offset;
	subtilis_ir_operand_t table_ptr;
	subtilis_ir_operand_t array_ptr;

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

	table_ptr.reg = table_base;
	array_ptr.reg = array_base;

	op1.integer = entries * sizeof(int32_t) * 2;
	table_end.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADDI_I32, table_ptr, 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;

	op1.integer = 0;
	size.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, table_ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;
	subtilis_ir_section_add_instr_reg(p->current, SUBTILIS_OP_INSTR_JMPC,
					  size, gt_zero, zero_len, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	op1.integer = sizeof(int32_t);
	lca_offset.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, table_ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_reference_type_deref(p, array_ptr.reg, 0, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_string_init_from_lca(p, array_ptr.reg, 0, lca_offset.reg,
				      size.reg, false, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	subtilis_ir_section_add_instr_no_reg(p->current, SUBTILIS_OP_INSTR_JMP,
					     skip, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	subtilis_reference_type_set_size(p, array_ptr.reg, 0, size.reg, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

	op1.integer = (int32_t)element_size;
	subtilis_ir_section_add_instr_reg(p->current,
					  SUBTILIS_OP_INSTR_ADDI_I32, array_ptr,
					  array_ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = sizeof(int32_t) * 2;
	subtilis_ir_section_add_instr_reg(p->current,
					  SUBTILIS_OP_INSTR_ADDI_I32, table_ptr,
					  table_ptr, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	cond.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LT_I32, table_ptr, table_end, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

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

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %rbx
movq %r8, 0x30(%rsp)
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, 0x8(%rsp)
movq %rdi, %r14
movq 0x48(%rdi), %rdi
callq 0x2d00a
movq %rax, 0x20(%rsp)
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, 0x10(%rsp)
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, %rbp
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, %r12
movq 0x48(%r14), %rdi
callq 0x2d00a
movq %rax, 0x18(%rsp)
shll $0x3, %r15d
movq 0x48(%r14), %rdi
movl $0x9, %esi
movq %r13, %rdx
movq %r15, %rcx
movq %rbx, %r8
callq 0x2c00f
movq %rax, 0x28(%rsp)
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movq 0x20(%rsp), %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movl $0x12, %esi
movq %r13, %rdx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq %r12, %rcx
movq %rbp, %r8
movq %rbx, %r9
movq %rax, %r15
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movl $0x4, %ecx
movl $0x12, %esi
movq %r13, %rdx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x17e67
movq %rax, %r12
movq %r14, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x4db70
cmpl $0x0, (%rbx)
jne 0x17e67
movq %r15, %r8
movq %rbx, (%rsp)
movq %r14, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
movq %r12, %rcx
xorl %r9d, %r9d
callq 0x4851e
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movl $0x45, %esi
movq 0x18(%rsp), %rdx
movq %rbx, %rcx
callq 0x2c19f
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x17e67
movq %r14, %rdi
movq 0x8(%rsp), %rsi
xorl %edx, %edx
movq %r15, %rcx
movq %rbx, %r8
callq 0x4d921
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movq 0x18(%rsp), %rsi
movq %rbx, %rdx
callq 0x2d017
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movl 0x30(%rsp), %r8d
movl $0x9, %esi
movq 0x8(%rsp), %rcx
movq %rcx, %rdx
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movl $0x8, %r8d
movl $0x9, %esi
movq %r13, %rdx
movq %r13, %rcx
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movl $0x3b, %esi
movq %r13, %rdx
movq 0x28(%rsp), %rcx
movq %rbx, %r8
callq 0x2c00f
cmpl $0x0, (%rbx)
jne 0x17e67
movq 0x48(%r14), %rdi
movl $0x43, %esi
movq %rax, %rdx
movq 0x20(%rsp), %rcx
movq 0x10(%rsp), %r8
movq %rbx, %r9
callq 0x2c0c2
cmpl $0x0, (%rbx)
je 0x17e76
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%r14), %rdi
movq 0x10(%rsp), %rsi
movq %rbx, %rdx
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2d017