View on GitHub

JST

By Janelle Blankenburg, Shubham Gogna, and Terence Henriod
UNR CS 660: Compiler Construction

Download this project as a .zip file Download this project as a tar.gz file

Matrix Multiplication

Input

const int ARRAY_DIM = 2;

// hard code dimensions for simplicity
int matrix_multiply(int C[ARRAY_DIM][ARRAY_DIM],
                    int A[ARRAY_DIM][ARRAY_DIM],
                    int B[ARRAY_DIM][ARRAY_DIM]);
int print_matrix(int C[ARRAY_DIM][ARRAY_DIM]);

int main() {
 int i, j, k;
 int sum;
 int A[ARRAY_DIM][ARRAY_DIM], B[ARRAY_DIM][ARRAY_DIM], C[ARRAY_DIM][ARRAY_DIM];

 for (i = 0; i < ARRAY_DIM; i++) {
   for (j = 0; j < ARRAY_DIM; j++) {
     A[i][j] = B[i][j] = 2;
   }
 }

 // matrix_multiply
 matrix_multiply(C, A, B);

 // print_matrix
 print_matrix(C);

 return 0;
}

int matrix_multiply(int C[ARRAY_DIM][ARRAY_DIM],
                    int A[ARRAY_DIM][ARRAY_DIM],
                    int B[ARRAY_DIM][ARRAY_DIM])
{
 int i, j, k, sum;

 // matrix_multiply
 for (i = 0; i < ARRAY_DIM; i++) {
    for (j = 0; j < ARRAY_DIM; j++) {
       sum = 0;
       for( k=0; k < ARRAY_DIM; k++) {
           sum = sum + A[i][k] * B[k][j];
       }
       C[i][j] = sum;
    }
 }
}

int print_matrix( int C[ARRAY_DIM][ARRAY_DIM])
{
 int i, j;

 // print_matrix
 for (i = 0; i < ARRAY_DIM; i++) {
       for (j = 0; j < ARRAY_DIM; j++) {
           print_int(C[i][j]);     // expect to see four 8's
           print_char(' ');
       }
       print_char('\n');
 }
}

