// File: /workspace/github_c_makefile_star2_O3/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 0x7a9c
cmpl $0x5, %eax
je 0x1819
leaq 0x10(%rbp), %rdi
callq 0x7a9c
cmpl $0x5, %eax
jne 0x184d
movups 0x7973(%rip), %xmm0     # 0x9193
leaq 0xbcb9(%rip), %rax      # 0xd4e0
movaps %xmm0, 0x10(%rax)
movups 0x7951(%rip), %xmm0     # 0x9183
movaps %xmm0, (%rax)
movabsq $0x64656e69666564, %rcx # imm = 0x64656E69666564
movq %rcx, 0x1f(%rax)
movl $0x1, %edi
callq 0x5b10
movq %r13, %rdi
callq 0x7a9c
movl %eax, %r12d
leaq 0x10(%rbp), %rdi
callq 0x7a9c
cmpl $0x4, %r12d
jne 0x18ad
movq %r14, %rbp
movq %r14, %r12
cmpl $0x4, %eax
jne 0x18bd
movups 0x7961(%rip), %xmm0     # 0x91da
leaq 0xbb60(%rip), %rax      # 0xd3e0
movaps %xmm0, 0x30(%rax)
movups 0x793f(%rip), %xmm0     # 0x91ca
movaps %xmm0, 0x20(%rax)
movups 0x7924(%rip), %xmm0     # 0x91ba
movaps %xmm0, 0x10(%rax)
movups 0x7909(%rip), %xmm0     # 0x91aa
movaps %xmm0, (%rax)
xorl %eax, %eax
callq 0x5af8
jmp 0x1900
movq 0x10(%rsp), %r12
movq %rbp, %r15
cmpl $0x4, %eax
movq %r14, %rbp
jne 0x18f9
movq %r15, %r13
addq $0x10, %r13
movq %r13, %rdi
movl $0x1, %esi
callq 0x1990
cmpl $0x1, %eax
movq 0x8(%rsp), %r14
je 0x1942
cmpl $0x4, %eax
jne 0x1907
leaq 0x7913(%rip), %rsi      # 0x91fa
movq %r14, %rdi
movq %r12, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x171c
jmp 0x1942
leaq 0xb880(%rip), %r13      # 0xd180
movq 0x8(%rsp), %r14
jmp 0x1942
leaq 0x78fb(%rip), %rsi      # 0x9209
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x171c
leaq 0x78f4(%rip), %rsi      # 0x9215
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x171c
leaq 0x78ee(%rip), %rsi      # 0x9223
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x171c
leaq 0x78a1(%rip), %rsi      # 0x91ea
movq %r14, %rdi
movq 0x10(%rsp), %rcx
movq %rcx, %rdx
movq %rbp, %r8
xorl %eax, %eax
callq 0x171c
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