How can i squeeze my code into a ATTiny 2313

Check the datasheet for the 2313:

https://cdn.solarbotics.com/products/datasheets/doc2543.pdf

2K flash, 128 bytes of RAM. You simply have far more program than microcontroller here.