static void mtree_print_mr(fprintf_function mon_printf, void *f,

                           const MemoryRegion *mr, unsigned int level,

                           hwaddr base,

                           MemoryRegionListHead *alias_print_queue)

{

    MemoryRegionList *new_ml, *ml, *next_ml;

    MemoryRegionListHead submr_print_queue;

    const MemoryRegion *submr;

    unsigned int i;



    if (!mr) {

        return;

    }



    for (i = 0; i < level; i++) {

        mon_printf(f, MTREE_INDENT);

    }



    if (mr->alias) {

        MemoryRegionList *ml;

        bool found = false;



        /* check if the alias is already in the queue */

        QTAILQ_FOREACH(ml, alias_print_queue, queue) {

            if (ml->mr == mr->alias) {

                found = true;

            }

        }



        if (!found) {

            ml = g_new(MemoryRegionList, 1);

            ml->mr = mr->alias;

            QTAILQ_INSERT_TAIL(alias_print_queue, ml, queue);

        }

        mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx

                   " (prio %d, %s): alias %s @%s " TARGET_FMT_plx

                   "-" TARGET_FMT_plx "%s\n",

                   base + mr->addr,

                   base + mr->addr + MR_SIZE(mr->size),

                   mr->priority,

                   memory_region_type((MemoryRegion *)mr),

                   memory_region_name(mr),

                   memory_region_name(mr->alias),

                   mr->alias_offset,

                   mr->alias_offset + MR_SIZE(mr->size),

                   mr->enabled ? "" : " [disabled]");

    } else {

        mon_printf(f,

                   TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s\n",

                   base + mr->addr,

                   base + mr->addr + MR_SIZE(mr->size),

                   mr->priority,

                   memory_region_type((MemoryRegion *)mr),

                   memory_region_name(mr),

                   mr->enabled ? "" : " [disabled]");

    }



    QTAILQ_INIT(&submr_print_queue);



    QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {

        new_ml = g_new(MemoryRegionList, 1);

        new_ml->mr = submr;

        QTAILQ_FOREACH(ml, &submr_print_queue, queue) {

            if (new_ml->mr->addr < ml->mr->addr ||

                (new_ml->mr->addr == ml->mr->addr &&

                 new_ml->mr->priority > ml->mr->priority)) {

                QTAILQ_INSERT_BEFORE(ml, new_ml, queue);

                new_ml = NULL;

                break;

            }

        }

        if (new_ml) {

            QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);

        }

    }



    QTAILQ_FOREACH(ml, &submr_print_queue, queue) {

        mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,

                       alias_print_queue);

    }



    QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, queue, next_ml) {

        g_free(ml);

    }

}

static void mtree_print_mr(fprintf_function mon_printf, void *f,

                           const MemoryRegion *mr, unsigned int level,

                           hwaddr base,

                           MemoryRegionListHead *alias_print_queue)

