// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/parser_array.c
// Function: prv_init_lca_table
static size_t prv_init_lca_table(subtilis_parser_t *p, subtilis_exp_t **ee,
				 size_t entries, subtilis_error_t *err)
{
	size_t i;
	size_t buf_size;
	size_t table_base;
	const subtilis_symbol_t *s;
	size_t local_block_size;
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;
	const subtilis_buffer_t *str;

	/*
	 * TODO: pointer size is hardcoded to 4
	 */

	local_block_size = entries * sizeof(int32_t) * 2;
	s = subtilis_symbol_table_create_local_buf(p->local_st,
						   local_block_size, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return 0;

	op0.reg = SUBTILIS_IR_REG_LOCAL;
	op1.integer = s->loc;
	table_base = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_ADDI_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return 0;

	for (i = 0; i < entries; i++) {
		str = &ee[i]->exp.str;
		buf_size = subtilis_buffer_get_size(str) - 1;
		op1.integer = buf_size;
		op0.reg = subtilis_ir_section_add_instr2(
		    p->current, SUBTILIS_OP_INSTR_MOVI_I32, op1, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return 0;
		op1.reg = table_base;
		op2.integer = i * sizeof(int32_t) * 2;
		subtilis_ir_section_add_instr_reg(p->current,
						  SUBTILIS_OP_INSTR_STOREO_I32,
						  op0, op1, op2, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return 0;

		if (buf_size == 0)
			continue;

		op0.reg = subtilis_string_type_lca_const(
		    p, subtilis_buffer_get_string(str), buf_size, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return 0;

		op1.reg = table_base;
		op2.integer = (i * sizeof(int32_t) * 2) + sizeof(int32_t);
		subtilis_ir_section_add_instr_reg(p->current,
						  SUBTILIS_OP_INSTR_STOREO_I32,
						  op0, op1, op2, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return 0;
	}

	return table_base;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x20(%rbp), %rax
shlq $0x2, %rax
shlq %rax
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movq 0x68(%rax), %rdi
movq -0x50(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x3c7d0
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1a909
movq $0x0, -0x8(%rbp)
jmp 0x1aacb
movq $0x2, -0x58(%rbp)
movq -0x48(%rbp), %rax
movq (%rax), %rax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r8
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movl $0x9, %esi
callq 0x38230
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1a953
movq $0x0, -0x8(%rbp)
jmp 0x1aacb
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x1aac3
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq $0x148, %rax            # imm = 0x148
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
callq 0x16270
subq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl %eax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %rcx
movq -0x60(%rbp), %rdx
movl $0x1b, %esi
callq 0x38490
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1a9cb
movq $0x0, -0x8(%rbp)
jmp 0x1aacb
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
shlq $0x2, %rax
shlq %rax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x68(%rbp), %r8
movl $0x17, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1aa19
movq $0x0, -0x8(%rbp)
jmp 0x1aacb
cmpq $0x0, -0x38(%rbp)
jne 0x1aa25
jmp 0x1aab2
movq -0x10(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
callq 0x16760
movq -0x78(%rbp), %rdi
movq %rax, %rsi
movq -0x38(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x65d80
movq %rax, -0x58(%rbp)
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1aa61
movq $0x0, -0x8(%rbp)
jmp 0x1aacb
movq -0x40(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
shlq $0x2, %rax
shlq %rax
addq $0x4, %rax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x28(%rbp), %r9
movq -0x58(%rbp), %rdx
movq -0x60(%rbp), %rcx
movq -0x68(%rbp), %r8
movl $0x17, %esi
callq 0x38360
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
je 0x1aab0
movq $0x0, -0x8(%rbp)
jmp 0x1aacb
jmp 0x1aab2
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1a95b
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)