// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstants.java
// static int mask(final int size) {
//     return MASKS[size - 1];
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeByte(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Byte.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Byte.SIZE);
//     }
//     if (unsigned && size == Byte.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned byte");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeChar(final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Character.SIZE) {
//         throw new IllegalArgumentException("size(" + size + ") > " + Character.SIZE);
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeInt(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Integer.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Integer.SIZE);
//     }
//     if (unsigned && size == Integer.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned integer");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeLong(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Long.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Long.SIZE);
//     }
//     if (unsigned && size == Long.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned long");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeShort(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Short.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Short.SIZE);
//     }
//     if (unsigned && size == Short.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned short");
//     }
//     return size;
// }


import java.io.IOException;
import static com.github.jinahya.bit.io.BitIoConstants.mask;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeByte;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeChar;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeInt;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeLong;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeShort;
            writeInt(true, 1, value < 0 ? 1 : 0);
            if (--size > 0) {
                writeInt(true, size, value);
            }
            return;
        }
        final int quotient = size >> 3;
        final int remainder = size & 7;
        if (remainder > 0) {
            unsigned8(remainder, value >> (quotient << 3));
        }
        for (int i = Byte.SIZE * (quotient - 1); i >= 0; i -= Byte.SIZE) {
            unsigned8(Byte.SIZE, value >> i);
        }
    }

    @Override
    public void writeInt32(final int value) throws IOException {
        writeInt(false, Integer.SIZE, value);
    }

    @Override
    public void writeInt32Le(final int value) throws IOException {
        writeShort16Le((short) value);
        writeShort16Le((short) (value >> Short.SIZE));
    }

    // ------------------------------------------------------------------------------------------------------------ long
    @Override
    public void writeLong(final boolean unsigned, int size, final long value) throws IOException {
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstants.java
// static int mask(final int size) {
//     return MASKS[size - 1];
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeByte(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Byte.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Byte.SIZE);
//     }
//     if (unsigned && size == Byte.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned byte");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeChar(final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Character.SIZE) {
//         throw new IllegalArgumentException("size(" + size + ") > " + Character.SIZE);
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeInt(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Integer.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Integer.SIZE);
//     }
//     if (unsigned && size == Integer.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned integer");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeLong(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Long.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Long.SIZE);
//     }
//     if (unsigned && size == Long.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned long");
//     }
//     return size;
// }
// 
// Path: src/main/java/com/github/jinahya/bit/io/BitIoConstraints.java
// static int requireValidSizeShort(final boolean unsigned, final int size) {
//     if (size <= 0) {
//         throw new IllegalArgumentException("size(" + size + ") <= 0");
//     }
//     if (size > Short.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") > " + Short.SIZE);
//     }
//     if (unsigned && size == Short.SIZE) {
//         throw new IllegalArgumentException("invalid size(" + size + ") for unsigned short");
//     }
//     return size;
// }


// Path: src/main/java/com/github/jinahya/bit/io/AbstractBitOutput.java
import java.io.IOException;
import static com.github.jinahya.bit.io.BitIoConstants.mask;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeByte;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeChar;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeInt;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeLong;
import static com.github.jinahya.bit.io.BitIoConstraints.requireValidSizeShort;

            writeInt(true, 1, value < 0 ? 1 : 0);
            if (--size > 0) {
                writeInt(true, size, value);
            }
            return;
        }
        final int quotient = size >> 3;
        final int remainder = size & 7;
        if (remainder > 0) {
            unsigned8(remainder, value >> (quotient << 3));
        }
        for (int i = Byte.SIZE * (quotient - 1); i >= 0; i -= Byte.SIZE) {
            unsigned8(Byte.SIZE, value >> i);
        }
    }

    @Override
    public void writeInt32(final int value) throws IOException {
        writeInt(false, Integer.SIZE, value);
    }

    @Override
    public void writeInt32Le(final int value) throws IOException {
        writeShort16Le((short) value);
        writeShort16Le((short) (value >> Short.SIZE));
    }

    // ------------------------------------------------------------------------------------------------------------ long
    @Override
    public void writeLong(final boolean unsigned, int size, final long value) throws IOException {
        requireValidSizeLong(unsigned, size);