C语言优化问题
新手上路,想请教大神,下面这段程序怎么优化。如果要用到汇编的话,希望大神能说详细点哈,我不太懂汇编#include<stdio.h>
#include<stdlib.h>
#define BLOCK_SIZE 4
int a[16][16] ;
void forward4x4(int (*block)[16], int (*tblock)[16], int pos_y, int pos_x)
{
int i, ii;
int tmp[16];
int *pTmp = tmp, *pblock;
int p0,p1,p2,p3;
int t0,t1,t2,t3;
// Horizontal
for (i=pos_y; i < pos_y + BLOCK_SIZE; i++)
{
pblock = &block[i][pos_x];
p0 = *(pblock++);
p1 = *(pblock++);
p2 = *(pblock++);
p3 = *(pblock );
t0 = p0 + p3;
t1 = p1 + p2;
t2 = p1 - p2;
t3 = p0 - p3;
*(pTmp++) = t0 + t1;
*(pTmp++) = (t3 << 1) + t2;
*(pTmp++) = t0 - t1;
*(pTmp++) = t3 - (t2 << 1);
}
// Vertical
for (i=0; i < BLOCK_SIZE; i++)
{
pTmp = tmp + i;
p0 = *pTmp;
p1 = *(pTmp += BLOCK_SIZE);
p2 = *(pTmp += BLOCK_SIZE);
p3 = *(pTmp += BLOCK_SIZE);
t0 = p0 + p3;
t1 = p1 + p2;
t2 = p1 - p2;
t3 = p0 - p3;
ii = pos_x + i;
tblock[pos_y ][ii] = t0 + t1;
tblock[pos_y + 1][ii] = t2 + (t3 << 1);
tblock[pos_y + 2][ii] = t0 - t1;
tblock[pos_y + 3][ii] = t3 - (t2 << 1);
}
}
int main(){
int (*b)[16] = a;
int j,k;
//input
freopen("D:/BISHE/input.txt","r",stdin);
for(j=0;j<16;j++){
for(k=0;k<16;k++){
scanf("%d ",&b[j][k]);
}
}
freopen("CON","r",stdin);
for (j = 0; j < 16; j+=4)
{
for (k = 0;k < 16; k+=4)
{
forward4x4( b, b, j, k);
}
}
//output
freopen("D:/BISHE/output1.txt","w",stdout);
for (j = 0; j < 16; j++)
{
for (k = 0;k < 16; k++)
{
printf("%d ",a[j][k]);
}
printf("\n");
}
freopen("CON","w",stdout);
system("pause");
return 0;
}