According to the implementation of function JKF, it is level triggered rather than edge triggered.
Clk: 010
OuA: 011
OuB: 010
At the third clock transition, the OuA is still '1'. Hence JKF(Q, 1, 1, &Q2, &NQ2); toggles OuB to logic 0.
The transition of clock has to be considered rather than the current level of Clock in JKF function implementation.
As as simple remedy, the for loop can be changed as follows to take the clock transition into account.
for(n=0; n<Len; n++)
{
Clk^=1;
JKF(Clk, 1, 1, &Q, &NQ);
if (n > 0)
{
if (OA[n -1] != Q)
{
JKF(Q, 1, 1, &Q2, &NQ2);
}
if (OB[n -1] != Q2)
{
JKF(Q2, 1, 1, &Q3, &NQ3);
}
if (OC[n -1] != Q3)
{
JKF(Q3, 1, 1, &Q4, &NQ4);
}
}
else
{
JKF(Q, 1, 1, &Q2, &NQ2);
JKF(Q2, 1, 1, &Q3, &NQ3);
JKF(Q3, 1, 1, &Q4, &NQ4);
}
ClkA[n] = Clk;
OA[n] = Q;
OB[n] = Q2;
OC[n] = Q3;
OD[n] = Q4;
}