@target mips, mipt2

package main;

const (
    LIN = 5
    COL = 5
)

var (
    origin [LIN][COL]int
    result [LIN][COL]int
)

func preenche_matriz() {
    var (
        w = 1
        value int
    )
    
    LM1 := LIN - 1
    CM1 := COL - 1

    for i := 0; i < LIN; i++ {
        for j := 0; j < COL; j++ {
            switch {
                case i == 0, i == LM1: // Primeira  e ultima linha
                    value = 0
                case j == 0, j == CM1: // Primeira e ultima coluna
                    value = 0
                default:               // Elementos do interior da matriz
                    value = w
                    w++
            }
            origin[i][j] = value
        }
    }
}

func laplaciano() {
    var (
        l int
        //LM1,CM1 int
        
    )
    LM1 := LIN - 1
    CM1 := COL - 1

    for i:= 1; i < LM1; i++ {
        for j := 1; j < CM1; j++ {
            l = origin[i-1][j] + origin[i][j-1] + origin[i][j+1] + origin[i+1][j] - (4 * origin[i][j])

            if l > 255 { l = 255 }
            result[i][j] = l
        }
    }
}

func main() {
  preenche_matriz()
  laplaciano()
}

/*
lab_1:
            l = origin[i-1][j] + origin[i][j-1] + origin[i][j+1] + origin[i+1][j] - (4 * origin[i][j])
lab_2:
            l = l + origin[i][j-1]
lab_3:
            l = l + origin[i][j+1] 
lab_4:
            l = l + origin[i+1][j]
lab_5:
            l = l - (4 * origin[i][j])
lab_6:

*/

/**

*/
/*

const (
    X = 10
    Y = 20
)
func main(){
    var (
        x [Y]int
        i = 12
    )
    //i++
    //i += 10
    //x[i + 3] = 40
    x[X + 3] = i
}
*/