can someone explain how CreateShuffleVector works
I have the following code

Value *OutLo; //v16i8
Value *OutHi; //v16i8
// how does this mask work? what elements it takes from OutLo and OutHi?
// the Interlaced should be v32i8
Value *Interlaced =
Builder.CreateShuffleVector(OutLo, OutHi, ArrayRef{0, 1, 16, 17});
NewOutput = Builder.CreateBitCast(Interlaced, Builder.getInt32Ty());

Yes, it takes elements from both. Your result type here will be <4 x i8>. The low 2 elements will come from OutLo, and the second two will come from OutHi. This corresponds exactly to the shufflevector instruction definition

Assume you have shufflevector inp1, inp2, mask. Both inp1 and inp2 need to be of the same type, say each has N elements. Conceptually, the two vectors are concatenated to form one vector inp, so that inp[0] = inp1[0], and inp[N] = inp2[0].
Then the output vector is formed by going over the mask, and each element of the mask is the index into inp of the element of the output. The number of elements in the mask will be the number of the elements in the output, and it can be different from N.

For example
shufflemask <a0, a1>, <b0, b1>, <0, 1, 2, 3> will simply concatenate the both inputs into <a0, a1, b0, b1>.
shufflemask <a0, a1, a2, a3>, <b0, b1, b2, b3>, <0, 2, 4, 6> will pick even elements from each vector: <a0, a2, b0, b2>.