static int kvm_irqchip_get_virq(KVMState *s)

{

    uint32_t *word = s->used_gsi_bitmap;

    int max_words = ALIGN(s->gsi_count, 32) / 32;

    int i, bit;

    bool retry = true;



again:

    /* Return the lowest unused GSI in the bitmap */

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

        bit = ffs(~word[i]);

        if (!bit) {

            continue;

        }



        return bit - 1 + i * 32;

    }

    if (retry) {

        retry = false;

        kvm_flush_dynamic_msi_routes(s);

        goto again;

    }

    return -ENOSPC;



}

static int kvm_irqchip_get_virq(KVMState *s)

{

    uint32_t *word = s->used_gsi_bitmap;

    int max_words = ALIGN(s->gsi_count, 32) / 32;

    int i, bit;

    bool retry = true;



again:

    

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

        bit = ffs(~word[i]);

        if (!bit) {

            continue;

        }



        return bit - 1 + i * 32;

    }

    if (retry) {

        retry = false;

        kvm_flush_dynamic_msi_routes(s);

        goto again;

    }

    return -ENOSPC;



}

static int FUNC_0(KVMState *VAR_0)

{

    uint32_t *word = VAR_0->used_gsi_bitmap;

    int VAR_1 = ALIGN(VAR_0->gsi_count, 32) / 32;

    int VAR_2, VAR_3;

    bool retry = true;



again:

    

    for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {

        VAR_3 = ffs(~word[VAR_2]);

        if (!VAR_3) {

            continue;

        }



        return VAR_3 - 1 + VAR_2 * 32;

    }

    if (retry) {

        retry = false;

        kvm_flush_dynamic_msi_routes(VAR_0);

        goto again;

    }

    return -ENOSPC;



}

static int FUNC_0(KVMState *VAR_0)
{ uint32_t *word = VAR_0->used_gsi_bitmap; int VAR_1 = ALIGN(VAR_0->gsi_count, 32) / 32; int VAR_2, VAR_3; bool retry = true; again:
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) { VAR_3 = ffs(~word[VAR_2]); if (!VAR_3) { continue; } return VAR_3 - 1 + VAR_2 * 32; } if (retry) { retry = false; kvm_flush_dynamic_msi_routes(VAR_0); goto again; } return -ENOSPC; }