static void crs_replace_with_free_ranges(GPtrArray *ranges,

                                         uint64_t start, uint64_t end)

{

    GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free);

    uint64_t free_base = start;

    int i;



    g_ptr_array_sort(ranges, crs_range_compare);

    for (i = 0; i < ranges->len; i++) {

        CrsRangeEntry *used = g_ptr_array_index(ranges, i);



        if (free_base < used->base) {

            crs_range_insert(free_ranges, free_base, used->base - 1);

        }



        free_base = used->limit + 1;

    }



    if (free_base < end) {

        crs_range_insert(free_ranges, free_base, end);

    }



    g_ptr_array_set_size(ranges, 0);

    for (i = 0; i < free_ranges->len; i++) {

        g_ptr_array_add(ranges, g_ptr_array_index(free_ranges, i));

    }



    g_ptr_array_free(free_ranges, false);

}

static void crs_replace_with_free_ranges(GPtrArray *ranges,

                                         uint64_t start, uint64_t end)

{

    GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free);

    uint64_t free_base = start;

    int i;



    g_ptr_array_sort(ranges, crs_range_compare);

    for (i = 0; i < ranges->len; i++) {

        CrsRangeEntry *used = g_ptr_array_index(ranges, i);



        if (free_base < used->base) {

            crs_range_insert(free_ranges, free_base, used->base - 1);

        }



        free_base = used->limit + 1;

    }



    if (free_base < end) {

        crs_range_insert(free_ranges, free_base, end);

    }



    g_ptr_array_set_size(ranges, 0);

    for (i = 0; i < free_ranges->len; i++) {

        g_ptr_array_add(ranges, g_ptr_array_index(free_ranges, i));

    }



    g_ptr_array_free(free_ranges, false);

}

    GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free);     g_ptr_array_free(free_ranges, false);
static void FUNC_0(GPtrArray *VAR_0,

                                         uint64_t VAR_1, uint64_t VAR_2)

{

    GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free);

    uint64_t free_base = VAR_1;

    int VAR_3;



    g_ptr_array_sort(VAR_0, crs_range_compare);

    for (VAR_3 = 0; VAR_3 < VAR_0->len; VAR_3++) {

        CrsRangeEntry *used = g_ptr_array_index(VAR_0, VAR_3);



        if (free_base < used->base) {

            crs_range_insert(free_ranges, free_base, used->base - 1);

        }



        free_base = used->limit + 1;

    }



    if (free_base < VAR_2) {

        crs_range_insert(free_ranges, free_base, VAR_2);

    }



    g_ptr_array_set_size(VAR_0, 0);

    for (VAR_3 = 0; VAR_3 < free_ranges->len; VAR_3++) {

        g_ptr_array_add(VAR_0, g_ptr_array_index(free_ranges, VAR_3));

    }



    g_ptr_array_free(free_ranges, false);

}

static void FUNC_0(GPtrArray *VAR_0,
uint64_t VAR_1, uint64_t VAR_2)
{ GPtrArray *free_ranges = g_ptr_array_new_with_free_func(crs_range_free); uint64_t free_base = VAR_1; int VAR_3; g_ptr_array_sort(VAR_0, crs_range_compare); for (VAR_3 = 0; VAR_3 < VAR_0->len; VAR_3++) { CrsRangeEntry *used = g_ptr_array_index(VAR_0, VAR_3); if (free_base < used->base) { crs_range_insert(free_ranges, free_base, used->base - 1); } free_base = used->limit + 1; } if (free_base < VAR_2) { crs_range_insert(free_ranges, free_base, VAR_2); } g_ptr_array_set_size(VAR_0, 0); for (VAR_3 = 0; VAR_3 < free_ranges->len; VAR_3++) { g_ptr_array_add(VAR_0, g_ptr_array_index(free_ranges, VAR_3)); } g_ptr_array_free(free_ranges, false); }