static int rdma_add_block(RDMAContext *rdma, const char *block_name,

                         void *host_addr,

                         ram_addr_t block_offset, uint64_t length)

{

    RDMALocalBlocks *local = &rdma->local_ram_blocks;

    RDMALocalBlock *block;

    RDMALocalBlock *old = local->block;



    local->block = g_malloc0(sizeof(RDMALocalBlock) * (local->nb_blocks + 1));



    if (local->nb_blocks) {

        int x;



        if (rdma->blockmap) {

            for (x = 0; x < local->nb_blocks; x++) {

                g_hash_table_remove(rdma->blockmap,

                                    (void *)(uintptr_t)old[x].offset);

                g_hash_table_insert(rdma->blockmap,

                                    (void *)(uintptr_t)old[x].offset,

                                    &local->block[x]);

            }

        }

        memcpy(local->block, old, sizeof(RDMALocalBlock) * local->nb_blocks);

        g_free(old);

    }



    block = &local->block[local->nb_blocks];



    block->block_name = g_strdup(block_name);

    block->local_host_addr = host_addr;

    block->offset = block_offset;

    block->length = length;

    block->index = local->nb_blocks;

    block->src_index = ~0U; /* Filled in by the receipt of the block list */

    block->nb_chunks = ram_chunk_index(host_addr, host_addr + length) + 1UL;

    block->transit_bitmap = bitmap_new(block->nb_chunks);

    bitmap_clear(block->transit_bitmap, 0, block->nb_chunks);

    block->unregister_bitmap = bitmap_new(block->nb_chunks);

    bitmap_clear(block->unregister_bitmap, 0, block->nb_chunks);

    block->remote_keys = g_malloc0(block->nb_chunks * sizeof(uint32_t));



    block->is_ram_block = local->init ? false : true;



    if (rdma->blockmap) {

        g_hash_table_insert(rdma->blockmap, (void *) block_offset, block);

    }



    trace_rdma_add_block(block_name, local->nb_blocks,

                         (uintptr_t) block->local_host_addr,

                         block->offset, block->length,

                         (uintptr_t) (block->local_host_addr + block->length),

                         BITS_TO_LONGS(block->nb_chunks) *

                             sizeof(unsigned long) * 8,

                         block->nb_chunks);



    local->nb_blocks++;



    return 0;

}

static int rdma_add_block(RDMAContext *rdma, const char *block_name,

                         void *host_addr,

                         ram_addr_t block_offset, uint64_t length)

{

    RDMALocalBlocks *local = &rdma->local_ram_blocks;

    RDMALocalBlock *block;

    RDMALocalBlock *old = local->block;



    local->block = g_malloc0(sizeof(RDMALocalBlock) * (local->nb_blocks + 1));



    if (local->nb_blocks) {

        int x;



        if (rdma->blockmap) {

            for (x = 0; x < local->nb_blocks; x++) {

                g_hash_table_remove(rdma->blockmap,

                                    (void *)(uintptr_t)old[x].offset);

                g_hash_table_insert(rdma->blockmap,

                                    (void *)(uintptr_t)old[x].offset,

                                    &local->block[x]);

            }

        }

        memcpy(local->block, old, sizeof(RDMALocalBlock) * local->nb_blocks);

        g_free(old);

    }



    block = &local->block[local->nb_blocks];



    block->block_name = g_strdup(block_name);

    block->local_host_addr = host_addr;

    block->offset = block_offset;

    block->length = length;

    block->index = local->nb_blocks;

    block->src_index = ~0U; 

    block->nb_chunks = ram_chunk_index(host_addr, host_addr + length) + 1UL;

    block->transit_bitmap = bitmap_new(block->nb_chunks);

    bitmap_clear(block->transit_bitmap, 0, block->nb_chunks);

    block->unregister_bitmap = bitmap_new(block->nb_chunks);

    bitmap_clear(block->unregister_bitmap, 0, block->nb_chunks);

    block->remote_keys = g_malloc0(block->nb_chunks * sizeof(uint32_t));



    block->is_ram_block = local->init ? false : true;



    if (rdma->blockmap) {

        g_hash_table_insert(rdma->blockmap, (void *) block_offset, block);

    }



    trace_rdma_add_block(block_name, local->nb_blocks,

                         (uintptr_t) block->local_host_addr,

                         block->offset, block->length,

                         (uintptr_t) (block->local_host_addr + block->length),

                         BITS_TO_LONGS(block->nb_chunks) *

                             sizeof(unsigned long) * 8,

                         block->nb_chunks);



    local->nb_blocks++;



    return 0;

}

    local->block = g_malloc0(sizeof(RDMALocalBlock) * (local->nb_blocks + 1));     block->remote_keys = g_malloc0(block->nb_chunks * sizeof(uint32_t));
