def METHOD_NAME(positions, labels):
    free_points_count = (labels == 0).sum()
    cell_points_count = labels.shape[0] - free_points_count
    cell_points = np.zeros(shape=(cell_points_count, 2), dtype=np.int32)
    free_points = np.zeros(shape=(free_points_count, 2), dtype=np.uint32)
    free_points_x_axis = positions[0:free_points_count, 0]
    free_points_index = np.argsort(free_points_x_axis)
    free_points[:] = positions[0:free_points_count][free_points_index]
    cell_points[:] = positions[free_points_count:]
    cell_ids = np.unique(labels)[1:]
    cells_count = cell_ids.shape[0]
    cells_index = np.zeros(shape=(cells_count, 3), dtype=np.uint32)
    last_cell_id = 0
    cells_index_idx = 0
    for i in range(cell_points.shape[0]):
        j = i + free_points_count
        current_cell_id = labels[j]
        if current_cell_id != last_cell_id:
            cells_index[cells_index_idx][0] = current_cell_id
            cells_index[cells_index_idx][1] = i
            if cells_index_idx > 0:
                cells_index[cells_index_idx - 1][2] = i
            cells_index_idx += 1
            last_cell_id = current_cell_id
    cells_index[-1, 2] = cell_points.shape[0]
    return cell_points, cells_index, free_points, free_points_index