{

    MemoryRegionList *new_ml, *ml, *next_ml;

    MemoryRegionListHead submr_print_queue;

    const MemoryRegion *submr;

    unsigned int i;



    if (!mr) {

        return;

    }



    for (i = 0; i < level; i++) {

        mon_printf(f, MTREE_INDENT);

    }



    if (mr->alias) {

        MemoryRegionList *ml;

        bool found = false;



        

        QTAILQ_FOREACH(ml, alias_print_queue, queue) {

            if (ml->mr == mr->alias) {

                found = true;

            }

        }



        if (!found) {

            ml = g_new(MemoryRegionList, 1);

            ml->mr = mr->alias;

            QTAILQ_INSERT_TAIL(alias_print_queue, ml, queue);

        }

        mon_printf(f, TARGET_FMT_plx "-" TARGET_FMT_plx

                   " (prio %d, %s): alias %s @%s " TARGET_FMT_plx

                   "-" TARGET_FMT_plx "%s\n",

                   base + mr->addr,

                   base + mr->addr + MR_SIZE(mr->size),

                   mr->priority,

                   memory_region_type((MemoryRegion *)mr),

                   memory_region_name(mr),

                   memory_region_name(mr->alias),

                   mr->alias_offset,

                   mr->alias_offset + MR_SIZE(mr->size),

                   mr->enabled ? "" : " [disabled]");

    } else {

        mon_printf(f,

                   TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s\n",

                   base + mr->addr,

                   base + mr->addr + MR_SIZE(mr->size),

                   mr->priority,

                   memory_region_type((MemoryRegion *)mr),

                   memory_region_name(mr),

                   mr->enabled ? "" : " [disabled]");

    }



    QTAILQ_INIT(&submr_print_queue);



    QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {

        new_ml = g_new(MemoryRegionList, 1);

        new_ml->mr = submr;

        QTAILQ_FOREACH(ml, &submr_print_queue, queue) {

            if (new_ml->mr->addr < ml->mr->addr ||

                (new_ml->mr->addr == ml->mr->addr &&

                 new_ml->mr->priority > ml->mr->priority)) {

                QTAILQ_INSERT_BEFORE(ml, new_ml, queue);

                new_ml = NULL;

                break;

            }

        }

        if (new_ml) {

            QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);

        }

    }



    QTAILQ_FOREACH(ml, &submr_print_queue, queue) {

        mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,

                       alias_print_queue);

    }



    QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, queue, next_ml) {

        g_free(ml);

    }

}

                   base + mr->addr,                    base + mr->addr + MR_SIZE(mr->size),                    base + mr->addr,                    base + mr->addr + MR_SIZE(mr->size),         mtree_print_mr(mon_printf, f, ml->mr, level + 1, base + mr->addr,
static void FUNC_0(fprintf_function VAR_0, void *VAR_1,

                           const MemoryRegion *VAR_2, unsigned int VAR_3,

                           hwaddr VAR_4,

                           MemoryRegionListHead *VAR_5)

{

    MemoryRegionList *new_ml, *ml, *next_ml;

    MemoryRegionListHead submr_print_queue;

    const MemoryRegion *VAR_6;

    unsigned int VAR_7;



    if (!VAR_2) {

        return;

    }



    for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) {

        VAR_0(VAR_1, MTREE_INDENT);

    }



    if (VAR_2->alias) {

        MemoryRegionList *ml;

        bool found = false;



        

        QTAILQ_FOREACH(ml, VAR_5, queue) {

            if (ml->VAR_2 == VAR_2->alias) {

                found = true;

            }

        }



        if (!found) {

            ml = g_new(MemoryRegionList, 1);

            ml->VAR_2 = VAR_2->alias;

            QTAILQ_INSERT_TAIL(VAR_5, ml, queue);

        }

        VAR_0(VAR_1, TARGET_FMT_plx "-" TARGET_FMT_plx

                   " (prio %d, %s): alias %s @%s " TARGET_FMT_plx

                   "-" TARGET_FMT_plx "%s\n",

                   VAR_4 + VAR_2->addr,

                   VAR_4 + VAR_2->addr + MR_SIZE(VAR_2->size),

                   VAR_2->priority,

                   memory_region_type((MemoryRegion *)VAR_2),

                   memory_region_name(VAR_2),

                   memory_region_name(VAR_2->alias),

                   VAR_2->alias_offset,

                   VAR_2->alias_offset + MR_SIZE(VAR_2->size),

                   VAR_2->enabled ? "" : " [disabled]");

    } else {

        VAR_0(VAR_1,

                   TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s\n",

                   VAR_4 + VAR_2->addr,

                   VAR_4 + VAR_2->addr + MR_SIZE(VAR_2->size),

                   VAR_2->priority,

                   memory_region_type((MemoryRegion *)VAR_2),

                   memory_region_name(VAR_2),

                   VAR_2->enabled ? "" : " [disabled]");

    }



    QTAILQ_INIT(&submr_print_queue);



    QTAILQ_FOREACH(VAR_6, &VAR_2->subregions, subregions_link) {

        new_ml = g_new(MemoryRegionList, 1);

        new_ml->VAR_2 = VAR_6;

        QTAILQ_FOREACH(ml, &submr_print_queue, queue) {

            if (new_ml->VAR_2->addr < ml->VAR_2->addr ||

                (new_ml->VAR_2->addr == ml->VAR_2->addr &&

                 new_ml->VAR_2->priority > ml->VAR_2->priority)) {

                QTAILQ_INSERT_BEFORE(ml, new_ml, queue);

                new_ml = NULL;

                break;

            }

        }

        if (new_ml) {

            QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue);

        }

    }



    QTAILQ_FOREACH(ml, &submr_print_queue, queue) {

        FUNC_0(VAR_0, VAR_1, ml->VAR_2, VAR_3 + 1, VAR_4 + VAR_2->addr,

                       VAR_5);

    }



    QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, queue, next_ml) {

        g_free(ml);

    }

}

