         var rep3 = 0
         var state = 0
 
-        func decodeLiteral(_ state: Int, _ rep0: Int) {
-            let prevByte = outWindow.isEmpty ? 0 : outWindow.byte(at: 1)
-            // TODO: Something is not quite right.
-            var symbol = 1
-            let litState = ((outWindow.totalPosition & ((1 << lp.toInt()) - 1)) << lc.toInt()) + (prevByte >> (8 - lc)).toInt()
-            let probsIndex = 0x300 * litState
-            if state >= 7 {
-                var matchByte = outWindow.byte(at: rep0 + 1)
-                repeat {
-                    let matchBit = ((matchByte >> 7) & 1).toInt()
-                    matchByte <<= 1
-                    let bit = rangeDecoder.decode(bitWithProb: &literalProbs[((1 + matchBit) << 8) + symbol],
-                                                  pointerData: &pointerData)
-                    symbol = (symbol << 1) | bit
-                    if matchBit != bit {
-                        break
-                    }
-                } while symbol < 0x100
-            }
-            while symbol < 0x100 {
-                symbol = (symbol << 1) | rangeDecoder.decode(bitWithProb: &literalProbs[symbol], pointerData: &pointerData)
-            }
-            let byte = (symbol - 0x100).toUInt8()
-            outWindow.put(byte, &out, &outIndex, &uncompressedSize)
-        }
-
-        func decodeDistance(_ len: Int) -> Int {
-            var lenState = len
-            if lenState > Constants.numLenToPosStates - 1 {
-                lenState = Constants.numLenToPosStates - 1
-            }
-
-            let posSlot = posSlotDecoder[lenState].decode(with: &rangeDecoder, pointerData: &pointerData)
-            if posSlot < 4 {
-                return posSlot
-            }
-
-            let numDirectBits = (posSlot >> 1) - 1
-            var dist = ((2 | (posSlot & 1)) << numDirectBits)
-            if posSlot < Constants.endPosModelIndex {
-                // TODO: Probably incorrect first argument.
-                dist += bitTreeReverseDecode(probs: &posDecoders, bits: numDirectBits, rangeDecoder: &rangeDecoder, pointerData: &pointerData)
-            } else {
-                dist += rangeDecoder.decode(directBits: (numDirectBits - Constants.numAlignBits) << Constants.numAlignBits,
-                                            pointerData: &pointerData)
-                dist += alignDecoder.reverseDecode(with: &rangeDecoder, pointerData: &pointerData)
-            }
-            return dist
-        }
-
         // Main decoding cycle.
         while true {
             // If uncompressed size was defined and everything is unpacked then stop.

        var out: [UInt8] = uncompressedSize == -1 ? [] : Array(repeating: 0, count: uncompressedSize)
        var outIndex = uncompressedSize == -1 ? -1 : 0

        print("uncompressedSize: \(uncompressedSize)")

        let outWindow = OutWindow(dictSize: dictionarySize)


                } else {
                    state -= 6
                }

                continue
            }

