Super High Performance Pin I/O Technique

void setup() 
{
  PIND = 0b00000100; // toggle D2 by writing to the input register.
  PORTD = 0b00000100;
  DDRD = 0b00000100;
}

void loop() {
  // put your main code here, to run repeatedly:

}
000000a6 <setup>:
  a6:	84 e0       	ldi	r24, 0x04	; 4
  a8:	89 b9       	out	0x09, r24	; 9
  aa:	8b b9       	out	0x0b, r24	; 11
  ac:	8a b9       	out	0x0a, r24	; 10
  ae:	08 95       	ret

Load Immediate to get the 0b00000100 value into a register (r24) followed by an Out Port to write the value to an I/O port. Two machine instructions (or one if a register already has the value to be written).