import "std/io"
import "std/list"

extern str_cmp(a: string, b: string) -> int64;

//mat-mul
fun mat_mul(a: [[int64]], b: [[int64]]) -> [[int64]] {
    let a_rows = len(a);
    let a_cols = len(a[0]);
    let b_rows = len(b);
    let b_cols = len(b[0]);
    let i_res = 0;
    let result = new [[int64]; a_rows];
    while i_res < a_rows {
        result[i_res] = new [int64; b_cols];
        i_res = i_res + 1;
    }
    let i = 0;
    while i < a_rows {
        let j = 0;
        while j < b_cols {
            let k = 0;
            let sum = 0;
            while k < a_cols {
                sum = sum + a[i][k] * b[k][j];
                k = k + 1;
            }
            result[i][j] = sum;
            j = j + 1;
        }
        i = i + 1;
    }
    return result;
}

fun main() {
    let a: [[int64]] = [[1, 2, 3], [4, 5, 6]];
    let b: [[int64]] = [[7, 8], [9, 10], [11, 12]];
    let result = mat_mul(a, b);
    let i = 0;
    while i < len(result) {
        let j = 0;
        while j < len(result[0]) {
            print(" ");
            print(result[i][j]);
            j = j + 1;
        }
        println("");
        i = i + 1;
    }
    //The result should be: [[58, 64], [139, 154]]

    if str_cmp("Hello", "Hello") == 0 {
        println("Hello is equal to Hello");
    } else {
        println("Hello is not equal to Hello for some reason");
    }

    println("Done");
}
