The clown is the mastermind.
Ace Attorney: Miles Edgeworth Investigations 2
The 9 is actually a q and your childhood friend is 0/10
You are a cat and the dog is the tutorial guy
The detective was the mastermind all long
The prosecutor was the killer
The prosecutor still has the bullet in his shoulder (holy shit why are prosecutors or their friends always the bad guys in those games)
The first boss enemy that you fight, the warrior in a heavy robe with the face hidden, is you from the future. Your actions pretty much fucked over the world, so you got yourself sent back in time to stop your past self, but you were too weak to do so.
No it's not DMC3 even though it's similar.
It's AAI2, pic related.