def deinterleave(data, b_cap):
    """De-interleaves the bytes from a QR code"""
    n_bufs = len(b_cap)
    bufs = []
    for _ in range(n_bufs):
        bufs.append([])
    b_i = 0
    for i in range(sum(b_cap)):
        b = data[i]
        while b_cap[b_i] <= len(bufs[b_i]):
            b_i = (b_i + 1) % n_bufs
        bufs[b_i].append(b)
        b_i = (b_i + 1) % n_bufs
    buf = ''
    for b in bufs:
        buf += ''.join(b)
    return buf
