Refactored codegen_cond using pattern matching.