Optimization. How to use bootloader UART code from the main program?

You can always program your code with an ISP programmer and remove the bootloader entirely, then there will be no duplication of code.