// File: /workspace/github_c_makefile_star2_O1/been-jamming[P]MinimalCC/expression.c
// Function: operation_add_func
void operation_add_func(char *reg_a, char *reg_b, value *value_a, value *value_b, FILE *output_file, type *output_type){
	value *pointer_value;
	char *integer_reg;
	unsigned int pointer_size;

	if(peek_type(&(value_a->data_type)) == type_function || peek_type(&(value_b->data_type)) == type_function){
		snprintf(error_message, sizeof(error_message), "Addition of function type is undefined");
		do_error(1);
	}
	if(peek_type(&(value_a->data_type)) == type_pointer){
		if(peek_type(&(value_b->data_type)) == type_pointer){
			snprintf(warning_message, sizeof(warning_message), "Adding two pointers together. Treating them as integers instead");
			do_warning();
			fileprint(output_file, "add %s, %s, %s\n", reg_a, reg_a, reg_b);
			*output_type = value_a->data_type;
			return;
		}
		pointer_value = value_a;
		integer_reg = reg_b;
	} else {
		if(peek_type(&(value_b->data_type)) == type_pointer){
			pointer_value = value_b;
			integer_reg = reg_a;
		} else {
			fileprint(output_file, "add %s, %s, %s\n", reg_a, reg_a, reg_b);
			*output_type = INT_TYPE;
			return;
		}
	}
	pointer_size = type_size(&(pointer_value->data_type), 1);
	if(pointer_size == 4){
		fileprint(output_file, "sll %s, %s, 2\n", integer_reg, integer_reg);
	} else if(pointer_size != 1){
		fileprint(output_file, "li $t2, %d\n", pointer_size);
		fileprint(output_file, "mult %s, $t2\n", integer_reg);
		fileprint(output_file, "mflo %s\n", integer_reg);
	}
	fileprint(output_file, "add %s, %s, %s\n", reg_a, reg_a, reg_b);

	*output_type = pointer_value->data_type;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, %rbx
movq %r8, 0x8(%rsp)
movq %rcx, %rbp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, 0x10(%rsp)
leaq 0x10(%rdx), %r13
movq %r13, %rdi
callq 0x7a61
cmpl $0x5, %eax
je 0x180d
leaq 0x10(%rbp), %rdi
callq 0x7a61
cmpl $0x5, %eax
jne 0x1841
movups 0x797f(%rip), %xmm0     # 0x9193
leaq 0xbcc5(%rip), %rax      # 0xd4e0
movaps %xmm0, 0x10(%rax)
movups 0x795d(%rip), %xmm0     # 0x9183
movaps %xmm0, (%rax)
movabsq $0x64656e69666564, %rcx # imm = 0x64656E69666564
movq %rcx, 0x1f(%rax)
movl $0x1, %edi
callq 0x5ae0
movq %r13, %rdi
callq 0x7a61
movl %eax, %r12d
leaq 0x10(%rbp), %rdi
callq 0x7a61
cmpl $0x4, %r12d
jne 0x18a1
movq %r14, %rbp
movq %r14, %r12
cmpl $0x4, %eax
jne 0x18b1
movups 0x796d(%rip), %xmm0     # 0x91da
leaq 0xbb6c(%rip), %rax      # 0xd3e0
movaps %xmm0, 0x30(%rax)
movups 0x794b(%rip), %xmm0     # 0x91ca
movaps %xmm0, 0x20(%rax)
movups 0x7930(%rip), %xmm0     # 0x91ba
movaps %xmm0, 0x10(%rax)
movups 0x7915(%rip), %xmm0     # 0x91aa
movaps %xmm0, (%rax)
xorl %eax, %eax
callq 0x5ac8
jmp 0x18f4
movq 0x10(%rsp), %r12
movq %rbp, %r15
cmpl $0x4, %eax
movq %r14, %rbp
jne 0x18ed
movq %r15, %r13
addq $0x10, %r13
movq %r13, %rdi
movl $0x1, %esi
callq 0x1984
cmpl $0x1, %eax
movq 0x8(%rsp), %r14
je 0x1936
cmpl $0x4, %eax
jne 0x18fb
leaq 0x791f(%rip), %rsi      # 0x91fa
movq %r14, %rdi
movq %r12, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x1710
jmp 0x1936
leaq 0xb88c(%rip), %r13      # 0xd180
movq 0x8(%rsp), %r14
jmp 0x1936
leaq 0x7907(%rip), %rsi      # 0x9209
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x1710
leaq 0x7900(%rip), %rsi      # 0x9215
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1710
leaq 0x78fa(%rip), %rsi      # 0x9223
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x1710
leaq 0x78ad(%rip), %rsi      # 0x91ea
movq %r14, %rdi
movq 0x10(%rsp), %rcx
movq %rcx, %rdx
movq %rbp, %r8
xorl %eax, %eax
callq 0x1710
movups (%r13), %xmm0
movups 0x10(%r13), %xmm1
movups 0x20(%r13), %xmm2
movups 0x30(%r13), %xmm3
movups %xmm3, 0x30(%rbx)
movups %xmm2, 0x20(%rbx)
movups %xmm1, 0x10(%rbx)
movups %xmm0, (%rbx)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq