// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/builtins_ir.c
// Function: prv_builtins_ir_gen_rec_deref
static void prv_builtins_ir_gen_rec_deref(subtilis_parser_t *p,
					  const subtilis_type_t *type,
					  subtilis_ir_section_t *current,
					  subtilis_error_t *err)
{
	subtilis_ir_section_t *old_current;
	subtilis_type_t *field;
	size_t i;
	size_t call_index;
	subtilis_ir_operand_t base;
	subtilis_ir_operand_t reg;
	subtilis_ir_operand_t offset;
	const subtilis_type_rec_t *rec = &type->params.rec;

	old_current = p->current;
	p->current = current;
	base.reg = SUBTILIS_IR_REG_TEMP_START;

	for (i = 0; i < rec->num_fields; i++) {
		field = &rec->field_types[i];
		call_index = subtilis_type_if_destructor(p, field, err);
		if (err->type != SUBTILIS_ERROR_OK)
			goto cleanup;
		if (call_index == SIZE_MAX)
			continue;

		if (i == 0) {
			reg.reg = base.reg;
		} else {
			offset.integer =
				subtilis_type_rec_field_offset_id(rec, i);
			reg.reg = subtilis_ir_section_add_instr(
				p->current, SUBTILIS_OP_INSTR_ADDI_I32, base,
				offset, err);
			if (err->type != SUBTILIS_ERROR_OK)
				goto cleanup;
		}

		(void)subtilis_parser_call_1_arg_fn(
			p, p->prog->string_pool->strings[call_index], reg.reg,
			SUBTILIS_BUILTINS_MAX, SUBTILIS_IR_REG_TYPE_INTEGER,
			&subtilis_type_void, false, 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 %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x60(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
movq $0x4, -0x48(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x60(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jae 0x46e65
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x148, -0x38(%rbp), %rcx # imm = 0x148
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x4a570
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46da8
jmp 0x46e7b
cmpq $-0x1, -0x40(%rbp)
jne 0x46db4
jmp 0x46e54
cmpq $0x0, -0x38(%rbp)
jne 0x46dc5
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x46e04
movq -0x60(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x3efb0
movl %eax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %r8
movq -0x48(%rbp), %rdx
movq -0x58(%rbp), %rcx
movl $0x9, %esi
callq 0x38230
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46e02
jmp 0x46e7b
jmp 0x46e04
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x50(%rbp), %rdx
movq -0x20(%rbp), %rax
movl $0x9, %ecx
xorl %r8d, %r8d
leaq 0x64e72(%rip), %r9      # 0xabca8
movl $0x0, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x24790
movq -0x20(%rbp), %rax
cmpl $0x0, (%rax)
je 0x46e52
jmp 0x46e7b
jmp 0x46e54
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x46d5c
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x20(%rbp), %rdx
movl $0x46, %esi
callq 0x385f0
movq -0x28(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x48(%rax)
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)