seriously need help i am stumped and need other opinions

Alright so I got a 2000 celica gts I just bought a few months ago, the guy I bought it off of thought it had a blown head gasket but it didn't just air in the lines, and it was out of time so I got the air out of the lines and timed it, and started it up and then there's this ticking/knocking noise coming from the top of the motor and I've already checked the rod caps and everything and there fine, I know its not bottom end, oh yeah and its back firing through the Intake you can hear it, like someone is playing a drum or something, I thought it was a bent valve so I took a sheet of paper and held it to the tail pipe to see if it would suck in, and it didn't and me being aggravated about not being able to figure it out I started it up and slowly pushed the throttle in till I finally hit the rev limiter and nothing, now I'm not stupid if it had a bent valve by me doing this it would of messed a lot up and sounded even worse and it didn't, oh yeah and once it hits operating temperature it dies and won't start back up till it cools off, and you can turn either the a/c or heat on and the rpms will drop to the point it almost dies...I don't understand any of this, I'm pretty sure it needs a tune up but I seriously doubt it would cause all that...I kinda wonder if the wrong gas was put in it and it ain't got enough octane but Idk what it would even act like if it didn't have enough honestly, but yet it still has power, Idk someone help me!