docs: def write_xbm(matrix, version, out, scale=1, border=None, name='img'):
      """\
      Serializes the matrix as `XBM <https://en.wikipedia.org/wiki/X_BitMap>`_ image.
  
      :param matrix: The matrix to serialize.
      :param int version: The (Micro) QR code version
      :param out: Filename or a file-like object supporting to write text data.
      :param scale: Indicates the size of a single module (default: 1 which
              corresponds to 1 x 1 in the provided unit per module).
      :param int border: Integer indicating the size of the quiet zone.
              If set to ``None`` (default), the recommended border size
              will be used (``4`` for QR Codes, ``2`` for a Micro QR Codes).
      :param name: Prefix for the variable names. Default: "img".
                   The prefix is used to construct the variable names:
                   ```#define <prefix>_width``` ```static unsigned char <prefix>_bits[]```
      """
      row_iter = matrix_iter(matrix, version, scale, border)
      border = get_border(version, border)
      width, height = get_symbol_size(version, scale=scale, border=border)
      with writable(out, 'wt') as f:
          write = f.write
          write('#define {0}_width {1}\n'
                '#define {0}_height {2}\n'
                'static unsigned char {0}_bits[] = {{\n'.format(name, width, height))
          for i, row in enumerate(row_iter, start=1):
              iter_ = zip_longest(*[iter(row)] * 8, fillvalue=0x0)
              # Reverse bits since XBM uses little endian
              bits = ['0x{0:02x}'.format(reduce(lambda x, y: (x << 1) + y, bits[::-1])) for bits in iter_]
              write('    ')
              write(', '.join(bits))
              write(',\n' if i < height else '\n')
          write('};\n')