I’ve narrowed down the error (at least I think so) but still don’t know why it’s happening. For the dataset:
mask = 1XX010X01110X110100000X11101X10X0X11 mem[3