module main
{
    type state_t = enum { GREEN, YELLOW, RED, AMBER };

    var L1, L2, L3, L4 : state_t;
    var C : int;

    init {
        L1 = RED;
        L2 = RED;
        L3 = RED;
        L4 = RED;
        C = 0;
    }

    procedure switchLights()
    {
        if (C == 0) {
            L1 = GREEN;
            L3 = GREEN;
        } else if (C == 1) {
            L1 = YELLOW;
            L3 = YELLOW;
            L2 = GREEN;
        } else if (C == 2) {
            L1 = RED;
            L3 = RED;
            L2 = YELLOW;
        } else if (C == 3) {
            L2 = RED;
            L4 = GREEN;
        } else if (C == 4) {
            L4 = YELLOW;
        } else if (C == 5) {
            L4 = RED;
        }
    }

    next {
        if (C == 0 || C == 1 || C == 2) {
            switchLights();
        } else if (C == 3 || C == 4 || C == 5) {
            switchLights();
        }

        if (C == 5) {
            C = 0;
        } else {
            C = C + 1;
        }
    }
}