static int FUNC_0(RDMAContext *VAR_0, const char *VAR_1,

                         void *VAR_2,

                         ram_addr_t VAR_3, uint64_t VAR_4)

{

    RDMALocalBlocks *local = &VAR_0->local_ram_blocks;

    RDMALocalBlock *block;

    RDMALocalBlock *old = local->block;



    local->block = g_malloc0(sizeof(RDMALocalBlock) * (local->nb_blocks + 1));



    if (local->nb_blocks) {

        int VAR_5;



        if (VAR_0->blockmap) {

            for (VAR_5 = 0; VAR_5 < local->nb_blocks; VAR_5++) {

                g_hash_table_remove(VAR_0->blockmap,

                                    (void *)(uintptr_t)old[VAR_5].offset);

                g_hash_table_insert(VAR_0->blockmap,

                                    (void *)(uintptr_t)old[VAR_5].offset,

                                    &local->block[VAR_5]);

            }

        }

        memcpy(local->block, old, sizeof(RDMALocalBlock) * local->nb_blocks);

        g_free(old);

    }



    block = &local->block[local->nb_blocks];



    block->VAR_1 = g_strdup(VAR_1);

    block->local_host_addr = VAR_2;

    block->offset = VAR_3;

    block->VAR_4 = VAR_4;

    block->index = local->nb_blocks;

    block->src_index = ~0U; 

    block->nb_chunks = ram_chunk_index(VAR_2, VAR_2 + VAR_4) + 1UL;

    block->transit_bitmap = bitmap_new(block->nb_chunks);

    bitmap_clear(block->transit_bitmap, 0, block->nb_chunks);

    block->unregister_bitmap = bitmap_new(block->nb_chunks);

    bitmap_clear(block->unregister_bitmap, 0, block->nb_chunks);

    block->remote_keys = g_malloc0(block->nb_chunks * sizeof(uint32_t));



    block->is_ram_block = local->init ? false : true;



    if (VAR_0->blockmap) {

        g_hash_table_insert(VAR_0->blockmap, (void *) VAR_3, block);

    }



    trace_rdma_add_block(VAR_1, local->nb_blocks,

                         (uintptr_t) block->local_host_addr,

                         block->offset, block->VAR_4,

                         (uintptr_t) (block->local_host_addr + block->VAR_4),

                         BITS_TO_LONGS(block->nb_chunks) *

                             sizeof(unsigned long) * 8,

                         block->nb_chunks);



    local->nb_blocks++;



    return 0;

}

static int FUNC_0(RDMAContext *VAR_0, const char *VAR_1,
void *VAR_2,
ram_addr_t VAR_3, uint64_t VAR_4)
{ RDMALocalBlocks *local = &VAR_0->local_ram_blocks; RDMALocalBlock *block; RDMALocalBlock *old = local->block; local->block = g_malloc0(sizeof(RDMALocalBlock) * (local->nb_blocks + 1)); if (local->nb_blocks) { int VAR_5; if (VAR_0->blockmap) { for (VAR_5 = 0; VAR_5 < local->nb_blocks; VAR_5++) { g_hash_table_remove(VAR_0->blockmap,
(void *)(uintptr_t)old[VAR_5].offset); g_hash_table_insert(VAR_0->blockmap,
(void *)(uintptr_t)old[VAR_5].offset,
&local->block[VAR_5]); } } memcpy(local->block, old, sizeof(RDMALocalBlock) * local->nb_blocks); g_free(old); } block = &local->block[local->nb_blocks]; block->VAR_1 = g_strdup(VAR_1); block->local_host_addr = VAR_2; block->offset = VAR_3; block->VAR_4 = VAR_4; block->index = local->nb_blocks; block->src_index = ~0U; block->nb_chunks = ram_chunk_index(VAR_2, VAR_2 + VAR_4) + 1UL; block->transit_bitmap = bitmap_new(block->nb_chunks); bitmap_clear(block->transit_bitmap, 0, block->nb_chunks); block->unregister_bitmap = bitmap_new(block->nb_chunks); bitmap_clear(block->unregister_bitmap, 0, block->nb_chunks); block->remote_keys = g_malloc0(block->nb_chunks * sizeof(uint32_t)); block->is_ram_block = local->init ? false : true; if (VAR_0->blockmap) { g_hash_table_insert(VAR_0->blockmap, (void *) VAR_3, block); } trace_rdma_add_block(VAR_1, local->nb_blocks,
(uintptr_t) block->local_host_addr,
block->offset, block->VAR_4,
(uintptr_t) (block->local_host_addr + block->VAR_4),
BITS_TO_LONGS(block->nb_chunks) *
sizeof(unsigned long) * 8,
block->nb_chunks); local->nb_blocks++; return 0; }