// File: /workspace/github_c_makefile_star2_O0/been-jamming[P]MinimalCC/expression.c
// Function: compile_operation
void compile_operation(value *first_value, value *next_value, operation op, FILE *output_file){
	char reg0_str_buffer[5] = {0, 0, 0, 0, 0};
	char reg1_str_buffer[5] = {0, 0, 0, 0, 0};
	char *reg0_str = "";
	char *reg1_str = "";
	type output_type;

	if(types_equal(&(first_value->data_type), &VOID_TYPE) || types_equal(&(next_value->data_type), &VOID_TYPE)){
		snprintf(error_message, sizeof(error_message), "Can't operate on void value");
		do_error(1);
	}

	if(first_value->data.type == data_register){
		snprintf(reg0_str_buffer, sizeof(reg0_str_buffer)/sizeof(char), "$s%d", first_value->data.reg);
		reg0_str = reg0_str_buffer;
	} else if(first_value->data.type == data_stack){
		reg0_str = "$t0";
		if(type_size(&(first_value->data_type), 0) == 4){
			fileprint(output_file, "lw $t0, %d($sp)\n", get_stack_pos(first_value->data));
		} else if(type_size(&(first_value->data_type), 0) == 1){
			fileprint(output_file, "lb $t0, %d($sp)\n", get_stack_pos(first_value->data));
		} else {
			snprintf(error_message, sizeof(error_message), "[INTERNAL] Unusable type size %d", type_size(&(first_value->data_type), 0));
			do_error(1);
		}
	}
	if(next_value->data.type == data_register){
		snprintf(reg1_str_buffer, sizeof(reg1_str_buffer)/sizeof(char), "$s%d", next_value->data.reg);
		reg1_str = reg1_str_buffer;
	} else if(next_value->data.type == data_stack){
		reg1_str = "$t1";
		if(type_size(&(next_value->data_type), 0) == 4){
			fileprint(output_file, "lw $t1, %d($sp)\n", get_stack_pos(next_value->data));
		} else if(type_size(&(next_value->data_type), 0) == 1){
			fileprint(output_file, "lb $t1, %d($sp)\n", get_stack_pos(next_value->data));
		} else {
			snprintf(error_message, sizeof(error_message), "[INTERNAL] Unusable type size %d", type_size(&(next_value->data_type), 0));
			do_error(1);
		}
	}
	operation_functions[op](reg0_str, reg1_str, first_value, next_value, output_file, &output_type);
	deallocate(next_value->data);
	if(first_value->data.type == data_stack){
		if(type_size(&output_type, 0) == 4){
			fileprint(output_file, "sw $t0, %d($sp)\n", get_stack_pos(first_value->data));
		} else if(type_size(&output_type, 0) == 1){
			fileprint(output_file, "sb $t0, %d($sp)\n", get_stack_pos(first_value->data));
		} else {
			snprintf(error_message, sizeof(error_message), "[INTERNAL] Unusable type size %d", type_size(&output_type, 0));
			do_error(1);
		}
	}
	first_value->data_type = output_type;
	first_value->is_reference = 0;
}

