very fast read-writes to port / pin

Just wanted to correct something for you. You are declaring "byte x" twice, so your code will never work. In fact you do not need the byte at all, your "data_in" can be as simple as this:

void data_in()
{
  if (PINB & B00000100) bitSet(PORTD, 5);
  else bitClear(PORTD, 5);
}