static int nbd_negotiate_send_rep_len(QIOChannel *ioc, uint32_t type,

                                      uint32_t opt, uint32_t len, Error **errp)

{

    uint64_t magic;



    trace_nbd_negotiate_send_rep_len(opt, type, len);



    magic = cpu_to_be64(NBD_REP_MAGIC);

    if (nbd_write(ioc, &magic, sizeof(magic), errp) < 0) {

        error_prepend(errp, "write failed (rep magic): ");

        return -EINVAL;

    }



    opt = cpu_to_be32(opt);

    if (nbd_write(ioc, &opt, sizeof(opt), errp) < 0) {

        error_prepend(errp, "write failed (rep opt): ");

        return -EINVAL;

    }



    type = cpu_to_be32(type);

    if (nbd_write(ioc, &type, sizeof(type), errp) < 0) {

        error_prepend(errp, "write failed (rep type): ");

        return -EINVAL;

    }



    len = cpu_to_be32(len);

    if (nbd_write(ioc, &len, sizeof(len), errp) < 0) {

        error_prepend(errp, "write failed (rep data length): ");

        return -EINVAL;

    }

    return 0;

}

static int nbd_negotiate_send_rep_len(QIOChannel *ioc, uint32_t type,

                                      uint32_t opt, uint32_t len, Error **errp)

{

    uint64_t magic;



    trace_nbd_negotiate_send_rep_len(opt, type, len);



    magic = cpu_to_be64(NBD_REP_MAGIC);

    if (nbd_write(ioc, &magic, sizeof(magic), errp) < 0) {

        error_prepend(errp, "write failed (rep magic): ");

        return -EINVAL;

    }



    opt = cpu_to_be32(opt);

    if (nbd_write(ioc, &opt, sizeof(opt), errp) < 0) {

        error_prepend(errp, "write failed (rep opt): ");

        return -EINVAL;

    }



    type = cpu_to_be32(type);

    if (nbd_write(ioc, &type, sizeof(type), errp) < 0) {

        error_prepend(errp, "write failed (rep type): ");

        return -EINVAL;

    }



    len = cpu_to_be32(len);

    if (nbd_write(ioc, &len, sizeof(len), errp) < 0) {

        error_prepend(errp, "write failed (rep data length): ");

        return -EINVAL;

    }

    return 0;

}

static int FUNC_0(QIOChannel *VAR_0, uint32_t VAR_1,

                                      uint32_t VAR_2, uint32_t VAR_3, Error **VAR_4)

{

    uint64_t magic;



    trace_nbd_negotiate_send_rep_len(VAR_2, VAR_1, VAR_3);



    magic = cpu_to_be64(NBD_REP_MAGIC);

    if (nbd_write(VAR_0, &magic, sizeof(magic), VAR_4) < 0) {

        error_prepend(VAR_4, "write failed (rep magic): ");

        return -EINVAL;

    }



    VAR_2 = cpu_to_be32(VAR_2);

    if (nbd_write(VAR_0, &VAR_2, sizeof(VAR_2), VAR_4) < 0) {

        error_prepend(VAR_4, "write failed (rep VAR_2): ");

        return -EINVAL;

    }



    VAR_1 = cpu_to_be32(VAR_1);

    if (nbd_write(VAR_0, &VAR_1, sizeof(VAR_1), VAR_4) < 0) {

        error_prepend(VAR_4, "write failed (rep VAR_1): ");

        return -EINVAL;

    }



    VAR_3 = cpu_to_be32(VAR_3);

    if (nbd_write(VAR_0, &VAR_3, sizeof(VAR_3), VAR_4) < 0) {

        error_prepend(VAR_4, "write failed (rep data length): ");

        return -EINVAL;

    }

    return 0;

}

static int FUNC_0(QIOChannel *VAR_0, uint32_t VAR_1,
uint32_t VAR_2, uint32_t VAR_3, Error **VAR_4)
{ uint64_t magic; trace_nbd_negotiate_send_rep_len(VAR_2, VAR_1, VAR_3); magic = cpu_to_be64(NBD_REP_MAGIC); if (nbd_write(VAR_0, &magic, sizeof(magic), VAR_4) < 0) { error_prepend(VAR_4, "write failed (rep magic): "); return -EINVAL; } VAR_2 = cpu_to_be32(VAR_2); if (nbd_write(VAR_0, &VAR_2, sizeof(VAR_2), VAR_4) < 0) { error_prepend(VAR_4, "write failed (rep VAR_2): "); return -EINVAL; } VAR_1 = cpu_to_be32(VAR_1); if (nbd_write(VAR_0, &VAR_1, sizeof(VAR_1), VAR_4) < 0) { error_prepend(VAR_4, "write failed (rep VAR_1): "); return -EINVAL; } VAR_3 = cpu_to_be32(VAR_3); if (nbd_write(VAR_0, &VAR_3, sizeof(VAR_3), VAR_4) < 0) { error_prepend(VAR_4, "write failed (rep data length): "); return -EINVAL; } return 0; }