void gostdecrypt(gost_ctx * c, const byte * in, byte * out)
{
    register word32 n1, n2;     /* As named in the GOST */
    n1 = in[0] | (in[1] << 8) | (in[2] << 16) | ((word32) in[3] << 24);
    n2 = in[4] | (in[5] << 8) | (in[6] << 16) | ((word32) in[7] << 24);

    n2 ^= f(c, n1 + c->k[0]);
    n1 ^= f(c, n2 + c->k[1]);
    n2 ^= f(c, n1 + c->k[2]);
    n1 ^= f(c, n2 + c->k[3]);
    n2 ^= f(c, n1 + c->k[4]);
    n1 ^= f(c, n2 + c->k[5]);
    n2 ^= f(c, n1 + c->k[6]);
    n1 ^= f(c, n2 + c->k[7]);

    n2 ^= f(c, n1 + c->k[7]);
    n1 ^= f(c, n2 + c->k[6]);
    n2 ^= f(c, n1 + c->k[5]);
    n1 ^= f(c, n2 + c->k[4]);
    n2 ^= f(c, n1 + c->k[3]);
    n1 ^= f(c, n2 + c->k[2]);
    n2 ^= f(c, n1 + c->k[1]);
    n1 ^= f(c, n2 + c->k[0]);

    n2 ^= f(c, n1 + c->k[7]);
    n1 ^= f(c, n2 + c->k[6]);
    n2 ^= f(c, n1 + c->k[5]);
    n1 ^= f(c, n2 + c->k[4]);
    n2 ^= f(c, n1 + c->k[3]);
    n1 ^= f(c, n2 + c->k[2]);
    n2 ^= f(c, n1 + c->k[1]);
    n1 ^= f(c, n2 + c->k[0]);

    n2 ^= f(c, n1 + c->k[7]);
    n1 ^= f(c, n2 + c->k[6]);
    n2 ^= f(c, n1 + c->k[5]);
    n1 ^= f(c, n2 + c->k[4]);
    n2 ^= f(c, n1 + c->k[3]);
    n1 ^= f(c, n2 + c->k[2]);
    n2 ^= f(c, n1 + c->k[1]);
    n1 ^= f(c, n2 + c->k[0]);

    out[0] = (byte) (n2 & 0xff);
    out[1] = (byte) ((n2 >> 8) & 0xff);
    out[2] = (byte) ((n2 >> 16) & 0xff);
    out[3] = (byte) (n2 >> 24);
    out[4] = (byte) (n1 & 0xff);
    out[5] = (byte) ((n1 >> 8) & 0xff);
    out[6] = (byte) ((n1 >> 16) & 0xff);
    out[7] = (byte) (n1 >> 24);
}