// File: /workspace/github_c_makefile_star2_O2/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 0x7603
cmpl $0x5, %eax
je 0x15e3
leaq 0x10(%rbp), %rdi
callq 0x7603
cmpl $0x5, %eax
jne 0x1615
movups 0x6b89(%rip), %xmm0     # 0x8173
leaq 0xaeef(%rip), %rax      # 0xc4e0
movaps %xmm0, 0x10(%rax)
movups 0x6b67(%rip), %xmm0     # 0x8163
movaps %xmm0, (%rax)
movabsq $0x64656e69666564, %rcx # imm = 0x64656E69666564
movq %rcx, 0x1f(%rax)
pushq $0x1
popq %rdi
callq 0x56c5
movq %r13, %rdi
callq 0x7603
movl %eax, %r12d
leaq 0x10(%rbp), %rdi
callq 0x7603
cmpl $0x4, %r12d
jne 0x1675
movq %r14, %rbp
movq %r14, %r12
cmpl $0x4, %eax
jne 0x1685
movups 0x6b79(%rip), %xmm0     # 0x81ba
leaq 0xad98(%rip), %rax      # 0xc3e0
movaps %xmm0, 0x30(%rax)
movups 0x6b57(%rip), %xmm0     # 0x81aa
movaps %xmm0, 0x20(%rax)
movups 0x6b3c(%rip), %xmm0     # 0x819a
movaps %xmm0, 0x10(%rax)
movups 0x6b21(%rip), %xmm0     # 0x818a
movaps %xmm0, (%rax)
xorl %eax, %eax
callq 0x5688
jmp 0x16c6
movq 0x10(%rsp), %r12
movq %rbp, %r15
cmpl $0x4, %eax
movq %r14, %rbp
jne 0x16bf
movq %r15, %r13
addq $0x10, %r13
pushq $0x1
popq %rsi
movq %r13, %rdi
callq 0x1756
cmpl $0x1, %eax
movq 0x8(%rsp), %r14
je 0x1708
cmpl $0x4, %eax
jne 0x16cd
leaq 0x6b2d(%rip), %rsi      # 0x81da
movq %r14, %rdi
movq %r12, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x14e8
jmp 0x1708
leaq 0xaaba(%rip), %r13      # 0xc180
movq 0x8(%rsp), %r14
jmp 0x1708
leaq 0x6b15(%rip), %rsi      # 0x81e9
movq %r14, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0x14e8
leaq 0x6b0e(%rip), %rsi      # 0x81f5
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x14e8
leaq 0x6b08(%rip), %rsi      # 0x8203
movq %r14, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x14e8
leaq 0x6abb(%rip), %rsi      # 0x81ca
movq %r14, %rdi
movq 0x10(%rsp), %rcx
movq %rcx, %rdx
movq %rbp, %r8
xorl %eax, %eax
callq 0x14e8
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