summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--condense/CondenseVisitor.java11
-rw-r--r--output/BinaryTree.opt.s1052
-rw-r--r--output/BinaryTree.opt.vaporm797
-rw-r--r--output/BubbleSort.opt.s543
-rw-r--r--output/BubbleSort.opt.vaporm301
-rw-r--r--output/Factorial.opt.s73
-rw-r--r--output/Factorial.opt.vaporm30
-rw-r--r--output/LinearSearch.opt.s290
-rw-r--r--output/LinearSearch.opt.vaporm162
-rw-r--r--output/LinkedList.opt.s781
-rw-r--r--output/LinkedList.opt.vaporm562
-rw-r--r--output/MoreThan4.opt.s115
-rw-r--r--output/MoreThan4.opt.vaporm57
-rw-r--r--output/QuickSort.opt.s710
-rw-r--r--output/QuickSort.opt.vaporm418
-rw-r--r--output/TreeVisitor.opt.s1241
-rw-r--r--output/TreeVisitor.opt.vaporm948
-rwxr-xr-xtest.sh6
18 files changed, 8093 insertions, 4 deletions
diff --git a/condense/CondenseVisitor.java b/condense/CondenseVisitor.java
index 436ddfa..def8289 100644
--- a/condense/CondenseVisitor.java
+++ b/condense/CondenseVisitor.java
@@ -122,14 +122,19 @@ public class CondenseVisitor extends VInstr.Visitor<RuntimeException>{
n.getClass().getSimpleName(),
n.sourcePos.toString()));
///////////////////////////////////////////////////////////////
- if (this.isNumeric(n.source.toString()))
+ String source = n.source.toString();
+ if (this.isNumeric(source))
this.addMIPS(String.format(" li $%s %s",
((VVarRef.Register) n.dest).ident,
- n.source.toString()));
+ source));
+ else if (source.contains(":"))
+ this.addMIPS(String.format(" la $%s %s",
+ ((VVarRef.Register) n.dest).ident,
+ source.substring(1)));
else
this.addMIPS(String.format(" move $%s %s",
((VVarRef.Register) n.dest).ident,
- n.source.toString()));
+ source));
///////////////////////////////////////////////////////////////
MinimalLogger.info(String.format("<-%s (%s)",
n.getClass().getSimpleName(),
diff --git a/output/BinaryTree.opt.s b/output/BinaryTree.opt.s
new file mode 100644
index 0000000..c4c4530
--- /dev/null
+++ b/output/BinaryTree.opt.s
@@ -0,0 +1,1052 @@
+.data
+empty_BT:
+empty_Tree:
+.text
+jal Main
+li $v0 10
+syscall
+Main:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ la $a0 empty_BT
+ jal BT.Start
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+BT.Start:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ li $a0 24
+ jal _heapAlloc
+ move $s0 $v0
+ bgtz $s0 null1
+ la $a0 _str0
+ j _error
+null1:
+ move $a0 $s0
+ li $a1 16
+ jal Tree.Init
+ bgtz $s0 null2
+ la $a0 _str0
+ j _error
+null2:
+ move $a0 $s0
+ jal Tree.Print
+ li $a0 100000000
+ jal _print
+ bgtz $s0 null3
+ la $a0 _str0
+ j _error
+null3:
+ move $a0 $s0
+ li $a1 8
+ jal Tree.Insert
+ bgtz $s0 null4
+ la $a0 _str0
+ j _error
+null4:
+ move $a0 $s0
+ jal Tree.Print
+ bgtz $s0 null5
+ la $a0 _str0
+ j _error
+null5:
+ move $a0 $s0
+ li $a1 24
+ jal Tree.Insert
+ bgtz $s0 null6
+ la $a0 _str0
+ j _error
+null6:
+ move $a0 $s0
+ li $a1 4
+ jal Tree.Insert
+ bgtz $s0 null7
+ la $a0 _str0
+ j _error
+null7:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Insert
+ bgtz $s0 null8
+ la $a0 _str0
+ j _error
+null8:
+ move $a0 $s0
+ li $a1 20
+ jal Tree.Insert
+ bgtz $s0 null9
+ la $a0 _str0
+ j _error
+null9:
+ move $a0 $s0
+ li $a1 28
+ jal Tree.Insert
+ bgtz $s0 null10
+ la $a0 _str0
+ j _error
+null10:
+ move $a0 $s0
+ li $a1 14
+ jal Tree.Insert
+ bgtz $s0 null11
+ la $a0 _str0
+ j _error
+null11:
+ move $a0 $s0
+ jal Tree.Print
+ bgtz $s0 null12
+ la $a0 _str0
+ j _error
+null12:
+ move $a0 $s0
+ li $a1 24
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null13
+ la $a0 _str0
+ j _error
+null13:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null14
+ la $a0 _str0
+ j _error
+null14:
+ move $a0 $s0
+ li $a1 16
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null15
+ la $a0 _str0
+ j _error
+null15:
+ move $a0 $s0
+ li $a1 50
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null16
+ la $a0 _str0
+ j _error
+null16:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null17
+ la $a0 _str0
+ j _error
+null17:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Delete
+ bgtz $s0 null18
+ la $a0 _str0
+ j _error
+null18:
+ move $a0 $s0
+ jal Tree.Print
+ bgtz $s0 null19
+ la $a0 _str0
+ j _error
+null19:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+Tree.Init:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 8($t0)
+ li $t9 0
+ sw $t9 12($t0)
+ li $t9 0
+ sw $t9 16($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetRight:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 4($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetLeft:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 0($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetRight:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 4($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetLeft:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 0($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetKey:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 8($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetKey:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 8($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetHas_Right:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 16($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetHas_Left:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 12($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetHas_Left:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 12($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetHas_Right:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 16($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.Compare:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a1
+ move $t1 $a2
+ move $a0 $t1
+ li $t9 1
+ addu $t2 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ slt $t1 $a0 $t9
+ blez $t1 if1_else
+ li $t1 0
+ j if1_end
+if1_else:
+ move $a0 $t0
+ move $t9 $t2
+ slt $t2 $a0 $t9
+ bgtz $t2 if2_else
+ li $t1 0
+ j if2_end
+if2_else:
+ li $t1 1
+if2_end:
+if1_end:
+ move $v0 $t1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.Insert:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 24
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ sw $s3 -24($fp)
+ move $s0 $a0
+ move $s1 $a1
+ li $a0 24
+ jal _heapAlloc
+ move $s2 $v0
+ bgtz $s2 null20
+ la $a0 _str0
+ j _error
+null20:
+ move $a0 $s2
+ move $a1 $s1
+ jal Tree.Init
+ move $s0 $s0
+ li $s3 1
+while1_top:
+ blez $s3 while1_end
+ bgtz $s0 null21
+ la $a0 _str0
+ j _error
+null21:
+ move $a0 $s0
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s1
+ move $t9 $t0
+ slt $t0 $a0 $t9
+ blez $t0 if3_else
+ bgtz $s0 null22
+ la $a0 _str0
+ j _error
+null22:
+ move $a0 $s0
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 if4_else
+ bgtz $s0 null23
+ la $a0 _str0
+ j _error
+null23:
+ move $a0 $s0
+ jal Tree.GetLeft
+ move $s0 $v0
+ j if4_end
+if4_else:
+ li $s3 0
+ bgtz $s0 null24
+ la $a0 _str0
+ j _error
+null24:
+ move $a0 $s0
+ li $a1 1
+ jal Tree.SetHas_Left
+ bgtz $s0 null25
+ la $a0 _str0
+ j _error
+null25:
+ move $a0 $s0
+ move $a1 $s2
+ jal Tree.SetLeft
+if4_end:
+ j if3_end
+if3_else:
+ bgtz $s0 null26
+ la $a0 _str0
+ j _error
+null26:
+ move $a0 $s0
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if5_else
+ bgtz $s0 null27
+ la $a0 _str0
+ j _error
+null27:
+ move $a0 $s0
+ jal Tree.GetRight
+ move $s0 $v0
+ j if5_end
+if5_else:
+ li $s3 0
+ bgtz $s0 null28
+ la $a0 _str0
+ j _error
+null28:
+ move $a0 $s0
+ li $a1 1
+ jal Tree.SetHas_Right
+ bgtz $s0 null29
+ la $a0 _str0
+ j _error
+null29:
+ move $a0 $s0
+ move $a1 $s2
+ jal Tree.SetRight
+if5_end:
+if3_end:
+ j while1_top
+while1_end:
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $s3 -24($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 24
+ jr $ra
+Tree.Delete:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 36
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ sw $s3 -24($fp)
+ sw $s4 -28($fp)
+ sw $s5 -32($fp)
+ sw $s6 -36($fp)
+ move $s0 $a0
+ move $s1 $a1
+ move $s2 $s0
+ move $s3 $s0
+ li $s4 1
+ li $s5 0
+ li $s6 1
+while2_top:
+ blez $s4 while2_end
+ bgtz $s2 null30
+ la $a0 _str0
+ j _error
+null30:
+ move $a0 $s2
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s1
+ move $t9 $t0
+ slt $t1 $a0 $t9
+ blez $t1 if6_else
+ bgtz $s2 null31
+ la $a0 _str0
+ j _error
+null31:
+ move $a0 $s2
+ jal Tree.GetHas_Left
+ move $t1 $v0
+ blez $t1 if7_else
+ move $s3 $s2
+ bgtz $s2 null32
+ la $a0 _str0
+ j _error
+null32:
+ move $a0 $s2
+ jal Tree.GetLeft
+ move $s2 $v0
+ j if7_end
+if7_else:
+ li $s4 0
+if7_end:
+ j if6_end
+if6_else:
+ move $a0 $t0
+ move $t9 $s1
+ slt $t0 $a0 $t9
+ blez $t0 if8_else
+ bgtz $s2 null33
+ la $a0 _str0
+ j _error
+null33:
+ move $a0 $s2
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if9_else
+ move $s3 $s2
+ bgtz $s2 null34
+ la $a0 _str0
+ j _error
+null34:
+ move $a0 $s2
+ jal Tree.GetRight
+ move $s2 $v0
+ j if9_end
+if9_else:
+ li $s4 0
+if9_end:
+ j if8_end
+if8_else:
+ blez $s6 if10_else
+ bgtz $s2 null35
+ la $a0 _str0
+ j _error
+null35:
+ move $a0 $s2
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ bgtz $t0 if11_else
+ bgtz $s2 null36
+ la $a0 _str0
+ j _error
+null36:
+ move $a0 $s2
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ bgtz $t0 if11_else
+ j if11_end
+if11_else:
+ move $a0 $s0
+ move $a1 $s3
+ move $a2 $s2
+ jal Tree.Remove
+if11_end:
+ j if10_end
+if10_else:
+ move $a0 $s0
+ move $a1 $s3
+ move $a2 $s2
+ jal Tree.Remove
+if10_end:
+ li $s5 1
+ li $s4 0
+if8_end:
+if6_end:
+ li $s6 0
+ j while2_top
+while2_end:
+ move $v0 $s5
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $s3 -24($fp)
+ lw $s4 -28($fp)
+ lw $s5 -32($fp)
+ lw $s6 -36($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 36
+ jr $ra
+Tree.Remove:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ move $s0 $a0
+ move $s1 $a1
+ move $s2 $a2
+ bgtz $s2 null37
+ la $a0 _str0
+ j _error
+null37:
+ move $a0 $s2
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 if12_else
+ move $a0 $s0
+ move $a1 $s1
+ move $a2 $s2
+ jal Tree.RemoveLeft
+ j if12_end
+if12_else:
+ bgtz $s2 null38
+ la $a0 _str0
+ j _error
+null38:
+ move $a0 $s2
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if13_else
+ move $a0 $s0
+ move $a1 $s1
+ move $a2 $s2
+ jal Tree.RemoveRight
+ j if13_end
+if13_else:
+ bgtz $s2 null39
+ la $a0 _str0
+ j _error
+null39:
+ move $a0 $s2
+ jal Tree.GetKey
+ move $s2 $v0
+ bgtz $s1 null40
+ la $a0 _str0
+ j _error
+null40:
+ move $a0 $s1
+ jal Tree.GetLeft
+ move $t0 $v0
+ bgtz $t0 null41
+ la $a0 _str0
+ j _error
+null41:
+ move $a0 $t0
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s0
+ move $a1 $s2
+ move $a2 $t0
+ jal Tree.Compare
+ move $t0 $v0
+ blez $t0 if14_else
+ bgtz $s1 null42
+ la $a0 _str0
+ j _error
+null42:
+ lw $t0 20($s0)
+ move $a0 $s1
+ move $a1 $t0
+ jal Tree.SetLeft
+ bgtz $s1 null43
+ la $a0 _str0
+ j _error
+null43:
+ move $a0 $s1
+ li $a1 0
+ jal Tree.SetHas_Left
+ j if14_end
+if14_else:
+ bgtz $s1 null44
+ la $a0 _str0
+ j _error
+null44:
+ lw $t0 20($s0)
+ move $a0 $s1
+ move $a1 $t0
+ jal Tree.SetRight
+ bgtz $s1 null45
+ la $a0 _str0
+ j _error
+null45:
+ move $a0 $s1
+ li $a1 0
+ jal Tree.SetHas_Right
+if14_end:
+if13_end:
+if12_end:
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+Tree.RemoveRight:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ move $s0 $a0
+ move $s1 $a1
+ move $s2 $a2
+while3_top:
+ bgtz $s2 null46
+ la $a0 _str0
+ j _error
+null46:
+ move $a0 $s2
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 while3_end
+ bgtz $s2 null47
+ la $a0 _str0
+ j _error
+null47:
+ bgtz $s2 null48
+ la $a0 _str0
+ j _error
+null48:
+ move $a0 $s2
+ jal Tree.GetRight
+ move $t0 $v0
+ bgtz $t0 null49
+ la $a0 _str0
+ j _error
+null49:
+ move $a0 $t0
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s2
+ move $a1 $t0
+ jal Tree.SetKey
+ move $s1 $s2
+ bgtz $s2 null50
+ la $a0 _str0
+ j _error
+null50:
+ move $a0 $s2
+ jal Tree.GetRight
+ move $s2 $v0
+ j while3_top
+while3_end:
+ bgtz $s1 null51
+ la $a0 _str0
+ j _error
+null51:
+ lw $t0 20($s0)
+ move $a0 $s1
+ move $a1 $t0
+ jal Tree.SetRight
+ bgtz $s1 null52
+ la $a0 _str0
+ j _error
+null52:
+ move $a0 $s1
+ li $a1 0
+ jal Tree.SetHas_Right
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+Tree.RemoveLeft:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ move $s0 $a0
+ move $s1 $a1
+ move $s2 $a2
+while4_top:
+ bgtz $s2 null53
+ la $a0 _str0
+ j _error
+null53:
+ move $a0 $s2
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 while4_end
+ bgtz $s2 null54
+ la $a0 _str0
+ j _error
+null54:
+ bgtz $s2 null55
+ la $a0 _str0
+ j _error
+null55:
+ move $a0 $s2
+ jal Tree.GetLeft
+ move $t0 $v0
+ bgtz $t0 null56
+ la $a0 _str0
+ j _error
+null56:
+ move $a0 $t0
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s2
+ move $a1 $t0
+ jal Tree.SetKey
+ move $s1 $s2
+ bgtz $s2 null57
+ la $a0 _str0
+ j _error
+null57:
+ move $a0 $s2
+ jal Tree.GetLeft
+ move $s2 $v0
+ j while4_top
+while4_end:
+ bgtz $s1 null58
+ la $a0 _str0
+ j _error
+null58:
+ lw $t0 20($s0)
+ move $a0 $s1
+ move $a1 $t0
+ jal Tree.SetLeft
+ bgtz $s1 null59
+ la $a0 _str0
+ j _error
+null59:
+ move $a0 $s1
+ li $a1 0
+ jal Tree.SetHas_Left
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+Tree.Search:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 24
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ sw $s3 -24($fp)
+ move $t0 $a0
+ move $s0 $a1
+ move $s1 $t0
+ li $s2 1
+ li $s3 0
+while5_top:
+ blez $s2 while5_end
+ bgtz $s1 null60
+ la $a0 _str0
+ j _error
+null60:
+ move $a0 $s1
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s0
+ move $t9 $t0
+ slt $t1 $a0 $t9
+ blez $t1 if15_else
+ bgtz $s1 null61
+ la $a0 _str0
+ j _error
+null61:
+ move $a0 $s1
+ jal Tree.GetHas_Left
+ move $t1 $v0
+ blez $t1 if16_else
+ bgtz $s1 null62
+ la $a0 _str0
+ j _error
+null62:
+ move $a0 $s1
+ jal Tree.GetLeft
+ move $s1 $v0
+ j if16_end
+if16_else:
+ li $s2 0
+if16_end:
+ j if15_end
+if15_else:
+ move $a0 $t0
+ move $t9 $s0
+ slt $t0 $a0 $t9
+ blez $t0 if17_else
+ bgtz $s1 null63
+ la $a0 _str0
+ j _error
+null63:
+ move $a0 $s1
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if18_else
+ bgtz $s1 null64
+ la $a0 _str0
+ j _error
+null64:
+ move $a0 $s1
+ jal Tree.GetRight
+ move $s1 $v0
+ j if18_end
+if18_else:
+ li $s2 0
+if18_end:
+ j if17_end
+if17_else:
+ li $s3 1
+ li $s2 0
+if17_end:
+if15_end:
+ j while5_top
+while5_end:
+ move $v0 $s3
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $s3 -24($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 24
+ jr $ra
+Tree.Print:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $t0
+ move $a0 $t0
+ move $a1 $t1
+ jal Tree.RecPrint
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.RecPrint:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 16
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ move $s0 $a0
+ move $s1 $a1
+ bgtz $s1 null65
+ la $a0 _str0
+ j _error
+null65:
+ move $a0 $s1
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 if19_else
+ bgtz $s1 null66
+ la $a0 _str0
+ j _error
+null66:
+ move $a0 $s1
+ jal Tree.GetLeft
+ move $t0 $v0
+ move $a0 $s0
+ move $a1 $t0
+ jal Tree.RecPrint
+ j if19_end
+if19_else:
+if19_end:
+ bgtz $s1 null67
+ la $a0 _str0
+ j _error
+null67:
+ move $a0 $s1
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s1 null68
+ la $a0 _str0
+ j _error
+null68:
+ move $a0 $s1
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if20_else
+ bgtz $s1 null69
+ la $a0 _str0
+ j _error
+null69:
+ move $a0 $s1
+ jal Tree.GetRight
+ move $t0 $v0
+ move $a0 $s0
+ move $a1 $t0
+ jal Tree.RecPrint
+ j if20_end
+if20_else:
+if20_end:
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 16
+ jr $ra
+_print:
+ li $v0 1 # syscall: print integer
+ syscall
+ la $a0 _newline
+ li $v0 4 # syscall: print string
+ syscall
+ jr $ra
+_error:
+ li $v0 4 # syscall: print string
+ syscall
+ li $v0 10 # syscall: exit
+ syscall
+_heapAlloc:
+ li $v0 9 # syscall: sbrk
+ syscall
+ jr $ra
+.data
+.align 0
+_newline: .asciiz "\n"
+_str0: .asciiz "null pointer\n"
diff --git a/output/BinaryTree.opt.vaporm b/output/BinaryTree.opt.vaporm
new file mode 100644
index 0000000..f3bee43
--- /dev/null
+++ b/output/BinaryTree.opt.vaporm
@@ -0,0 +1,797 @@
+const empty_BT
+
+const empty_Tree
+
+func Main [in 0, out 0, local 0]
+ $a0 = :empty_BT
+ call :BT.Start
+ $t0 = $v0
+ PrintIntS($t0)
+ ret
+
+func BT.Start [in 0, out 0, local 1]
+ local[0] = $s0
+ $s0 = HeapAllocZ(24)
+ if $s0 goto :null1
+ Error("null pointer")
+null1:
+ $a0 = $s0
+ $a1 = 16
+ call :Tree.Init
+ if $s0 goto :null2
+ Error("null pointer")
+null2:
+ $a0 = $s0
+ call :Tree.Print
+ PrintIntS(100000000)
+ if $s0 goto :null3
+ Error("null pointer")
+null3:
+ $a0 = $s0
+ $a1 = 8
+ call :Tree.Insert
+ if $s0 goto :null4
+ Error("null pointer")
+null4:
+ $a0 = $s0
+ call :Tree.Print
+ if $s0 goto :null5
+ Error("null pointer")
+null5:
+ $a0 = $s0
+ $a1 = 24
+ call :Tree.Insert
+ if $s0 goto :null6
+ Error("null pointer")
+null6:
+ $a0 = $s0
+ $a1 = 4
+ call :Tree.Insert
+ if $s0 goto :null7
+ Error("null pointer")
+null7:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Insert
+ if $s0 goto :null8
+ Error("null pointer")
+null8:
+ $a0 = $s0
+ $a1 = 20
+ call :Tree.Insert
+ if $s0 goto :null9
+ Error("null pointer")
+null9:
+ $a0 = $s0
+ $a1 = 28
+ call :Tree.Insert
+ if $s0 goto :null10
+ Error("null pointer")
+null10:
+ $a0 = $s0
+ $a1 = 14
+ call :Tree.Insert
+ if $s0 goto :null11
+ Error("null pointer")
+null11:
+ $a0 = $s0
+ call :Tree.Print
+ if $s0 goto :null12
+ Error("null pointer")
+null12:
+ $a0 = $s0
+ $a1 = 24
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null13
+ Error("null pointer")
+null13:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null14
+ Error("null pointer")
+null14:
+ $a0 = $s0
+ $a1 = 16
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null15
+ Error("null pointer")
+null15:
+ $a0 = $s0
+ $a1 = 50
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null16
+ Error("null pointer")
+null16:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null17
+ Error("null pointer")
+null17:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Delete
+ if $s0 goto :null18
+ Error("null pointer")
+null18:
+ $a0 = $s0
+ call :Tree.Print
+ if $s0 goto :null19
+ Error("null pointer")
+null19:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ $v0 = 0
+ $s0 = local[0]
+ ret
+
+func Tree.Init [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+8] = $t1
+ [$t0+12] = 0
+ [$t0+16] = 0
+ $v0 = 1
+ ret
+
+func Tree.SetRight [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+4] = $t1
+ $v0 = 1
+ ret
+
+func Tree.SetLeft [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0] = $t1
+ $v0 = 1
+ ret
+
+func Tree.GetRight [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+4]
+ $v0 = $t0
+ ret
+
+func Tree.GetLeft [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0]
+ $v0 = $t0
+ ret
+
+func Tree.GetKey [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+8]
+ $v0 = $t0
+ ret
+
+func Tree.SetKey [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+8] = $t1
+ $v0 = 1
+ ret
+
+func Tree.GetHas_Right [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+16]
+ $v0 = $t0
+ ret
+
+func Tree.GetHas_Left [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+12]
+ $v0 = $t0
+ ret
+
+func Tree.SetHas_Left [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+12] = $t1
+ $v0 = 1
+ ret
+
+func Tree.SetHas_Right [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+16] = $t1
+ $v0 = 1
+ ret
+
+func Tree.Compare [in 0, out 0, local 0]
+ $t0 = $a1
+ $t1 = $a2
+ $t2 = Add($t1 1)
+ $t1 = LtS($t0 $t1)
+ if0 $t1 goto :if1_else
+ $t1 = 0
+ goto :if1_end
+if1_else:
+ $t2 = LtS($t0 $t2)
+ if $t2 goto :if2_else
+ $t1 = 0
+ goto :if2_end
+if2_else:
+ $t1 = 1
+if2_end:
+if1_end:
+ $v0 = $t1
+ ret
+
+func Tree.Insert [in 0, out 0, local 4]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ local[3] = $s3
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = HeapAllocZ(24)
+ if $s2 goto :null20
+ Error("null pointer")
+null20:
+ $a0 = $s2
+ $a1 = $s1
+ call :Tree.Init
+ $s0 = $s0
+ $s3 = 1
+while1_top:
+ if0 $s3 goto :while1_end
+ if $s0 goto :null21
+ Error("null pointer")
+null21:
+ $a0 = $s0
+ call :Tree.GetKey
+ $t0 = $v0
+ $t0 = LtS($s1 $t0)
+ if0 $t0 goto :if3_else
+ if $s0 goto :null22
+ Error("null pointer")
+null22:
+ $a0 = $s0
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :if4_else
+ if $s0 goto :null23
+ Error("null pointer")
+null23:
+ $a0 = $s0
+ call :Tree.GetLeft
+ $s0 = $v0
+ goto :if4_end
+if4_else:
+ $s3 = 0
+ if $s0 goto :null24
+ Error("null pointer")
+null24:
+ $a0 = $s0
+ $a1 = 1
+ call :Tree.SetHas_Left
+ if $s0 goto :null25
+ Error("null pointer")
+null25:
+ $a0 = $s0
+ $a1 = $s2
+ call :Tree.SetLeft
+if4_end:
+ goto :if3_end
+if3_else:
+ if $s0 goto :null26
+ Error("null pointer")
+null26:
+ $a0 = $s0
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if5_else
+ if $s0 goto :null27
+ Error("null pointer")
+null27:
+ $a0 = $s0
+ call :Tree.GetRight
+ $s0 = $v0
+ goto :if5_end
+if5_else:
+ $s3 = 0
+ if $s0 goto :null28
+ Error("null pointer")
+null28:
+ $a0 = $s0
+ $a1 = 1
+ call :Tree.SetHas_Right
+ if $s0 goto :null29
+ Error("null pointer")
+null29:
+ $a0 = $s0
+ $a1 = $s2
+ call :Tree.SetRight
+if5_end:
+if3_end:
+ goto :while1_top
+while1_end:
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ $s3 = local[3]
+ ret
+
+func Tree.Delete [in 0, out 0, local 7]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ local[3] = $s3
+ local[4] = $s4
+ local[5] = $s5
+ local[6] = $s6
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = $s0
+ $s3 = $s0
+ $s4 = 1
+ $s5 = 0
+ $s6 = 1
+while2_top:
+ if0 $s4 goto :while2_end
+ if $s2 goto :null30
+ Error("null pointer")
+null30:
+ $a0 = $s2
+ call :Tree.GetKey
+ $t0 = $v0
+ $t1 = LtS($s1 $t0)
+ if0 $t1 goto :if6_else
+ if $s2 goto :null31
+ Error("null pointer")
+null31:
+ $a0 = $s2
+ call :Tree.GetHas_Left
+ $t1 = $v0
+ if0 $t1 goto :if7_else
+ $s3 = $s2
+ if $s2 goto :null32
+ Error("null pointer")
+null32:
+ $a0 = $s2
+ call :Tree.GetLeft
+ $s2 = $v0
+ goto :if7_end
+if7_else:
+ $s4 = 0
+if7_end:
+ goto :if6_end
+if6_else:
+ $t0 = LtS($t0 $s1)
+ if0 $t0 goto :if8_else
+ if $s2 goto :null33
+ Error("null pointer")
+null33:
+ $a0 = $s2
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if9_else
+ $s3 = $s2
+ if $s2 goto :null34
+ Error("null pointer")
+null34:
+ $a0 = $s2
+ call :Tree.GetRight
+ $s2 = $v0
+ goto :if9_end
+if9_else:
+ $s4 = 0
+if9_end:
+ goto :if8_end
+if8_else:
+ if0 $s6 goto :if10_else
+ if $s2 goto :null35
+ Error("null pointer")
+null35:
+ $a0 = $s2
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if $t0 goto :if11_else
+ if $s2 goto :null36
+ Error("null pointer")
+null36:
+ $a0 = $s2
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if $t0 goto :if11_else
+ goto :if11_end
+if11_else:
+ $a0 = $s0
+ $a1 = $s3
+ $a2 = $s2
+ call :Tree.Remove
+if11_end:
+ goto :if10_end
+if10_else:
+ $a0 = $s0
+ $a1 = $s3
+ $a2 = $s2
+ call :Tree.Remove
+if10_end:
+ $s5 = 1
+ $s4 = 0
+if8_end:
+if6_end:
+ $s6 = 0
+ goto :while2_top
+while2_end:
+ $v0 = $s5
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ $s3 = local[3]
+ $s4 = local[4]
+ $s5 = local[5]
+ $s6 = local[6]
+ ret
+
+func Tree.Remove [in 0, out 0, local 3]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = $a2
+ if $s2 goto :null37
+ Error("null pointer")
+null37:
+ $a0 = $s2
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :if12_else
+ $a0 = $s0
+ $a1 = $s1
+ $a2 = $s2
+ call :Tree.RemoveLeft
+ goto :if12_end
+if12_else:
+ if $s2 goto :null38
+ Error("null pointer")
+null38:
+ $a0 = $s2
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if13_else
+ $a0 = $s0
+ $a1 = $s1
+ $a2 = $s2
+ call :Tree.RemoveRight
+ goto :if13_end
+if13_else:
+ if $s2 goto :null39
+ Error("null pointer")
+null39:
+ $a0 = $s2
+ call :Tree.GetKey
+ $s2 = $v0
+ if $s1 goto :null40
+ Error("null pointer")
+null40:
+ $a0 = $s1
+ call :Tree.GetLeft
+ $t0 = $v0
+ if $t0 goto :null41
+ Error("null pointer")
+null41:
+ $a0 = $t0
+ call :Tree.GetKey
+ $t0 = $v0
+ $a0 = $s0
+ $a1 = $s2
+ $a2 = $t0
+ call :Tree.Compare
+ $t0 = $v0
+ if0 $t0 goto :if14_else
+ if $s1 goto :null42
+ Error("null pointer")
+null42:
+ $t0 = [$s0+20]
+ $a0 = $s1
+ $a1 = $t0
+ call :Tree.SetLeft
+ if $s1 goto :null43
+ Error("null pointer")
+null43:
+ $a0 = $s1
+ $a1 = 0
+ call :Tree.SetHas_Left
+ goto :if14_end
+if14_else:
+ if $s1 goto :null44
+ Error("null pointer")
+null44:
+ $t0 = [$s0+20]
+ $a0 = $s1
+ $a1 = $t0
+ call :Tree.SetRight
+ if $s1 goto :null45
+ Error("null pointer")
+null45:
+ $a0 = $s1
+ $a1 = 0
+ call :Tree.SetHas_Right
+if14_end:
+if13_end:
+if12_end:
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ ret
+
+func Tree.RemoveRight [in 0, out 0, local 3]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = $a2
+while3_top:
+ if $s2 goto :null46
+ Error("null pointer")
+null46:
+ $a0 = $s2
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :while3_end
+ if $s2 goto :null47
+ Error("null pointer")
+null47:
+ if $s2 goto :null48
+ Error("null pointer")
+null48:
+ $a0 = $s2
+ call :Tree.GetRight
+ $t0 = $v0
+ if $t0 goto :null49
+ Error("null pointer")
+null49:
+ $a0 = $t0
+ call :Tree.GetKey
+ $t0 = $v0
+ $a0 = $s2
+ $a1 = $t0
+ call :Tree.SetKey
+ $s1 = $s2
+ if $s2 goto :null50
+ Error("null pointer")
+null50:
+ $a0 = $s2
+ call :Tree.GetRight
+ $s2 = $v0
+ goto :while3_top
+while3_end:
+ if $s1 goto :null51
+ Error("null pointer")
+null51:
+ $t0 = [$s0+20]
+ $a0 = $s1
+ $a1 = $t0
+ call :Tree.SetRight
+ if $s1 goto :null52
+ Error("null pointer")
+null52:
+ $a0 = $s1
+ $a1 = 0
+ call :Tree.SetHas_Right
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ ret
+
+func Tree.RemoveLeft [in 0, out 0, local 3]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = $a2
+while4_top:
+ if $s2 goto :null53
+ Error("null pointer")
+null53:
+ $a0 = $s2
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :while4_end
+ if $s2 goto :null54
+ Error("null pointer")
+null54:
+ if $s2 goto :null55
+ Error("null pointer")
+null55:
+ $a0 = $s2
+ call :Tree.GetLeft
+ $t0 = $v0
+ if $t0 goto :null56
+ Error("null pointer")
+null56:
+ $a0 = $t0
+ call :Tree.GetKey
+ $t0 = $v0
+ $a0 = $s2
+ $a1 = $t0
+ call :Tree.SetKey
+ $s1 = $s2
+ if $s2 goto :null57
+ Error("null pointer")
+null57:
+ $a0 = $s2
+ call :Tree.GetLeft
+ $s2 = $v0
+ goto :while4_top
+while4_end:
+ if $s1 goto :null58
+ Error("null pointer")
+null58:
+ $t0 = [$s0+20]
+ $a0 = $s1
+ $a1 = $t0
+ call :Tree.SetLeft
+ if $s1 goto :null59
+ Error("null pointer")
+null59:
+ $a0 = $s1
+ $a1 = 0
+ call :Tree.SetHas_Left
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ ret
+
+func Tree.Search [in 0, out 0, local 4]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ local[3] = $s3
+ $t0 = $a0
+ $s0 = $a1
+ $s1 = $t0
+ $s2 = 1
+ $s3 = 0
+while5_top:
+ if0 $s2 goto :while5_end
+ if $s1 goto :null60
+ Error("null pointer")
+null60:
+ $a0 = $s1
+ call :Tree.GetKey
+ $t0 = $v0
+ $t1 = LtS($s0 $t0)
+ if0 $t1 goto :if15_else
+ if $s1 goto :null61
+ Error("null pointer")
+null61:
+ $a0 = $s1
+ call :Tree.GetHas_Left
+ $t1 = $v0
+ if0 $t1 goto :if16_else
+ if $s1 goto :null62
+ Error("null pointer")
+null62:
+ $a0 = $s1
+ call :Tree.GetLeft
+ $s1 = $v0
+ goto :if16_end
+if16_else:
+ $s2 = 0
+if16_end:
+ goto :if15_end
+if15_else:
+ $t0 = LtS($t0 $s0)
+ if0 $t0 goto :if17_else
+ if $s1 goto :null63
+ Error("null pointer")
+null63:
+ $a0 = $s1
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if18_else
+ if $s1 goto :null64
+ Error("null pointer")
+null64:
+ $a0 = $s1
+ call :Tree.GetRight
+ $s1 = $v0
+ goto :if18_end
+if18_else:
+ $s2 = 0
+if18_end:
+ goto :if17_end
+if17_else:
+ $s3 = 1
+ $s2 = 0
+if17_end:
+if15_end:
+ goto :while5_top
+while5_end:
+ $v0 = $s3
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ $s3 = local[3]
+ ret
+
+func Tree.Print [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $t0
+ $a0 = $t0
+ $a1 = $t1
+ call :Tree.RecPrint
+ $v0 = 1
+ ret
+
+func Tree.RecPrint [in 0, out 0, local 2]
+ local[0] = $s0
+ local[1] = $s1
+ $s0 = $a0
+ $s1 = $a1
+ if $s1 goto :null65
+ Error("null pointer")
+null65:
+ $a0 = $s1
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :if19_else
+ if $s1 goto :null66
+ Error("null pointer")
+null66:
+ $a0 = $s1
+ call :Tree.GetLeft
+ $t0 = $v0
+ $a0 = $s0
+ $a1 = $t0
+ call :Tree.RecPrint
+ goto :if19_end
+if19_else:
+if19_end:
+ if $s1 goto :null67
+ Error("null pointer")
+null67:
+ $a0 = $s1
+ call :Tree.GetKey
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s1 goto :null68
+ Error("null pointer")
+null68:
+ $a0 = $s1
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if20_else
+ if $s1 goto :null69
+ Error("null pointer")
+null69:
+ $a0 = $s1
+ call :Tree.GetRight
+ $t0 = $v0
+ $a0 = $s0
+ $a1 = $t0
+ call :Tree.RecPrint
+ goto :if20_end
+if20_else:
+if20_end:
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ ret
+
diff --git a/output/BubbleSort.opt.s b/output/BubbleSort.opt.s
new file mode 100644
index 0000000..5db3d03
--- /dev/null
+++ b/output/BubbleSort.opt.s
@@ -0,0 +1,543 @@
+.data
+empty_BBS:
+.text
+jal Main
+li $v0 10
+syscall
+Main:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ li $a0 8
+ jal _heapAlloc
+ move $t0 $v0
+ bgtz $t0 null1
+ la $a0 _str0
+ j _error
+null1:
+ move $a0 $t0
+ li $a1 10
+ jal BBS.Start
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+BBS.Start:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ move $s0 $a0
+ move $t0 $a1
+ move $a0 $s0
+ move $a1 $t0
+ jal BBS.Init
+ move $a0 $s0
+ jal BBS.Print
+ li $a0 99999
+ jal _print
+ move $a0 $s0
+ jal BBS.Sort
+ move $a0 $s0
+ jal BBS.Print
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+BBS.Sort:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t1 4($t0)
+ move $a0 $t1
+ li $t9 1
+ subu $t1 $a0 $t9
+ li $a0 0
+ li $t9 1
+ subu $t2 $a0 $t9
+while1_top:
+ move $a0 $t2
+ move $t9 $t1
+ slt $t3 $a0 $t9
+ blez $t3 while1_end
+ li $t3 1
+while2_top:
+ move $a0 $t1
+ li $t9 1
+ addu $t4 $a0 $t9
+ move $a0 $t3
+ move $t9 $t4
+ slt $t4 $a0 $t9
+ blez $t4 while2_end
+ move $a0 $t3
+ li $t9 1
+ subu $t4 $a0 $t9
+ lw $t5 0($t0)
+ bgtz $t5 null2
+ la $a0 _str0
+ j _error
+null2:
+ lw $t6 0($t5)
+ move $a0 $t4
+ move $t9 $t6
+ sltu $t6 $a0 $t9
+ bgtz $t6 bounds1
+ la $a0 _str0
+ j _error
+bounds1:
+ move $a0 $t4
+ li $t9 4
+ mul $t6 $a0 $t9
+ move $a0 $t6
+ move $t9 $t5
+ addu $t6 $a0 $t9
+ lw $t6 4($t6)
+ lw $t5 0($t0)
+ bgtz $t5 null3
+ la $a0 _str0
+ j _error
+null3:
+ lw $t4 0($t5)
+ move $a0 $t3
+ move $t9 $t4
+ sltu $t4 $a0 $t9
+ bgtz $t4 bounds2
+ la $a0 _str0
+ j _error
+bounds2:
+ move $a0 $t3
+ li $t9 4
+ mul $t4 $a0 $t9
+ move $a0 $t4
+ move $t9 $t5
+ addu $t4 $a0 $t9
+ lw $t4 4($t4)
+ move $a0 $t4
+ move $t9 $t6
+ slt $t4 $a0 $t9
+ blez $t4 if1_else
+ move $a0 $t3
+ li $t9 1
+ subu $t4 $a0 $t9
+ lw $t6 0($t0)
+ bgtz $t6 null4
+ la $a0 _str0
+ j _error
+null4:
+ lw $t5 0($t6)
+ move $a0 $t4
+ move $t9 $t5
+ sltu $t5 $a0 $t9
+ bgtz $t5 bounds3
+ la $a0 _str0
+ j _error
+bounds3:
+ move $a0 $t4
+ li $t9 4
+ mul $t5 $a0 $t9
+ move $a0 $t5
+ move $t9 $t6
+ addu $t5 $a0 $t9
+ lw $t5 4($t5)
+ lw $t6 0($t0)
+ bgtz $t6 null5
+ la $a0 _str0
+ j _error
+null5:
+ lw $t7 0($t6)
+ move $a0 $t4
+ move $t9 $t7
+ sltu $t7 $a0 $t9
+ bgtz $t7 bounds4
+ la $a0 _str0
+ j _error
+bounds4:
+ move $a0 $t4
+ li $t9 4
+ mul $t7 $a0 $t9
+ move $a0 $t7
+ move $t9 $t6
+ addu $t7 $a0 $t9
+ lw $t6 0($t0)
+ bgtz $t6 null6
+ la $a0 _str0
+ j _error
+null6:
+ lw $t4 0($t6)
+ move $a0 $t3
+ move $t9 $t4
+ sltu $t4 $a0 $t9
+ bgtz $t4 bounds5
+ la $a0 _str0
+ j _error
+bounds5:
+ move $a0 $t3
+ li $t9 4
+ mul $t4 $a0 $t9
+ move $a0 $t4
+ move $t9 $t6
+ addu $t4 $a0 $t9
+ lw $t4 4($t4)
+ sw $t4 4($t7)
+ lw $t4 0($t0)
+ bgtz $t4 null7
+ la $a0 _str0
+ j _error
+null7:
+ lw $t7 0($t4)
+ move $a0 $t3
+ move $t9 $t7
+ sltu $t7 $a0 $t9
+ bgtz $t7 bounds6
+ la $a0 _str0
+ j _error
+bounds6:
+ move $a0 $t3
+ li $t9 4
+ mul $t7 $a0 $t9
+ move $a0 $t7
+ move $t9 $t4
+ addu $t7 $a0 $t9
+ sw $t5 4($t7)
+ j if1_end
+if1_else:
+if1_end:
+ move $a0 $t3
+ li $t9 1
+ addu $t3 $a0 $t9
+ j while2_top
+while2_end:
+ move $a0 $t1
+ li $t9 1
+ subu $t1 $a0 $t9
+ j while1_top
+while1_end:
+ li $v0 0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+BBS.Print:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ li $t1 0
+while3_top:
+ lw $t2 4($t0)
+ move $a0 $t1
+ move $t9 $t2
+ slt $t2 $a0 $t9
+ blez $t2 while3_end
+ lw $t2 0($t0)
+ bgtz $t2 null8
+ la $a0 _str0
+ j _error
+null8:
+ lw $t3 0($t2)
+ move $a0 $t1
+ move $t9 $t3
+ sltu $t3 $a0 $t9
+ bgtz $t3 bounds7
+ la $a0 _str0
+ j _error
+bounds7:
+ move $a0 $t1
+ li $t9 4
+ mul $t3 $a0 $t9
+ move $a0 $t3
+ move $t9 $t2
+ addu $t3 $a0 $t9
+ lw $t3 4($t3)
+ move $a0 $t3
+ jal _print
+ move $a0 $t1
+ li $t9 1
+ addu $t1 $a0 $t9
+ j while3_top
+while3_end:
+ li $v0 0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+BBS.Init:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ move $s0 $a0
+ move $t0 $a1
+ sw $t0 4($s0)
+ move $a0 $t0
+ jal AllocArray
+ move $t0 $v0
+ sw $t0 0($s0)
+ lw $t0 0($s0)
+ bgtz $t0 null9
+ la $a0 _str0
+ j _error
+null9:
+ lw $t1 0($t0)
+ li $a0 0
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds8
+ la $a0 _str0
+ j _error
+bounds8:
+ li $a0 0
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 20
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null10
+ la $a0 _str0
+ j _error
+null10:
+ lw $t0 0($t1)
+ li $a0 1
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds9
+ la $a0 _str0
+ j _error
+bounds9:
+ li $a0 1
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 7
+ sw $t9 4($t0)
+ lw $t0 0($s0)
+ bgtz $t0 null11
+ la $a0 _str0
+ j _error
+null11:
+ lw $t1 0($t0)
+ li $a0 2
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds10
+ la $a0 _str0
+ j _error
+bounds10:
+ li $a0 2
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 12
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null12
+ la $a0 _str0
+ j _error
+null12:
+ lw $t0 0($t1)
+ li $a0 3
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds11
+ la $a0 _str0
+ j _error
+bounds11:
+ li $a0 3
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 18
+ sw $t9 4($t0)
+ lw $t0 0($s0)
+ bgtz $t0 null13
+ la $a0 _str0
+ j _error
+null13:
+ lw $t1 0($t0)
+ li $a0 4
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds12
+ la $a0 _str0
+ j _error
+bounds12:
+ li $a0 4
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 2
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null14
+ la $a0 _str0
+ j _error
+null14:
+ lw $t0 0($t1)
+ li $a0 5
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds13
+ la $a0 _str0
+ j _error
+bounds13:
+ li $a0 5
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 11
+ sw $t9 4($t0)
+ lw $t0 0($s0)
+ bgtz $t0 null15
+ la $a0 _str0
+ j _error
+null15:
+ lw $t1 0($t0)
+ li $a0 6
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds14
+ la $a0 _str0
+ j _error
+bounds14:
+ li $a0 6
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 6
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null16
+ la $a0 _str0
+ j _error
+null16:
+ lw $t0 0($t1)
+ li $a0 7
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds15
+ la $a0 _str0
+ j _error
+bounds15:
+ li $a0 7
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 9
+ sw $t9 4($t0)
+ lw $t0 0($s0)
+ bgtz $t0 null17
+ la $a0 _str0
+ j _error
+null17:
+ lw $t1 0($t0)
+ li $a0 8
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds16
+ la $a0 _str0
+ j _error
+bounds16:
+ li $a0 8
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 19
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null18
+ la $a0 _str0
+ j _error
+null18:
+ lw $t0 0($t1)
+ li $a0 9
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds17
+ la $a0 _str0
+ j _error
+bounds17:
+ li $a0 9
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 5
+ sw $t9 4($t0)
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+AllocArray:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $a0 $t0
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ li $t9 4
+ addu $t1 $a0 $t9
+ move $a0 $t1
+ jal _heapAlloc
+ move $t1 $v0
+ sw $t0 0($t1)
+ move $v0 $t1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+_print:
+ li $v0 1 # syscall: print integer
+ syscall
+ la $a0 _newline
+ li $v0 4 # syscall: print string
+ syscall
+ jr $ra
+_error:
+ li $v0 4 # syscall: print string
+ syscall
+ li $v0 10 # syscall: exit
+ syscall
+_heapAlloc:
+ li $v0 9 # syscall: sbrk
+ syscall
+ jr $ra
+.data
+.align 0
+_newline: .asciiz "\n"
+_str0: .asciiz "null pointer\n"
diff --git a/output/BubbleSort.opt.vaporm b/output/BubbleSort.opt.vaporm
new file mode 100644
index 0000000..41c6ac4
--- /dev/null
+++ b/output/BubbleSort.opt.vaporm
@@ -0,0 +1,301 @@
+const empty_BBS
+
+func Main [in 0, out 0, local 0]
+ $t0 = HeapAllocZ(8)
+ if $t0 goto :null1
+ Error("null pointer")
+null1:
+ $a0 = $t0
+ $a1 = 10
+ call :BBS.Start
+ $t0 = $v0
+ PrintIntS($t0)
+ ret
+
+func BBS.Start [in 0, out 0, local 1]
+ local[0] = $s0
+ $s0 = $a0
+ $t0 = $a1
+ $a0 = $s0
+ $a1 = $t0
+ call :BBS.Init
+ $a0 = $s0
+ call :BBS.Print
+ PrintIntS(99999)
+ $a0 = $s0
+ call :BBS.Sort
+ $a0 = $s0
+ call :BBS.Print
+ $v0 = 0
+ $s0 = local[0]
+ ret
+
+func BBS.Sort [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = [$t0+4]
+ $t1 = Sub($t1 1)
+ $t2 = Sub(0 1)
+while1_top:
+ $t3 = LtS($t2 $t1)
+ if0 $t3 goto :while1_end
+ $t3 = 1
+while2_top:
+ $t4 = Add($t1 1)
+ $t4 = LtS($t3 $t4)
+ if0 $t4 goto :while2_end
+ $t4 = Sub($t3 1)
+ $t5 = [$t0]
+ if $t5 goto :null2
+ Error("null pointer")
+null2:
+ $t6 = [$t5]
+ $t6 = Lt($t4 $t6)
+ if $t6 goto :bounds1
+ Error("array index out of bounds")
+bounds1:
+ $t6 = MulS($t4 4)
+ $t6 = Add($t6 $t5)
+ $t6 = [$t6+4]
+ $t5 = [$t0]
+ if $t5 goto :null3
+ Error("null pointer")
+null3:
+ $t4 = [$t5]
+ $t4 = Lt($t3 $t4)
+ if $t4 goto :bounds2
+ Error("array index out of bounds")
+bounds2:
+ $t4 = MulS($t3 4)
+ $t4 = Add($t4 $t5)
+ $t4 = [$t4+4]
+ $t4 = LtS($t4 $t6)
+ if0 $t4 goto :if1_else
+ $t4 = Sub($t3 1)
+ $t6 = [$t0]
+ if $t6 goto :null4
+ Error("null pointer")
+null4:
+ $t5 = [$t6]
+ $t5 = Lt($t4 $t5)
+ if $t5 goto :bounds3
+ Error("array index out of bounds")
+bounds3:
+ $t5 = MulS($t4 4)
+ $t5 = Add($t5 $t6)
+ $t5 = [$t5+4]
+ $t6 = [$t0]
+ if $t6 goto :null5
+ Error("null pointer")
+null5:
+ $t7 = [$t6]
+ $t7 = Lt($t4 $t7)
+ if $t7 goto :bounds4
+ Error("array index out of bounds")
+bounds4:
+ $t7 = MulS($t4 4)
+ $t7 = Add($t7 $t6)
+ $t6 = [$t0]
+ if $t6 goto :null6
+ Error("null pointer")
+null6:
+ $t4 = [$t6]
+ $t4 = Lt($t3 $t4)
+ if $t4 goto :bounds5
+ Error("array index out of bounds")
+bounds5:
+ $t4 = MulS($t3 4)
+ $t4 = Add($t4 $t6)
+ $t4 = [$t4+4]
+ [$t7+4] = $t4
+ $t4 = [$t0]
+ if $t4 goto :null7
+ Error("null pointer")
+null7:
+ $t7 = [$t4]
+ $t7 = Lt($t3 $t7)
+ if $t7 goto :bounds6
+ Error("array index out of bounds")
+bounds6:
+ $t7 = MulS($t3 4)
+ $t7 = Add($t7 $t4)
+ [$t7+4] = $t5
+ goto :if1_end
+if1_else:
+if1_end:
+ $t3 = Add($t3 1)
+ goto :while2_top
+while2_end:
+ $t1 = Sub($t1 1)
+ goto :while1_top
+while1_end:
+ $v0 = 0
+ ret
+
+func BBS.Print [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = 0
+while3_top:
+ $t2 = [$t0+4]
+ $t2 = LtS($t1 $t2)
+ if0 $t2 goto :while3_end
+ $t2 = [$t0]
+ if $t2 goto :null8
+ Error("null pointer")
+null8:
+ $t3 = [$t2]
+ $t3 = Lt($t1 $t3)
+ if $t3 goto :bounds7
+ Error("array index out of bounds")
+bounds7:
+ $t3 = MulS($t1 4)
+ $t3 = Add($t3 $t2)
+ $t3 = [$t3+4]
+ PrintIntS($t3)
+ $t1 = Add($t1 1)
+ goto :while3_top
+while3_end:
+ $v0 = 0
+ ret
+
+func BBS.Init [in 0, out 0, local 1]
+ local[0] = $s0
+ $s0 = $a0
+ $t0 = $a1
+ [$s0+4] = $t0
+ $a0 = $t0
+ call :AllocArray
+ $t0 = $v0
+ [$s0] = $t0
+ $t0 = [$s0]
+ if $t0 goto :null9
+ Error("null pointer")
+null9:
+ $t1 = [$t0]
+ $t1 = Lt(0 $t1)
+ if $t1 goto :bounds8
+ Error("array index out of bounds")
+bounds8:
+ $t1 = MulS(0 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 20
+ $t1 = [$s0]
+ if $t1 goto :null10
+ Error("null pointer")
+null10:
+ $t0 = [$t1]
+ $t0 = Lt(1 $t0)
+ if $t0 goto :bounds9
+ Error("array index out of bounds")
+bounds9:
+ $t0 = MulS(1 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 7
+ $t0 = [$s0]
+ if $t0 goto :null11
+ Error("null pointer")
+null11:
+ $t1 = [$t0]
+ $t1 = Lt(2 $t1)
+ if $t1 goto :bounds10
+ Error("array index out of bounds")
+bounds10:
+ $t1 = MulS(2 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 12
+ $t1 = [$s0]
+ if $t1 goto :null12
+ Error("null pointer")
+null12:
+ $t0 = [$t1]
+ $t0 = Lt(3 $t0)
+ if $t0 goto :bounds11
+ Error("array index out of bounds")
+bounds11:
+ $t0 = MulS(3 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 18
+ $t0 = [$s0]
+ if $t0 goto :null13
+ Error("null pointer")
+null13:
+ $t1 = [$t0]
+ $t1 = Lt(4 $t1)
+ if $t1 goto :bounds12
+ Error("array index out of bounds")
+bounds12:
+ $t1 = MulS(4 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 2
+ $t1 = [$s0]
+ if $t1 goto :null14
+ Error("null pointer")
+null14:
+ $t0 = [$t1]
+ $t0 = Lt(5 $t0)
+ if $t0 goto :bounds13
+ Error("array index out of bounds")
+bounds13:
+ $t0 = MulS(5 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 11
+ $t0 = [$s0]
+ if $t0 goto :null15
+ Error("null pointer")
+null15:
+ $t1 = [$t0]
+ $t1 = Lt(6 $t1)
+ if $t1 goto :bounds14
+ Error("array index out of bounds")
+bounds14:
+ $t1 = MulS(6 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 6
+ $t1 = [$s0]
+ if $t1 goto :null16
+ Error("null pointer")
+null16:
+ $t0 = [$t1]
+ $t0 = Lt(7 $t0)
+ if $t0 goto :bounds15
+ Error("array index out of bounds")
+bounds15:
+ $t0 = MulS(7 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 9
+ $t0 = [$s0]
+ if $t0 goto :null17
+ Error("null pointer")
+null17:
+ $t1 = [$t0]
+ $t1 = Lt(8 $t1)
+ if $t1 goto :bounds16
+ Error("array index out of bounds")
+bounds16:
+ $t1 = MulS(8 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 19
+ $t1 = [$s0]
+ if $t1 goto :null18
+ Error("null pointer")
+null18:
+ $t0 = [$t1]
+ $t0 = Lt(9 $t0)
+ if $t0 goto :bounds17
+ Error("array index out of bounds")
+bounds17:
+ $t0 = MulS(9 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 5
+ $v0 = 0
+ $s0 = local[0]
+ ret
+
+func AllocArray [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = MulS($t0 4)
+ $t1 = Add($t1 4)
+ $t1 = HeapAllocZ($t1)
+ [$t1] = $t0
+ $v0 = $t1
+ ret
+
diff --git a/output/Factorial.opt.s b/output/Factorial.opt.s
new file mode 100644
index 0000000..c71d219
--- /dev/null
+++ b/output/Factorial.opt.s
@@ -0,0 +1,73 @@
+.data
+empty_Fac:
+.text
+jal Main
+li $v0 10
+syscall
+Main:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ la $a0 empty_Fac
+ li $a1 10
+ jal Fac.ComputeFac
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Fac.ComputeFac:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ move $t0 $a0
+ move $s0 $a1
+ move $a0 $s0
+ li $t9 1
+ slt $t1 $a0 $t9
+ blez $t1 if1_else
+ li $t1 1
+ j if1_end
+if1_else:
+ move $a0 $s0
+ li $t9 1
+ subu $t2 $a0 $t9
+ move $a0 $t0
+ move $a1 $t2
+ jal Fac.ComputeFac
+ move $t2 $v0
+ move $a0 $s0
+ move $t9 $t2
+ mul $t1 $a0 $t9
+if1_end:
+ move $v0 $t1
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+_print:
+ li $v0 1 # syscall: print integer
+ syscall
+ la $a0 _newline
+ li $v0 4 # syscall: print string
+ syscall
+ jr $ra
+_error:
+ li $v0 4 # syscall: print string
+ syscall
+ li $v0 10 # syscall: exit
+ syscall
+_heapAlloc:
+ li $v0 9 # syscall: sbrk
+ syscall
+ jr $ra
+.data
+.align 0
+_newline: .asciiz "\n"
+_str0: .asciiz "null pointer\n"
diff --git a/output/Factorial.opt.vaporm b/output/Factorial.opt.vaporm
new file mode 100644
index 0000000..fb5f8e6
--- /dev/null
+++ b/output/Factorial.opt.vaporm
@@ -0,0 +1,30 @@
+const empty_Fac
+
+func Main [in 0, out 0, local 0]
+ $a0 = :empty_Fac
+ $a1 = 10
+ call :Fac.ComputeFac
+ $t0 = $v0
+ PrintIntS($t0)
+ ret
+
+func Fac.ComputeFac [in 0, out 0, local 1]
+ local[0] = $s0
+ $t0 = $a0
+ $s0 = $a1
+ $t1 = LtS($s0 1)
+ if0 $t1 goto :if1_else
+ $t1 = 1
+ goto :if1_end
+if1_else:
+ $t2 = Sub($s0 1)
+ $a0 = $t0
+ $a1 = $t2
+ call :Fac.ComputeFac
+ $t2 = $v0
+ $t1 = MulS($s0 $t2)
+if1_end:
+ $v0 = $t1
+ $s0 = local[0]
+ ret
+
diff --git a/output/LinearSearch.opt.s b/output/LinearSearch.opt.s
new file mode 100644
index 0000000..a012e02
--- /dev/null
+++ b/output/LinearSearch.opt.s
@@ -0,0 +1,290 @@
+.data
+empty_LS:
+.text
+jal Main
+li $v0 10
+syscall
+Main:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ li $a0 8
+ jal _heapAlloc
+ move $t0 $v0
+ bgtz $t0 null1
+ la $a0 _str0
+ j _error
+null1:
+ move $a0 $t0
+ li $a1 10
+ jal LS.Start
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+LS.Start:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ move $s0 $a0
+ move $t0 $a1
+ move $a0 $s0
+ move $a1 $t0
+ jal LS.Init
+ move $a0 $s0
+ jal LS.Print
+ li $a0 9999
+ jal _print
+ move $a0 $s0
+ li $a1 8
+ jal LS.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ move $a0 $s0
+ li $a1 12
+ jal LS.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ move $a0 $s0
+ li $a1 17
+ jal LS.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ move $a0 $s0
+ li $a1 50
+ jal LS.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ li $v0 55
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+LS.Print:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ li $t1 1
+while1_top:
+ lw $t2 4($t0)
+ move $a0 $t1
+ move $t9 $t2
+ slt $t2 $a0 $t9
+ blez $t2 while1_end
+ lw $t2 0($t0)
+ bgtz $t2 null2
+ la $a0 _str0
+ j _error
+null2:
+ lw $t3 0($t2)
+ move $a0 $t1
+ move $t9 $t3
+ sltu $t3 $a0 $t9
+ bgtz $t3 bounds1
+ la $a0 _str0
+ j _error
+bounds1:
+ move $a0 $t1
+ li $t9 4
+ mul $t3 $a0 $t9
+ move $a0 $t3
+ move $t9 $t2
+ addu $t3 $a0 $t9
+ lw $t3 4($t3)
+ move $a0 $t3
+ jal _print
+ move $a0 $t1
+ li $t9 1
+ addu $t1 $a0 $t9
+ j while1_top
+while1_end:
+ li $v0 0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+LS.Search:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ li $t2 1
+ li $t3 0
+while2_top:
+ lw $t4 4($t0)
+ move $a0 $t2
+ move $t9 $t4
+ slt $t4 $a0 $t9
+ blez $t4 while2_end
+ lw $t4 0($t0)
+ bgtz $t4 null3
+ la $a0 _str0
+ j _error
+null3:
+ lw $t5 0($t4)
+ move $a0 $t2
+ move $t9 $t5
+ sltu $t5 $a0 $t9
+ bgtz $t5 bounds2
+ la $a0 _str0
+ j _error
+bounds2:
+ move $a0 $t2
+ li $t9 4
+ mul $t5 $a0 $t9
+ move $a0 $t5
+ move $t9 $t4
+ addu $t5 $a0 $t9
+ lw $t5 4($t5)
+ move $a0 $t1
+ li $t9 1
+ addu $t4 $a0 $t9
+ move $a0 $t5
+ move $t9 $t1
+ slt $t6 $a0 $t9
+ blez $t6 if1_else
+ j if1_end
+if1_else:
+ move $a0 $t5
+ move $t9 $t4
+ slt $t4 $a0 $t9
+ bgtz $t4 if2_else
+ j if2_end
+if2_else:
+ li $t3 1
+ lw $t2 4($t0)
+if2_end:
+if1_end:
+ move $a0 $t2
+ li $t9 1
+ addu $t2 $a0 $t9
+ j while2_top
+while2_end:
+ move $v0 $t3
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+LS.Init:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ move $s0 $a0
+ move $t0 $a1
+ sw $t0 4($s0)
+ move $a0 $t0
+ jal AllocArray
+ move $t0 $v0
+ sw $t0 0($s0)
+ li $t0 1
+ lw $t1 4($s0)
+ move $a0 $t1
+ li $t9 1
+ addu $t1 $a0 $t9
+while3_top:
+ lw $t2 4($s0)
+ move $a0 $t0
+ move $t9 $t2
+ slt $t2 $a0 $t9
+ blez $t2 while3_end
+ li $a0 2
+ move $t9 $t0
+ mul $t2 $a0 $t9
+ move $a0 $t1
+ li $t9 3
+ subu $t3 $a0 $t9
+ lw $t4 0($s0)
+ bgtz $t4 null4
+ la $a0 _str0
+ j _error
+null4:
+ lw $t5 0($t4)
+ move $a0 $t0
+ move $t9 $t5
+ sltu $t5 $a0 $t9
+ bgtz $t5 bounds3
+ la $a0 _str0
+ j _error
+bounds3:
+ move $a0 $t0
+ li $t9 4
+ mul $t5 $a0 $t9
+ move $a0 $t5
+ move $t9 $t4
+ addu $t5 $a0 $t9
+ move $a0 $t2
+ move $t9 $t3
+ addu $t3 $a0 $t9
+ sw $t3 4($t5)
+ move $a0 $t0
+ li $t9 1
+ addu $t0 $a0 $t9
+ move $a0 $t1
+ li $t9 1
+ subu $t1 $a0 $t9
+ j while3_top
+while3_end:
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+AllocArray:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $a0 $t0
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ li $t9 4
+ addu $t1 $a0 $t9
+ move $a0 $t1
+ jal _heapAlloc
+ move $t1 $v0
+ sw $t0 0($t1)
+ move $v0 $t1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+_print:
+ li $v0 1 # syscall: print integer
+ syscall
+ la $a0 _newline
+ li $v0 4 # syscall: print string
+ syscall
+ jr $ra
+_error:
+ li $v0 4 # syscall: print string
+ syscall
+ li $v0 10 # syscall: exit
+ syscall
+_heapAlloc:
+ li $v0 9 # syscall: sbrk
+ syscall
+ jr $ra
+.data
+.align 0
+_newline: .asciiz "\n"
+_str0: .asciiz "null pointer\n"
diff --git a/output/LinearSearch.opt.vaporm b/output/LinearSearch.opt.vaporm
new file mode 100644
index 0000000..4fa8c5c
--- /dev/null
+++ b/output/LinearSearch.opt.vaporm
@@ -0,0 +1,162 @@
+const empty_LS
+
+func Main [in 0, out 0, local 0]
+ $t0 = HeapAllocZ(8)
+ if $t0 goto :null1
+ Error("null pointer")
+null1:
+ $a0 = $t0
+ $a1 = 10
+ call :LS.Start
+ $t0 = $v0
+ PrintIntS($t0)
+ ret
+
+func LS.Start [in 0, out 0, local 1]
+ local[0] = $s0
+ $s0 = $a0
+ $t0 = $a1
+ $a0 = $s0
+ $a1 = $t0
+ call :LS.Init
+ $a0 = $s0
+ call :LS.Print
+ PrintIntS(9999)
+ $a0 = $s0
+ $a1 = 8
+ call :LS.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ $a0 = $s0
+ $a1 = 12
+ call :LS.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ $a0 = $s0
+ $a1 = 17
+ call :LS.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ $a0 = $s0
+ $a1 = 50
+ call :LS.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ $v0 = 55
+ $s0 = local[0]
+ ret
+
+func LS.Print [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = 1
+while1_top:
+ $t2 = [$t0+4]
+ $t2 = LtS($t1 $t2)
+ if0 $t2 goto :while1_end
+ $t2 = [$t0]
+ if $t2 goto :null2
+ Error("null pointer")
+null2:
+ $t3 = [$t2]
+ $t3 = Lt($t1 $t3)
+ if $t3 goto :bounds1
+ Error("array index out of bounds")
+bounds1:
+ $t3 = MulS($t1 4)
+ $t3 = Add($t3 $t2)
+ $t3 = [$t3+4]
+ PrintIntS($t3)
+ $t1 = Add($t1 1)
+ goto :while1_top
+while1_end:
+ $v0 = 0
+ ret
+
+func LS.Search [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ $t2 = 1
+ $t3 = 0
+while2_top:
+ $t4 = [$t0+4]
+ $t4 = LtS($t2 $t4)
+ if0 $t4 goto :while2_end
+ $t4 = [$t0]
+ if $t4 goto :null3
+ Error("null pointer")
+null3:
+ $t5 = [$t4]
+ $t5 = Lt($t2 $t5)
+ if $t5 goto :bounds2
+ Error("array index out of bounds")
+bounds2:
+ $t5 = MulS($t2 4)
+ $t5 = Add($t5 $t4)
+ $t5 = [$t5+4]
+ $t4 = Add($t1 1)
+ $t6 = LtS($t5 $t1)
+ if0 $t6 goto :if1_else
+ goto :if1_end
+if1_else:
+ $t4 = LtS($t5 $t4)
+ if $t4 goto :if2_else
+ goto :if2_end
+if2_else:
+ $t3 = 1
+ $t2 = [$t0+4]
+if2_end:
+if1_end:
+ $t2 = Add($t2 1)
+ goto :while2_top
+while2_end:
+ $v0 = $t3
+ ret
+
+func LS.Init [in 0, out 0, local 1]
+ local[0] = $s0
+ $s0 = $a0
+ $t0 = $a1
+ [$s0+4] = $t0
+ $a0 = $t0
+ call :AllocArray
+ $t0 = $v0
+ [$s0] = $t0
+ $t0 = 1
+ $t1 = [$s0+4]
+ $t1 = Add($t1 1)
+while3_top:
+ $t2 = [$s0+4]
+ $t2 = LtS($t0 $t2)
+ if0 $t2 goto :while3_end
+ $t2 = MulS(2 $t0)
+ $t3 = Sub($t1 3)
+ $t4 = [$s0]
+ if $t4 goto :null4
+ Error("null pointer")
+null4:
+ $t5 = [$t4]
+ $t5 = Lt($t0 $t5)
+ if $t5 goto :bounds3
+ Error("array index out of bounds")
+bounds3:
+ $t5 = MulS($t0 4)
+ $t5 = Add($t5 $t4)
+ $t3 = Add($t2 $t3)
+ [$t5+4] = $t3
+ $t0 = Add($t0 1)
+ $t1 = Sub($t1 1)
+ goto :while3_top
+while3_end:
+ $v0 = 0
+ $s0 = local[0]
+ ret
+
+func AllocArray [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = MulS($t0 4)
+ $t1 = Add($t1 4)
+ $t1 = HeapAllocZ($t1)
+ [$t1] = $t0
+ $v0 = $t1
+ ret
+
diff --git a/output/LinkedList.opt.s b/output/LinkedList.opt.s
new file mode 100644
index 0000000..5e1ebe8
--- /dev/null
+++ b/output/LinkedList.opt.s
@@ -0,0 +1,781 @@
+.data
+empty_Element:
+empty_List:
+empty_LL:
+.text
+jal Main
+li $v0 10
+syscall
+Main:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ la $a0 empty_LL
+ jal LL.Start
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Element.Init:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ move $t2 $a2
+ move $t3 $a3
+ sw $t1 0($t0)
+ sw $t2 4($t0)
+ sw $t3 8($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Element.GetAge:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 0($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Element.GetSalary:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 4($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Element.GetMarried:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 8($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Element.Equal:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ move $s0 $a0
+ move $s1 $a1
+ li $s2 1
+ bgtz $s1 null1
+ la $a0 _str0
+ j _error
+null1:
+ move $a0 $s1
+ jal Element.GetAge
+ move $t0 $v0
+ lw $t1 0($s0)
+ move $a0 $s0
+ move $a1 $t0
+ move $a2 $t1
+ jal Element.Compare
+ move $t1 $v0
+ bgtz $t1 if1_else
+ li $s2 0
+ j if1_end
+if1_else:
+ bgtz $s1 null2
+ la $a0 _str0
+ j _error
+null2:
+ move $a0 $s1
+ jal Element.GetSalary
+ move $t1 $v0
+ lw $t0 4($s0)
+ move $a0 $s0
+ move $a1 $t1
+ move $a2 $t0
+ jal Element.Compare
+ move $t0 $v0
+ bgtz $t0 if2_else
+ li $s2 0
+ j if2_end
+if2_else:
+ lw $t0 8($s0)
+ blez $t0 if3_else
+ bgtz $s1 null3
+ la $a0 _str0
+ j _error
+null3:
+ move $a0 $s1
+ jal Element.GetMarried
+ move $t0 $v0
+ bgtz $t0 if4_else
+ li $s2 0
+ j if4_end
+if4_else:
+if4_end:
+ j if3_end
+if3_else:
+ bgtz $s1 null4
+ la $a0 _str0
+ j _error
+null4:
+ move $a0 $s1
+ jal Element.GetMarried
+ move $t0 $v0
+ blez $t0 if5_else
+ li $s2 0
+ j if5_end
+if5_else:
+if5_end:
+if3_end:
+if2_end:
+if1_end:
+ move $v0 $s2
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+Element.Compare:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a1
+ move $t1 $a2
+ move $a0 $t1
+ li $t9 1
+ addu $t2 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ slt $t1 $a0 $t9
+ blez $t1 if6_else
+ li $t1 0
+ j if6_end
+if6_else:
+ move $a0 $t0
+ move $t9 $t2
+ slt $t2 $a0 $t9
+ bgtz $t2 if7_else
+ li $t1 0
+ j if7_end
+if7_else:
+ li $t1 1
+if7_end:
+if6_end:
+ move $v0 $t1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+List.Init:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ li $t9 1
+ sw $t9 8($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+List.InitNew:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ move $t2 $a2
+ move $t3 $a3
+ sw $t3 8($t0)
+ sw $t1 0($t0)
+ sw $t2 4($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+List.Insert:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ move $t0 $a0
+ move $t1 $a1
+ move $t0 $t0
+ li $a0 12
+ jal _heapAlloc
+ move $s0 $v0
+ bgtz $s0 null5
+ la $a0 _str0
+ j _error
+null5:
+ move $a0 $s0
+ move $a1 $t1
+ move $a2 $t0
+ li $a3 0
+ jal List.InitNew
+ move $v0 $s0
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+List.SetNext:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 4($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+List.Delete:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 40
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ sw $s3 -24($fp)
+ sw $s4 -28($fp)
+ sw $s5 -32($fp)
+ sw $s6 -36($fp)
+ sw $s7 -40($fp)
+ move $t0 $a0
+ move $s0 $a1
+ move $s1 $t0
+ li $s2 0
+ li $a0 0
+ li $t9 1
+ subu $s3 $a0 $t9
+ move $s4 $t0
+ move $s5 $t0
+ lw $s6 8($t0)
+ lw $s7 0($t0)
+while1_top:
+ bgtz $s6 ss1_else
+ li $a0 1
+ move $t9 $s2
+ subu $t0 $a0 $t9
+ j ss1_end
+ss1_else:
+ li $t0 0
+ss1_end:
+ blez $t0 while1_end
+ bgtz $s0 null6
+ la $a0 _str0
+ j _error
+null6:
+ move $a0 $s0
+ move $a1 $s7
+ jal Element.Equal
+ move $t0 $v0
+ blez $t0 if8_else
+ li $s2 1
+ move $a0 $s3
+ li $t9 0
+ slt $t0 $a0 $t9
+ blez $t0 if9_else
+ bgtz $s4 null7
+ la $a0 _str0
+ j _error
+null7:
+ move $a0 $s4
+ jal List.GetNext
+ move $s1 $v0
+ j if9_end
+if9_else:
+ li $a0 0
+ li $t9 555
+ subu $t0 $a0 $t9
+ move $a0 $t0
+ jal _print
+ bgtz $s5 null8
+ la $a0 _str0
+ j _error
+null8:
+ bgtz $s4 null9
+ la $a0 _str0
+ j _error
+null9:
+ move $a0 $s4
+ jal List.GetNext
+ move $t0 $v0
+ move $a0 $s5
+ move $a1 $t0
+ jal List.SetNext
+ li $a0 0
+ li $t9 555
+ subu $t0 $a0 $t9
+ move $a0 $t0
+ jal _print
+if9_end:
+ j if8_end
+if8_else:
+if8_end:
+ bgtz $s2 if10_else
+ move $s5 $s4
+ bgtz $s4 null10
+ la $a0 _str0
+ j _error
+null10:
+ move $a0 $s4
+ jal List.GetNext
+ move $s4 $v0
+ bgtz $s4 null11
+ la $a0 _str0
+ j _error
+null11:
+ move $a0 $s4
+ jal List.GetEnd
+ move $s6 $v0
+ bgtz $s4 null12
+ la $a0 _str0
+ j _error
+null12:
+ move $a0 $s4
+ jal List.GetElem
+ move $s7 $v0
+ li $s3 1
+ j if10_end
+if10_else:
+if10_end:
+ j while1_top
+while1_end:
+ move $v0 $s1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $s3 -24($fp)
+ lw $s4 -28($fp)
+ lw $s5 -32($fp)
+ lw $s6 -36($fp)
+ lw $s7 -40($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 40
+ jr $ra
+List.Search:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 24
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ sw $s3 -24($fp)
+ move $t0 $a0
+ move $s0 $a1
+ li $s1 0
+ move $s2 $t0
+ lw $s3 8($t0)
+ lw $t0 0($t0)
+while2_top:
+ li $a0 1
+ move $t9 $s3
+ subu $t1 $a0 $t9
+ blez $t1 while2_end
+ bgtz $s0 null13
+ la $a0 _str0
+ j _error
+null13:
+ move $a0 $s0
+ move $a1 $t0
+ jal Element.Equal
+ move $t1 $v0
+ blez $t1 if11_else
+ li $s1 1
+ j if11_end
+if11_else:
+if11_end:
+ bgtz $s2 null14
+ la $a0 _str0
+ j _error
+null14:
+ move $a0 $s2
+ jal List.GetNext
+ move $s2 $v0
+ bgtz $s2 null15
+ la $a0 _str0
+ j _error
+null15:
+ move $a0 $s2
+ jal List.GetEnd
+ move $s3 $v0
+ bgtz $s2 null16
+ la $a0 _str0
+ j _error
+null16:
+ move $a0 $s2
+ jal List.GetElem
+ move $t0 $v0
+ j while2_top
+while2_end:
+ move $v0 $s1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $s3 -24($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 24
+ jr $ra
+List.GetEnd:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 8($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+List.GetElem:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 0($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+List.GetNext:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 4($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+List.Print:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 16
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ move $t0 $a0
+ move $s0 $t0
+ lw $s1 8($t0)
+ lw $t0 0($t0)
+while3_top:
+ li $a0 1
+ move $t9 $s1
+ subu $t1 $a0 $t9
+ blez $t1 while3_end
+ bgtz $t0 null17
+ la $a0 _str0
+ j _error
+null17:
+ move $a0 $t0
+ jal Element.GetAge
+ move $t1 $v0
+ move $a0 $t1
+ jal _print
+ bgtz $s0 null18
+ la $a0 _str0
+ j _error
+null18:
+ move $a0 $s0
+ jal List.GetNext
+ move $s0 $v0
+ bgtz $s0 null19
+ la $a0 _str0
+ j _error
+null19:
+ move $a0 $s0
+ jal List.GetEnd
+ move $s1 $v0
+ bgtz $s0 null20
+ la $a0 _str0
+ j _error
+null20:
+ move $a0 $s0
+ jal List.GetElem
+ move $t0 $v0
+ j while3_top
+while3_end:
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 16
+ jr $ra
+LL.Start:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 24
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ sw $s3 -24($fp)
+ li $a0 12
+ jal _heapAlloc
+ move $s0 $v0
+ bgtz $s0 null21
+ la $a0 _str0
+ j _error
+null21:
+ move $a0 $s0
+ jal List.Init
+ move $s0 $s0
+ bgtz $s0 null22
+ la $a0 _str0
+ j _error
+null22:
+ move $a0 $s0
+ jal List.Init
+ bgtz $s0 null23
+ la $a0 _str0
+ j _error
+null23:
+ move $a0 $s0
+ jal List.Print
+ li $a0 12
+ jal _heapAlloc
+ move $s1 $v0
+ bgtz $s1 null24
+ la $a0 _str0
+ j _error
+null24:
+ move $a0 $s1
+ li $a1 25
+ li $a2 37000
+ li $a3 0
+ jal Element.Init
+ bgtz $s0 null25
+ la $a0 _str0
+ j _error
+null25:
+ move $a0 $s0
+ move $a1 $s1
+ jal List.Insert
+ move $s0 $v0
+ bgtz $s0 null26
+ la $a0 _str0
+ j _error
+null26:
+ move $a0 $s0
+ jal List.Print
+ li $a0 10000000
+ jal _print
+ li $a0 12
+ jal _heapAlloc
+ move $s1 $v0
+ bgtz $s1 null27
+ la $a0 _str0
+ j _error
+null27:
+ move $a0 $s1
+ li $a1 39
+ li $a2 42000
+ li $a3 1
+ jal Element.Init
+ move $s2 $s1
+ bgtz $s0 null28
+ la $a0 _str0
+ j _error
+null28:
+ move $a0 $s0
+ move $a1 $s1
+ jal List.Insert
+ move $s0 $v0
+ bgtz $s0 null29
+ la $a0 _str0
+ j _error
+null29:
+ move $a0 $s0
+ jal List.Print
+ li $a0 10000000
+ jal _print
+ li $a0 12
+ jal _heapAlloc
+ move $s1 $v0
+ bgtz $s1 null30
+ la $a0 _str0
+ j _error
+null30:
+ move $a0 $s1
+ li $a1 22
+ li $a2 34000
+ li $a3 0
+ jal Element.Init
+ bgtz $s0 null31
+ la $a0 _str0
+ j _error
+null31:
+ move $a0 $s0
+ move $a1 $s1
+ jal List.Insert
+ move $s0 $v0
+ bgtz $s0 null32
+ la $a0 _str0
+ j _error
+null32:
+ move $a0 $s0
+ jal List.Print
+ li $a0 12
+ jal _heapAlloc
+ move $s3 $v0
+ bgtz $s3 null33
+ la $a0 _str0
+ j _error
+null33:
+ move $a0 $s3
+ li $a1 27
+ li $a2 34000
+ li $a3 0
+ jal Element.Init
+ bgtz $s0 null34
+ la $a0 _str0
+ j _error
+null34:
+ move $a0 $s0
+ move $a1 $s2
+ jal List.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null35
+ la $a0 _str0
+ j _error
+null35:
+ move $a0 $s0
+ move $a1 $s3
+ jal List.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ li $a0 10000000
+ jal _print
+ li $a0 12
+ jal _heapAlloc
+ move $s1 $v0
+ bgtz $s1 null36
+ la $a0 _str0
+ j _error
+null36:
+ move $a0 $s1
+ li $a1 28
+ li $a2 35000
+ li $a3 0
+ jal Element.Init
+ bgtz $s0 null37
+ la $a0 _str0
+ j _error
+null37:
+ move $a0 $s0
+ move $a1 $s1
+ jal List.Insert
+ move $s0 $v0
+ bgtz $s0 null38
+ la $a0 _str0
+ j _error
+null38:
+ move $a0 $s0
+ jal List.Print
+ li $a0 2220000
+ jal _print
+ bgtz $s0 null39
+ la $a0 _str0
+ j _error
+null39:
+ move $a0 $s0
+ move $a1 $s2
+ jal List.Delete
+ move $s0 $v0
+ bgtz $s0 null40
+ la $a0 _str0
+ j _error
+null40:
+ move $a0 $s0
+ jal List.Print
+ li $a0 33300000
+ jal _print
+ bgtz $s0 null41
+ la $a0 _str0
+ j _error
+null41:
+ move $a0 $s0
+ move $a1 $s1
+ jal List.Delete
+ move $s0 $v0
+ bgtz $s0 null42
+ la $a0 _str0
+ j _error
+null42:
+ move $a0 $s0
+ jal List.Print
+ li $a0 44440000
+ jal _print
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $s3 -24($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 24
+ jr $ra
+_print:
+ li $v0 1 # syscall: print integer
+ syscall
+ la $a0 _newline
+ li $v0 4 # syscall: print string
+ syscall
+ jr $ra
+_error:
+ li $v0 4 # syscall: print string
+ syscall
+ li $v0 10 # syscall: exit
+ syscall
+_heapAlloc:
+ li $v0 9 # syscall: sbrk
+ syscall
+ jr $ra
+.data
+.align 0
+_newline: .asciiz "\n"
+_str0: .asciiz "null pointer\n"
diff --git a/output/LinkedList.opt.vaporm b/output/LinkedList.opt.vaporm
new file mode 100644
index 0000000..b9bef66
--- /dev/null
+++ b/output/LinkedList.opt.vaporm
@@ -0,0 +1,562 @@
+const empty_Element
+
+const empty_List
+
+const empty_LL
+
+func Main [in 0, out 0, local 0]
+ $a0 = :empty_LL
+ call :LL.Start
+ $t0 = $v0
+ PrintIntS($t0)
+ ret
+
+func Element.Init [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ $t2 = $a2
+ $t3 = $a3
+ [$t0] = $t1
+ [$t0+4] = $t2
+ [$t0+8] = $t3
+ $v0 = 1
+ ret
+
+func Element.GetAge [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0]
+ $v0 = $t0
+ ret
+
+func Element.GetSalary [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+4]
+ $v0 = $t0
+ ret
+
+func Element.GetMarried [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+8]
+ $v0 = $t0
+ ret
+
+func Element.Equal [in 0, out 0, local 3]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = 1
+ if $s1 goto :null1
+ Error("null pointer")
+null1:
+ $a0 = $s1
+ call :Element.GetAge
+ $t0 = $v0
+ $t1 = [$s0]
+ $a0 = $s0
+ $a1 = $t0
+ $a2 = $t1
+ call :Element.Compare
+ $t1 = $v0
+ if $t1 goto :if1_else
+ $s2 = 0
+ goto :if1_end
+if1_else:
+ if $s1 goto :null2
+ Error("null pointer")
+null2:
+ $a0 = $s1
+ call :Element.GetSalary
+ $t1 = $v0
+ $t0 = [$s0+4]
+ $a0 = $s0
+ $a1 = $t1
+ $a2 = $t0
+ call :Element.Compare
+ $t0 = $v0
+ if $t0 goto :if2_else
+ $s2 = 0
+ goto :if2_end
+if2_else:
+ $t0 = [$s0+8]
+ if0 $t0 goto :if3_else
+ if $s1 goto :null3
+ Error("null pointer")
+null3:
+ $a0 = $s1
+ call :Element.GetMarried
+ $t0 = $v0
+ if $t0 goto :if4_else
+ $s2 = 0
+ goto :if4_end
+if4_else:
+if4_end:
+ goto :if3_end
+if3_else:
+ if $s1 goto :null4
+ Error("null pointer")
+null4:
+ $a0 = $s1
+ call :Element.GetMarried
+ $t0 = $v0
+ if0 $t0 goto :if5_else
+ $s2 = 0
+ goto :if5_end
+if5_else:
+if5_end:
+if3_end:
+if2_end:
+if1_end:
+ $v0 = $s2
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ ret
+
+func Element.Compare [in 0, out 0, local 0]
+ $t0 = $a1
+ $t1 = $a2
+ $t2 = Add($t1 1)
+ $t1 = LtS($t0 $t1)
+ if0 $t1 goto :if6_else
+ $t1 = 0
+ goto :if6_end
+if6_else:
+ $t2 = LtS($t0 $t2)
+ if $t2 goto :if7_else
+ $t1 = 0
+ goto :if7_end
+if7_else:
+ $t1 = 1
+if7_end:
+if6_end:
+ $v0 = $t1
+ ret
+
+func List.Init [in 0, out 0, local 0]
+ $t0 = $a0
+ [$t0+8] = 1
+ $v0 = 1
+ ret
+
+func List.InitNew [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ $t2 = $a2
+ $t3 = $a3
+ [$t0+8] = $t3
+ [$t0] = $t1
+ [$t0+4] = $t2
+ $v0 = 1
+ ret
+
+func List.Insert [in 0, out 0, local 1]
+ local[0] = $s0
+ $t0 = $a0
+ $t1 = $a1
+ $t0 = $t0
+ $s0 = HeapAllocZ(12)
+ if $s0 goto :null5
+ Error("null pointer")
+null5:
+ $a0 = $s0
+ $a1 = $t1
+ $a2 = $t0
+ $a3 = 0
+ call :List.InitNew
+ $v0 = $s0
+ $s0 = local[0]
+ ret
+
+func List.SetNext [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+4] = $t1
+ $v0 = 1
+ ret
+
+func List.Delete [in 0, out 0, local 8]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ local[3] = $s3
+ local[4] = $s4
+ local[5] = $s5
+ local[6] = $s6
+ local[7] = $s7
+ $t0 = $a0
+ $s0 = $a1
+ $s1 = $t0
+ $s2 = 0
+ $s3 = Sub(0 1)
+ $s4 = $t0
+ $s5 = $t0
+ $s6 = [$t0+8]
+ $s7 = [$t0]
+while1_top:
+ if $s6 goto :ss1_else
+ $t0 = Sub(1 $s2)
+ goto :ss1_end
+ss1_else:
+ $t0 = 0
+ss1_end:
+ if0 $t0 goto :while1_end
+ if $s0 goto :null6
+ Error("null pointer")
+null6:
+ $a0 = $s0
+ $a1 = $s7
+ call :Element.Equal
+ $t0 = $v0
+ if0 $t0 goto :if8_else
+ $s2 = 1
+ $t0 = LtS($s3 0)
+ if0 $t0 goto :if9_else
+ if $s4 goto :null7
+ Error("null pointer")
+null7:
+ $a0 = $s4
+ call :List.GetNext
+ $s1 = $v0
+ goto :if9_end
+if9_else:
+ $t0 = Sub(0 555)
+ PrintIntS($t0)
+ if $s5 goto :null8
+ Error("null pointer")
+null8:
+ if $s4 goto :null9
+ Error("null pointer")
+null9:
+ $a0 = $s4
+ call :List.GetNext
+ $t0 = $v0
+ $a0 = $s5
+ $a1 = $t0
+ call :List.SetNext
+ $t0 = Sub(0 555)
+ PrintIntS($t0)
+if9_end:
+ goto :if8_end
+if8_else:
+if8_end:
+ if $s2 goto :if10_else
+ $s5 = $s4
+ if $s4 goto :null10
+ Error("null pointer")
+null10:
+ $a0 = $s4
+ call :List.GetNext
+ $s4 = $v0
+ if $s4 goto :null11
+ Error("null pointer")
+null11:
+ $a0 = $s4
+ call :List.GetEnd
+ $s6 = $v0
+ if $s4 goto :null12
+ Error("null pointer")
+null12:
+ $a0 = $s4
+ call :List.GetElem
+ $s7 = $v0
+ $s3 = 1
+ goto :if10_end
+if10_else:
+if10_end:
+ goto :while1_top
+while1_end:
+ $v0 = $s1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ $s3 = local[3]
+ $s4 = local[4]
+ $s5 = local[5]
+ $s6 = local[6]
+ $s7 = local[7]
+ ret
+
+func List.Search [in 0, out 0, local 4]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ local[3] = $s3
+ $t0 = $a0
+ $s0 = $a1
+ $s1 = 0
+ $s2 = $t0
+ $s3 = [$t0+8]
+ $t0 = [$t0]
+while2_top:
+ $t1 = Sub(1 $s3)
+ if0 $t1 goto :while2_end
+ if $s0 goto :null13
+ Error("null pointer")
+null13:
+ $a0 = $s0
+ $a1 = $t0
+ call :Element.Equal
+ $t1 = $v0
+ if0 $t1 goto :if11_else
+ $s1 = 1
+ goto :if11_end
+if11_else:
+if11_end:
+ if $s2 goto :null14
+ Error("null pointer")
+null14:
+ $a0 = $s2
+ call :List.GetNext
+ $s2 = $v0
+ if $s2 goto :null15
+ Error("null pointer")
+null15:
+ $a0 = $s2
+ call :List.GetEnd
+ $s3 = $v0
+ if $s2 goto :null16
+ Error("null pointer")
+null16:
+ $a0 = $s2
+ call :List.GetElem
+ $t0 = $v0
+ goto :while2_top
+while2_end:
+ $v0 = $s1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ $s3 = local[3]
+ ret
+
+func List.GetEnd [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+8]
+ $v0 = $t0
+ ret
+
+func List.GetElem [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0]
+ $v0 = $t0
+ ret
+
+func List.GetNext [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+4]
+ $v0 = $t0
+ ret
+
+func List.Print [in 0, out 0, local 2]
+ local[0] = $s0
+ local[1] = $s1
+ $t0 = $a0
+ $s0 = $t0
+ $s1 = [$t0+8]
+ $t0 = [$t0]
+while3_top:
+ $t1 = Sub(1 $s1)
+ if0 $t1 goto :while3_end
+ if $t0 goto :null17
+ Error("null pointer")
+null17:
+ $a0 = $t0
+ call :Element.GetAge
+ $t1 = $v0
+ PrintIntS($t1)
+ if $s0 goto :null18
+ Error("null pointer")
+null18:
+ $a0 = $s0
+ call :List.GetNext
+ $s0 = $v0
+ if $s0 goto :null19
+ Error("null pointer")
+null19:
+ $a0 = $s0
+ call :List.GetEnd
+ $s1 = $v0
+ if $s0 goto :null20
+ Error("null pointer")
+null20:
+ $a0 = $s0
+ call :List.GetElem
+ $t0 = $v0
+ goto :while3_top
+while3_end:
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ ret
+
+func LL.Start [in 0, out 0, local 4]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ local[3] = $s3
+ $s0 = HeapAllocZ(12)
+ if $s0 goto :null21
+ Error("null pointer")
+null21:
+ $a0 = $s0
+ call :List.Init
+ $s0 = $s0
+ if $s0 goto :null22
+ Error("null pointer")
+null22:
+ $a0 = $s0
+ call :List.Init
+ if $s0 goto :null23
+ Error("null pointer")
+null23:
+ $a0 = $s0
+ call :List.Print
+ $s1 = HeapAllocZ(12)
+ if $s1 goto :null24
+ Error("null pointer")
+null24:
+ $a0 = $s1
+ $a1 = 25
+ $a2 = 37000
+ $a3 = 0
+ call :Element.Init
+ if $s0 goto :null25
+ Error("null pointer")
+null25:
+ $a0 = $s0
+ $a1 = $s1
+ call :List.Insert
+ $s0 = $v0
+ if $s0 goto :null26
+ Error("null pointer")
+null26:
+ $a0 = $s0
+ call :List.Print
+ PrintIntS(10000000)
+ $s1 = HeapAllocZ(12)
+ if $s1 goto :null27
+ Error("null pointer")
+null27:
+ $a0 = $s1
+ $a1 = 39
+ $a2 = 42000
+ $a3 = 1
+ call :Element.Init
+ $s2 = $s1
+ if $s0 goto :null28
+ Error("null pointer")
+null28:
+ $a0 = $s0
+ $a1 = $s1
+ call :List.Insert
+ $s0 = $v0
+ if $s0 goto :null29
+ Error("null pointer")
+null29:
+ $a0 = $s0
+ call :List.Print
+ PrintIntS(10000000)
+ $s1 = HeapAllocZ(12)
+ if $s1 goto :null30
+ Error("null pointer")
+null30:
+ $a0 = $s1
+ $a1 = 22
+ $a2 = 34000
+ $a3 = 0
+ call :Element.Init
+ if $s0 goto :null31
+ Error("null pointer")
+null31:
+ $a0 = $s0
+ $a1 = $s1
+ call :List.Insert
+ $s0 = $v0
+ if $s0 goto :null32
+ Error("null pointer")
+null32:
+ $a0 = $s0
+ call :List.Print
+ $s3 = HeapAllocZ(12)
+ if $s3 goto :null33
+ Error("null pointer")
+null33:
+ $a0 = $s3
+ $a1 = 27
+ $a2 = 34000
+ $a3 = 0
+ call :Element.Init
+ if $s0 goto :null34
+ Error("null pointer")
+null34:
+ $a0 = $s0
+ $a1 = $s2
+ call :List.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null35
+ Error("null pointer")
+null35:
+ $a0 = $s0
+ $a1 = $s3
+ call :List.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ PrintIntS(10000000)
+ $s1 = HeapAllocZ(12)
+ if $s1 goto :null36
+ Error("null pointer")
+null36:
+ $a0 = $s1
+ $a1 = 28
+ $a2 = 35000
+ $a3 = 0
+ call :Element.Init
+ if $s0 goto :null37
+ Error("null pointer")
+null37:
+ $a0 = $s0
+ $a1 = $s1
+ call :List.Insert
+ $s0 = $v0
+ if $s0 goto :null38
+ Error("null pointer")
+null38:
+ $a0 = $s0
+ call :List.Print
+ PrintIntS(2220000)
+ if $s0 goto :null39
+ Error("null pointer")
+null39:
+ $a0 = $s0
+ $a1 = $s2
+ call :List.Delete
+ $s0 = $v0
+ if $s0 goto :null40
+ Error("null pointer")
+null40:
+ $a0 = $s0
+ call :List.Print
+ PrintIntS(33300000)
+ if $s0 goto :null41
+ Error("null pointer")
+null41:
+ $a0 = $s0
+ $a1 = $s1
+ call :List.Delete
+ $s0 = $v0
+ if $s0 goto :null42
+ Error("null pointer")
+null42:
+ $a0 = $s0
+ call :List.Print
+ PrintIntS(44440000)
+ $v0 = 0
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ $s3 = local[3]
+ ret
+
diff --git a/output/MoreThan4.opt.s b/output/MoreThan4.opt.s
new file mode 100644
index 0000000..3ecb6d4
--- /dev/null
+++ b/output/MoreThan4.opt.s
@@ -0,0 +1,115 @@
+.data
+empty_MT4:
+.text
+jal Main
+li $v0 10
+syscall
+Main:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ la $a0 empty_MT4
+ li $a1 1
+ li $a2 2
+ li $a3 3
+ li $t9 4
+ sw $t9 -20($fp)
+ li $t9 5
+ sw $t9 -16($fp)
+ li $t9 6
+ sw $t9 -12($fp)
+ jal MT4.Start
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+MT4.Start:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ move $t2 $a2
+ move $t3 $a3
+ lw $t4 0($fp)
+ lw $t5 4($fp)
+ lw $t6 8($fp)
+ move $a0 $t1
+ jal _print
+ move $a0 $t2
+ jal _print
+ move $a0 $t3
+ jal _print
+ move $a0 $t4
+ jal _print
+ move $a0 $t5
+ jal _print
+ move $a0 $t6
+ jal _print
+ move $a0 $t0
+ move $a1 $t6
+ move $a2 $t5
+ move $a3 $t4
+ sw $t3 -20($fp)
+ sw $t2 -16($fp)
+ sw $t1 -12($fp)
+ jal MT4.Change
+ move $t6 $v0
+ move $v0 $t6
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+MT4.Change:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a1
+ move $t1 $a2
+ move $t2 $a3
+ lw $t3 0($fp)
+ lw $t4 4($fp)
+ lw $t5 8($fp)
+ move $a0 $t0
+ jal _print
+ move $a0 $t1
+ jal _print
+ move $a0 $t2
+ jal _print
+ move $a0 $t3
+ jal _print
+ move $a0 $t4
+ jal _print
+ move $a0 $t5
+ jal _print
+ li $v0 0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+_print:
+ li $v0 1 # syscall: print integer
+ syscall
+ la $a0 _newline
+ li $v0 4 # syscall: print string
+ syscall
+ jr $ra
+_error:
+ li $v0 4 # syscall: print string
+ syscall
+ li $v0 10 # syscall: exit
+ syscall
+_heapAlloc:
+ li $v0 9 # syscall: sbrk
+ syscall
+ jr $ra
+.data
+.align 0
+_newline: .asciiz "\n"
+_str0: .asciiz "null pointer\n"
diff --git a/output/MoreThan4.opt.vaporm b/output/MoreThan4.opt.vaporm
new file mode 100644
index 0000000..d1d663b
--- /dev/null
+++ b/output/MoreThan4.opt.vaporm
@@ -0,0 +1,57 @@
+const empty_MT4
+
+func Main [in 0, out 3, local 0]
+ $a0 = :empty_MT4
+ $a1 = 1
+ $a2 = 2
+ $a3 = 3
+ out[0] = 4
+ out[1] = 5
+ out[2] = 6
+ call :MT4.Start
+ $t0 = $v0
+ PrintIntS($t0)
+ ret
+
+func MT4.Start [in 3, out 3, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ $t2 = $a2
+ $t3 = $a3
+ $t4 = in[0]
+ $t5 = in[1]
+ $t6 = in[2]
+ PrintIntS($t1)
+ PrintIntS($t2)
+ PrintIntS($t3)
+ PrintIntS($t4)
+ PrintIntS($t5)
+ PrintIntS($t6)
+ $a0 = $t0
+ $a1 = $t6
+ $a2 = $t5
+ $a3 = $t4
+ out[0] = $t3
+ out[1] = $t2
+ out[2] = $t1
+ call :MT4.Change
+ $t6 = $v0
+ $v0 = $t6
+ ret
+
+func MT4.Change [in 3, out 0, local 0]
+ $t0 = $a1
+ $t1 = $a2
+ $t2 = $a3
+ $t3 = in[0]
+ $t4 = in[1]
+ $t5 = in[2]
+ PrintIntS($t0)
+ PrintIntS($t1)
+ PrintIntS($t2)
+ PrintIntS($t3)
+ PrintIntS($t4)
+ PrintIntS($t5)
+ $v0 = 0
+ ret
+
diff --git a/output/QuickSort.opt.s b/output/QuickSort.opt.s
new file mode 100644
index 0000000..510aa92
--- /dev/null
+++ b/output/QuickSort.opt.s
@@ -0,0 +1,710 @@
+.data
+empty_QS:
+.text
+jal Main
+li $v0 10
+syscall
+Main:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ li $a0 8
+ jal _heapAlloc
+ move $t0 $v0
+ bgtz $t0 null1
+ la $a0 _str0
+ j _error
+null1:
+ move $a0 $t0
+ li $a1 10
+ jal QS.Start
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+QS.Start:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ move $s0 $a0
+ move $t0 $a1
+ move $a0 $s0
+ move $a1 $t0
+ jal QS.Init
+ move $a0 $s0
+ jal QS.Print
+ li $a0 9999
+ jal _print
+ lw $t0 4($s0)
+ move $a0 $t0
+ li $t9 1
+ subu $t0 $a0 $t9
+ move $a0 $s0
+ li $a1 0
+ move $a2 $t0
+ jal QS.Sort
+ move $a0 $s0
+ jal QS.Print
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+QS.Sort:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ move $s0 $a0
+ move $t0 $a1
+ move $s1 $a2
+ li $t1 0
+ move $a0 $t0
+ move $t9 $s1
+ slt $t2 $a0 $t9
+ blez $t2 if1_else
+ lw $t2 0($s0)
+ bgtz $t2 null2
+ la $a0 _str0
+ j _error
+null2:
+ lw $t3 0($t2)
+ move $a0 $s1
+ move $t9 $t3
+ sltu $t3 $a0 $t9
+ bgtz $t3 bounds1
+ la $a0 _str0
+ j _error
+bounds1:
+ move $a0 $s1
+ li $t9 4
+ mul $t3 $a0 $t9
+ move $a0 $t3
+ move $t9 $t2
+ addu $t3 $a0 $t9
+ lw $t3 4($t3)
+ move $a0 $t0
+ li $t9 1
+ subu $s2 $a0 $t9
+ move $t2 $s1
+ li $t4 1
+while1_top:
+ blez $t4 while1_end
+ li $t5 1
+while2_top:
+ blez $t5 while2_end
+ move $a0 $s2
+ li $t9 1
+ addu $s2 $a0 $t9
+ lw $t6 0($s0)
+ bgtz $t6 null3
+ la $a0 _str0
+ j _error
+null3:
+ lw $t7 0($t6)
+ move $a0 $s2
+ move $t9 $t7
+ sltu $t7 $a0 $t9
+ bgtz $t7 bounds2
+ la $a0 _str0
+ j _error
+bounds2:
+ move $a0 $s2
+ li $t9 4
+ mul $t7 $a0 $t9
+ move $a0 $t7
+ move $t9 $t6
+ addu $t7 $a0 $t9
+ lw $t7 4($t7)
+ move $a0 $t7
+ move $t9 $t3
+ slt $t6 $a0 $t9
+ bgtz $t6 if2_else
+ li $t5 0
+ j if2_end
+if2_else:
+ li $t5 1
+if2_end:
+ j while2_top
+while2_end:
+ li $t5 1
+while3_top:
+ blez $t5 while3_end
+ move $a0 $t2
+ li $t9 1
+ subu $t2 $a0 $t9
+ lw $t6 0($s0)
+ bgtz $t6 null4
+ la $a0 _str0
+ j _error
+null4:
+ lw $t8 0($t6)
+ move $a0 $t2
+ move $t9 $t8
+ sltu $t8 $a0 $t9
+ bgtz $t8 bounds3
+ la $a0 _str0
+ j _error
+bounds3:
+ move $a0 $t2
+ li $t9 4
+ mul $t8 $a0 $t9
+ move $a0 $t8
+ move $t9 $t6
+ addu $t8 $a0 $t9
+ lw $t7 4($t8)
+ move $a0 $t3
+ move $t9 $t7
+ slt $t7 $a0 $t9
+ bgtz $t7 if3_else
+ li $t5 0
+ j if3_end
+if3_else:
+ li $t5 1
+if3_end:
+ j while3_top
+while3_end:
+ lw $t5 0($s0)
+ bgtz $t5 null5
+ la $a0 _str0
+ j _error
+null5:
+ lw $t7 0($t5)
+ move $a0 $s2
+ move $t9 $t7
+ sltu $t7 $a0 $t9
+ bgtz $t7 bounds4
+ la $a0 _str0
+ j _error
+bounds4:
+ move $a0 $s2
+ li $t9 4
+ mul $t7 $a0 $t9
+ move $a0 $t7
+ move $t9 $t5
+ addu $t7 $a0 $t9
+ lw $t1 4($t7)
+ lw $t7 0($s0)
+ bgtz $t7 null6
+ la $a0 _str0
+ j _error
+null6:
+ lw $t5 0($t7)
+ move $a0 $s2
+ move $t9 $t5
+ sltu $t5 $a0 $t9
+ bgtz $t5 bounds5
+ la $a0 _str0
+ j _error
+bounds5:
+ move $a0 $s2
+ li $t9 4
+ mul $t5 $a0 $t9
+ move $a0 $t5
+ move $t9 $t7
+ addu $t5 $a0 $t9
+ lw $t7 0($s0)
+ bgtz $t7 null7
+ la $a0 _str0
+ j _error
+null7:
+ lw $t8 0($t7)
+ move $a0 $t2
+ move $t9 $t8
+ sltu $t8 $a0 $t9
+ bgtz $t8 bounds6
+ la $a0 _str0
+ j _error
+bounds6:
+ move $a0 $t2
+ li $t9 4
+ mul $t8 $a0 $t9
+ move $a0 $t8
+ move $t9 $t7
+ addu $t8 $a0 $t9
+ lw $t8 4($t8)
+ sw $t8 4($t5)
+ lw $t8 0($s0)
+ bgtz $t8 null8
+ la $a0 _str0
+ j _error
+null8:
+ lw $t5 0($t8)
+ move $a0 $t2
+ move $t9 $t5
+ sltu $t5 $a0 $t9
+ bgtz $t5 bounds7
+ la $a0 _str0
+ j _error
+bounds7:
+ move $a0 $t2
+ li $t9 4
+ mul $t5 $a0 $t9
+ move $a0 $t5
+ move $t9 $t8
+ addu $t5 $a0 $t9
+ sw $t1 4($t5)
+ move $a0 $s2
+ li $t9 1
+ addu $t5 $a0 $t9
+ move $a0 $t2
+ move $t9 $t5
+ slt $t5 $a0 $t9
+ blez $t5 if4_else
+ li $t4 0
+ j if4_end
+if4_else:
+ li $t4 1
+if4_end:
+ j while1_top
+while1_end:
+ lw $t4 0($s0)
+ bgtz $t4 null9
+ la $a0 _str0
+ j _error
+null9:
+ lw $t3 0($t4)
+ move $a0 $t2
+ move $t9 $t3
+ sltu $t3 $a0 $t9
+ bgtz $t3 bounds8
+ la $a0 _str0
+ j _error
+bounds8:
+ move $a0 $t2
+ li $t9 4
+ mul $t3 $a0 $t9
+ move $a0 $t3
+ move $t9 $t4
+ addu $t3 $a0 $t9
+ lw $t4 0($s0)
+ bgtz $t4 null10
+ la $a0 _str0
+ j _error
+null10:
+ lw $t2 0($t4)
+ move $a0 $s2
+ move $t9 $t2
+ sltu $t2 $a0 $t9
+ bgtz $t2 bounds9
+ la $a0 _str0
+ j _error
+bounds9:
+ move $a0 $s2
+ li $t9 4
+ mul $t2 $a0 $t9
+ move $a0 $t2
+ move $t9 $t4
+ addu $t2 $a0 $t9
+ lw $t2 4($t2)
+ sw $t2 4($t3)
+ lw $t2 0($s0)
+ bgtz $t2 null11
+ la $a0 _str0
+ j _error
+null11:
+ lw $t3 0($t2)
+ move $a0 $s2
+ move $t9 $t3
+ sltu $t3 $a0 $t9
+ bgtz $t3 bounds10
+ la $a0 _str0
+ j _error
+bounds10:
+ move $a0 $s2
+ li $t9 4
+ mul $t3 $a0 $t9
+ move $a0 $t3
+ move $t9 $t2
+ addu $t3 $a0 $t9
+ lw $t2 0($s0)
+ bgtz $t2 null12
+ la $a0 _str0
+ j _error
+null12:
+ lw $t4 0($t2)
+ move $a0 $s1
+ move $t9 $t4
+ sltu $t4 $a0 $t9
+ bgtz $t4 bounds11
+ la $a0 _str0
+ j _error
+bounds11:
+ move $a0 $s1
+ li $t9 4
+ mul $t4 $a0 $t9
+ move $a0 $t4
+ move $t9 $t2
+ addu $t4 $a0 $t9
+ lw $t4 4($t4)
+ sw $t4 4($t3)
+ lw $t4 0($s0)
+ bgtz $t4 null13
+ la $a0 _str0
+ j _error
+null13:
+ lw $t3 0($t4)
+ move $a0 $s1
+ move $t9 $t3
+ sltu $t3 $a0 $t9
+ bgtz $t3 bounds12
+ la $a0 _str0
+ j _error
+bounds12:
+ move $a0 $s1
+ li $t9 4
+ mul $t3 $a0 $t9
+ move $a0 $t3
+ move $t9 $t4
+ addu $t3 $a0 $t9
+ sw $t1 4($t3)
+ move $a0 $s2
+ li $t9 1
+ subu $t3 $a0 $t9
+ move $a0 $s0
+ move $a1 $t0
+ move $a2 $t3
+ jal QS.Sort
+ move $a0 $s2
+ li $t9 1
+ addu $t3 $a0 $t9
+ move $a0 $s0
+ move $a1 $t3
+ move $a2 $s1
+ jal QS.Sort
+ j if1_end
+if1_else:
+if1_end:
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+QS.Print:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ li $t1 0
+while4_top:
+ lw $t2 4($t0)
+ move $a0 $t1
+ move $t9 $t2
+ slt $t2 $a0 $t9
+ blez $t2 while4_end
+ lw $t2 0($t0)
+ bgtz $t2 null14
+ la $a0 _str0
+ j _error
+null14:
+ lw $t3 0($t2)
+ move $a0 $t1
+ move $t9 $t3
+ sltu $t3 $a0 $t9
+ bgtz $t3 bounds13
+ la $a0 _str0
+ j _error
+bounds13:
+ move $a0 $t1
+ li $t9 4
+ mul $t3 $a0 $t9
+ move $a0 $t3
+ move $t9 $t2
+ addu $t3 $a0 $t9
+ lw $t3 4($t3)
+ move $a0 $t3
+ jal _print
+ move $a0 $t1
+ li $t9 1
+ addu $t1 $a0 $t9
+ j while4_top
+while4_end:
+ li $v0 0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+QS.Init:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ move $s0 $a0
+ move $t0 $a1
+ sw $t0 4($s0)
+ move $a0 $t0
+ jal AllocArray
+ move $t0 $v0
+ sw $t0 0($s0)
+ lw $t0 0($s0)
+ bgtz $t0 null15
+ la $a0 _str0
+ j _error
+null15:
+ lw $t1 0($t0)
+ li $a0 0
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds14
+ la $a0 _str0
+ j _error
+bounds14:
+ li $a0 0
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 20
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null16
+ la $a0 _str0
+ j _error
+null16:
+ lw $t0 0($t1)
+ li $a0 1
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds15
+ la $a0 _str0
+ j _error
+bounds15:
+ li $a0 1
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 7
+ sw $t9 4($t0)
+ lw $t0 0($s0)
+ bgtz $t0 null17
+ la $a0 _str0
+ j _error
+null17:
+ lw $t1 0($t0)
+ li $a0 2
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds16
+ la $a0 _str0
+ j _error
+bounds16:
+ li $a0 2
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 12
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null18
+ la $a0 _str0
+ j _error
+null18:
+ lw $t0 0($t1)
+ li $a0 3
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds17
+ la $a0 _str0
+ j _error
+bounds17:
+ li $a0 3
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 18
+ sw $t9 4($t0)
+ lw $t0 0($s0)
+ bgtz $t0 null19
+ la $a0 _str0
+ j _error
+null19:
+ lw $t1 0($t0)
+ li $a0 4
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds18
+ la $a0 _str0
+ j _error
+bounds18:
+ li $a0 4
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 2
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null20
+ la $a0 _str0
+ j _error
+null20:
+ lw $t0 0($t1)
+ li $a0 5
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds19
+ la $a0 _str0
+ j _error
+bounds19:
+ li $a0 5
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 11
+ sw $t9 4($t0)
+ lw $t0 0($s0)
+ bgtz $t0 null21
+ la $a0 _str0
+ j _error
+null21:
+ lw $t1 0($t0)
+ li $a0 6
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds20
+ la $a0 _str0
+ j _error
+bounds20:
+ li $a0 6
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 6
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null22
+ la $a0 _str0
+ j _error
+null22:
+ lw $t0 0($t1)
+ li $a0 7
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds21
+ la $a0 _str0
+ j _error
+bounds21:
+ li $a0 7
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 9
+ sw $t9 4($t0)
+ lw $t0 0($s0)
+ bgtz $t0 null23
+ la $a0 _str0
+ j _error
+null23:
+ lw $t1 0($t0)
+ li $a0 8
+ move $t9 $t1
+ sltu $t1 $a0 $t9
+ bgtz $t1 bounds22
+ la $a0 _str0
+ j _error
+bounds22:
+ li $a0 8
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ move $t9 $t0
+ addu $t1 $a0 $t9
+ li $t9 19
+ sw $t9 4($t1)
+ lw $t1 0($s0)
+ bgtz $t1 null24
+ la $a0 _str0
+ j _error
+null24:
+ lw $t0 0($t1)
+ li $a0 9
+ move $t9 $t0
+ sltu $t0 $a0 $t9
+ bgtz $t0 bounds23
+ la $a0 _str0
+ j _error
+bounds23:
+ li $a0 9
+ li $t9 4
+ mul $t0 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ addu $t0 $a0 $t9
+ li $t9 5
+ sw $t9 4($t0)
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+AllocArray:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $a0 $t0
+ li $t9 4
+ mul $t1 $a0 $t9
+ move $a0 $t1
+ li $t9 4
+ addu $t1 $a0 $t9
+ move $a0 $t1
+ jal _heapAlloc
+ move $t1 $v0
+ sw $t0 0($t1)
+ move $v0 $t1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+_print:
+ li $v0 1 # syscall: print integer
+ syscall
+ la $a0 _newline
+ li $v0 4 # syscall: print string
+ syscall
+ jr $ra
+_error:
+ li $v0 4 # syscall: print string
+ syscall
+ li $v0 10 # syscall: exit
+ syscall
+_heapAlloc:
+ li $v0 9 # syscall: sbrk
+ syscall
+ jr $ra
+.data
+.align 0
+_newline: .asciiz "\n"
+_str0: .asciiz "null pointer\n"
diff --git a/output/QuickSort.opt.vaporm b/output/QuickSort.opt.vaporm
new file mode 100644
index 0000000..61f1151
--- /dev/null
+++ b/output/QuickSort.opt.vaporm
@@ -0,0 +1,418 @@
+const empty_QS
+
+func Main [in 0, out 0, local 0]
+ $t0 = HeapAllocZ(8)
+ if $t0 goto :null1
+ Error("null pointer")
+null1:
+ $a0 = $t0
+ $a1 = 10
+ call :QS.Start
+ $t0 = $v0
+ PrintIntS($t0)
+ ret
+
+func QS.Start [in 0, out 0, local 1]
+ local[0] = $s0
+ $s0 = $a0
+ $t0 = $a1
+ $a0 = $s0
+ $a1 = $t0
+ call :QS.Init
+ $a0 = $s0
+ call :QS.Print
+ PrintIntS(9999)
+ $t0 = [$s0+4]
+ $t0 = Sub($t0 1)
+ $a0 = $s0
+ $a1 = 0
+ $a2 = $t0
+ call :QS.Sort
+ $a0 = $s0
+ call :QS.Print
+ $v0 = 0
+ $s0 = local[0]
+ ret
+
+func QS.Sort [in 0, out 0, local 3]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ $s0 = $a0
+ $t0 = $a1
+ $s1 = $a2
+ $t1 = 0
+ $t2 = LtS($t0 $s1)
+ if0 $t2 goto :if1_else
+ $t2 = [$s0]
+ if $t2 goto :null2
+ Error("null pointer")
+null2:
+ $t3 = [$t2]
+ $t3 = Lt($s1 $t3)
+ if $t3 goto :bounds1
+ Error("array index out of bounds")
+bounds1:
+ $t3 = MulS($s1 4)
+ $t3 = Add($t3 $t2)
+ $t3 = [$t3+4]
+ $s2 = Sub($t0 1)
+ $t2 = $s1
+ $t4 = 1
+while1_top:
+ if0 $t4 goto :while1_end
+ $t5 = 1
+while2_top:
+ if0 $t5 goto :while2_end
+ $s2 = Add($s2 1)
+ $t6 = [$s0]
+ if $t6 goto :null3
+ Error("null pointer")
+null3:
+ $t7 = [$t6]
+ $t7 = Lt($s2 $t7)
+ if $t7 goto :bounds2
+ Error("array index out of bounds")
+bounds2:
+ $t7 = MulS($s2 4)
+ $t7 = Add($t7 $t6)
+ $t7 = [$t7+4]
+ $t6 = LtS($t7 $t3)
+ if $t6 goto :if2_else
+ $t5 = 0
+ goto :if2_end
+if2_else:
+ $t5 = 1
+if2_end:
+ goto :while2_top
+while2_end:
+ $t5 = 1
+while3_top:
+ if0 $t5 goto :while3_end
+ $t2 = Sub($t2 1)
+ $t6 = [$s0]
+ if $t6 goto :null4
+ Error("null pointer")
+null4:
+ $t8 = [$t6]
+ $t8 = Lt($t2 $t8)
+ if $t8 goto :bounds3
+ Error("array index out of bounds")
+bounds3:
+ $t8 = MulS($t2 4)
+ $t8 = Add($t8 $t6)
+ $t7 = [$t8+4]
+ $t7 = LtS($t3 $t7)
+ if $t7 goto :if3_else
+ $t5 = 0
+ goto :if3_end
+if3_else:
+ $t5 = 1
+if3_end:
+ goto :while3_top
+while3_end:
+ $t5 = [$s0]
+ if $t5 goto :null5
+ Error("null pointer")
+null5:
+ $t7 = [$t5]
+ $t7 = Lt($s2 $t7)
+ if $t7 goto :bounds4
+ Error("array index out of bounds")
+bounds4:
+ $t7 = MulS($s2 4)
+ $t7 = Add($t7 $t5)
+ $t1 = [$t7+4]
+ $t7 = [$s0]
+ if $t7 goto :null6
+ Error("null pointer")
+null6:
+ $t5 = [$t7]
+ $t5 = Lt($s2 $t5)
+ if $t5 goto :bounds5
+ Error("array index out of bounds")
+bounds5:
+ $t5 = MulS($s2 4)
+ $t5 = Add($t5 $t7)
+ $t7 = [$s0]
+ if $t7 goto :null7
+ Error("null pointer")
+null7:
+ $t8 = [$t7]
+ $t8 = Lt($t2 $t8)
+ if $t8 goto :bounds6
+ Error("array index out of bounds")
+bounds6:
+ $t8 = MulS($t2 4)
+ $t8 = Add($t8 $t7)
+ $t8 = [$t8+4]
+ [$t5+4] = $t8
+ $t8 = [$s0]
+ if $t8 goto :null8
+ Error("null pointer")
+null8:
+ $t5 = [$t8]
+ $t5 = Lt($t2 $t5)
+ if $t5 goto :bounds7
+ Error("array index out of bounds")
+bounds7:
+ $t5 = MulS($t2 4)
+ $t5 = Add($t5 $t8)
+ [$t5+4] = $t1
+ $t5 = Add($s2 1)
+ $t5 = LtS($t2 $t5)
+ if0 $t5 goto :if4_else
+ $t4 = 0
+ goto :if4_end
+if4_else:
+ $t4 = 1
+if4_end:
+ goto :while1_top
+while1_end:
+ $t4 = [$s0]
+ if $t4 goto :null9
+ Error("null pointer")
+null9:
+ $t3 = [$t4]
+ $t3 = Lt($t2 $t3)
+ if $t3 goto :bounds8
+ Error("array index out of bounds")
+bounds8:
+ $t3 = MulS($t2 4)
+ $t3 = Add($t3 $t4)
+ $t4 = [$s0]
+ if $t4 goto :null10
+ Error("null pointer")
+null10:
+ $t2 = [$t4]
+ $t2 = Lt($s2 $t2)
+ if $t2 goto :bounds9
+ Error("array index out of bounds")
+bounds9:
+ $t2 = MulS($s2 4)
+ $t2 = Add($t2 $t4)
+ $t2 = [$t2+4]
+ [$t3+4] = $t2
+ $t2 = [$s0]
+ if $t2 goto :null11
+ Error("null pointer")
+null11:
+ $t3 = [$t2]
+ $t3 = Lt($s2 $t3)
+ if $t3 goto :bounds10
+ Error("array index out of bounds")
+bounds10:
+ $t3 = MulS($s2 4)
+ $t3 = Add($t3 $t2)
+ $t2 = [$s0]
+ if $t2 goto :null12
+ Error("null pointer")
+null12:
+ $t4 = [$t2]
+ $t4 = Lt($s1 $t4)
+ if $t4 goto :bounds11
+ Error("array index out of bounds")
+bounds11:
+ $t4 = MulS($s1 4)
+ $t4 = Add($t4 $t2)
+ $t4 = [$t4+4]
+ [$t3+4] = $t4
+ $t4 = [$s0]
+ if $t4 goto :null13
+ Error("null pointer")
+null13:
+ $t3 = [$t4]
+ $t3 = Lt($s1 $t3)
+ if $t3 goto :bounds12
+ Error("array index out of bounds")
+bounds12:
+ $t3 = MulS($s1 4)
+ $t3 = Add($t3 $t4)
+ [$t3+4] = $t1
+ $t3 = Sub($s2 1)
+ $a0 = $s0
+ $a1 = $t0
+ $a2 = $t3
+ call :QS.Sort
+ $t3 = Add($s2 1)
+ $a0 = $s0
+ $a1 = $t3
+ $a2 = $s1
+ call :QS.Sort
+ goto :if1_end
+if1_else:
+if1_end:
+ $v0 = 0
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ ret
+
+func QS.Print [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = 0
+while4_top:
+ $t2 = [$t0+4]
+ $t2 = LtS($t1 $t2)
+ if0 $t2 goto :while4_end
+ $t2 = [$t0]
+ if $t2 goto :null14
+ Error("null pointer")
+null14:
+ $t3 = [$t2]
+ $t3 = Lt($t1 $t3)
+ if $t3 goto :bounds13
+ Error("array index out of bounds")
+bounds13:
+ $t3 = MulS($t1 4)
+ $t3 = Add($t3 $t2)
+ $t3 = [$t3+4]
+ PrintIntS($t3)
+ $t1 = Add($t1 1)
+ goto :while4_top
+while4_end:
+ $v0 = 0
+ ret
+
+func QS.Init [in 0, out 0, local 1]
+ local[0] = $s0
+ $s0 = $a0
+ $t0 = $a1
+ [$s0+4] = $t0
+ $a0 = $t0
+ call :AllocArray
+ $t0 = $v0
+ [$s0] = $t0
+ $t0 = [$s0]
+ if $t0 goto :null15
+ Error("null pointer")
+null15:
+ $t1 = [$t0]
+ $t1 = Lt(0 $t1)
+ if $t1 goto :bounds14
+ Error("array index out of bounds")
+bounds14:
+ $t1 = MulS(0 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 20
+ $t1 = [$s0]
+ if $t1 goto :null16
+ Error("null pointer")
+null16:
+ $t0 = [$t1]
+ $t0 = Lt(1 $t0)
+ if $t0 goto :bounds15
+ Error("array index out of bounds")
+bounds15:
+ $t0 = MulS(1 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 7
+ $t0 = [$s0]
+ if $t0 goto :null17
+ Error("null pointer")
+null17:
+ $t1 = [$t0]
+ $t1 = Lt(2 $t1)
+ if $t1 goto :bounds16
+ Error("array index out of bounds")
+bounds16:
+ $t1 = MulS(2 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 12
+ $t1 = [$s0]
+ if $t1 goto :null18
+ Error("null pointer")
+null18:
+ $t0 = [$t1]
+ $t0 = Lt(3 $t0)
+ if $t0 goto :bounds17
+ Error("array index out of bounds")
+bounds17:
+ $t0 = MulS(3 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 18
+ $t0 = [$s0]
+ if $t0 goto :null19
+ Error("null pointer")
+null19:
+ $t1 = [$t0]
+ $t1 = Lt(4 $t1)
+ if $t1 goto :bounds18
+ Error("array index out of bounds")
+bounds18:
+ $t1 = MulS(4 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 2
+ $t1 = [$s0]
+ if $t1 goto :null20
+ Error("null pointer")
+null20:
+ $t0 = [$t1]
+ $t0 = Lt(5 $t0)
+ if $t0 goto :bounds19
+ Error("array index out of bounds")
+bounds19:
+ $t0 = MulS(5 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 11
+ $t0 = [$s0]
+ if $t0 goto :null21
+ Error("null pointer")
+null21:
+ $t1 = [$t0]
+ $t1 = Lt(6 $t1)
+ if $t1 goto :bounds20
+ Error("array index out of bounds")
+bounds20:
+ $t1 = MulS(6 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 6
+ $t1 = [$s0]
+ if $t1 goto :null22
+ Error("null pointer")
+null22:
+ $t0 = [$t1]
+ $t0 = Lt(7 $t0)
+ if $t0 goto :bounds21
+ Error("array index out of bounds")
+bounds21:
+ $t0 = MulS(7 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 9
+ $t0 = [$s0]
+ if $t0 goto :null23
+ Error("null pointer")
+null23:
+ $t1 = [$t0]
+ $t1 = Lt(8 $t1)
+ if $t1 goto :bounds22
+ Error("array index out of bounds")
+bounds22:
+ $t1 = MulS(8 4)
+ $t1 = Add($t1 $t0)
+ [$t1+4] = 19
+ $t1 = [$s0]
+ if $t1 goto :null24
+ Error("null pointer")
+null24:
+ $t0 = [$t1]
+ $t0 = Lt(9 $t0)
+ if $t0 goto :bounds23
+ Error("array index out of bounds")
+bounds23:
+ $t0 = MulS(9 4)
+ $t0 = Add($t0 $t1)
+ [$t0+4] = 5
+ $v0 = 0
+ $s0 = local[0]
+ ret
+
+func AllocArray [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = MulS($t0 4)
+ $t1 = Add($t1 4)
+ $t1 = HeapAllocZ($t1)
+ [$t1] = $t0
+ $v0 = $t1
+ ret
+
diff --git a/output/TreeVisitor.opt.s b/output/TreeVisitor.opt.s
new file mode 100644
index 0000000..25b4b10
--- /dev/null
+++ b/output/TreeVisitor.opt.s
@@ -0,0 +1,1241 @@
+.data
+empty_TV:
+empty_Tree:
+vmt_Visitor:
+ Visitor.visit
+vmt_MyVisitor:
+ MyVisitor.visit
+.text
+jal Main
+li $v0 10
+syscall
+Main:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ la $a0 empty_TV
+ jal TV.Start
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+TV.Start:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 12
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ li $a0 24
+ jal _heapAlloc
+ move $s0 $v0
+ bgtz $s0 null1
+ la $a0 _str0
+ j _error
+null1:
+ move $a0 $s0
+ li $a1 16
+ jal Tree.Init
+ bgtz $s0 null2
+ la $a0 _str0
+ j _error
+null2:
+ move $a0 $s0
+ jal Tree.Print
+ li $a0 100000000
+ jal _print
+ bgtz $s0 null3
+ la $a0 _str0
+ j _error
+null3:
+ move $a0 $s0
+ li $a1 8
+ jal Tree.Insert
+ bgtz $s0 null4
+ la $a0 _str0
+ j _error
+null4:
+ move $a0 $s0
+ li $a1 24
+ jal Tree.Insert
+ bgtz $s0 null5
+ la $a0 _str0
+ j _error
+null5:
+ move $a0 $s0
+ li $a1 4
+ jal Tree.Insert
+ bgtz $s0 null6
+ la $a0 _str0
+ j _error
+null6:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Insert
+ bgtz $s0 null7
+ la $a0 _str0
+ j _error
+null7:
+ move $a0 $s0
+ li $a1 20
+ jal Tree.Insert
+ bgtz $s0 null8
+ la $a0 _str0
+ j _error
+null8:
+ move $a0 $s0
+ li $a1 28
+ jal Tree.Insert
+ bgtz $s0 null9
+ la $a0 _str0
+ j _error
+null9:
+ move $a0 $s0
+ li $a1 14
+ jal Tree.Insert
+ bgtz $s0 null10
+ la $a0 _str0
+ j _error
+null10:
+ move $a0 $s0
+ jal Tree.Print
+ li $a0 100000000
+ jal _print
+ li $a0 12
+ jal _heapAlloc
+ move $t0 $v0
+ la $t9 vmt_MyVisitor
+ sw $t9 0($t0)
+ move $t0 $t0
+ li $a0 50000000
+ jal _print
+ bgtz $s0 null11
+ la $a0 _str0
+ j _error
+null11:
+ move $a0 $s0
+ move $a1 $t0
+ jal Tree.accept
+ li $a0 100000000
+ jal _print
+ bgtz $s0 null12
+ la $a0 _str0
+ j _error
+null12:
+ move $a0 $s0
+ li $a1 24
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null13
+ la $a0 _str0
+ j _error
+null13:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null14
+ la $a0 _str0
+ j _error
+null14:
+ move $a0 $s0
+ li $a1 16
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null15
+ la $a0 _str0
+ j _error
+null15:
+ move $a0 $s0
+ li $a1 50
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null16
+ la $a0 _str0
+ j _error
+null16:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s0 null17
+ la $a0 _str0
+ j _error
+null17:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Delete
+ bgtz $s0 null18
+ la $a0 _str0
+ j _error
+null18:
+ move $a0 $s0
+ jal Tree.Print
+ bgtz $s0 null19
+ la $a0 _str0
+ j _error
+null19:
+ move $a0 $s0
+ li $a1 12
+ jal Tree.Search
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 12
+ jr $ra
+Tree.Init:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 8($t0)
+ li $t9 0
+ sw $t9 12($t0)
+ li $t9 0
+ sw $t9 16($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetRight:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 4($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetLeft:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 0($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetRight:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 4($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetLeft:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 0($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetKey:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 8($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetKey:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 8($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetHas_Right:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 16($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.GetHas_Left:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ lw $t0 12($t0)
+ move $v0 $t0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetHas_Left:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 12($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.SetHas_Right:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ sw $t1 16($t0)
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.Compare:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a1
+ move $t1 $a2
+ move $a0 $t1
+ li $t9 1
+ addu $t2 $a0 $t9
+ move $a0 $t0
+ move $t9 $t1
+ slt $t1 $a0 $t9
+ blez $t1 if1_else
+ li $t1 0
+ j if1_end
+if1_else:
+ move $a0 $t0
+ move $t9 $t2
+ slt $t2 $a0 $t9
+ bgtz $t2 if2_else
+ li $t1 0
+ j if2_end
+if2_else:
+ li $t1 1
+if2_end:
+if1_end:
+ move $v0 $t1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.Insert:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 24
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ sw $s3 -24($fp)
+ move $s0 $a0
+ move $s1 $a1
+ li $a0 24
+ jal _heapAlloc
+ move $s2 $v0
+ bgtz $s2 null20
+ la $a0 _str0
+ j _error
+null20:
+ move $a0 $s2
+ move $a1 $s1
+ jal Tree.Init
+ move $s0 $s0
+ li $s3 1
+while1_top:
+ blez $s3 while1_end
+ bgtz $s0 null21
+ la $a0 _str0
+ j _error
+null21:
+ move $a0 $s0
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s1
+ move $t9 $t0
+ slt $t0 $a0 $t9
+ blez $t0 if3_else
+ bgtz $s0 null22
+ la $a0 _str0
+ j _error
+null22:
+ move $a0 $s0
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 if4_else
+ bgtz $s0 null23
+ la $a0 _str0
+ j _error
+null23:
+ move $a0 $s0
+ jal Tree.GetLeft
+ move $s0 $v0
+ j if4_end
+if4_else:
+ li $s3 0
+ bgtz $s0 null24
+ la $a0 _str0
+ j _error
+null24:
+ move $a0 $s0
+ li $a1 1
+ jal Tree.SetHas_Left
+ bgtz $s0 null25
+ la $a0 _str0
+ j _error
+null25:
+ move $a0 $s0
+ move $a1 $s2
+ jal Tree.SetLeft
+if4_end:
+ j if3_end
+if3_else:
+ bgtz $s0 null26
+ la $a0 _str0
+ j _error
+null26:
+ move $a0 $s0
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if5_else
+ bgtz $s0 null27
+ la $a0 _str0
+ j _error
+null27:
+ move $a0 $s0
+ jal Tree.GetRight
+ move $s0 $v0
+ j if5_end
+if5_else:
+ li $s3 0
+ bgtz $s0 null28
+ la $a0 _str0
+ j _error
+null28:
+ move $a0 $s0
+ li $a1 1
+ jal Tree.SetHas_Right
+ bgtz $s0 null29
+ la $a0 _str0
+ j _error
+null29:
+ move $a0 $s0
+ move $a1 $s2
+ jal Tree.SetRight
+if5_end:
+if3_end:
+ j while1_top
+while1_end:
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $s3 -24($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 24
+ jr $ra
+Tree.Delete:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 36
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ sw $s3 -24($fp)
+ sw $s4 -28($fp)
+ sw $s5 -32($fp)
+ sw $s6 -36($fp)
+ move $s0 $a0
+ move $s1 $a1
+ move $s2 $s0
+ move $s3 $s0
+ li $s4 1
+ li $s5 0
+ li $s6 1
+while2_top:
+ blez $s4 while2_end
+ bgtz $s2 null30
+ la $a0 _str0
+ j _error
+null30:
+ move $a0 $s2
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s1
+ move $t9 $t0
+ slt $t1 $a0 $t9
+ blez $t1 if6_else
+ bgtz $s2 null31
+ la $a0 _str0
+ j _error
+null31:
+ move $a0 $s2
+ jal Tree.GetHas_Left
+ move $t1 $v0
+ blez $t1 if7_else
+ move $s3 $s2
+ bgtz $s2 null32
+ la $a0 _str0
+ j _error
+null32:
+ move $a0 $s2
+ jal Tree.GetLeft
+ move $s2 $v0
+ j if7_end
+if7_else:
+ li $s4 0
+if7_end:
+ j if6_end
+if6_else:
+ move $a0 $t0
+ move $t9 $s1
+ slt $t0 $a0 $t9
+ blez $t0 if8_else
+ bgtz $s2 null33
+ la $a0 _str0
+ j _error
+null33:
+ move $a0 $s2
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if9_else
+ move $s3 $s2
+ bgtz $s2 null34
+ la $a0 _str0
+ j _error
+null34:
+ move $a0 $s2
+ jal Tree.GetRight
+ move $s2 $v0
+ j if9_end
+if9_else:
+ li $s4 0
+if9_end:
+ j if8_end
+if8_else:
+ blez $s6 if10_else
+ bgtz $s2 null35
+ la $a0 _str0
+ j _error
+null35:
+ move $a0 $s2
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ bgtz $t0 if11_else
+ bgtz $s2 null36
+ la $a0 _str0
+ j _error
+null36:
+ move $a0 $s2
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ bgtz $t0 if11_else
+ j if11_end
+if11_else:
+ move $a0 $s0
+ move $a1 $s3
+ move $a2 $s2
+ jal Tree.Remove
+if11_end:
+ j if10_end
+if10_else:
+ move $a0 $s0
+ move $a1 $s3
+ move $a2 $s2
+ jal Tree.Remove
+if10_end:
+ li $s5 1
+ li $s4 0
+if8_end:
+if6_end:
+ li $s6 0
+ j while2_top
+while2_end:
+ move $v0 $s5
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $s3 -24($fp)
+ lw $s4 -28($fp)
+ lw $s5 -32($fp)
+ lw $s6 -36($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 36
+ jr $ra
+Tree.Remove:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ move $s0 $a0
+ move $s1 $a1
+ move $s2 $a2
+ bgtz $s2 null37
+ la $a0 _str0
+ j _error
+null37:
+ move $a0 $s2
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 if12_else
+ move $a0 $s0
+ move $a1 $s1
+ move $a2 $s2
+ jal Tree.RemoveLeft
+ j if12_end
+if12_else:
+ bgtz $s2 null38
+ la $a0 _str0
+ j _error
+null38:
+ move $a0 $s2
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if13_else
+ move $a0 $s0
+ move $a1 $s1
+ move $a2 $s2
+ jal Tree.RemoveRight
+ j if13_end
+if13_else:
+ bgtz $s2 null39
+ la $a0 _str0
+ j _error
+null39:
+ move $a0 $s2
+ jal Tree.GetKey
+ move $s2 $v0
+ bgtz $s1 null40
+ la $a0 _str0
+ j _error
+null40:
+ move $a0 $s1
+ jal Tree.GetLeft
+ move $t0 $v0
+ bgtz $t0 null41
+ la $a0 _str0
+ j _error
+null41:
+ move $a0 $t0
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s0
+ move $a1 $s2
+ move $a2 $t0
+ jal Tree.Compare
+ move $t0 $v0
+ blez $t0 if14_else
+ bgtz $s1 null42
+ la $a0 _str0
+ j _error
+null42:
+ lw $t0 20($s0)
+ move $a0 $s1
+ move $a1 $t0
+ jal Tree.SetLeft
+ bgtz $s1 null43
+ la $a0 _str0
+ j _error
+null43:
+ move $a0 $s1
+ li $a1 0
+ jal Tree.SetHas_Left
+ j if14_end
+if14_else:
+ bgtz $s1 null44
+ la $a0 _str0
+ j _error
+null44:
+ lw $t0 20($s0)
+ move $a0 $s1
+ move $a1 $t0
+ jal Tree.SetRight
+ bgtz $s1 null45
+ la $a0 _str0
+ j _error
+null45:
+ move $a0 $s1
+ li $a1 0
+ jal Tree.SetHas_Right
+if14_end:
+if13_end:
+if12_end:
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+Tree.RemoveRight:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ move $s0 $a0
+ move $s1 $a1
+ move $s2 $a2
+while3_top:
+ bgtz $s2 null46
+ la $a0 _str0
+ j _error
+null46:
+ move $a0 $s2
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 while3_end
+ bgtz $s2 null47
+ la $a0 _str0
+ j _error
+null47:
+ bgtz $s2 null48
+ la $a0 _str0
+ j _error
+null48:
+ move $a0 $s2
+ jal Tree.GetRight
+ move $t0 $v0
+ bgtz $t0 null49
+ la $a0 _str0
+ j _error
+null49:
+ move $a0 $t0
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s2
+ move $a1 $t0
+ jal Tree.SetKey
+ move $s1 $s2
+ bgtz $s2 null50
+ la $a0 _str0
+ j _error
+null50:
+ move $a0 $s2
+ jal Tree.GetRight
+ move $s2 $v0
+ j while3_top
+while3_end:
+ bgtz $s1 null51
+ la $a0 _str0
+ j _error
+null51:
+ lw $t0 20($s0)
+ move $a0 $s1
+ move $a1 $t0
+ jal Tree.SetRight
+ bgtz $s1 null52
+ la $a0 _str0
+ j _error
+null52:
+ move $a0 $s1
+ li $a1 0
+ jal Tree.SetHas_Right
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+Tree.RemoveLeft:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 20
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ move $s0 $a0
+ move $s1 $a1
+ move $s2 $a2
+while4_top:
+ bgtz $s2 null53
+ la $a0 _str0
+ j _error
+null53:
+ move $a0 $s2
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 while4_end
+ bgtz $s2 null54
+ la $a0 _str0
+ j _error
+null54:
+ bgtz $s2 null55
+ la $a0 _str0
+ j _error
+null55:
+ move $a0 $s2
+ jal Tree.GetLeft
+ move $t0 $v0
+ bgtz $t0 null56
+ la $a0 _str0
+ j _error
+null56:
+ move $a0 $t0
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s2
+ move $a1 $t0
+ jal Tree.SetKey
+ move $s1 $s2
+ bgtz $s2 null57
+ la $a0 _str0
+ j _error
+null57:
+ move $a0 $s2
+ jal Tree.GetLeft
+ move $s2 $v0
+ j while4_top
+while4_end:
+ bgtz $s1 null58
+ la $a0 _str0
+ j _error
+null58:
+ lw $t0 20($s0)
+ move $a0 $s1
+ move $a1 $t0
+ jal Tree.SetLeft
+ bgtz $s1 null59
+ la $a0 _str0
+ j _error
+null59:
+ move $a0 $s1
+ li $a1 0
+ jal Tree.SetHas_Left
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 20
+ jr $ra
+Tree.Search:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 24
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ sw $s2 -20($fp)
+ sw $s3 -24($fp)
+ move $t0 $a0
+ move $s0 $a1
+ move $s1 $t0
+ li $s2 1
+ li $s3 0
+while5_top:
+ blez $s2 while5_end
+ bgtz $s1 null60
+ la $a0 _str0
+ j _error
+null60:
+ move $a0 $s1
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $s0
+ move $t9 $t0
+ slt $t1 $a0 $t9
+ blez $t1 if15_else
+ bgtz $s1 null61
+ la $a0 _str0
+ j _error
+null61:
+ move $a0 $s1
+ jal Tree.GetHas_Left
+ move $t1 $v0
+ blez $t1 if16_else
+ bgtz $s1 null62
+ la $a0 _str0
+ j _error
+null62:
+ move $a0 $s1
+ jal Tree.GetLeft
+ move $s1 $v0
+ j if16_end
+if16_else:
+ li $s2 0
+if16_end:
+ j if15_end
+if15_else:
+ move $a0 $t0
+ move $t9 $s0
+ slt $t0 $a0 $t9
+ blez $t0 if17_else
+ bgtz $s1 null63
+ la $a0 _str0
+ j _error
+null63:
+ move $a0 $s1
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if18_else
+ bgtz $s1 null64
+ la $a0 _str0
+ j _error
+null64:
+ move $a0 $s1
+ jal Tree.GetRight
+ move $s1 $v0
+ j if18_end
+if18_else:
+ li $s2 0
+if18_end:
+ j if17_end
+if17_else:
+ li $s3 1
+ li $s2 0
+if17_end:
+if15_end:
+ j while5_top
+while5_end:
+ move $v0 $s3
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $s2 -20($fp)
+ lw $s3 -24($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 24
+ jr $ra
+Tree.Print:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $t0
+ move $a0 $t0
+ move $a1 $t1
+ jal Tree.RecPrint
+ li $v0 1
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Tree.RecPrint:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 16
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ move $s0 $a0
+ move $s1 $a1
+ bgtz $s1 null65
+ la $a0 _str0
+ j _error
+null65:
+ move $a0 $s1
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 if19_else
+ bgtz $s1 null66
+ la $a0 _str0
+ j _error
+null66:
+ move $a0 $s1
+ jal Tree.GetLeft
+ move $t0 $v0
+ move $a0 $s0
+ move $a1 $t0
+ jal Tree.RecPrint
+ j if19_end
+if19_else:
+if19_end:
+ bgtz $s1 null67
+ la $a0 _str0
+ j _error
+null67:
+ move $a0 $s1
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s1 null68
+ la $a0 _str0
+ j _error
+null68:
+ move $a0 $s1
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if20_else
+ bgtz $s1 null69
+ la $a0 _str0
+ j _error
+null69:
+ move $a0 $s1
+ jal Tree.GetRight
+ move $t0 $v0
+ move $a0 $s0
+ move $a1 $t0
+ jal Tree.RecPrint
+ j if20_end
+if20_else:
+if20_end:
+ li $v0 1
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 16
+ jr $ra
+Tree.accept:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 8
+ sw $ra -4($fp)
+ move $t0 $a0
+ move $t1 $a1
+ li $a0 333
+ jal _print
+ bgtz $t1 null70
+ la $a0 _str0
+ j _error
+null70:
+ lw $t2 0($t1)
+ lw $t2 0($t2)
+ move $a0 $t1
+ move $a1 $t0
+ jalr $t2
+ li $v0 0
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 8
+ jr $ra
+Visitor.visit:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 16
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ move $s0 $a0
+ move $s1 $a1
+ bgtz $s1 null71
+ la $a0 _str0
+ j _error
+null71:
+ move $a0 $s1
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if21_else
+ bgtz $s1 null72
+ la $a0 _str0
+ j _error
+null72:
+ move $a0 $s1
+ jal Tree.GetRight
+ move $t0 $v0
+ sw $t0 8($s0)
+ lw $t0 8($s0)
+ bgtz $t0 null73
+ la $a0 _str0
+ j _error
+null73:
+ move $a0 $t0
+ move $a1 $s0
+ jal Tree.accept
+ j if21_end
+if21_else:
+if21_end:
+ bgtz $s1 null74
+ la $a0 _str0
+ j _error
+null74:
+ move $a0 $s1
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 if22_else
+ bgtz $s1 null75
+ la $a0 _str0
+ j _error
+null75:
+ move $a0 $s1
+ jal Tree.GetLeft
+ move $t0 $v0
+ sw $t0 4($s0)
+ lw $t0 4($s0)
+ bgtz $t0 null76
+ la $a0 _str0
+ j _error
+null76:
+ move $a0 $t0
+ move $a1 $s0
+ jal Tree.accept
+ j if22_end
+if22_else:
+if22_end:
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 16
+ jr $ra
+MyVisitor.visit:
+ sw $fp -8($sp)
+ move $fp $sp
+ subu $sp $sp 16
+ sw $ra -4($fp)
+ sw $s0 -12($fp)
+ sw $s1 -16($fp)
+ move $s0 $a0
+ move $s1 $a1
+ bgtz $s1 null77
+ la $a0 _str0
+ j _error
+null77:
+ move $a0 $s1
+ jal Tree.GetHas_Right
+ move $t0 $v0
+ blez $t0 if23_else
+ bgtz $s1 null78
+ la $a0 _str0
+ j _error
+null78:
+ move $a0 $s1
+ jal Tree.GetRight
+ move $t0 $v0
+ sw $t0 8($s0)
+ lw $t0 8($s0)
+ bgtz $t0 null79
+ la $a0 _str0
+ j _error
+null79:
+ move $a0 $t0
+ move $a1 $s0
+ jal Tree.accept
+ j if23_end
+if23_else:
+if23_end:
+ bgtz $s1 null80
+ la $a0 _str0
+ j _error
+null80:
+ move $a0 $s1
+ jal Tree.GetKey
+ move $t0 $v0
+ move $a0 $t0
+ jal _print
+ bgtz $s1 null81
+ la $a0 _str0
+ j _error
+null81:
+ move $a0 $s1
+ jal Tree.GetHas_Left
+ move $t0 $v0
+ blez $t0 if24_else
+ bgtz $s1 null82
+ la $a0 _str0
+ j _error
+null82:
+ move $a0 $s1
+ jal Tree.GetLeft
+ move $t0 $v0
+ sw $t0 4($s0)
+ lw $t0 4($s0)
+ bgtz $t0 null83
+ la $a0 _str0
+ j _error
+null83:
+ move $a0 $t0
+ move $a1 $s0
+ jal Tree.accept
+ j if24_end
+if24_else:
+if24_end:
+ li $v0 0
+ lw $s0 -12($fp)
+ lw $s1 -16($fp)
+ lw $ra -4($fp)
+ lw $fp -8($fp)
+ addu $sp $sp 16
+ jr $ra
+_print:
+ li $v0 1 # syscall: print integer
+ syscall
+ la $a0 _newline
+ li $v0 4 # syscall: print string
+ syscall
+ jr $ra
+_error:
+ li $v0 4 # syscall: print string
+ syscall
+ li $v0 10 # syscall: exit
+ syscall
+_heapAlloc:
+ li $v0 9 # syscall: sbrk
+ syscall
+ jr $ra
+.data
+.align 0
+_newline: .asciiz "\n"
+_str0: .asciiz "null pointer\n"
diff --git a/output/TreeVisitor.opt.vaporm b/output/TreeVisitor.opt.vaporm
new file mode 100644
index 0000000..0ff4fc4
--- /dev/null
+++ b/output/TreeVisitor.opt.vaporm
@@ -0,0 +1,948 @@
+const empty_TV
+
+const empty_Tree
+
+const vmt_Visitor
+ :Visitor.visit
+
+const vmt_MyVisitor
+ :MyVisitor.visit
+
+func Main [in 0, out 0, local 0]
+ $a0 = :empty_TV
+ call :TV.Start
+ $t0 = $v0
+ PrintIntS($t0)
+ ret
+
+func TV.Start [in 0, out 0, local 1]
+ local[0] = $s0
+ $s0 = HeapAllocZ(24)
+ if $s0 goto :null1
+ Error("null pointer")
+null1:
+ $a0 = $s0
+ $a1 = 16
+ call :Tree.Init
+ if $s0 goto :null2
+ Error("null pointer")
+null2:
+ $a0 = $s0
+ call :Tree.Print
+ PrintIntS(100000000)
+ if $s0 goto :null3
+ Error("null pointer")
+null3:
+ $a0 = $s0
+ $a1 = 8
+ call :Tree.Insert
+ if $s0 goto :null4
+ Error("null pointer")
+null4:
+ $a0 = $s0
+ $a1 = 24
+ call :Tree.Insert
+ if $s0 goto :null5
+ Error("null pointer")
+null5:
+ $a0 = $s0
+ $a1 = 4
+ call :Tree.Insert
+ if $s0 goto :null6
+ Error("null pointer")
+null6:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Insert
+ if $s0 goto :null7
+ Error("null pointer")
+null7:
+ $a0 = $s0
+ $a1 = 20
+ call :Tree.Insert
+ if $s0 goto :null8
+ Error("null pointer")
+null8:
+ $a0 = $s0
+ $a1 = 28
+ call :Tree.Insert
+ if $s0 goto :null9
+ Error("null pointer")
+null9:
+ $a0 = $s0
+ $a1 = 14
+ call :Tree.Insert
+ if $s0 goto :null10
+ Error("null pointer")
+null10:
+ $a0 = $s0
+ call :Tree.Print
+ PrintIntS(100000000)
+ $t0 = HeapAllocZ(12)
+ [$t0] = :vmt_MyVisitor
+ $t0 = $t0
+ PrintIntS(50000000)
+ if $s0 goto :null11
+ Error("null pointer")
+null11:
+ $a0 = $s0
+ $a1 = $t0
+ call :Tree.accept
+ PrintIntS(100000000)
+ if $s0 goto :null12
+ Error("null pointer")
+null12:
+ $a0 = $s0
+ $a1 = 24
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null13
+ Error("null pointer")
+null13:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null14
+ Error("null pointer")
+null14:
+ $a0 = $s0
+ $a1 = 16
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null15
+ Error("null pointer")
+null15:
+ $a0 = $s0
+ $a1 = 50
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null16
+ Error("null pointer")
+null16:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s0 goto :null17
+ Error("null pointer")
+null17:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Delete
+ if $s0 goto :null18
+ Error("null pointer")
+null18:
+ $a0 = $s0
+ call :Tree.Print
+ if $s0 goto :null19
+ Error("null pointer")
+null19:
+ $a0 = $s0
+ $a1 = 12
+ call :Tree.Search
+ $t0 = $v0
+ PrintIntS($t0)
+ $v0 = 0
+ $s0 = local[0]
+ ret
+
+func Tree.Init [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+8] = $t1
+ [$t0+12] = 0
+ [$t0+16] = 0
+ $v0 = 1
+ ret
+
+func Tree.SetRight [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+4] = $t1
+ $v0 = 1
+ ret
+
+func Tree.SetLeft [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0] = $t1
+ $v0 = 1
+ ret
+
+func Tree.GetRight [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+4]
+ $v0 = $t0
+ ret
+
+func Tree.GetLeft [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0]
+ $v0 = $t0
+ ret
+
+func Tree.GetKey [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+8]
+ $v0 = $t0
+ ret
+
+func Tree.SetKey [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+8] = $t1
+ $v0 = 1
+ ret
+
+func Tree.GetHas_Right [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+16]
+ $v0 = $t0
+ ret
+
+func Tree.GetHas_Left [in 0, out 0, local 0]
+ $t0 = $a0
+ $t0 = [$t0+12]
+ $v0 = $t0
+ ret
+
+func Tree.SetHas_Left [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+12] = $t1
+ $v0 = 1
+ ret
+
+func Tree.SetHas_Right [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ [$t0+16] = $t1
+ $v0 = 1
+ ret
+
+func Tree.Compare [in 0, out 0, local 0]
+ $t0 = $a1
+ $t1 = $a2
+ $t2 = Add($t1 1)
+ $t1 = LtS($t0 $t1)
+ if0 $t1 goto :if1_else
+ $t1 = 0
+ goto :if1_end
+if1_else:
+ $t2 = LtS($t0 $t2)
+ if $t2 goto :if2_else
+ $t1 = 0
+ goto :if2_end
+if2_else:
+ $t1 = 1
+if2_end:
+if1_end:
+ $v0 = $t1
+ ret
+
+func Tree.Insert [in 0, out 0, local 4]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ local[3] = $s3
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = HeapAllocZ(24)
+ if $s2 goto :null20
+ Error("null pointer")
+null20:
+ $a0 = $s2
+ $a1 = $s1
+ call :Tree.Init
+ $s0 = $s0
+ $s3 = 1
+while1_top:
+ if0 $s3 goto :while1_end
+ if $s0 goto :null21
+ Error("null pointer")
+null21:
+ $a0 = $s0
+ call :Tree.GetKey
+ $t0 = $v0
+ $t0 = LtS($s1 $t0)
+ if0 $t0 goto :if3_else
+ if $s0 goto :null22
+ Error("null pointer")
+null22:
+ $a0 = $s0
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :if4_else
+ if $s0 goto :null23
+ Error("null pointer")
+null23:
+ $a0 = $s0
+ call :Tree.GetLeft
+ $s0 = $v0
+ goto :if4_end
+if4_else:
+ $s3 = 0
+ if $s0 goto :null24
+ Error("null pointer")
+null24:
+ $a0 = $s0
+ $a1 = 1
+ call :Tree.SetHas_Left
+ if $s0 goto :null25
+ Error("null pointer")
+null25:
+ $a0 = $s0
+ $a1 = $s2
+ call :Tree.SetLeft
+if4_end:
+ goto :if3_end
+if3_else:
+ if $s0 goto :null26
+ Error("null pointer")
+null26:
+ $a0 = $s0
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if5_else
+ if $s0 goto :null27
+ Error("null pointer")
+null27:
+ $a0 = $s0
+ call :Tree.GetRight
+ $s0 = $v0
+ goto :if5_end
+if5_else:
+ $s3 = 0
+ if $s0 goto :null28
+ Error("null pointer")
+null28:
+ $a0 = $s0
+ $a1 = 1
+ call :Tree.SetHas_Right
+ if $s0 goto :null29
+ Error("null pointer")
+null29:
+ $a0 = $s0
+ $a1 = $s2
+ call :Tree.SetRight
+if5_end:
+if3_end:
+ goto :while1_top
+while1_end:
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ $s3 = local[3]
+ ret
+
+func Tree.Delete [in 0, out 0, local 7]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ local[3] = $s3
+ local[4] = $s4
+ local[5] = $s5
+ local[6] = $s6
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = $s0
+ $s3 = $s0
+ $s4 = 1
+ $s5 = 0
+ $s6 = 1
+while2_top:
+ if0 $s4 goto :while2_end
+ if $s2 goto :null30
+ Error("null pointer")
+null30:
+ $a0 = $s2
+ call :Tree.GetKey
+ $t0 = $v0
+ $t1 = LtS($s1 $t0)
+ if0 $t1 goto :if6_else
+ if $s2 goto :null31
+ Error("null pointer")
+null31:
+ $a0 = $s2
+ call :Tree.GetHas_Left
+ $t1 = $v0
+ if0 $t1 goto :if7_else
+ $s3 = $s2
+ if $s2 goto :null32
+ Error("null pointer")
+null32:
+ $a0 = $s2
+ call :Tree.GetLeft
+ $s2 = $v0
+ goto :if7_end
+if7_else:
+ $s4 = 0
+if7_end:
+ goto :if6_end
+if6_else:
+ $t0 = LtS($t0 $s1)
+ if0 $t0 goto :if8_else
+ if $s2 goto :null33
+ Error("null pointer")
+null33:
+ $a0 = $s2
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if9_else
+ $s3 = $s2
+ if $s2 goto :null34
+ Error("null pointer")
+null34:
+ $a0 = $s2
+ call :Tree.GetRight
+ $s2 = $v0
+ goto :if9_end
+if9_else:
+ $s4 = 0
+if9_end:
+ goto :if8_end
+if8_else:
+ if0 $s6 goto :if10_else
+ if $s2 goto :null35
+ Error("null pointer")
+null35:
+ $a0 = $s2
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if $t0 goto :if11_else
+ if $s2 goto :null36
+ Error("null pointer")
+null36:
+ $a0 = $s2
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if $t0 goto :if11_else
+ goto :if11_end
+if11_else:
+ $a0 = $s0
+ $a1 = $s3
+ $a2 = $s2
+ call :Tree.Remove
+if11_end:
+ goto :if10_end
+if10_else:
+ $a0 = $s0
+ $a1 = $s3
+ $a2 = $s2
+ call :Tree.Remove
+if10_end:
+ $s5 = 1
+ $s4 = 0
+if8_end:
+if6_end:
+ $s6 = 0
+ goto :while2_top
+while2_end:
+ $v0 = $s5
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ $s3 = local[3]
+ $s4 = local[4]
+ $s5 = local[5]
+ $s6 = local[6]
+ ret
+
+func Tree.Remove [in 0, out 0, local 3]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = $a2
+ if $s2 goto :null37
+ Error("null pointer")
+null37:
+ $a0 = $s2
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :if12_else
+ $a0 = $s0
+ $a1 = $s1
+ $a2 = $s2
+ call :Tree.RemoveLeft
+ goto :if12_end
+if12_else:
+ if $s2 goto :null38
+ Error("null pointer")
+null38:
+ $a0 = $s2
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if13_else
+ $a0 = $s0
+ $a1 = $s1
+ $a2 = $s2
+ call :Tree.RemoveRight
+ goto :if13_end
+if13_else:
+ if $s2 goto :null39
+ Error("null pointer")
+null39:
+ $a0 = $s2
+ call :Tree.GetKey
+ $s2 = $v0
+ if $s1 goto :null40
+ Error("null pointer")
+null40:
+ $a0 = $s1
+ call :Tree.GetLeft
+ $t0 = $v0
+ if $t0 goto :null41
+ Error("null pointer")
+null41:
+ $a0 = $t0
+ call :Tree.GetKey
+ $t0 = $v0
+ $a0 = $s0
+ $a1 = $s2
+ $a2 = $t0
+ call :Tree.Compare
+ $t0 = $v0
+ if0 $t0 goto :if14_else
+ if $s1 goto :null42
+ Error("null pointer")
+null42:
+ $t0 = [$s0+20]
+ $a0 = $s1
+ $a1 = $t0
+ call :Tree.SetLeft
+ if $s1 goto :null43
+ Error("null pointer")
+null43:
+ $a0 = $s1
+ $a1 = 0
+ call :Tree.SetHas_Left
+ goto :if14_end
+if14_else:
+ if $s1 goto :null44
+ Error("null pointer")
+null44:
+ $t0 = [$s0+20]
+ $a0 = $s1
+ $a1 = $t0
+ call :Tree.SetRight
+ if $s1 goto :null45
+ Error("null pointer")
+null45:
+ $a0 = $s1
+ $a1 = 0
+ call :Tree.SetHas_Right
+if14_end:
+if13_end:
+if12_end:
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ ret
+
+func Tree.RemoveRight [in 0, out 0, local 3]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = $a2
+while3_top:
+ if $s2 goto :null46
+ Error("null pointer")
+null46:
+ $a0 = $s2
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :while3_end
+ if $s2 goto :null47
+ Error("null pointer")
+null47:
+ if $s2 goto :null48
+ Error("null pointer")
+null48:
+ $a0 = $s2
+ call :Tree.GetRight
+ $t0 = $v0
+ if $t0 goto :null49
+ Error("null pointer")
+null49:
+ $a0 = $t0
+ call :Tree.GetKey
+ $t0 = $v0
+ $a0 = $s2
+ $a1 = $t0
+ call :Tree.SetKey
+ $s1 = $s2
+ if $s2 goto :null50
+ Error("null pointer")
+null50:
+ $a0 = $s2
+ call :Tree.GetRight
+ $s2 = $v0
+ goto :while3_top
+while3_end:
+ if $s1 goto :null51
+ Error("null pointer")
+null51:
+ $t0 = [$s0+20]
+ $a0 = $s1
+ $a1 = $t0
+ call :Tree.SetRight
+ if $s1 goto :null52
+ Error("null pointer")
+null52:
+ $a0 = $s1
+ $a1 = 0
+ call :Tree.SetHas_Right
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ ret
+
+func Tree.RemoveLeft [in 0, out 0, local 3]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ $s0 = $a0
+ $s1 = $a1
+ $s2 = $a2
+while4_top:
+ if $s2 goto :null53
+ Error("null pointer")
+null53:
+ $a0 = $s2
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :while4_end
+ if $s2 goto :null54
+ Error("null pointer")
+null54:
+ if $s2 goto :null55
+ Error("null pointer")
+null55:
+ $a0 = $s2
+ call :Tree.GetLeft
+ $t0 = $v0
+ if $t0 goto :null56
+ Error("null pointer")
+null56:
+ $a0 = $t0
+ call :Tree.GetKey
+ $t0 = $v0
+ $a0 = $s2
+ $a1 = $t0
+ call :Tree.SetKey
+ $s1 = $s2
+ if $s2 goto :null57
+ Error("null pointer")
+null57:
+ $a0 = $s2
+ call :Tree.GetLeft
+ $s2 = $v0
+ goto :while4_top
+while4_end:
+ if $s1 goto :null58
+ Error("null pointer")
+null58:
+ $t0 = [$s0+20]
+ $a0 = $s1
+ $a1 = $t0
+ call :Tree.SetLeft
+ if $s1 goto :null59
+ Error("null pointer")
+null59:
+ $a0 = $s1
+ $a1 = 0
+ call :Tree.SetHas_Left
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ ret
+
+func Tree.Search [in 0, out 0, local 4]
+ local[0] = $s0
+ local[1] = $s1
+ local[2] = $s2
+ local[3] = $s3
+ $t0 = $a0
+ $s0 = $a1
+ $s1 = $t0
+ $s2 = 1
+ $s3 = 0
+while5_top:
+ if0 $s2 goto :while5_end
+ if $s1 goto :null60
+ Error("null pointer")
+null60:
+ $a0 = $s1
+ call :Tree.GetKey
+ $t0 = $v0
+ $t1 = LtS($s0 $t0)
+ if0 $t1 goto :if15_else
+ if $s1 goto :null61
+ Error("null pointer")
+null61:
+ $a0 = $s1
+ call :Tree.GetHas_Left
+ $t1 = $v0
+ if0 $t1 goto :if16_else
+ if $s1 goto :null62
+ Error("null pointer")
+null62:
+ $a0 = $s1
+ call :Tree.GetLeft
+ $s1 = $v0
+ goto :if16_end
+if16_else:
+ $s2 = 0
+if16_end:
+ goto :if15_end
+if15_else:
+ $t0 = LtS($t0 $s0)
+ if0 $t0 goto :if17_else
+ if $s1 goto :null63
+ Error("null pointer")
+null63:
+ $a0 = $s1
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if18_else
+ if $s1 goto :null64
+ Error("null pointer")
+null64:
+ $a0 = $s1
+ call :Tree.GetRight
+ $s1 = $v0
+ goto :if18_end
+if18_else:
+ $s2 = 0
+if18_end:
+ goto :if17_end
+if17_else:
+ $s3 = 1
+ $s2 = 0
+if17_end:
+if15_end:
+ goto :while5_top
+while5_end:
+ $v0 = $s3
+ $s0 = local[0]
+ $s1 = local[1]
+ $s2 = local[2]
+ $s3 = local[3]
+ ret
+
+func Tree.Print [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $t0
+ $a0 = $t0
+ $a1 = $t1
+ call :Tree.RecPrint
+ $v0 = 1
+ ret
+
+func Tree.RecPrint [in 0, out 0, local 2]
+ local[0] = $s0
+ local[1] = $s1
+ $s0 = $a0
+ $s1 = $a1
+ if $s1 goto :null65
+ Error("null pointer")
+null65:
+ $a0 = $s1
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :if19_else
+ if $s1 goto :null66
+ Error("null pointer")
+null66:
+ $a0 = $s1
+ call :Tree.GetLeft
+ $t0 = $v0
+ $a0 = $s0
+ $a1 = $t0
+ call :Tree.RecPrint
+ goto :if19_end
+if19_else:
+if19_end:
+ if $s1 goto :null67
+ Error("null pointer")
+null67:
+ $a0 = $s1
+ call :Tree.GetKey
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s1 goto :null68
+ Error("null pointer")
+null68:
+ $a0 = $s1
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if20_else
+ if $s1 goto :null69
+ Error("null pointer")
+null69:
+ $a0 = $s1
+ call :Tree.GetRight
+ $t0 = $v0
+ $a0 = $s0
+ $a1 = $t0
+ call :Tree.RecPrint
+ goto :if20_end
+if20_else:
+if20_end:
+ $v0 = 1
+ $s0 = local[0]
+ $s1 = local[1]
+ ret
+
+func Tree.accept [in 0, out 0, local 0]
+ $t0 = $a0
+ $t1 = $a1
+ PrintIntS(333)
+ if $t1 goto :null70
+ Error("null pointer")
+null70:
+ $t2 = [$t1]
+ $t2 = [$t2]
+ $a0 = $t1
+ $a1 = $t0
+ call $t2
+ $v0 = 0
+ ret
+
+func Visitor.visit [in 0, out 0, local 2]
+ local[0] = $s0
+ local[1] = $s1
+ $s0 = $a0
+ $s1 = $a1
+ if $s1 goto :null71
+ Error("null pointer")
+null71:
+ $a0 = $s1
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if21_else
+ if $s1 goto :null72
+ Error("null pointer")
+null72:
+ $a0 = $s1
+ call :Tree.GetRight
+ $t0 = $v0
+ [$s0+8] = $t0
+ $t0 = [$s0+8]
+ if $t0 goto :null73
+ Error("null pointer")
+null73:
+ $a0 = $t0
+ $a1 = $s0
+ call :Tree.accept
+ goto :if21_end
+if21_else:
+if21_end:
+ if $s1 goto :null74
+ Error("null pointer")
+null74:
+ $a0 = $s1
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :if22_else
+ if $s1 goto :null75
+ Error("null pointer")
+null75:
+ $a0 = $s1
+ call :Tree.GetLeft
+ $t0 = $v0
+ [$s0+4] = $t0
+ $t0 = [$s0+4]
+ if $t0 goto :null76
+ Error("null pointer")
+null76:
+ $a0 = $t0
+ $a1 = $s0
+ call :Tree.accept
+ goto :if22_end
+if22_else:
+if22_end:
+ $v0 = 0
+ $s0 = local[0]
+ $s1 = local[1]
+ ret
+
+func MyVisitor.visit [in 0, out 0, local 2]
+ local[0] = $s0
+ local[1] = $s1
+ $s0 = $a0
+ $s1 = $a1
+ if $s1 goto :null77
+ Error("null pointer")
+null77:
+ $a0 = $s1
+ call :Tree.GetHas_Right
+ $t0 = $v0
+ if0 $t0 goto :if23_else
+ if $s1 goto :null78
+ Error("null pointer")
+null78:
+ $a0 = $s1
+ call :Tree.GetRight
+ $t0 = $v0
+ [$s0+8] = $t0
+ $t0 = [$s0+8]
+ if $t0 goto :null79
+ Error("null pointer")
+null79:
+ $a0 = $t0
+ $a1 = $s0
+ call :Tree.accept
+ goto :if23_end
+if23_else:
+if23_end:
+ if $s1 goto :null80
+ Error("null pointer")
+null80:
+ $a0 = $s1
+ call :Tree.GetKey
+ $t0 = $v0
+ PrintIntS($t0)
+ if $s1 goto :null81
+ Error("null pointer")
+null81:
+ $a0 = $s1
+ call :Tree.GetHas_Left
+ $t0 = $v0
+ if0 $t0 goto :if24_else
+ if $s1 goto :null82
+ Error("null pointer")
+null82:
+ $a0 = $s1
+ call :Tree.GetLeft
+ $t0 = $v0
+ [$s0+4] = $t0
+ $t0 = [$s0+4]
+ if $t0 goto :null83
+ Error("null pointer")
+null83:
+ $a0 = $t0
+ $a1 = $s0
+ call :Tree.accept
+ goto :if24_end
+if24_else:
+if24_end:
+ $v0 = 0
+ $s0 = local[0]
+ $s1 = local[1]
+ ret
+
diff --git a/test.sh b/test.sh
index 1f8f11e..a7ba75d 100755
--- a/test.sh
+++ b/test.sh
@@ -6,7 +6,11 @@
##################################################
function java() {
- expected=$(bash runner.sh java "$1.java")
+ base="$1"
+ if [[ $(basename $base) == *.* ]]; then
+ base="${base%.*}"
+ fi
+ expected=$(bash runner.sh java "${base}.java")
}
function match() {