def process_region_file(region, start, stop):
    """Given a region, return the number of blocks of each ID in that region"""
    rx = region.loc.x
    rz = region.loc.z

    # Does the region overlap the bounding box at all?
    if (start != None):
        if ( (rx+1)*512-1 < int(start[0]) or (rz+1)*512-1 < int(start[2]) ):
            return
    elif (stop != None):
        if ( rx*512-1 > int(stop[0]) or rz*512-1 > int(stop[2]) ):
            return

    # Get all chunks
    print("Parsing region %s..." % os.path.basename(region.filename))
    for c in region.iter_chunks_class():
        cx, cz = c.get_coords();
        # Does the chunk overlap the bounding box at all?
        if (start != None):
            if ( (cx+1)*16 + rx*512 - 1 < int(start[0]) or (cz+1)*16 + rz*512 - 1 < int(start[2]) ):
                continue
        elif (stop != None):
            if ( cx*16 + rx*512 - 1 > int(stop[0]) or cz*16 + rz*512 - 1 > int(stop[2]) ):
                continue

        #print("Parsing chunk (" + str(cx) + ", " + str(cz) + ")...")

        # Fast code if no start or stop coordinates are specified
        # TODO: also use this code if start/stop is specified, but the complete chunk is included
        if (start == None and stop == None):
            stats_per_chunk(c)
        else:
            # Slow code that iterates through each coordinate
            bounded_stats_per_chunk(c, start, stop)
Given a region, return the number of blocks of each ID in that region