Translating Matlab scrambler function to C
I think the mistake would be this line

current[0] = xor ^ bin[bin_ndx] ^ 1;


Remove the xor with 1 at the end.

current[0] = xor ^ bin[bin_ndx];


The MATLAB figure shows 1 because that is the multiplier (scale factor) and may not mean xor with 1.