[ create a new paste ] login | about

Link: http://codepad.org/Mwek5qUR    [ raw code | output | fork ]

C, pasted on Feb 5:
#include <stdio.h>

void func(unsigned int *p,unsigned int a,unsigned int b,unsigned int c)
{
	unsigned int ax = b;
	unsigned int dx = c;
	unsigned int si,di,cx,bp,bx;
	si = ax + 0x0F;
	ax = si;
	si &= 0x1F;
	cx = 0x20 - si;
	ax >>= 5;
	if (cx <= dx)
	{
		b = cx;
	}
	else
	{
		cx = dx;
		b = dx;
	}
	di = si + cx;
	if (di >= 0x20)
	{
		di = 0x20;
	}
	cx = 0x20 - di;
	di = a;
	c = cx;
	bp = 0xFFFFFFFF; // bp = -1
	cx = 0x20 - dx;
	bx = di;
	bx <<= cx;
	cx = si;
	bp <<= cx;
	bx >>= cx;
	bp >>= cx;
	cx = c;
	bp >>= cx;
	bp <<= cx;
	cx = b;
	bp = ~bp;
	bp &= *(p + ax);
	bx |= bp;
	*(p + ax) = bx;
	if (cx < dx)
	{
		dx -= cx;
		cx = 0x20 - dx;
		di <<= cx;
		bx = 0xFFFFFFFF;
		cx = dx;
		bx >>= cx;
		++ax;
		bx &= *(p + ax);
		di |= bx;
		*(p + ax) = di;
	}
	return;
}

void test(unsigned int *p,int n,int m)
{
	int i;
	unsigned int k = 0,l = 0;
	for(i = n - 1;i >= 0;--i)
	{
		k = (*(p + i) >> (32 - m));
		*(p + i) = (*(p + i) << m)|l;
		l = k;
	}
	return;
}

void test2(unsigned int *p,int n,unsigned int m)
{
	*(p + n - 1) |= m;
	return;
}

int main(int argc,char **argv)
{
	unsigned int n[48] = {0};
	unsigned int p[16] = {0};
	int i,j;
	for(i = 0;i < 48;++i)
	{
		n[i] = (i % 8) + 1;
	}
	for(i = 0,j = 0;i < 35;i += 5)
	{
		if ((i + 5) <= 226)
		{
			if (i <= 0x71)
			{
				func(p,((i + 5) > 0x71) ? (n[j] >> (i + 5 - 0x71)) : (n[j]),i,((i + 5) > 0x71) ? (0x71 - i) : 5);
			}
			if ((i + 5) > 0x71)
			{
				func(p + 0x10,n[j],(i > 0x71) ? (i + 5 - 0x76) : 0,(i > 0x71) ? (0x76 - 5 - 0x6c) : (i - 0x6c));
			}
		}
		j++;
	}
	for(i = 0;i < 16;i++)
		printf("%02X ",p[i]);
	return 0;
}


Output:
1
110C 8531C000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 


Create a new paste based on this one


Comments: