static uint64_t pit_ioport_read(void *opaque, hwaddr addr,
                                unsigned size)
{
    PITCommonState *pit = opaque;
    int ret, count;
    PITChannelState *s;
    addr &= 3;
    s = &pit->channels[addr];
    if (s->status_latched) {
        s->status_latched = 0;
        ret = s->status;
    } else if (s->count_latched) {
        switch(s->count_latched) {
        default:
        case RW_STATE_LSB:
            ret = s->latched_count & 0xff;
            s->count_latched = 0;
            break;
        case RW_STATE_MSB:
            ret = s->latched_count >> 8;
            s->count_latched = 0;
            break;
        case RW_STATE_WORD0:
            ret = s->latched_count & 0xff;
            s->count_latched = RW_STATE_MSB;
            break;
    } else {
        switch(s->read_state) {
        default:
        case RW_STATE_LSB:
            count = pit_get_count(s);
            ret = count & 0xff;
            break;
        case RW_STATE_MSB:
            count = pit_get_count(s);
            ret = (count >> 8) & 0xff;
            break;
        case RW_STATE_WORD0:
            count = pit_get_count(s);
            ret = count & 0xff;
            s->read_state = RW_STATE_WORD1;
            break;
        case RW_STATE_WORD1:
            count = pit_get_count(s);
            ret = (count >> 8) & 0xff;
            s->read_state = RW_STATE_WORD0;
            break;
    return ret;
static uint64_t pit_ioport_read(void *opaque, hwaddr addr,
                                unsigned size)
{
    PITCommonState *pit = opaque;
    int ret, count;
    PITChannelState *s;
    addr &= 3;
    s = &pit->channels[addr];
    if (s->status_latched) {
        s->status_latched = 0;
        ret = s->status;
    } else if (s->count_latched) {
        switch(s->count_latched) {
        default:
        case RW_STATE_LSB:
            ret = s->latched_count & 0xff;
            s->count_latched = 0;
            break;
        case RW_STATE_MSB:
            ret = s->latched_count >> 8;
            s->count_latched = 0;
            break;
        case RW_STATE_WORD0:
            ret = s->latched_count & 0xff;
            s->count_latched = RW_STATE_MSB;
            break;
    } else {
        switch(s->read_state) {
        default:
        case RW_STATE_LSB:
            count = pit_get_count(s);
            ret = count & 0xff;
            break;
        case RW_STATE_MSB:
            count = pit_get_count(s);
            ret = (count >> 8) & 0xff;
            break;
        case RW_STATE_WORD0:
            count = pit_get_count(s);
            ret = count & 0xff;
            s->read_state = RW_STATE_WORD1;
            break;
        case RW_STATE_WORD1:
            count = pit_get_count(s);
            ret = (count >> 8) & 0xff;
            s->read_state = RW_STATE_WORD0;
            break;
    return ret;
static uint64_t FUNC_0(void *opaque, hwaddr addr,
                                unsigned size)
{
    PITCommonState *pit = opaque;
    int VAR_0, VAR_1;
    PITChannelState *s;
    addr &= 3;
    s = &pit->channels[addr];
    if (s->status_latched) {
        s->status_latched = 0;
        VAR_0 = s->status;
    } else if (s->count_latched) {
        switch(s->count_latched) {
        default:
        case RW_STATE_LSB:
            VAR_0 = s->latched_count & 0xff;
            s->count_latched = 0;
            break;
        case RW_STATE_MSB:
            VAR_0 = s->latched_count >> 8;
            s->count_latched = 0;
            break;
        case RW_STATE_WORD0:
            VAR_0 = s->latched_count & 0xff;
            s->count_latched = RW_STATE_MSB;
            break;
    } else {
        switch(s->read_state) {
        default:
        case RW_STATE_LSB:
            VAR_1 = pit_get_count(s);
            VAR_0 = VAR_1 & 0xff;
            break;
        case RW_STATE_MSB:
            VAR_1 = pit_get_count(s);
            VAR_0 = (VAR_1 >> 8) & 0xff;
            break;
        case RW_STATE_WORD0:
            VAR_1 = pit_get_count(s);
            VAR_0 = VAR_1 & 0xff;
            s->read_state = RW_STATE_WORD1;
            break;
        case RW_STATE_WORD1:
            VAR_1 = pit_get_count(s);
            VAR_0 = (VAR_1 >> 8) & 0xff;
            s->read_state = RW_STATE_WORD0;
            break;
    return VAR_0;
static uint64_t FUNC_0(void *opaque, hwaddr addr,
unsigned size)
{ PITCommonState *pit = opaque; int VAR_0, VAR_1; PITChannelState *s; addr &= 3; s = &pit->channels[addr]; if (s->status_latched) { s->status_latched = 0; VAR_0 = s->status; } else if (s->count_latched) { switch(s->count_latched) { default:
case RW_STATE_LSB:
VAR_0 = s->latched_count & 0xff; s->count_latched = 0; break; case RW_STATE_MSB:
VAR_0 = s->latched_count >> 8; s->count_latched = 0; break; case RW_STATE_WORD0:
VAR_0 = s->latched_count & 0xff; s->count_latched = RW_STATE_MSB; break; } else { switch(s->read_state) { default:
case RW_STATE_LSB:
VAR_1 = pit_get_count(s); VAR_0 = VAR_1 & 0xff; break; case RW_STATE_MSB:
VAR_1 = pit_get_count(s); VAR_0 = (VAR_1 >> 8) & 0xff; break; case RW_STATE_WORD0:
VAR_1 = pit_get_count(s); VAR_0 = VAR_1 & 0xff; s->read_state = RW_STATE_WORD1; break; case RW_STATE_WORD1:
VAR_1 = pit_get_count(s); VAR_0 = (VAR_1 >> 8) & 0xff; s->read_state = RW_STATE_WORD0; break; return VAR_0;