// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x98, %rsp
movq %rdi, 0x90(%rsp)
movq %rsi, 0x88(%rsp)
movq 0x90(%rsp), %rsi
addq $0x10, %rsi
leaq 0x48(%rsp), %rdi
movl $0x40, %edx
callq 0x1120
leaq 0x48(%rsp), %rdi
callq 0xbe20
cmpl $0x4, %eax
je 0x4465
leaq 0xd0e8(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x94b5(%rip), %rdx      # 0xd909
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
leaq 0x48(%rsp), %rdi
callq 0xbdb0
cmpl $0x1, %eax
jne 0x4498
leaq 0xd0b5(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x94a6(%rip), %rdx      # 0xd92d
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
leaq 0x48(%rsp), %rdi
callq 0xbdb0
cmpl $0x7, %eax
jne 0x44d6
leaq 0x48(%rsp), %rdi
callq 0xbe20
movl 0x80(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0x80(%rsp)
leaq 0x48(%rsp), %rdi
movl $0x4, %esi
callq 0xb510
jmp 0x46bb
leaq 0x48(%rsp), %rdi
callq 0xbdb0
cmpl $0x5, %eax
je 0x46b9
movq 0x90(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x457d
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
jne 0x4539
movq 0x88(%rsp), %rdi
movq 0x90(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x90(%rsp), %rax
movl 0x4(%rax), %ecx
leaq 0x941d(%rip), %rsi      # 0xd94d
movb $0x0, %al
callq 0x16f0
jmp 0x4578
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x4576
movq 0x88(%rsp), %rdi
movq 0x90(%rsp), %rax
movl 0x4(%rax), %edx
movq 0x90(%rsp), %rax
movl 0x4(%rax), %ecx
leaq 0x93f0(%rip), %rsi      # 0xd95f
movb $0x0, %al
callq 0x16f0
jmp 0x4578
jmp 0x46b7
movq 0x90(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x46b5
movq 0x88(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x90(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x38(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x40(%rsp)
movq 0x38(%rsp), %rdi
movl 0x40(%rsp), %esi
callq 0x1490
movq 0x10(%rsp), %rdi
movl %eax, %edx
leaq 0x929c(%rip), %rsi      # 0xd86a
movb $0x0, %al
callq 0x16f0
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
jne 0x4645
movq 0x88(%rsp), %rdi
leaq 0x937c(%rip), %rsi      # 0xd971
movb $0x0, %al
callq 0x16f0
movq 0x88(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x28(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x30(%rsp)
movq 0x28(%rsp), %rdi
movl 0x30(%rsp), %esi
callq 0x1490
movq 0x8(%rsp), %rdi
movl %eax, %edx
leaq 0x9345(%rip), %rsi      # 0xd981
movb $0x0, %al
callq 0x16f0
jmp 0x46b3
leaq 0x48(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x46b1
movq 0x88(%rsp), %rdi
leaq 0x932d(%rip), %rsi      # 0xd992
movb $0x0, %al
callq 0x16f0
movq 0x88(%rsp), %rax
movq %rax, (%rsp)
movq 0x90(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x18(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x20(%rsp)
movq 0x18(%rsp), %rdi
movl 0x20(%rsp), %esi
callq 0x1490
movq (%rsp), %rdi
movl %eax, %edx
leaq 0x912f(%rip), %rsi      # 0xd7d9
movb $0x0, %al
callq 0x16f0
jmp 0x46b3
jmp 0x46b5
jmp 0x46b7
jmp 0x46b9
jmp 0x46bb
movq 0x90(%rsp), %rdi
addq $0x10, %rdi
leaq 0x48(%rsp), %rsi
movl $0x40, %edx
callq 0x1120
movq 0x90(%rsp), %rax
movb $0x0, 0x50(%rax)
addq $0x98, %rsp
retq
nopw (%rax,%rax)