Assert that IR blocks originating from the frontend do not have nonsensical structure.

    Args:
        ir_blocks: list of BasicBlocks representing the IR to sanity-check

    Raises:
        AssertionError, if the IR has unexpected structure. If the IR produced by the front-end
        cannot be successfully and correctly used to generate MATCH or Gremlin due to a bug,
        this is the method that should catch the problem.

def sanity_check_ir_blocks_from_frontend(ir_blocks, query_metadata_table):
    """Assert that IR blocks originating from the frontend do not have nonsensical structure.

    Args:
        ir_blocks: list of BasicBlocks representing the IR to sanity-check

    Raises:
        AssertionError, if the IR has unexpected structure. If the IR produced by the front-end
        cannot be successfully and correctly used to generate MATCH or Gremlin due to a bug,
        this is the method that should catch the problem.
    """
    if not ir_blocks:
        raise AssertionError(u'Received no ir_blocks: {}'.format(ir_blocks))

    _sanity_check_fold_scope_locations_are_unique(ir_blocks)
    _sanity_check_no_nested_folds(ir_blocks)
    _sanity_check_query_root_block(ir_blocks)
    _sanity_check_output_source_follower_blocks(ir_blocks)
    _sanity_check_block_pairwise_constraints(ir_blocks)
    _sanity_check_mark_location_preceding_optional_traverse(ir_blocks)
    _sanity_check_every_location_is_marked(ir_blocks)
    _sanity_check_coerce_type_outside_of_fold(ir_blocks)
    _sanity_check_all_marked_locations_are_registered(ir_blocks, query_metadata_table)
    _sanity_check_registered_locations_parent_locations(query_metadata_table)