static void FUNC_0(fprintf_function VAR_0, void *VAR_1,
const MemoryRegion *VAR_2, unsigned int VAR_3,
hwaddr VAR_4,
MemoryRegionListHead *VAR_5)
{ MemoryRegionList *new_ml, *ml, *next_ml; MemoryRegionListHead submr_print_queue; const MemoryRegion *VAR_6; unsigned int VAR_7; if (!VAR_2) { return; } for (VAR_7 = 0; VAR_7 < VAR_3; VAR_7++) { VAR_0(VAR_1, MTREE_INDENT); } if (VAR_2->alias) { MemoryRegionList *ml; bool found = false; QTAILQ_FOREACH(ml, VAR_5, queue) { if (ml->VAR_2 == VAR_2->alias) { found = true; } } if (!found) { ml = g_new(MemoryRegionList, 1); ml->VAR_2 = VAR_2->alias; QTAILQ_INSERT_TAIL(VAR_5, ml, queue); } VAR_0(VAR_1, TARGET_FMT_plx "-" TARGET_FMT_plx
" (prio %d, %s): alias %s @%s " TARGET_FMT_plx
"-" TARGET_FMT_plx "%s\n",
VAR_4 + VAR_2->addr,
VAR_4 + VAR_2->addr + MR_SIZE(VAR_2->size),
VAR_2->priority,
memory_region_type((MemoryRegion *)VAR_2),
memory_region_name(VAR_2),
memory_region_name(VAR_2->alias),
VAR_2->alias_offset,
VAR_2->alias_offset + MR_SIZE(VAR_2->size),
VAR_2->enabled ? "" : " [disabled]"); } else { VAR_0(VAR_1,
TARGET_FMT_plx "-" TARGET_FMT_plx " (prio %d, %s): %s%s\n",
VAR_4 + VAR_2->addr,
VAR_4 + VAR_2->addr + MR_SIZE(VAR_2->size),
VAR_2->priority,
memory_region_type((MemoryRegion *)VAR_2),
memory_region_name(VAR_2),
VAR_2->enabled ? "" : " [disabled]"); } QTAILQ_INIT(&submr_print_queue); QTAILQ_FOREACH(VAR_6, &VAR_2->subregions, subregions_link) { new_ml = g_new(MemoryRegionList, 1); new_ml->VAR_2 = VAR_6; QTAILQ_FOREACH(ml, &submr_print_queue, queue) { if (new_ml->VAR_2->addr < ml->VAR_2->addr ||
(new_ml->VAR_2->addr == ml->VAR_2->addr &&
new_ml->VAR_2->priority > ml->VAR_2->priority)) { QTAILQ_INSERT_BEFORE(ml, new_ml, queue); new_ml = NULL; break; } } if (new_ml) { QTAILQ_INSERT_TAIL(&submr_print_queue, new_ml, queue); } } QTAILQ_FOREACH(ml, &submr_print_queue, queue) { FUNC_0(VAR_0, VAR_1, ml->VAR_2, VAR_3 + 1, VAR_4 + VAR_2->addr,
VAR_5); } QTAILQ_FOREACH_SAFE(ml, &submr_print_queue, queue, next_ml) { g_free(ml); } }