def div(x, y):
    """
    Compute integer division x//y.
    """
    # find largest shift less than x
    i = 0
    s = y
    while s < x:
        s <<= 1
        i += 1
    s >>= 1
    i -= 1

    d = 0
    rem = x
    while i >= 0:
        if s < rem:
            rem -= s
            d += 1<<i
        i -= 1
        s >>= 1

    return d