#include <poll.h>
#include <array>
#include <iostream>
#include <string>

int main() {
    // Supplied observations, not a poll/recv system-call trace.
    pollfd event{7, POLLIN, static_cast<short>(POLLIN | POLLHUP)};
    const int poll_result{1};
    std::cout << "model=given-sequence\n";
    std::cout << "poll-count=" << poll_result
              << " readable=" << ((event.revents & POLLIN) != 0)
              << " hup=" << ((event.revents & POLLHUP) != 0) << '\n';
    const std::string input{"abcdef"};
    const std::array<int, 3> returns{2, 1, 3};
    std::size_t offset{0};
    std::string output;
    for (const int returned : returns) {
        if (returned <= 0) return 1;
        const auto count{static_cast<std::size_t>(returned)};
        if (count > input.size() - offset) return 1;
        output.append(input, offset, count);
        offset += count;
        std::cout << "returned=" << returned << " offset=" << offset
                  << " data=" << output << '\n';
    }
    const int eof_return{0};
    std::cout << "returned=" << eof_return << " eof=1 offset=" << offset << '\n';
    return output == input && offset == 6 ? 0 : 1;
}
