#pragma TASS input 
int N_BOUND;
//need  BB % N = 0
//so add code similar to tile impl to check last iteration stays in bounds
#pragma TASS input {N>=0 && N<=N_BOUND} 
int N;
#pragma TASS input  {BB>0}
int BB;
#pragma TASS input 
double A[N][N];
#pragma TASS input 
double B[N][N];
#pragma TASS output 
double C[N][N];

void main() {
	int i; 
	int j;
	int k;
	int ii;
	int jj;
	int kk;
	double D[N][N];
	int hi;
	int hi2;
	int hi3;
	
	i = 0;
	while (i < N) {
		j = 0;
		while (j < N) {
			D[i][j] = 0.0;
			j = j + 1;
		}
		i = i + 1;
	}
	
	ii = 0;
	while (ii < N) {
		jj = 0;
		while (jj < N) {
			kk = 0;
			while (kk < N) {
				i = ii;
				if (ii + BB < N){
					hi = ii + BB;
				} else {
					hi = N;
				}
				while (i < hi) {
					j = jj;
					if (jj + BB < N) {
						hi2 = jj + BB;
					} else {
						hi2 = N;
					}
					while (j < hi2) {
						k = kk;
						if (kk + BB < N) {
							hi3 = kk + BB;
						} else {
							hi3 = N;
						}
						while (k < hi3) {
							D[i][j] = D[i][j] + A[i][k] * B[k][j]; 
							k = k + 1;
						}
						j  = j + 1;
					}
					i = i + 1;
				}
				kk = kk + BB;
			}
			jj = jj + BB;
		}
		ii = ii + BB;
	}
	
	i = 0;
	while (i < N) {
		j = 0;
		while (j < N) {
			C[i][j] = D[i][j];
			j = j + 1;
		}
		i = i + 1;
	}
	
}