// Assembly:
subq $0x128, %rsp            # imm = 0x128
movq %rdi, 0x120(%rsp)
movq %rsi, 0x118(%rsp)
movl %edx, 0x114(%rsp)
movq %rcx, 0x108(%rsp)
leaq 0x103(%rsp), %rdi
xorl %esi, %esi
movl $0x5, %edx
callq 0x10c0
leaq 0xfe(%rsp), %rdi
xorl %esi, %esi
movl $0x5, %edx
callq 0x10c0
leaq 0x624e(%rip), %rax      # 0xda03
movq %rax, 0xf0(%rsp)
leaq 0x623f(%rip), %rax      # 0xda03
movq %rax, 0xe8(%rsp)
movq 0x120(%rsp), %rdi
addq $0x10, %rdi
leaq 0x9a29(%rip), %rsi      # 0x11208
callq 0xbec0
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x780c
movq 0x118(%rsp), %rdi
addq $0x10, %rdi
leaq 0x9a09(%rip), %rsi      # 0x11208
callq 0xbec0
movzbl %al, %eax
cmpl $0x0, %eax
je 0x7830
leaq 0x9d1d(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x6492(%rip), %rdx      # 0xdcb1
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
movq 0x120(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x7878
leaq 0x103(%rsp), %rdi
movq 0x120(%rsp), %rax
movl 0x4(%rax), %ecx
movl $0x5, %esi
leaq 0x6471(%rip), %rdx      # 0xdccd
movb $0x0, %al
callq 0x10b0
leaq 0x103(%rsp), %rax
movq %rax, 0xf0(%rsp)
jmp 0x79b4
movq 0x120(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x79b2
leaq 0x6442(%rip), %rax      # 0xdcd2
movq %rax, 0xf0(%rsp)
movq 0x120(%rsp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x7908
movq 0x108(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x120(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x98(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0xa0(%rsp)
movq 0x98(%rsp), %rdi
movl 0xa0(%rsp), %esi
callq 0x1490
movq 0x30(%rsp), %rdi
movl %eax, %edx
leaq 0x5f6e(%rip), %rsi      # 0xd86a
movb $0x0, %al
callq 0x16f0
jmp 0x79b0
movq 0x120(%rsp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
jne 0x7975
movq 0x108(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x120(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x88(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x90(%rsp)
movq 0x88(%rsp), %rdi
movl 0x90(%rsp), %esi
callq 0x1490
movq 0x28(%rsp), %rdi
movl %eax, %edx
leaq 0x5f33(%rip), %rsi      # 0xd89f
movb $0x0, %al
callq 0x16f0
jmp 0x79ae
movq 0x120(%rsp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x1a40
movl %eax, %ecx
leaq 0x9b9f(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x6339(%rip), %rdx      # 0xdcd6
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
jmp 0x79b0
jmp 0x79b2
jmp 0x79b4
movq 0x118(%rsp), %rax
cmpl $0x0, (%rax)
jne 0x79fc
leaq 0xfe(%rsp), %rdi
movq 0x118(%rsp), %rax
movl 0x4(%rax), %ecx
movl $0x5, %esi
leaq 0x62ed(%rip), %rdx      # 0xdccd
movb $0x0, %al
callq 0x10b0
leaq 0xfe(%rsp), %rax
movq %rax, 0xe8(%rsp)
jmp 0x7b26
movq 0x118(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x7b24
leaq 0x62e3(%rip), %rax      # 0xdcf7
movq %rax, 0xe8(%rsp)
movq 0x118(%rsp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x7a86
movq 0x108(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x118(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x78(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x80(%rsp)
movq 0x78(%rsp), %rdi
movl 0x80(%rsp), %esi
callq 0x1490
movq 0x20(%rsp), %rdi
movl %eax, %edx
leaq 0x6051(%rip), %rsi      # 0xdacb
movb $0x0, %al
callq 0x16f0
jmp 0x7b22
movq 0x118(%rsp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
jne 0x7ae7
movq 0x108(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x118(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x68(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x70(%rsp)
movq 0x68(%rsp), %rdi
movl 0x70(%rsp), %esi
callq 0x1490
movq 0x18(%rsp), %rdi
movl %eax, %edx
leaq 0x621d(%rip), %rsi      # 0xdcfb
movb $0x0, %al
callq 0x16f0
jmp 0x7b20
movq 0x118(%rsp), %rdi
addq $0x10, %rdi
xorl %esi, %esi
callq 0x1a40
movl %eax, %ecx
leaq 0x9a2d(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x61c7(%rip), %rdx      # 0xdcd6
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
jmp 0x7b22
jmp 0x7b24
jmp 0x7b26
movl 0x114(%rsp), %eax
movl %eax, %ecx
leaq 0x959a(%rip), %rax      # 0x110d0
movq (%rax,%rcx,8), %rax
movq 0xf0(%rsp), %rdi
movq 0xe8(%rsp), %rsi
movq 0x120(%rsp), %rdx
movq 0x118(%rsp), %rcx
movq 0x108(%rsp), %r8
leaq 0xa8(%rsp), %r9
callq *%rax
movq 0x118(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x58(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x60(%rsp)
movq 0x58(%rsp), %rdi
movl 0x60(%rsp), %esi
callq 0x13b0
movq 0x120(%rsp), %rax
cmpl $0x1, (%rax)
jne 0x7c98
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x4, %eax
jne 0x7c02
movq 0x108(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x120(%rsp), %rax
movq (%rax), %rcx
movq %rcx, 0x48(%rsp)
movl 0x8(%rax), %eax
movl %eax, 0x50(%rsp)
movq 0x48(%rsp), %rdi
movl 0x50(%rsp), %esi
callq 0x1490
movq 0x10(%rsp), %rdi
movl %eax, %edx
leaq 0x5be3(%rip), %rsi      # 0xd7d9
movb $0x0, %al
callq 0x16f0
jmp 0x7c96
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
cmpl $0x1, %eax
jne 0x7c5f
movq 0x108(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x120(%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 0x8(%rsp), %rdi
movl %eax, %edx
leaq 0x5d2b(%rip), %rsi      # 0xd981
movb $0x0, %al
callq 0x16f0
jmp 0x7c94
leaq 0xa8(%rsp), %rdi
xorl %esi, %esi
callq 0x1a40
movl %eax, %ecx
leaq 0x98b9(%rip), %rdi      # 0x11530
movl $0x100, %esi            # imm = 0x100
leaq 0x6053(%rip), %rdx      # 0xdcd6
movb $0x0, %al
callq 0x10b0
movl $0x1, %edi
callq 0x87b0
jmp 0x7c96
jmp 0x7c98
movq 0x120(%rsp), %rdi
addq $0x10, %rdi
leaq 0xa8(%rsp), %rsi
movl $0x40, %edx
callq 0x1120
movq 0x120(%rsp), %rax
movb $0x0, 0x50(%rax)
addq $0x128, %rsp            # imm = 0x128
retq
nopw (%rax,%rax)