Value appears to change sign suddenly When slot == SLOT_1 is true, speed_value is positive but when slot == SLOT_2 is true, speed_value becomes negative.

I printed the value of speed_value immediately after the statement speed_value = -speed_value and it shows a positive number. How did speed_value changed sign when it enters the slot == SLOT_2 argument?

case ENCODER_BOARD:
  if(port == 0)
  {
    uint8_t slot = readBuffer(7);
    int16_t speed_value = readShort(8);
    speed_value = -speed_value;

    if(slot == SLOT_1)
    {
      Encoder_1.setTarPWM(speed_value);
    }
    else if(slot == SLOT_2)
    {
      Encoder_2.setTarPWM(speed_value);
    }
    else if(slot == SLOT_3)
    {
      Encoder_3.setTarPWM(speed_value);
    }
    else if(slot == SLOT_4)
    {
      Encoder_4.setTarPWM(speed_value);
    }
  }

int16_t readShort(int16_t idx)
{
  valShort.byteVal[0] = readBuffer(idx);
  valShort.byteVal[1] = readBuffer(idx+1);
  return valShort.shortVal; 
}

uint8_t readBuffer(int16_t index)
{
  if(BluetoothSource == DATA_SERIAL)
  {
    return buffer[index];
  }
  else if(BluetoothSource == DATA_SERIAL2)
  {
    return bufferBt1[index];
  }
  else if(BluetoothSource == DATA_SERIAL3)
  {
    return bufferBt2[index];
  }
}


All the code are taken from here and I am not the owner. I myself still studying how these whole code works. I am hoping someone out there who have experience with these kind of implementations be able to help me out.
I think I understand what's going on from here. That's why speed_value appears to change sign suddenly when entering the if...else... statement. But why speed_value == -speed_value is necessary is yet to be answered.