See the AVR assembly output from the IDE

MiniCore includes the version of optiboot that allows you to write to flash and supports the ATmega328P: