// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq %rsi, 0x38(%rsp)
movq %rdx, 0x30(%rsp)
movq %rcx, 0x28(%rsp)
movq %r8, 0x20(%rsp)
movq %r9, 0x18(%rsp)
movq 0x30(%rsp), %rdi
addq $0x10, %rdi
callq 0xbdb0
cmpl $0x5, %eax
je 0x1848
movq 0x28(%rsp), %rdi
addq $0x10, %rdi
callq 0xbdb0
cmpl $0x5, %eax
jne 0x186c
leaq 0xfce1(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0xbb2c(%rip), %rdx      # 0xd387
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
movq 0x30(%rsp), %rdi
addq $0x10, %rdi
callq 0xbdb0
cmpl $0x4, %eax
jne 0x190c
movq 0x28(%rsp), %rdi
addq $0x10, %rdi
callq 0xbdb0
cmpl $0x4, %eax
jne 0x18f6
leaq 0xfb93(%rip), %rdi      # 0x11430
movl $0x100, %esi            # imm = 0x100
leaq 0xbb05(%rip), %rdx      # 0xd3ae
movb $0x0, %al
callq 0x10b0
movb $0x0, %al
callq 0x8770
movq 0x20(%rsp), %rdi
movq 0x40(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %r8
leaq 0xbb1c(%rip), %rsi      # 0xd3ee
movb $0x0, %al
callq 0x16f0
movq 0x18(%rsp), %rdi
movq 0x30(%rsp), %rsi
addq $0x10, %rsi
movl $0x40, %edx
callq 0x1120
jmp 0x1a3b
movq 0x30(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x1974
movq 0x28(%rsp), %rdi
addq $0x10, %rdi
callq 0xbdb0
cmpl $0x4, %eax
jne 0x1935
movq 0x28(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x8(%rsp)
jmp 0x1972
movq 0x20(%rsp), %rdi
movq 0x40(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %r8
leaq 0xba9e(%rip), %rsi      # 0xd3ee
movb $0x0, %al
callq 0x16f0
movq 0x18(%rsp), %rdi
leaq 0xf865(%rip), %rsi      # 0x111c8
movl $0x40, %edx
callq 0x1120
jmp 0x1a3b
jmp 0x1974
movq 0x10(%rsp), %rdi
addq $0x10, %rdi
movl $0x1, %esi
callq 0x1a40
movl %eax, 0x4(%rsp)
cmpl $0x4, 0x4(%rsp)
jne 0x19b1
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rdx
movq 0x8(%rsp), %rcx
leaq 0xba56(%rip), %rsi      # 0xd3fe
movb $0x0, %al
callq 0x16f0
jmp 0x1a01
cmpl $0x1, 0x4(%rsp)
je 0x19ff
movq 0x20(%rsp), %rdi
movl 0x4(%rsp), %edx
leaq 0xba45(%rip), %rsi      # 0xd40d
movb $0x0, %al
callq 0x16f0
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0xba39(%rip), %rsi      # 0xd419
movb $0x0, %al
callq 0x16f0
movq 0x20(%rsp), %rdi
movq 0x8(%rsp), %rdx
leaq 0xba2f(%rip), %rsi      # 0xd427
movb $0x0, %al
callq 0x16f0
jmp 0x1a01
movq 0x20(%rsp), %rdi
movq 0x40(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x38(%rsp), %r8
leaq 0xb9d2(%rip), %rsi      # 0xd3ee
movb $0x0, %al
callq 0x16f0
movq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
addq $0x10, %rsi
movl $0x40, %edx
callq 0x1120
addq $0x48, %rsp
retq