MIPS


  .macro SAVE_T_REGISTERS
  # brace yourself for a long, unrolled loop...
  sw           $t0,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $t1,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $t2,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $t3,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $t4,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $t5,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $t6,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $t7,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $t8,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $t9,    ($sp)
  subiu        $sp,      $sp,        4
  .end_macro

  .macro RESTORE_T_REGISTERS
  # brace yourself for a long, unrolled loop...
  addiu        $sp,      $sp,        4
  lw           $t9,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $t8,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $t7,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $t6,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $t5,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $t4,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $t3,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $t2,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $t1,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $t0,    ($sp)
  .end_macro

  .macro SAVE_SPILL_MEM
  # brace yourself for a long, unrolled loop...
  lw           $a3, SPILL_MEMORY
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 4
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 8
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 12
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 16
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 20
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 24
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 28
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 32
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 36
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 40
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 44
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 48
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 52
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 56
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  lw           $a3, SPILL_MEMORY + 60
  sw           $a3,    ($sp)
  subiu        $sp,      $sp,        4
  .end_macro

  .macro RESTORE_SPILL_MEM
  # brace yourself for a long, unrolled loop...
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 60
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 56
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 52
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 48
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 44
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 40
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 36
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 32
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 28
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 24
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 20
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 16
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 12
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 8
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY + 4
  addiu        $sp,      $sp,        4
  lw           $a3,    ($sp)
  sw           $a3, SPILL_MEMORY
  .end_macro

  .macro CALLEE_FUNCTION_PROLOGUE (%variable_size)
  # set $fp to the proper spot by recovering the value from $a0
  add          $fp,      $a0,    $zero
  # allocate stack space for variables ($sp = $sp - space for variables)
  li           $a0,        4
  mulu         $a1,      $a0, %variable_size
  sub          $sp,      $sp,      $a1
  .end_macro

  .macro CALLEE_FUNCTION_EPILOGUE
  # de-allocate the memory used for local variables and parameters
  add          $sp,      $fp,    $zero
  # jump back to the caller
  jr           $ra
  .end_macro

  .macro CALLER_FUNCTION_PROLOGUE
  # caller should save it's own $ra, $fp, and registers
  sw           $ra,    ($sp)
  subiu        $sp,      $sp,        4
  sw           $fp,    ($sp)
  subiu        $sp,      $sp,        4
  # caller pushes registers and spill memory onto the stack as well
  SAVE_T_REGISTERS()
  SAVE_SPILL_MEM()
  # save the value of $sp here into $a0 as temporary storage until the arguments are moved
  # $fp needs to stay where it's at while the arguments are copied after this macro
  add          $a0,      $sp,    $zero
  .end_macro

  .macro CALLER_FUNCTION_EPILOGUE
  # recover the spill memory and the stored registers
  RESTORE_SPILL_MEM()
  RESTORE_T_REGISTERS()
  # recover the caller's $fp and $ra
  addiu        $sp,      $sp,        4
  lw           $fp,    ($sp)
  addiu        $sp,      $sp,        4
  lw           $ra,    ($sp)
  .end_macro

  .macro __LAND (%lhs, %rhs)
  beqz        %lhs, __LAND_FALSE
  beqz        %rhs, __LAND_FALSE
  li           $a2,        1
  j       __LAND_END

  __LAND_FALSE:
  li           $a2,        0

  __LAND_END:
  .end_macro

  .macro __LOR (%lhs, %rhs)
  beqz        %lhs, __LOR_TRUE
  beqz        %rhs, __LOR_TRUE
  li           $a2,        0
  j       __LOR_END

  __LOR_TRUE:
  li           $a2,        1

  __LOR_END:
  .end_macro


  .data
  SPILL_MEMORY: .space 64
  ARRAY_DIM: .word 2

  .text
  add          $fp,      $sp,    $zero
  add          $a0,      $fp,    $zero
  jal         main
  j       PROG_END

  main:
  CALLEE_FUNCTION_PROLOGUE(16)
  la           $t0,    ($fp)
  li           $t1,        0
  sw           $t1,    ($t0)

  LOOP_CONDITION_00000:
  lw           $t1,    ($fp)
  li           $t0,        2
  lw           $t0, ARRAY_DIM
  slt          $t2,      $t1,      $t0
  bne          $t2,    $zero, LOOP_BODY_00000
  j       LOOP_EXIT_00000

  LOOP_BODY_00000:
  la           $t0,  -4($fp)
  li           $t1,        0
  sw           $t1,    ($t0)

  LOOP_CONDITION_00001:
  lw           $t1,  -4($fp)
  li           $t0,        2
  lw           $t0, ARRAY_DIM
  slt          $t3,      $t1,      $t0
  bne          $t3,    $zero, LOOP_BODY_00001
  j       LOOP_EXIT_00001

  LOOP_BODY_00001:
  lw           $t0,    ($fp)
  mul          $t0,      $t0,        2
  lw           $t1,  -4($fp)
  addu         $t0,      $t0,      $t1
  mul          $t0,      $t0,        4
  la           $t1, -16($fp)
  addi         $t4,      $t1,      -16
  sub          $t0,      $t1,      $t0
  tlt          $t1,      $t0
  tge          $t4,      $t0
  lw           $t4,    ($fp)
  mul          $t4,      $t4,        2
  lw           $t1,  -4($fp)
  addu         $t4,      $t4,      $t1
  mul          $t4,      $t4,        4
  la           $t1, -32($fp)
  addi         $t5,      $t1,      -16
  sub          $t4,      $t1,      $t4
  tlt          $t1,      $t4
  tge          $t5,      $t4
  li           $t5,        2
  sw           $t5,    ($t4)
  sw           $t5,    ($t0)
  la           $t5,  -4($fp)
  lw           $t0,    ($t5)
  add          $t4,      $t0,    $zero
  addiu        $t0,      $t0,        1
  sw           $t0,    ($t5)
  j       LOOP_CONDITION_00001

  LOOP_EXIT_00001:
  la           $t4,    ($fp)
  lw           $t0,    ($t4)
  add          $t5,      $t0,    $zero
  addiu        $t0,      $t0,        1
  sw           $t0,    ($t4)
  j       LOOP_CONDITION_00000

  LOOP_EXIT_00000:
  CALLER_FUNCTION_PROLOGUE()
  lw           $t5, -48($fp)
  la           $t5,    ($fp)
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,       16
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,        2
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,        2
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  lw           $t5, -16($fp)
  la           $t5, -16($fp)
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,       16
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,        2
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,        2
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  lw           $t5, -32($fp)
  la           $t5, -32($fp)
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,       16
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,        2
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,        2
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  jal     matrix_multiply
  CALLER_FUNCTION_EPILOGUE()
  add          $t5,      $v0,    $zero
  CALLER_FUNCTION_PROLOGUE()
  lw           $t5, -48($fp)
  la           $t5,    ($fp)
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,       16
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,        2
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  li           $t5,        2
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  jal     print_matrix
  CALLER_FUNCTION_EPILOGUE()
  add          $t5,      $v0,    $zero
  li           $t5,        0
  add          $v0,      $t5,    $zero
  CALLEE_FUNCTION_EPILOGUE()
  CALLEE_FUNCTION_EPILOGUE()

  matrix_multiply:
  CALLEE_FUNCTION_PROLOGUE(4)
  la           $t2, -48($fp)
  li           $t3,        0
  sw           $t3,    ($t2)

  LOOP_CONDITION_00002:
  lw           $t3, -48($fp)
  li           $t2,        2
  lw           $t2, ARRAY_DIM
  slt          $t5,      $t3,      $t2
  bne          $t5,    $zero, LOOP_BODY_00002
  j       LOOP_EXIT_00002

  LOOP_BODY_00002:
  la           $t2, -52($fp)
  li           $t3,        0
  sw           $t3,    ($t2)

  LOOP_CONDITION_00003:
  lw           $t3, -52($fp)
  li           $t2,        2
  lw           $t2, ARRAY_DIM
  slt          $t0,      $t3,      $t2
  bne          $t0,    $zero, LOOP_BODY_00003
  j       LOOP_EXIT_00003

  LOOP_BODY_00003:
  la           $t2, -60($fp)
  li           $t3,        0
  sw           $t3,    ($t2)
  la           $t3, -56($fp)
  li           $t2,        0
  sw           $t2,    ($t3)

  LOOP_CONDITION_00004:
  lw           $t2, -56($fp)
  li           $t3,        2
  lw           $t3, ARRAY_DIM
  slt          $t4,      $t2,      $t3
  bne          $t4,    $zero, LOOP_BODY_00004
  j       LOOP_EXIT_00004

  LOOP_BODY_00004:
  la           $t3, -60($fp)
  lw           $t2, -60($fp)
  lw           $t1, -48($fp)
  lw           $t6, -28($fp)
  mul          $t1,      $t1,      $t6
  lw           $t6, -56($fp)
  addu         $t1,      $t1,      $t6
  mul          $t1,      $t1,        4
  lw           $t6, -16($fp)
  lw           $t7, -20($fp)
  sub          $t7,      $t6,      $t7
  sub          $t1,      $t6,      $t1
  tlt          $t6,      $t1
  tge          $t7,      $t1
  lw           $t1,    ($t1)
  lw           $t7, -56($fp)
  lw           $t6, -44($fp)
  mul          $t7,      $t7,      $t6
  lw           $t6, -52($fp)
  addu         $t7,      $t7,      $t6
  mul          $t7,      $t7,        4
  lw           $t6, -32($fp)
  lw           $t8, -36($fp)
  sub          $t8,      $t6,      $t8
  sub          $t7,      $t6,      $t7
  tlt          $t6,      $t7
  tge          $t8,      $t7
  lw           $t7,    ($t7)
  mul          $t8,      $t1,      $t7
  add          $t7,      $t2,      $t8
  sw           $t7,    ($t3)
  la           $t7, -56($fp)
  lw           $t3,    ($t7)
  add          $t8,      $t3,    $zero
  addiu        $t3,      $t3,        1
  sw           $t3,    ($t7)
  j       LOOP_CONDITION_00004

  LOOP_EXIT_00004:
  lw           $t8, -48($fp)
  lw           $t3, -12($fp)
  mul          $t8,      $t8,      $t3
  lw           $t3, -52($fp)
  addu         $t8,      $t8,      $t3
  mul          $t8,      $t8,        4
  lw           $t3,    ($fp)
  lw           $t7,  -4($fp)
  sub          $t7,      $t3,      $t7
  sub          $t8,      $t3,      $t8
  tlt          $t3,      $t8
  tge          $t7,      $t8
  lw           $t7, -60($fp)
  sw           $t7,    ($t8)
  la           $t7, -52($fp)
  lw           $t8,    ($t7)
  add          $t3,      $t8,    $zero
  addiu        $t8,      $t8,        1
  sw           $t8,    ($t7)
  j       LOOP_CONDITION_00003

  LOOP_EXIT_00003:
  la           $t3, -48($fp)
  lw           $t8,    ($t3)
  add          $t7,      $t8,    $zero
  addiu        $t8,      $t8,        1
  sw           $t8,    ($t3)
  j       LOOP_CONDITION_00002

  LOOP_EXIT_00002:
  CALLEE_FUNCTION_EPILOGUE()

  print_matrix:
  CALLEE_FUNCTION_PROLOGUE(2)
  la           $t5, -16($fp)
  li           $t0,        0
  sw           $t0,    ($t5)

  LOOP_CONDITION_00005:
  lw           $t0, -16($fp)
  li           $t5,        2
  lw           $t5, ARRAY_DIM
  slt          $t4,      $t0,      $t5
  bne          $t4,    $zero, LOOP_BODY_00005
  j       LOOP_EXIT_00005

  LOOP_BODY_00005:
  la           $t5, -20($fp)
  li           $t0,        0
  sw           $t0,    ($t5)

  LOOP_CONDITION_00006:
  lw           $t0, -20($fp)
  li           $t5,        2
  lw           $t5, ARRAY_DIM
  slt          $t7,      $t0,      $t5
  bne          $t7,    $zero, LOOP_BODY_00006
  j       LOOP_EXIT_00006

  LOOP_BODY_00006:
  CALLER_FUNCTION_PROLOGUE()
  lw           $t5, -16($fp)
  lw           $t0, -12($fp)
  mul          $t5,      $t5,      $t0
  lw           $t0, -20($fp)
  addu         $t5,      $t5,      $t0
  mul          $t5,      $t5,        4
  lw           $t0,    ($fp)
  lw           $t8,  -4($fp)
  sub          $t8,      $t0,      $t8
  sub          $t5,      $t0,      $t5
  tlt          $t0,      $t5
  tge          $t8,      $t5
  lw           $t5,    ($t5)
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  jal     print_int
  CALLER_FUNCTION_EPILOGUE()
  add          $t5,      $v0,    $zero
  CALLER_FUNCTION_PROLOGUE()
  li           $t5,       32
  sw           $t5,    ($sp)
  sub          $sp,      $sp,        4
  jal     print_char
  CALLER_FUNCTION_EPILOGUE()
  add          $t5,      $v0,    $zero
  la           $t5, -20($fp)
  lw           $t8,    ($t5)
  add          $t0,      $t8,    $zero
  addiu        $t8,      $t8,        1
  sw           $t8,    ($t5)
  j       LOOP_CONDITION_00006

  LOOP_EXIT_00006:
  CALLER_FUNCTION_PROLOGUE()
  li           $t0,       10
  sw           $t0,    ($sp)
  sub          $sp,      $sp,        4
  jal     print_char
  CALLER_FUNCTION_EPILOGUE()
  add          $t0,      $v0,    $zero
  la           $t0, -16($fp)
  lw           $t8,    ($t0)
  add          $t5,      $t8,    $zero
  addiu        $t8,      $t8,        1
  sw           $t8,    ($t0)
  j       LOOP_CONDITION_00005

  LOOP_EXIT_00005:
  CALLEE_FUNCTION_EPILOGUE()

  print_char:
  CALLEE_FUNCTION_PROLOGUE(0)
  # load $v0 with the value for the print char syscall
  li           $v0,       11
  # the first (and only) argument is the value to print
  lw           $a0,    ($fp)
  syscall
  CALLEE_FUNCTION_EPILOGUE()

  print_int:
  CALLEE_FUNCTION_PROLOGUE(0)
  # load $v0 with the value for the print int syscall
  li           $v0,        1
  # the first (and only) argument is the value to print
  lw           $a0,    ($fp)
  syscall
  CALLEE_FUNCTION_EPILOGUE()

  print_string:
  CALLEE_FUNCTION_PROLOGUE(0)
  # load $v0 with the value for the print string syscall
  li           $v0,        4
  # the first (and only) argument is the base address of the null terminated ascii string
  la           $a0,    ($fp)
  syscall
  CALLEE_FUNCTION_EPILOGUE()

  print_float:
  CALLEE_FUNCTION_PROLOGUE(0)
  # load $v0 with the value for the print float syscall
  li           $v0,        2
  # the first (and only) argument is the base address of the null terminated ascii string
  lwc1        $f12,    ($fp)
  syscall
  CALLEE_FUNCTION_EPILOGUE()

  PROG_END:
  add          $a0,      $v0,    $zero
  li           $v0,       17
  syscall

