// File: /workspace/github_c_makefile_star2_O0/markdryan[P]subtilis/frontend/reference_type.c
// Function: subtilis_reference_type_init_ref
void subtilis_reference_type_init_ref(subtilis_parser_t *p, size_t dest_mem_reg,
				      size_t dest_loc, size_t source_reg,
				      bool check_size, bool ref,
				      subtilis_error_t *err)
{
	subtilis_ir_operand_t op0;
	subtilis_ir_operand_t op1;
	subtilis_ir_operand_t op2;
	subtilis_ir_operand_t copy;
	subtilis_ir_operand_t zero;
	subtilis_ir_operand_t gtzero;

	zero.label = SIZE_MAX;
	op0.reg = source_reg;

	op1.integer = SUBTIILIS_REFERENCE_SIZE_OFF;
	copy.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.reg = dest_mem_reg;
	op2.integer = dest_loc + SUBTIILIS_REFERENCE_SIZE_OFF;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_STOREO_I32, copy, op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (check_size) {
		zero.label = subtilis_ir_section_new_label(p->current);
		gtzero.label = subtilis_ir_section_new_label(p->current);
		subtilis_ir_section_add_instr_reg(p->current,
						  SUBTILIS_OP_INSTR_JMPC, copy,
						  gtzero, zero, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
		subtilis_ir_section_add_label(p->current, gtzero.label, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	op1.integer = SUBTIILIS_REFERENCE_DATA_OFF;
	copy.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.reg = dest_mem_reg;
	op2.integer = dest_loc + SUBTIILIS_REFERENCE_DATA_OFF;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_STOREO_I32, copy, op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = SUBTIILIS_REFERENCE_HEAP_OFF;
	copy.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (ref) {
		subtilis_ir_section_add_instr_no_reg(
		    p->current, SUBTILIS_OP_INSTR_REF, copy, err);
		if (err->type != SUBTILIS_ERROR_OK)
			return;
	}

	op1.reg = dest_mem_reg;
	op2.integer = dest_loc + SUBTIILIS_REFERENCE_HEAP_OFF;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_STOREO_I32, copy, op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.integer = SUBTIILIS_REFERENCE_ORIG_SIZE_OFF;
	copy.reg = subtilis_ir_section_add_instr(
	    p->current, SUBTILIS_OP_INSTR_LOADO_I32, op0, op1, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	op1.reg = dest_mem_reg;
	op2.integer = dest_loc + SUBTIILIS_REFERENCE_ORIG_SIZE_OFF;
	subtilis_ir_section_add_instr_reg(
	    p->current, SUBTILIS_OP_INSTR_STOREO_I32, copy, op1, op2, err);
	if (err->type != SUBTILIS_ERROR_OK)
		return;

	if (check_size)
		subtilis_ir_section_add_label(p->current, zero.label, err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movl %r8d, -0x74(%rbp)
movq %rcx, %rax
movl -0x74(%rbp), %ecx
movq %rax, -0x70(%rbp)
movq %rdx, %rax
movq -0x70(%rbp), %rdx
movq %rax, -0x68(%rbp)
movq %rsi, %rax
movq -0x68(%rbp), %rsi
movq %rax, -0x60(%rbp)
movq %rdi, %r8
movq -0x60(%rbp), %rdi
movb %r9b, %al
movq 0x10(%rbp), %r9
movq %r8, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
andb $0x1, %cl
movb %cl, -0x21(%rbp)
andb $0x1, %al
movb %al, -0x22(%rbp)
movq $-0x1, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r8
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6cbff
jmp 0x6ce72
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
addq $0x0, %rax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r9
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x17, %esi
callq 0x38360
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6cc42
jmp 0x6ce72
testb $0x1, -0x21(%rbp)
je 0x6ccbf
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x50(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x39940
movq %rax, -0x58(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r9
movq -0x48(%rbp), %rdx
movq -0x58(%rbp), %rcx
movq -0x50(%rbp), %r8
movl $0x43, %esi
callq 0x38360
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6cc9a
jmp 0x6ce72
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x58(%rbp), %rsi
movq 0x10(%rbp), %rdx
callq 0x39960
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ccbd
jmp 0x6ce72
jmp 0x6ccbf
movl $0x4, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r8
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ccf6
jmp 0x6ce72
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
addq $0x4, %rax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r9
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x17, %esi
callq 0x38360
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6cd39
jmp 0x6ce72
movl $0x8, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r8
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6cd70
jmp 0x6ce72
testb $0x1, -0x22(%rbp)
je 0x6cda0
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %rcx
movq -0x48(%rbp), %rdx
movl $0x78, %esi
callq 0x38540
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6cd9e
jmp 0x6ce72
jmp 0x6cda0
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
addq $0x8, %rax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r9
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x17, %esi
callq 0x38360
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6cde3
jmp 0x6ce72
movl $0xc, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r8
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rcx
movl $0x12, %esi
callq 0x38230
movq %rax, -0x48(%rbp)
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ce17
jmp 0x6ce72
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
addq $0xc, %rax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq 0x10(%rbp), %r9
movq -0x48(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x40(%rbp), %r8
movl $0x17, %esi
callq 0x38360
movq 0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x6ce57
jmp 0x6ce72
testb $0x1, -0x21(%rbp)
je 0x6ce72
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x50(%rbp), %rsi
movq 0x10(%rbp), %rdx
callq 0x39960
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax,%rax)