merged EmitBranch to single local static function