digraph {
        graph [label="Decoder state machine", labelloc="t"]
        Start [style="invis", shape="point"]
        empty
        input_available
        yield_literal
        backref_index_msb
        backref_index_lsb
        backref_count_msb
        backref_count_lsb
        yield_backref
        check_for_more_input
        done [peripheries=2]

        empty->input_available [label="sink()", color="blue", weight=10]
        Start->empty

        input_available->yield_literal [label="pop 1-bit"]
        input_available->backref_index_msb [label="pop 0-bit", weight=10]
        input_available->backref_index_lsb [label="pop 0-bit, index <8 bits", weight=10]

        yield_literal->yield_literal [label="sink()", color="blue"]
        yield_literal->yield_literal [label="poll()", color="red"]
        yield_literal->check_for_more_input [label="poll(), done", color="red"]
        
        backref_index_msb->backref_index_msb [label="sink()", color="blue"]
        backref_index_msb->backref_index_lsb [label="pop index, upper bits", weight=10]
        backref_index_msb->done [label="finish()", color="blue"]

        backref_index_lsb->backref_index_lsb [label="sink()", color="blue"]
        backref_index_lsb->backref_count_msb [label="pop index, lower bits", weight=10]
        backref_index_lsb->backref_count_lsb [label="pop index, count <=8 bits", weight=10]
        backref_index_lsb->done [label="finish()", color="blue"]

        backref_count_msb->backref_count_msb [label="sink()", color="blue"]
        backref_count_msb->backref_count_lsb [label="pop count, upper bits", weight=10]
        backref_count_msb->done [label="finish()", color="blue"]

        backref_count_lsb->backref_count_lsb [label="sink()", color="blue"]
        backref_count_lsb->yield_backref [label="pop count, lower bits", weight=10]
        backref_count_lsb->done [label="finish()", color="blue"]

        yield_backref->yield_backref [label="sink()", color="blue"]
        yield_backref->yield_backref [label="poll()", color="red"]
        yield_backref->check_for_more_input [label="poll(), done",
            color="red", weight=10]

        check_for_more_input->empty [label="no"]
        check_for_more_input->input_available [label="yes"]

        empty->done [label="finish()", color="blue"]
}