static int tpm_passthrough_unix_write(int fd, const uint8_t *buf, uint32_t len)

{

    int ret, remain;



    remain = len;

    while (len > 0) {

        ret = write(fd, buf, remain);

        if (ret < 0) {

            if (errno != EINTR && errno != EAGAIN) {

                return -1;

            }

        } else if (ret == 0) {

            break;

        } else {

            buf += ret;

            remain -= ret;

        }

    }

    return len - remain;

}

static int tpm_passthrough_unix_write(int fd, const uint8_t *buf, uint32_t len)

{

    int ret, remain;



    remain = len;

    while (len > 0) {

        ret = write(fd, buf, remain);

        if (ret < 0) {

            if (errno != EINTR && errno != EAGAIN) {

                return -1;

            }

        } else if (ret == 0) {

            break;

        } else {

            buf += ret;

            remain -= ret;

        }

    }

    return len - remain;

}

    while (len > 0) {
static int FUNC_0(int VAR_0, const uint8_t *VAR_1, uint32_t VAR_2)

{

    int VAR_3, VAR_4;



    VAR_4 = VAR_2;

    while (VAR_2 > 0) {

        VAR_3 = write(VAR_0, VAR_1, VAR_4);

        if (VAR_3 < 0) {

            if (errno != EINTR && errno != EAGAIN) {

                return -1;

            }

        } else if (VAR_3 == 0) {

            break;

        } else {

            VAR_1 += VAR_3;

            VAR_4 -= VAR_3;

        }

    }

    return VAR_2 - VAR_4;

}

static int FUNC_0(int VAR_0, const uint8_t *VAR_1, uint32_t VAR_2)
{ int VAR_3, VAR_4; VAR_4 = VAR_2; while (VAR_2 > 0) { VAR_3 = write(VAR_0, VAR_1, VAR_4); if (VAR_3 < 0) { if (errno != EINTR && errno != EAGAIN) { return -1; } } else if (VAR_3 == 0) { break; } else { VAR_1 += VAR_3; VAR_4 -= VAR_3; } } return VAR_2 - VAR_4; }