Hello Imspiderman!
B would make the most sense.
A along with C makes absolutely no sense. The words almost and had is showing and indicating ensurity or that something already happened. The sentence is furthermore about a nonexistent (aka something that didn't happen), yet would have happened if it did exist (hence the ifs), past (hence the past tense words taken, had, failed, and did) scenario.
D: He could failed is not proper grammar and very choppy opposed to being fluent and coherent (which sentences are supposed to be).