// File: /workspace/github_c_makefile_star2_O3/been-jamming[P]MinimalCC/expression.c
// Function: compile_dereference
void compile_dereference(value *v, FILE *output_file){
	type data_type;

	data_type = v->data_type;
	if(pop_type(&data_type) != type_pointer){
		snprintf(error_message, sizeof(error_message), "Cannot dereference non-pointer type");
		do_error(1);
	}
	if(peek_type(&data_type) == type_void){
		snprintf(error_message, sizeof(error_message), "Cannot dereference void pointer");
		do_error(1);
	}
	if(peek_type(&data_type) == type_list){
		pop_type(&data_type);
		data_type.current_index--;
		add_type_entry(&data_type, type_pointer);
	} else if(peek_type(&data_type) != type_function){
		if(v->data.type == data_register){
			if(type_size(&data_type, 0) == 1){
				fileprint(output_file, "lb $s%d, 0($s%d)\n", v->data.reg, v->data.reg);
			} else if(type_size(&data_type, 0) == 4){
				fileprint(output_file, "lw $s%d, 0($s%d)\n", v->data.reg, v->data.reg);
			}
		} else if(v->data.type == data_stack){
			fileprint(output_file, "lw $t0, %d($sp)\n", get_stack_pos(v->data));
			if(type_size(&data_type, 0) == 1){
				fileprint(output_file, "lb $t0, 0($t0)\n");
				fileprint(output_file, "sb $t0, %d($sp)\n", get_stack_pos(v->data));
			} else if(type_size(&data_type, 0) == 4){
				fileprint(output_file, "lw $t0, 0($t0)\n");
				fileprint(output_file, "sw $t0, %d($sp)\n", get_stack_pos(v->data));
			}
		}
	}

	v->data_type = data_type;
	v->is_reference = 0;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movups 0x10(%rdi), %xmm0
movups 0x20(%rdi), %xmm1
movups 0x30(%rdi), %xmm2
movups 0x40(%rdi), %xmm3
movq %rsp, %rdi
movaps %xmm3, 0x30(%rdi)
movaps %xmm2, 0x20(%rdi)
movaps %xmm1, 0x10(%rdi)
movaps %xmm0, (%rdi)
callq 0x7ab4
cmpl $0x4, %eax
je 0x374b
movups 0x5ff0(%rip), %xmm0     # 0x9715
leaq 0x9db4(%rip), %rax      # 0xd4e0
movaps %xmm0, 0x10(%rax)
movups 0x5fce(%rip), %xmm0     # 0x9705
movaps %xmm0, (%rax)
movl $0x657079, 0x20(%rax)   # imm = 0x657079
movl $0x1, %edi
callq 0x5b10
movq %rsp, %rdi
callq 0x7a9c
cmpl $0x1, %eax
jne 0x377e
movups 0x5fda(%rip), %xmm0     # 0x9739
leaq 0x9d7a(%rip), %rax      # 0xd4e0
movaps %xmm0, 0x10(%rax)
movups 0x5fb8(%rip), %xmm0     # 0x9729
movaps %xmm0, (%rax)
movl $0x1, %edi
callq 0x5b10
leaq 0x10(%rbx), %r15
movq %rsp, %rdi
callq 0x7a9c
cmpl $0x7, %eax
jne 0x37b0
movq %rsp, %r14
movq %r14, %rdi
callq 0x7ab4
decl 0x38(%r14)
movq %r14, %rdi
movl $0x4, %esi
callq 0x75ac
jmp 0x3892
movq %rsp, %rdi
callq 0x7a9c
cmpl $0x5, %eax
je 0x3892
movl (%rbx), %eax
cmpl $0x1, %eax
je 0x37f4
testl %eax, %eax
jne 0x3892
movq %rsp, %rdi
xorl %esi, %esi
callq 0x1990
cmpl $0x4, %eax
je 0x384b
cmpl $0x1, %eax
jne 0x3892
movl 0x4(%rbx), %ecx
leaq 0x5f57(%rip), %rsi      # 0x9749
jmp 0x3855
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x15ba
leaq 0x5e60(%rip), %rsi      # 0x9666
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x171c
movq %rsp, %rdi
xorl %esi, %esi
callq 0x1990
cmpl $0x4, %eax
je 0x3863
cmpl $0x1, %eax
jne 0x3892
leaq 0x5f40(%rip), %rsi      # 0x976d
movq %r14, %rdi
xorl %eax, %eax
callq 0x171c
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x15ba
leaq 0x5f34(%rip), %rsi      # 0x977d
jmp 0x3886
movl 0x4(%rbx), %ecx
leaq 0x5f06(%rip), %rsi      # 0x975b
movq %r14, %rdi
movl %ecx, %edx
xorl %eax, %eax
callq 0x171c
jmp 0x3892
leaq 0x5f24(%rip), %rsi      # 0x978e
movq %r14, %rdi
xorl %eax, %eax
callq 0x171c
movq (%rbx), %rdi
movl 0x8(%rbx), %esi
callq 0x15ba
leaq 0x5d4f(%rip), %rsi      # 0x95d5
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x171c
movaps (%rsp), %xmm0
movaps 0x10(%rsp), %xmm1
movaps 0x20(%rsp), %xmm2
movaps 0x30(%rsp), %xmm3
movups %xmm3, 0x30(%r15)
movups %xmm2, 0x20(%r15)
movups %xmm1, 0x10(%r15)
movups %xmm0, (%r15)
movb $0x0, 0x50(%rbx)
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq