summaryrefslogtreecommitdiff
path: root/base/BinaryTree.opt.s
blob: 3cea30c8da6b5f6a22f04046d255387f1c962c79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
.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 0($sp)
  li $a0 24
  jal _heapAlloc
  move $s0 $v0
  bnez $s0 null1
  la $a0 _str0
  j _error
null1:
  move $a0 $s0
  li $a1 16
  jal Tree.Init
  bnez $s0 null2
  la $a0 _str0
  j _error
null2:
  move $a0 $s0
  jal Tree.Print
  li $a0 100000000
  jal _print
  bnez $s0 null3
  la $a0 _str0
  j _error
null3:
  move $a0 $s0
  li $a1 8
  jal Tree.Insert
  bnez $s0 null4
  la $a0 _str0
  j _error
null4:
  move $a0 $s0
  jal Tree.Print
  bnez $s0 null5
  la $a0 _str0
  j _error
null5:
  move $a0 $s0
  li $a1 24
  jal Tree.Insert
  bnez $s0 null6
  la $a0 _str0
  j _error
null6:
  move $a0 $s0
  li $a1 4
  jal Tree.Insert
  bnez $s0 null7
  la $a0 _str0
  j _error
null7:
  move $a0 $s0
  li $a1 12
  jal Tree.Insert
  bnez $s0 null8
  la $a0 _str0
  j _error
null8:
  move $a0 $s0
  li $a1 20
  jal Tree.Insert
  bnez $s0 null9
  la $a0 _str0
  j _error
null9:
  move $a0 $s0
  li $a1 28
  jal Tree.Insert
  bnez $s0 null10
  la $a0 _str0
  j _error
null10:
  move $a0 $s0
  li $a1 14
  jal Tree.Insert
  bnez $s0 null11
  la $a0 _str0
  j _error
null11:
  move $a0 $s0
  jal Tree.Print
  bnez $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
  bnez $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
  bnez $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
  bnez $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
  bnez $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
  bnez $s0 null17
  la $a0 _str0
  j _error
null17:
  move $a0 $s0
  li $a1 12
  jal Tree.Delete
  bnez $s0 null18
  la $a0 _str0
  j _error
null18:
  move $a0 $s0
  jal Tree.Print
  bnez $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 0($sp)
  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)
  sw $0 12($t0)
  sw $0 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
  addu $t2 $t1 1
  slt $t1 $t0 $t1
  beqz $t1 if1_else
  li $t1 0
  j if1_end
if1_else:
  slt $t2 $t0 $t2
  bnez $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 0($sp)
  sw $s1 4($sp)
  sw $s2 8($sp)
  sw $s3 12($sp)
  move $s0 $a0
  move $s1 $a1
  li $a0 24
  jal _heapAlloc
  move $s2 $v0
  bnez $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:
  beqz $s3 while1_end
  bnez $s0 null21
  la $a0 _str0
  j _error
null21:
  move $a0 $s0
  jal Tree.GetKey
  move $t0 $v0
  slt $t0 $s1 $t0
  beqz $t0 if3_else
  bnez $s0 null22
  la $a0 _str0
  j _error
null22:
  move $a0 $s0
  jal Tree.GetHas_Left
  move $t0 $v0
  beqz $t0 if4_else
  bnez $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
  bnez $s0 null24
  la $a0 _str0
  j _error
null24:
  move $a0 $s0
  li $a1 1
  jal Tree.SetHas_Left
  bnez $s0 null25
  la $a0 _str0
  j _error
null25:
  move $a0 $s0
  move $a1 $s2
  jal Tree.SetLeft
if4_end:
  j if3_end
if3_else:
  bnez $s0 null26
  la $a0 _str0
  j _error
null26:
  move $a0 $s0
  jal Tree.GetHas_Right
  move $t0 $v0
  beqz $t0 if5_else
  bnez $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
  bnez $s0 null28
  la $a0 _str0
  j _error
null28:
  move $a0 $s0
  li $a1 1
  jal Tree.SetHas_Right
  bnez $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 0($sp)
  lw $s1 4($sp)
  lw $s2 8($sp)
  lw $s3 12($sp)
  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 0($sp)
  sw $s1 4($sp)
  sw $s2 8($sp)
  sw $s3 12($sp)
  sw $s4 16($sp)
  sw $s5 20($sp)
  sw $s6 24($sp)
  move $s0 $a0
  move $s1 $a1
  move $s2 $s0
  move $s3 $s0
  li $s4 1
  li $s5 0
  li $s6 1
while2_top:
  beqz $s4 while2_end
  bnez $s2 null30
  la $a0 _str0
  j _error
null30:
  move $a0 $s2
  jal Tree.GetKey
  move $t0 $v0
  slt $t1 $s1 $t0
  beqz $t1 if6_else
  bnez $s2 null31
  la $a0 _str0
  j _error
null31:
  move $a0 $s2
  jal Tree.GetHas_Left
  move $t1 $v0
  beqz $t1 if7_else
  move $s3 $s2
  bnez $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:
  slt $t0 $t0 $s1
  beqz $t0 if8_else
  bnez $s2 null33
  la $a0 _str0
  j _error
null33:
  move $a0 $s2
  jal Tree.GetHas_Right
  move $t0 $v0
  beqz $t0 if9_else
  move $s3 $s2
  bnez $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:
  beqz $s6 if10_else
  bnez $s2 null35
  la $a0 _str0
  j _error
null35:
  move $a0 $s2
  jal Tree.GetHas_Right
  move $t0 $v0
  bnez $t0 if11_else
  bnez $s2 null36
  la $a0 _str0
  j _error
null36:
  move $a0 $s2
  jal Tree.GetHas_Left
  move $t0 $v0
  bnez $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 0($sp)
  lw $s1 4($sp)
  lw $s2 8($sp)
  lw $s3 12($sp)
  lw $s4 16($sp)
  lw $s5 20($sp)
  lw $s6 24($sp)
  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 0($sp)
  sw $s1 4($sp)
  sw $s2 8($sp)
  move $s0 $a0
  move $s1 $a1
  move $s2 $a2
  bnez $s2 null37
  la $a0 _str0
  j _error
null37:
  move $a0 $s2
  jal Tree.GetHas_Left
  move $t0 $v0
  beqz $t0 if12_else
  move $a0 $s0
  move $a1 $s1
  move $a2 $s2
  jal Tree.RemoveLeft
  j if12_end
if12_else:
  bnez $s2 null38
  la $a0 _str0
  j _error
null38:
  move $a0 $s2
  jal Tree.GetHas_Right
  move $t0 $v0
  beqz $t0 if13_else
  move $a0 $s0
  move $a1 $s1
  move $a2 $s2
  jal Tree.RemoveRight
  j if13_end
if13_else:
  bnez $s2 null39
  la $a0 _str0
  j _error
null39:
  move $a0 $s2
  jal Tree.GetKey
  move $s2 $v0
  bnez $s1 null40
  la $a0 _str0
  j _error
null40:
  move $a0 $s1
  jal Tree.GetLeft
  move $t0 $v0
  bnez $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
  beqz $t0 if14_else
  bnez $s1 null42
  la $a0 _str0
  j _error
null42:
  lw $t0 20($s0)
  move $a0 $s1
  move $a1 $t0
  jal Tree.SetLeft
  bnez $s1 null43
  la $a0 _str0
  j _error
null43:
  move $a0 $s1
  li $a1 0
  jal Tree.SetHas_Left
  j if14_end
if14_else:
  bnez $s1 null44
  la $a0 _str0
  j _error
null44:
  lw $t0 20($s0)
  move $a0 $s1
  move $a1 $t0
  jal Tree.SetRight
  bnez $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 0($sp)
  lw $s1 4($sp)
  lw $s2 8($sp)
  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 0($sp)
  sw $s1 4($sp)
  sw $s2 8($sp)
  move $s0 $a0
  move $s1 $a1
  move $s2 $a2
while3_top:
  bnez $s2 null46
  la $a0 _str0
  j _error
null46:
  move $a0 $s2
  jal Tree.GetHas_Right
  move $t0 $v0
  beqz $t0 while3_end
  bnez $s2 null47
  la $a0 _str0
  j _error
null47:
  bnez $s2 null48
  la $a0 _str0
  j _error
null48:
  move $a0 $s2
  jal Tree.GetRight
  move $t0 $v0
  bnez $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
  bnez $s2 null50
  la $a0 _str0
  j _error
null50:
  move $a0 $s2
  jal Tree.GetRight
  move $s2 $v0
  j while3_top
while3_end:
  bnez $s1 null51
  la $a0 _str0
  j _error
null51:
  lw $t0 20($s0)
  move $a0 $s1
  move $a1 $t0
  jal Tree.SetRight
  bnez $s1 null52
  la $a0 _str0
  j _error
null52:
  move $a0 $s1
  li $a1 0
  jal Tree.SetHas_Right
  li $v0 1
  lw $s0 0($sp)
  lw $s1 4($sp)
  lw $s2 8($sp)
  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 0($sp)
  sw $s1 4($sp)
  sw $s2 8($sp)
  move $s0 $a0
  move $s1 $a1
  move $s2 $a2
while4_top:
  bnez $s2 null53
  la $a0 _str0
  j _error
null53:
  move $a0 $s2
  jal Tree.GetHas_Left
  move $t0 $v0
  beqz $t0 while4_end
  bnez $s2 null54
  la $a0 _str0
  j _error
null54:
  bnez $s2 null55
  la $a0 _str0
  j _error
null55:
  move $a0 $s2
  jal Tree.GetLeft
  move $t0 $v0
  bnez $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
  bnez $s2 null57
  la $a0 _str0
  j _error
null57:
  move $a0 $s2
  jal Tree.GetLeft
  move $s2 $v0
  j while4_top
while4_end:
  bnez $s1 null58
  la $a0 _str0
  j _error
null58:
  lw $t0 20($s0)
  move $a0 $s1
  move $a1 $t0
  jal Tree.SetLeft
  bnez $s1 null59
  la $a0 _str0
  j _error
null59:
  move $a0 $s1
  li $a1 0
  jal Tree.SetHas_Left
  li $v0 1
  lw $s0 0($sp)
  lw $s1 4($sp)
  lw $s2 8($sp)
  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 0($sp)
  sw $s1 4($sp)
  sw $s2 8($sp)
  sw $s3 12($sp)
  move $t0 $a0
  move $s0 $a1
  move $s1 $t0
  li $s2 1
  li $s3 0
while5_top:
  beqz $s2 while5_end
  bnez $s1 null60
  la $a0 _str0
  j _error
null60:
  move $a0 $s1
  jal Tree.GetKey
  move $t0 $v0
  slt $t1 $s0 $t0
  beqz $t1 if15_else
  bnez $s1 null61
  la $a0 _str0
  j _error
null61:
  move $a0 $s1
  jal Tree.GetHas_Left
  move $t1 $v0
  beqz $t1 if16_else
  bnez $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:
  slt $t0 $t0 $s0
  beqz $t0 if17_else
  bnez $s1 null63
  la $a0 _str0
  j _error
null63:
  move $a0 $s1
  jal Tree.GetHas_Right
  move $t0 $v0
  beqz $t0 if18_else
  bnez $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 0($sp)
  lw $s1 4($sp)
  lw $s2 8($sp)
  lw $s3 12($sp)
  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 0($sp)
  sw $s1 4($sp)
  move $s0 $a0
  move $s1 $a1
  bnez $s1 null65
  la $a0 _str0
  j _error
null65:
  move $a0 $s1
  jal Tree.GetHas_Left
  move $t0 $v0
  beqz $t0 if19_else
  bnez $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:
  bnez $s1 null67
  la $a0 _str0
  j _error
null67:
  move $a0 $s1
  jal Tree.GetKey
  move $t0 $v0
  move $a0 $t0
  jal _print
  bnez $s1 null68
  la $a0 _str0
  j _error
null68:
  move $a0 $s1
  jal Tree.GetHas_Right
  move $t0 $v0
  beqz $t0 if20_else
  bnez $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 0($sp)
  lw $s1 4($sp)
  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"