An engineer's job is to either find solutions to problems, or remove the problem.
You're in a situation where your engineer colleague is the problem.
For readers who aren't into software engineering: it's pretty bad.
Shoving all the C++ files into one huge blob has its uses. I've used it for small microcontroller code when I needed the optimizations. It can also be used for large applications, but that would only be for very performance-critical stuff like games. If you use llvm and clang, you can apply whole-program optimization if you set the options right. This involves compiling each source file into llvm bytecode (not machine code) then deferring the "llvm to machine code" translation after linkage, which allows an optimization pass on the whole program. But llvm/clang is not always as good as the other compilers, although sometimes it is better, so there is a trade-off. It could work, or not.
This is what your colleague should have told you: an explanation of why he chose this particular solution, which comes with its own set of compromises. Something like "Yeah, it sucks on (whatever), but it's really good on (whatever) so I think it's a good compromise."
Maybe you'd have agreed, if he had explained... But he did not!
In your case, I'd view this guy's approach as very suspicious.
In that moment he just immediately came over to my desk and repeatedly asked me like "So show me, c'mon show me what you have done" in a very pushy way.
By making a criticism, you questioned his position as leader (ie, alpha male). So he went into monkey mode and asserted dominance by humiliating you. Next time he does that, please visualize this picture:
Because this is exactly what happened.
having Asperger's makes me having trouble understanding others motivations, thoughts, and interests, as far they differ from mine. That means, to understand actions of someone I need to understand that person's motivations
OK, so I hope this helps understanding why he did that. It's a power/domination game, basically animal instincts. As I said in another post, we're all evolved monkeys, and sometimes it shows.
So, you should not interpret all the insults he threw at you, criticizing your performance etc, as literal. In fact, when he does that, visualize the thumping monkey, and replace every word that comes out of his mouth by "My authority is questioned! Must... assert... dominant... position... Onk! Onk!"
I started feeling VERY insecure and wasn't able to explain anything.
Insulting someone with Aspergers is extra cruel since they have trouble processing it.
I would take pleasure in firing this guy ;) In fact, I've fired people like that.
When you tell an engineer "are you sure this is the best way to do it" they should react on the lines of "hey, maybe there's a better way and we can improve the thingie." That's if they're good. In this guy's case, pride and short temper get in the way. He may favor bad solutions because they're his solutions and he's too proud to consider others.
Now, how to give him constructive criticism:
Feed him the feedback sandwich. Another example. Use Gordon's method and rephrase as "I..." instead of "You..."
Like: "I'm interested to know why you chose this solution, I'm sure I missed some of the advantages of this." instead of "Why did you do it like that?"
This does not work on everyone. Some people can handle criticism just fine and will tell you to cut the crap halfway through the first layer of sugar-coating, and that's excellent. Your colleague does not seem to be like that however.
He also probably needs a reminder about your condition, perhaps you can find an online guide about "how to handle people with Asperger's" and suggest he read it.
EDIT -- now taking into account the new info, and the old info I hadn't noticed.
He's the only developer in a largish company (~300 people). "That guy is crucial, he is the only one knowing how to code C except for me, and he is one of the most senior employees (...) they simply couldn't fire the only one being able to maintain productive code."
Translation: the manager allowed this guy to dig himself in like a barnacle and become irremovable. If this guy gets run over by a bus or is unable to work for an extended time, the whole company will be in deep shit. If they can hire 300 people, they could have hired a backup plan. Your manager is, thus, an idiot.
You're probably that backup plan, but you should have been hired much earlier, before that guy became "crucial". In this case you wouldn't have been a threat to his dominant position, because he wouldn't have been in a dominant position yet. But right now, I'd bet he knows that if he lets you master the code base, then you can eventually replace him... So it's in his own interest to get you out of the way.
It doesn't matter that you're a nice guy and not interested in stealing his job: when management gets tired of his antics, if you can replace him they will make you an offer.
If you agree this is true (I could've missed the point) then you need another job, because even if he's not an asshole, he has a strong incentive to get rid of you.
Now, let's try to enter this guy's state of mind, ie his "frame". A bit like writing a character description, but in first person:
"I'm so awesome! The whole company's future rests only on me! They respect me, beg me for help, and when my shitty code crashes and I fix it, they look up to me like a God!"
Positive I.D. confirmed... beep... zoom in... snapshot:
...complete with a skull on a stick. It would be better with flames coming out of the eyes, but this one will do for now.
The fact he's into power/domination games and humiliated you gives me a hunch that he knows very well that you're a threat to his dominant position. At first I attributed this to his short temper and your attempt at criticism, but I had missed the fact that he's in the perfect position to develop a Lone Superhero Syndrome.
I mean, if he was a mildly awkward geek like James Damore, it would be believable that he's in it for the thrill of coding and really wouldn't mind the help... but somehow that doesn't feel right.
And I just yelled "You really offend me like this and then just call it a day?" what he simply responded to with "Yes, I do."
Now, this is a very valuable nugget of information that I had missed. I wonder if he sounded like he was gloating?
If he was in monkey mode as I first thought, controlled by anger and primal urges, then he'd probably have replied something more emotional like "Go f- yourself" and slammed the door. But this "Yes, I do" is quite a witty line to pull in such circumstances. This hints of him being either such a professional asshole that he can stay witty even when angry (ie, bad) or it would hint that he wasn't really angry and still in control (ie, worse for you).
I know this line, because I like to use it when I really want to be a total asshole. It works very well, but it's like a weapon of mass destruction. Basically it means "I don't give a shit what you feel because you don't exist." Which, I'm sure you reckon, isn't something you say unless you're absolutely sure the person in front of you really deserves it, and you got no plans to be buddies in any kind of future or alternate dimensions...
Anyway, back to your case.
I'm gonna go out on a limb here, wild hypothesis, might be wrong, but I'll attempt it anyway. I'll characterize this guy as a high-level narcissist. I don't know if you know how a narcissist works, so I'm gonna illustrate, just in case. Also I'm having way too much fun writing this.
We all live inside our own movie which can be called a frame, this is the way we perceive reality. Call it a set of axioms that we take for granted and which govern the way we think. Look at a conservative: Trump is a jolly good fellow! Look at a liberal: Trump is a nazi! Same reality, different perceptions. Reality would be like: Trump is Trump, like an elementary particle, if you can figure out where he stands by reading his tweets, you violated the Heisenberg Uncertainty Principle and get Nobel prize, good for you!
So, frame influences what details are ignored or processed by our minds, it also influences how we react to real events. Since you're an aspie, I go by the assumption that your frame is very different from mine. So we probably interpret reality in different ways. Everyone does, it's fine.
Back to the issue: what is the frame of a narcissist? Well, it's basically this:
Damn! Still no flames coming out of the eyes.
So, a Narcissist sits on his throne, and his legions of worthless minions grovel at his feet. This is his reality: in his own movie, he's the hero, and everyone else is that secondary character who dies throwing themselves in front of a bullet aimed at the hero in chapter two.
For once, I'm not exaggerating. Some people are really like that. I'm not sure your colleague is, but think about what being the only developer in a 300+ people company will do to someone with an overinflated ego to begin with, over the years... scary!
When you criticize a Narcissist, perhaps you think you are making a simple constructive criticism, but what you are really doing is challenging their world view. In their movie, they're the hero. They're fucking Superman. So you step in and hint that Superman might, kinda, sometimes, be wrong.
This makes a Narcissistic brain short-circuit. That guy has two options: either acknowledge he's wrong, or get rid of you. His brain will choose the easier way out, and that is always the second option, because in his own frame, a Narcissist is never wrong. If he could be wrong, he wouldn't be a narcissist...
At this point I'll just quote wikipedia:
Narcissistic individuals use various strategies to protect the self at the expense of others. They tend to devalue, derogate, insult and blame others, and they often respond to threatening feedback with anger and hostility.
Sounds like "boom headshot" doesn't it.
Now... another feature of the Narcissist is that you're his buddy. He'll be super friendly (at first, before he destroys you). In fact, you'll think he's awesome... because he wants you to think he's awesome!
So here's my assessment:
Get another job.
In the interview for your next job, when they ask about your past experiences, mention that you were in a large company with only one person in charge of IT, and how crazy and illogical this sounds. Tell them the truth, you can use every word I wrote above also, it's meant to help you.