Output

8 8
8 8

3AC (Three-Address Code)


  .data
  GLOBLDECL      , ARRAY_DIM      , .word          , 2
  .text
  JAL            , main           , -              , -
  BR             , PROG_END       , -              , -
  main:
  PROCENTRY      , 64             , -              , -
  LA             , ireg_00000     , ($FP)          , -
  LI             , ireg_00001     , 0              , -
  STORE          , ireg_00001     , (ireg_00000)   , 4
  KICK           , ireg_00000     , -              , -
  KICK           , ireg_00001     , -              , -
  LOOP_CONDITION_00000:
  LOAD           , ireg_00002     , ($FP)          , 4
  LI             , ireg_00003     , 2              , -
  LOAD           , ireg_00003     , ARRAY_DIM      , 4
  LT             , ireg_00004     , ireg_00002     , ireg_00003
  KICK           , ireg_00002     , -              , -
  KICK           , ireg_00003     , -              , -
  BRNE           , LOOP_BODY_00000, ireg_00004     , $ZERO
  BR             , LOOP_EXIT_00000, -              , -
  LOOP_BODY_00000:
  LA             , ireg_00005     , -4($FP)        , -
  LI             , ireg_00006     , 0              , -
  STORE          , ireg_00006     , (ireg_00005)   , 4
  KICK           , ireg_00005     , -              , -
  KICK           , ireg_00006     , -              , -
  LOOP_CONDITION_00001:
  LOAD           , ireg_00007     , -4($FP)        , 4
  LI             , ireg_00008     , 2              , -
  LOAD           , ireg_00008     , ARRAY_DIM      , 4
  LT             , ireg_00009     , ireg_00007     , ireg_00008
  KICK           , ireg_00007     , -              , -
  KICK           , ireg_00008     , -              , -
  BRNE           , LOOP_BODY_00001, ireg_00009     , $ZERO
  BR             , LOOP_EXIT_00001, -              , -
  LOOP_BODY_00001:
  LOAD           , ireg_00010     , ($FP)          , 4
  MUL            , ireg_00010     , ireg_00010     , 2
  LOAD           , ireg_00011     , -4($FP)        , 4
  ADDU           , ireg_00010     , ireg_00010     , ireg_00011
  KICK           , ireg_00011     , -              , -
  MUL            , ireg_00010     , ireg_00010     , 4
  LA             , ireg_00012     , -16($FP)       , -
  ADDI           , ireg_00013     , ireg_00012     , -16
  SUB            , ireg_00010     , ireg_00012     , ireg_00010
  BOUND          , ireg_00010     , ireg_00012     , ireg_00013
  KICK           , ireg_00012     , -              , -
  KICK           , ireg_00013     , -              , -
  LOAD           , ireg_00014     , ($FP)          , 4
  MUL            , ireg_00014     , ireg_00014     , 2
  LOAD           , ireg_00015     , -4($FP)        , 4
  ADDU           , ireg_00014     , ireg_00014     , ireg_00015
  KICK           , ireg_00015     , -              , -
  MUL            , ireg_00014     , ireg_00014     , 4
  LA             , ireg_00016     , -32($FP)       , -
  ADDI           , ireg_00017     , ireg_00016     , -16
  SUB            , ireg_00014     , ireg_00016     , ireg_00014
  BOUND          , ireg_00014     , ireg_00016     , ireg_00017
  KICK           , ireg_00016     , -              , -
  KICK           , ireg_00017     , -              , -
  LI             , ireg_00018     , 2              , -
  STORE          , ireg_00018     , (ireg_00014)   , 4
  KICK           , ireg_00014     , -              , -
  STORE          , ireg_00018     , (ireg_00010)   , 4
  KICK           , ireg_00010     , -              , -
  KICK           , ireg_00018     , -              , -
  LA             , ireg_00019     , -4($FP)        , -
  LOAD           , ireg_00020     , (ireg_00019)   , 4
  ADD            , ireg_00021     , ireg_00020     , $ZERO
  ADDIU          , ireg_00020     , ireg_00020     , 1
  STORE          , ireg_00020     , (ireg_00019)   , 4
  KICK           , ireg_00019     , -              , -
  KICK           , ireg_00020     , -              , -
  KICK           , ireg_00021     , -              , -
  BR             , LOOP_CONDITION_00001, -              , -
  LOOP_EXIT_00001:
  LA             , ireg_00022     , ($FP)          , -
  LOAD           , ireg_00023     , (ireg_00022)   , 4
  ADD            , ireg_00024     , ireg_00023     , $ZERO
  ADDIU          , ireg_00023     , ireg_00023     , 1
  STORE          , ireg_00023     , (ireg_00022)   , 4
  KICK           , ireg_00022     , -              , -
  KICK           , ireg_00023     , -              , -
  KICK           , ireg_00024     , -              , -
  BR             , LOOP_CONDITION_00000, -              , -
  LOOP_EXIT_00000:
  CALL_PROC      , matrix_multiply, 64             , -
  LOAD           , ireg_00026     , -48($FP)       , 4
  KICK           , ireg_00026     , -              , -
  LA             , ireg_00027     , ($FP)          , -
  STORE          , ireg_00027     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00027     , 16             , -
  STORE          , ireg_00027     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00027     , 2              , -
  STORE          , ireg_00027     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00027     , 2              , -
  STORE          , ireg_00027     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  KICK           , ireg_00027     , -              , -
  LOAD           , ireg_00028     , -16($FP)       , 4
  KICK           , ireg_00028     , -              , -
  LA             , ireg_00029     , -16($FP)       , -
  STORE          , ireg_00029     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00029     , 16             , -
  STORE          , ireg_00029     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00029     , 2              , -
  STORE          , ireg_00029     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00029     , 2              , -
  STORE          , ireg_00029     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  KICK           , ireg_00029     , -              , -
  LOAD           , ireg_00030     , -32($FP)       , 4
  KICK           , ireg_00030     , -              , -
  LA             , ireg_00031     , -32($FP)       , -
  STORE          , ireg_00031     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00031     , 16             , -
  STORE          , ireg_00031     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00031     , 2              , -
  STORE          , ireg_00031     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00031     , 2              , -
  STORE          , ireg_00031     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  KICK           , ireg_00031     , -              , -
  JAL            , matrix_multiply, -              , -
  END_PROC       , 64             , -              , -
  ADD            , ireg_00025     , $RV            , $ZERO
  KICK           , ireg_00025     , -              , -
  CALL_PROC      , print_matrix   , 24             , -
  LOAD           , ireg_00033     , -48($FP)       , 4
  KICK           , ireg_00033     , -              , -
  LA             , ireg_00034     , ($FP)          , -
  STORE          , ireg_00034     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00034     , 16             , -
  STORE          , ireg_00034     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00034     , 2              , -
  STORE          , ireg_00034     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  LI             , ireg_00034     , 2              , -
  STORE          , ireg_00034     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  KICK           , ireg_00034     , -              , -
  JAL            , print_matrix   , -              , -
  END_PROC       , 24             , -              , -
  ADD            , ireg_00032     , $RV            , $ZERO
  KICK           , ireg_00032     , -              , -
  LI             , ireg_00035     , 0              , -
  RETURN         , ireg_00035     , -              , -
  ENDPROC        , -              , -              , -
  matrix_multiply:
  PROCENTRY      , 16             , -              , -
  LA             , ireg_00036     , -48($FP)       , -
  LI             , ireg_00037     , 0              , -
  STORE          , ireg_00037     , (ireg_00036)   , 4
  KICK           , ireg_00036     , -              , -
  KICK           , ireg_00037     , -              , -
  LOOP_CONDITION_00002:
  LOAD           , ireg_00038     , -48($FP)       , 4
  LI             , ireg_00039     , 2              , -
  LOAD           , ireg_00039     , ARRAY_DIM      , 4
  LT             , ireg_00040     , ireg_00038     , ireg_00039
  KICK           , ireg_00038     , -              , -
  KICK           , ireg_00039     , -              , -
  BRNE           , LOOP_BODY_00002, ireg_00040     , $ZERO
  BR             , LOOP_EXIT_00002, -              , -
  LOOP_BODY_00002:
  LA             , ireg_00041     , -52($FP)       , -
  LI             , ireg_00042     , 0              , -
  STORE          , ireg_00042     , (ireg_00041)   , 4
  KICK           , ireg_00041     , -              , -
  KICK           , ireg_00042     , -              , -
  LOOP_CONDITION_00003:
  LOAD           , ireg_00043     , -52($FP)       , 4
  LI             , ireg_00044     , 2              , -
  LOAD           , ireg_00044     , ARRAY_DIM      , 4
  LT             , ireg_00045     , ireg_00043     , ireg_00044
  KICK           , ireg_00043     , -              , -
  KICK           , ireg_00044     , -              , -
  BRNE           , LOOP_BODY_00003, ireg_00045     , $ZERO
  BR             , LOOP_EXIT_00003, -              , -
  LOOP_BODY_00003:
  LA             , ireg_00046     , -60($FP)       , -
  LI             , ireg_00047     , 0              , -
  STORE          , ireg_00047     , (ireg_00046)   , 4
  KICK           , ireg_00046     , -              , -
  KICK           , ireg_00047     , -              , -
  LA             , ireg_00048     , -56($FP)       , -
  LI             , ireg_00049     , 0              , -
  STORE          , ireg_00049     , (ireg_00048)   , 4
  KICK           , ireg_00048     , -              , -
  KICK           , ireg_00049     , -              , -
  LOOP_CONDITION_00004:
  LOAD           , ireg_00050     , -56($FP)       , 4
  LI             , ireg_00051     , 2              , -
  LOAD           , ireg_00051     , ARRAY_DIM      , 4
  LT             , ireg_00052     , ireg_00050     , ireg_00051
  KICK           , ireg_00050     , -              , -
  KICK           , ireg_00051     , -              , -
  BRNE           , LOOP_BODY_00004, ireg_00052     , $ZERO
  BR             , LOOP_EXIT_00004, -              , -
  LOOP_BODY_00004:
  LA             , ireg_00053     , -60($FP)       , -
  LOAD           , ireg_00054     , -60($FP)       , 4
  LOAD           , ireg_00055     , -48($FP)       , 4
  LOAD           , ireg_00056     , -28($FP)       , 4
  MUL            , ireg_00055     , ireg_00055     , ireg_00056
  KICK           , ireg_00056     , -              , -
  LOAD           , ireg_00057     , -56($FP)       , 4
  ADDU           , ireg_00055     , ireg_00055     , ireg_00057
  KICK           , ireg_00057     , -              , -
  MUL            , ireg_00055     , ireg_00055     , 4
  LOAD           , ireg_00058     , -16($FP)       , 4
  LOAD           , ireg_00059     , -20($FP)       , 4
  SUB            , ireg_00059     , ireg_00058     , ireg_00059
  SUB            , ireg_00055     , ireg_00058     , ireg_00055
  BOUND          , ireg_00055     , ireg_00058     , ireg_00059
  KICK           , ireg_00058     , -              , -
  KICK           , ireg_00059     , -              , -
  LOAD           , ireg_00055     , (ireg_00055)   , 4
  LOAD           , ireg_00060     , -56($FP)       , 4
  LOAD           , ireg_00061     , -44($FP)       , 4
  MUL            , ireg_00060     , ireg_00060     , ireg_00061
  KICK           , ireg_00061     , -              , -
  LOAD           , ireg_00062     , -52($FP)       , 4
  ADDU           , ireg_00060     , ireg_00060     , ireg_00062
  KICK           , ireg_00062     , -              , -
  MUL            , ireg_00060     , ireg_00060     , 4
  LOAD           , ireg_00063     , -32($FP)       , 4
  LOAD           , ireg_00064     , -36($FP)       , 4
  SUB            , ireg_00064     , ireg_00063     , ireg_00064
  SUB            , ireg_00060     , ireg_00063     , ireg_00060
  BOUND          , ireg_00060     , ireg_00063     , ireg_00064
  KICK           , ireg_00063     , -              , -
  KICK           , ireg_00064     , -              , -
  LOAD           , ireg_00060     , (ireg_00060)   , 4
  MUL            , ireg_00065     , ireg_00055     , ireg_00060
  KICK           , ireg_00055     , -              , -
  KICK           , ireg_00060     , -              , -
  ADD            , ireg_00066     , ireg_00054     , ireg_00065
  KICK           , ireg_00054     , -              , -
  KICK           , ireg_00065     , -              , -
  STORE          , ireg_00066     , (ireg_00053)   , 4
  KICK           , ireg_00053     , -              , -
  KICK           , ireg_00066     , -              , -
  LA             , ireg_00067     , -56($FP)       , -
  LOAD           , ireg_00068     , (ireg_00067)   , 4
  ADD            , ireg_00069     , ireg_00068     , $ZERO
  ADDIU          , ireg_00068     , ireg_00068     , 1
  STORE          , ireg_00068     , (ireg_00067)   , 4
  KICK           , ireg_00067     , -              , -
  KICK           , ireg_00068     , -              , -
  KICK           , ireg_00069     , -              , -
  BR             , LOOP_CONDITION_00004, -              , -
  LOOP_EXIT_00004:
  LOAD           , ireg_00070     , -48($FP)       , 4
  LOAD           , ireg_00071     , -12($FP)       , 4
  MUL            , ireg_00070     , ireg_00070     , ireg_00071
  KICK           , ireg_00071     , -              , -
  LOAD           , ireg_00072     , -52($FP)       , 4
  ADDU           , ireg_00070     , ireg_00070     , ireg_00072
  KICK           , ireg_00072     , -              , -
  MUL            , ireg_00070     , ireg_00070     , 4
  LOAD           , ireg_00073     , ($FP)          , 4
  LOAD           , ireg_00074     , -4($FP)        , 4
  SUB            , ireg_00074     , ireg_00073     , ireg_00074
  SUB            , ireg_00070     , ireg_00073     , ireg_00070
  BOUND          , ireg_00070     , ireg_00073     , ireg_00074
  KICK           , ireg_00073     , -              , -
  KICK           , ireg_00074     , -              , -
  LOAD           , ireg_00075     , -60($FP)       , 4
  STORE          , ireg_00075     , (ireg_00070)   , 4
  KICK           , ireg_00070     , -              , -
  KICK           , ireg_00075     , -              , -
  LA             , ireg_00076     , -52($FP)       , -
  LOAD           , ireg_00077     , (ireg_00076)   , 4
  ADD            , ireg_00078     , ireg_00077     , $ZERO
  ADDIU          , ireg_00077     , ireg_00077     , 1
  STORE          , ireg_00077     , (ireg_00076)   , 4
  KICK           , ireg_00076     , -              , -
  KICK           , ireg_00077     , -              , -
  KICK           , ireg_00078     , -              , -
  BR             , LOOP_CONDITION_00003, -              , -
  LOOP_EXIT_00003:
  LA             , ireg_00079     , -48($FP)       , -
  LOAD           , ireg_00080     , (ireg_00079)   , 4
  ADD            , ireg_00081     , ireg_00080     , $ZERO
  ADDIU          , ireg_00080     , ireg_00080     , 1
  STORE          , ireg_00080     , (ireg_00079)   , 4
  KICK           , ireg_00079     , -              , -
  KICK           , ireg_00080     , -              , -
  KICK           , ireg_00081     , -              , -
  BR             , LOOP_CONDITION_00002, -              , -
  LOOP_EXIT_00002:
  ENDPROC        , -              , -              , -
  print_matrix:
  PROCENTRY      , 8              , -              , -
  LA             , ireg_00082     , -16($FP)       , -
  LI             , ireg_00083     , 0              , -
  STORE          , ireg_00083     , (ireg_00082)   , 4
  KICK           , ireg_00082     , -              , -
  KICK           , ireg_00083     , -              , -
  LOOP_CONDITION_00005:
  LOAD           , ireg_00084     , -16($FP)       , 4
  LI             , ireg_00085     , 2              , -
  LOAD           , ireg_00085     , ARRAY_DIM      , 4
  LT             , ireg_00086     , ireg_00084     , ireg_00085
  KICK           , ireg_00084     , -              , -
  KICK           , ireg_00085     , -              , -
  BRNE           , LOOP_BODY_00005, ireg_00086     , $ZERO
  BR             , LOOP_EXIT_00005, -              , -
  LOOP_BODY_00005:
  LA             , ireg_00087     , -20($FP)       , -
  LI             , ireg_00088     , 0              , -
  STORE          , ireg_00088     , (ireg_00087)   , 4
  KICK           , ireg_00087     , -              , -
  KICK           , ireg_00088     , -              , -
  LOOP_CONDITION_00006:
  LOAD           , ireg_00089     , -20($FP)       , 4
  LI             , ireg_00090     , 2              , -
  LOAD           , ireg_00090     , ARRAY_DIM      , 4
  LT             , ireg_00091     , ireg_00089     , ireg_00090
  KICK           , ireg_00089     , -              , -
  KICK           , ireg_00090     , -              , -
  BRNE           , LOOP_BODY_00006, ireg_00091     , $ZERO
  BR             , LOOP_EXIT_00006, -              , -
  LOOP_BODY_00006:
  CALL_PROC      , print_int      , 0              , -
  LOAD           , ireg_00093     , -16($FP)       , 4
  LOAD           , ireg_00094     , -12($FP)       , 4
  MUL            , ireg_00093     , ireg_00093     , ireg_00094
  KICK           , ireg_00094     , -              , -
  LOAD           , ireg_00095     , -20($FP)       , 4
  ADDU           , ireg_00093     , ireg_00093     , ireg_00095
  KICK           , ireg_00095     , -              , -
  MUL            , ireg_00093     , ireg_00093     , 4
  LOAD           , ireg_00096     , ($FP)          , 4
  LOAD           , ireg_00097     , -4($FP)        , 4
  SUB            , ireg_00097     , ireg_00096     , ireg_00097
  SUB            , ireg_00093     , ireg_00096     , ireg_00093
  BOUND          , ireg_00093     , ireg_00096     , ireg_00097
  KICK           , ireg_00096     , -              , -
  KICK           , ireg_00097     , -              , -
  LOAD           , ireg_00093     , (ireg_00093)   , 4
  STORE          , ireg_00093     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  KICK           , ireg_00093     , -              , -
  JAL            , print_int      , -              , -
  END_PROC       , 0              , -              , -
  ADD            , ireg_00092     , $RV            , $ZERO
  KICK           , ireg_00092     , -              , -
  CALL_PROC      , print_char     , 0              , -
  LI             , ireg_00099     , 32             , -
  STORE          , ireg_00099     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  KICK           , ireg_00099     , -              , -
  JAL            , print_char     , -              , -
  END_PROC       , 0              , -              , -
  ADD            , ireg_00098     , $RV            , $ZERO
  KICK           , ireg_00098     , -              , -
  LA             , ireg_00100     , -20($FP)       , -
  LOAD           , ireg_00101     , (ireg_00100)   , 4
  ADD            , ireg_00102     , ireg_00101     , $ZERO
  ADDIU          , ireg_00101     , ireg_00101     , 1
  STORE          , ireg_00101     , (ireg_00100)   , 4
  KICK           , ireg_00100     , -              , -
  KICK           , ireg_00101     , -              , -
  KICK           , ireg_00102     , -              , -
  BR             , LOOP_CONDITION_00006, -              , -
  LOOP_EXIT_00006:
  CALL_PROC      , print_char     , 0              , -
  LI             , ireg_00104     , 10             , -
  STORE          , ireg_00104     , ($SP)          , 4
  SUB            , $SP            , $SP            , 4
  KICK           , ireg_00104     , -              , -
  JAL            , print_char     , -              , -
  END_PROC       , 0              , -              , -
  ADD            , ireg_00103     , $RV            , $ZERO
  KICK           , ireg_00103     , -              , -
  LA             , ireg_00105     , -16($FP)       , -
  LOAD           , ireg_00106     , (ireg_00105)   , 4
  ADD            , ireg_00107     , ireg_00106     , $ZERO
  ADDIU          , ireg_00106     , ireg_00106     , 1
  STORE          , ireg_00106     , (ireg_00105)   , 4
  KICK           , ireg_00105     , -              , -
  KICK           , ireg_00106     , -              , -
  KICK           , ireg_00107     , -              , -
  BR             , LOOP_CONDITION_00005, -              , -
  LOOP_EXIT_00005:
  ENDPROC        , -              , -              , -
  PROG_END: