const empty_BT const empty_Tree func Main [in 0, out 0, local 0] $a0 = :empty_BT call :BT.Start $t0{t.0} = $v0 PrintIntS($t0{t.0}) ret func BT.Start [in 0, out 0, local 1] local[0] = $s0 $s0{root} = HeapAllocZ(24) if $s0{root} goto :null1 Error("null pointer") null1: $a0 = $s0{root} $a1 = 16 call :Tree.Init if $s0{root} goto :null2 Error("null pointer") null2: $a0 = $s0{root} call :Tree.Print PrintIntS(100000000) if $s0{root} goto :null3 Error("null pointer") null3: $a0 = $s0{root} $a1 = 8 call :Tree.Insert if $s0{root} goto :null4 Error("null pointer") null4: $a0 = $s0{root} call :Tree.Print if $s0{root} goto :null5 Error("null pointer") null5: $a0 = $s0{root} $a1 = 24 call :Tree.Insert if $s0{root} goto :null6 Error("null pointer") null6: $a0 = $s0{root} $a1 = 4 call :Tree.Insert if $s0{root} goto :null7 Error("null pointer") null7: $a0 = $s0{root} $a1 = 12 call :Tree.Insert if $s0{root} goto :null8 Error("null pointer") null8: $a0 = $s0{root} $a1 = 20 call :Tree.Insert if $s0{root} goto :null9 Error("null pointer") null9: $a0 = $s0{root} $a1 = 28 call :Tree.Insert if $s0{root} goto :null10 Error("null pointer") null10: $a0 = $s0{root} $a1 = 14 call :Tree.Insert if $s0{root} goto :null11 Error("null pointer") null11: $a0 = $s0{root} call :Tree.Print if $s0{root} goto :null12 Error("null pointer") null12: $a0 = $s0{root} $a1 = 24 call :Tree.Search $t0{t.0} = $v0 PrintIntS($t0{t.0}) if $s0{root} goto :null13 Error("null pointer") null13: $a0 = $s0{root} $a1 = 12 call :Tree.Search $t0{t.1} = $v0 PrintIntS($t0{t.1}) if $s0{root} goto :null14 Error("null pointer") null14: $a0 = $s0{root} $a1 = 16 call :Tree.Search $t0{t.2} = $v0 PrintIntS($t0{t.2}) if $s0{root} goto :null15 Error("null pointer") null15: $a0 = $s0{root} $a1 = 50 call :Tree.Search $t0{t.3} = $v0 PrintIntS($t0{t.3}) if $s0{root} goto :null16 Error("null pointer") null16: $a0 = $s0{root} $a1 = 12 call :Tree.Search $t0{t.4} = $v0 PrintIntS($t0{t.4}) if $s0{root} goto :null17 Error("null pointer") null17: $a0 = $s0{root} $a1 = 12 call :Tree.Delete if $s0{root} goto :null18 Error("null pointer") null18: $a0 = $s0{root} call :Tree.Print if $s0{root} goto :null19 Error("null pointer") null19: $a0 = $s0{root} $a1 = 12 call :Tree.Search $t0{t.5} = $v0 PrintIntS($t0{t.5}) $v0 = 0 $s0 = local[0] ret func Tree.Init [in 0, out 0, local 0] $t0{this} = $a0 $t1{v_key} = $a1 [$t0{this}+8] = $t1{v_key} [$t0{this}+12] = 0 [$t0{this}+16] = 0 $v0 = 1 ret func Tree.SetRight [in 0, out 0, local 0] $t0{this} = $a0 $t1{rn} = $a1 [$t0{this}+4] = $t1{rn} $v0 = 1 ret func Tree.SetLeft [in 0, out 0, local 0] $t0{this} = $a0 $t1{ln} = $a1 [$t0{this}] = $t1{ln} $v0 = 1 ret func Tree.GetRight [in 0, out 0, local 0] $t0{this} = $a0 $t0{t.0} = [$t0{this}+4] $v0 = $t0{t.0} ret func Tree.GetLeft [in 0, out 0, local 0] $t0{this} = $a0 $t0{t.0} = [$t0{this}] $v0 = $t0{t.0} ret func Tree.GetKey [in 0, out 0, local 0] $t0{this} = $a0 $t0{t.0} = [$t0{this}+8] $v0 = $t0{t.0} ret func Tree.SetKey [in 0, out 0, local 0] $t0{this} = $a0 $t1{v_key} = $a1 [$t0{this}+8] = $t1{v_key} $v0 = 1 ret func Tree.GetHas_Right [in 0, out 0, local 0] $t0{this} = $a0 $t0{t.0} = [$t0{this}+16] $v0 = $t0{t.0} ret func Tree.GetHas_Left [in 0, out 0, local 0] $t0{this} = $a0 $t0{t.0} = [$t0{this}+12] $v0 = $t0{t.0} ret func Tree.SetHas_Left [in 0, out 0, local 0] $t0{this} = $a0 $t1{val} = $a1 [$t0{this}+12] = $t1{val} $v0 = 1 ret func Tree.SetHas_Right [in 0, out 0, local 0] $t0{this} = $a0 $t1{val} = $a1 [$t0{this}+16] = $t1{val} $v0 = 1 ret func Tree.Compare [in 0, out 0, local 0] $t0{num1} = $a1 $t1{num2} = $a2 $t2{nti} = Add($t1{num2} 1) $t1{t.0} = LtS($t0{num1} $t1{num2}) if0 $t1{t.0} goto :if1_else $t1{ntb} = 0 goto :if1_end if1_else: $t2{t.1} = LtS($t0{num1} $t2{nti}) if $t2{t.1} goto :if2_else $t1{ntb} = 0 goto :if2_end if2_else: $t1{ntb} = 1 if2_end: if1_end: $v0 = $t1{ntb} ret func Tree.Insert [in 0, out 0, local 4] local[0] = $s0 local[1] = $s1 local[2] = $s2 local[3] = $s3 $s0{this} = $a0 $s1{v_key} = $a1 $s2{new_node} = HeapAllocZ(24) if $s2{new_node} goto :null20 Error("null pointer") null20: $a0 = $s2{new_node} $a1 = $s1{v_key} call :Tree.Init $s0{current_node} = $s0{this} $s3{cont} = 1 while1_top: if0 $s3{cont} goto :while1_end if $s0{current_node} goto :null21 Error("null pointer") null21: $a0 = $s0{current_node} call :Tree.GetKey $t0{key_aux} = $v0 $t0{t.0} = LtS($s1{v_key} $t0{key_aux}) if0 $t0{t.0} goto :if3_else if $s0{current_node} goto :null22 Error("null pointer") null22: $a0 = $s0{current_node} call :Tree.GetHas_Left $t0{t.1} = $v0 if0 $t0{t.1} goto :if4_else if $s0{current_node} goto :null23 Error("null pointer") null23: $a0 = $s0{current_node} call :Tree.GetLeft $s0{current_node} = $v0 goto :if4_end if4_else: $s3{cont} = 0 if $s0{current_node} goto :null24 Error("null pointer") null24: $a0 = $s0{current_node} $a1 = 1 call :Tree.SetHas_Left if $s0{current_node} goto :null25 Error("null pointer") null25: $a0 = $s0{current_node} $a1 = $s2{new_node} call :Tree.SetLeft if4_end: goto :if3_end if3_else: if $s0{current_node} goto :null26 Error("null pointer") null26: $a0 = $s0{current_node} call :Tree.GetHas_Right $t0{t.2} = $v0 if0 $t0{t.2} goto :if5_else if $s0{current_node} goto :null27 Error("null pointer") null27: $a0 = $s0{current_node} call :Tree.GetRight $s0{current_node} = $v0 goto :if5_end if5_else: $s3{cont} = 0 if $s0{current_node} goto :null28 Error("null pointer") null28: $a0 = $s0{current_node} $a1 = 1 call :Tree.SetHas_Right if $s0{current_node} goto :null29 Error("null pointer") null29: $a0 = $s0{current_node} $a1 = $s2{new_node} 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{this} = $a0 $s1{v_key} = $a1 $s2{current_node} = $s0{this} $s3{parent_node} = $s0{this} $s4{cont} = 1 $s5{found} = 0 $s6{is_root} = 1 while2_top: if0 $s4{cont} goto :while2_end if $s2{current_node} goto :null30 Error("null pointer") null30: $a0 = $s2{current_node} call :Tree.GetKey $t0{key_aux} = $v0 $t1{t.0} = LtS($s1{v_key} $t0{key_aux}) if0 $t1{t.0} goto :if6_else if $s2{current_node} goto :null31 Error("null pointer") null31: $a0 = $s2{current_node} call :Tree.GetHas_Left $t1{t.1} = $v0 if0 $t1{t.1} goto :if7_else $s3{parent_node} = $s2{current_node} if $s2{current_node} goto :null32 Error("null pointer") null32: $a0 = $s2{current_node} call :Tree.GetLeft $s2{current_node} = $v0 goto :if7_end if7_else: $s4{cont} = 0 if7_end: goto :if6_end if6_else: $t0{t.2} = LtS($t0{key_aux} $s1{v_key}) if0 $t0{t.2} goto :if8_else if $s2{current_node} goto :null33 Error("null pointer") null33: $a0 = $s2{current_node} call :Tree.GetHas_Right $t0{t.3} = $v0 if0 $t0{t.3} goto :if9_else $s3{parent_node} = $s2{current_node} if $s2{current_node} goto :null34 Error("null pointer") null34: $a0 = $s2{current_node} call :Tree.GetRight $s2{current_node} = $v0 goto :if9_end if9_else: $s4{cont} = 0 if9_end: goto :if8_end if8_else: if0 $s6{is_root} goto :if10_else if $s2{current_node} goto :null35 Error("null pointer") null35: $a0 = $s2{current_node} call :Tree.GetHas_Right $t0{t.4} = $v0 if $t0{t.4} goto :if11_else if $s2{current_node} goto :null36 Error("null pointer") null36: $a0 = $s2{current_node} call :Tree.GetHas_Left $t0{t.5} = $v0 if $t0{t.5} goto :if11_else goto :if11_end if11_else: $a0 = $s0{this} $a1 = $s3{parent_node} $a2 = $s2{current_node} call :Tree.Remove if11_end: goto :if10_end if10_else: $a0 = $s0{this} $a1 = $s3{parent_node} $a2 = $s2{current_node} call :Tree.Remove if10_end: $s5{found} = 1 $s4{cont} = 0 if8_end: if6_end: $s6{is_root} = 0 goto :while2_top while2_end: $v0 = $s5{found} $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{this} = $a0 $s1{p_node} = $a1 $s2{c_node} = $a2 if $s2{c_node} goto :null37 Error("null pointer") null37: $a0 = $s2{c_node} call :Tree.GetHas_Left $t0{t.0} = $v0 if0 $t0{t.0} goto :if12_else $a0 = $s0{this} $a1 = $s1{p_node} $a2 = $s2{c_node} call :Tree.RemoveLeft goto :if12_end if12_else: if $s2{c_node} goto :null38 Error("null pointer") null38: $a0 = $s2{c_node} call :Tree.GetHas_Right $t0{t.1} = $v0 if0 $t0{t.1} goto :if13_else $a0 = $s0{this} $a1 = $s1{p_node} $a2 = $s2{c_node} call :Tree.RemoveRight goto :if13_end if13_else: if $s2{c_node} goto :null39 Error("null pointer") null39: $a0 = $s2{c_node} call :Tree.GetKey $s2{auxkey1} = $v0 if $s1{p_node} goto :null40 Error("null pointer") null40: $a0 = $s1{p_node} call :Tree.GetLeft $t0{t.2} = $v0 if $t0{t.2} goto :null41 Error("null pointer") null41: $a0 = $t0{t.2} call :Tree.GetKey $t0{auxkey2} = $v0 $a0 = $s0{this} $a1 = $s2{auxkey1} $a2 = $t0{auxkey2} call :Tree.Compare $t0{t.3} = $v0 if0 $t0{t.3} goto :if14_else if $s1{p_node} goto :null42 Error("null pointer") null42: $t0{t.4} = [$s0{this}+20] $a0 = $s1{p_node} $a1 = $t0{t.4} call :Tree.SetLeft if $s1{p_node} goto :null43 Error("null pointer") null43: $a0 = $s1{p_node} $a1 = 0 call :Tree.SetHas_Left goto :if14_end if14_else: if $s1{p_node} goto :null44 Error("null pointer") null44: $t0{t.5} = [$s0{this}+20] $a0 = $s1{p_node} $a1 = $t0{t.5} call :Tree.SetRight if $s1{p_node} goto :null45 Error("null pointer") null45: $a0 = $s1{p_node} $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{this} = $a0 $s1{p_node} = $a1 $s2{c_node} = $a2 while3_top: if $s2{c_node} goto :null46 Error("null pointer") null46: $a0 = $s2{c_node} call :Tree.GetHas_Right $t0{t.0} = $v0 if0 $t0{t.0} goto :while3_end if $s2{c_node} goto :null47 Error("null pointer") null47: if $s2{c_node} goto :null48 Error("null pointer") null48: $a0 = $s2{c_node} call :Tree.GetRight $t0{t.1} = $v0 if $t0{t.1} goto :null49 Error("null pointer") null49: $a0 = $t0{t.1} call :Tree.GetKey $t0{t.2} = $v0 $a0 = $s2{c_node} $a1 = $t0{t.2} call :Tree.SetKey $s1{p_node} = $s2{c_node} if $s2{c_node} goto :null50 Error("null pointer") null50: $a0 = $s2{c_node} call :Tree.GetRight $s2{c_node} = $v0 goto :while3_top while3_end: if $s1{p_node} goto :null51 Error("null pointer") null51: $t0{t.3} = [$s0{this}+20] $a0 = $s1{p_node} $a1 = $t0{t.3} call :Tree.SetRight if $s1{p_node} goto :null52 Error("null pointer") null52: $a0 = $s1{p_node} $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{this} = $a0 $s1{p_node} = $a1 $s2{c_node} = $a2 while4_top: if $s2{c_node} goto :null53 Error("null pointer") null53: $a0 = $s2{c_node} call :Tree.GetHas_Left $t0{t.0} = $v0 if0 $t0{t.0} goto :while4_end if $s2{c_node} goto :null54 Error("null pointer") null54: if $s2{c_node} goto :null55 Error("null pointer") null55: $a0 = $s2{c_node} call :Tree.GetLeft $t0{t.1} = $v0 if $t0{t.1} goto :null56 Error("null pointer") null56: $a0 = $t0{t.1} call :Tree.GetKey $t0{t.2} = $v0 $a0 = $s2{c_node} $a1 = $t0{t.2} call :Tree.SetKey $s1{p_node} = $s2{c_node} if $s2{c_node} goto :null57 Error("null pointer") null57: $a0 = $s2{c_node} call :Tree.GetLeft $s2{c_node} = $v0 goto :while4_top while4_end: if $s1{p_node} goto :null58 Error("null pointer") null58: $t0{t.3} = [$s0{this}+20] $a0 = $s1{p_node} $a1 = $t0{t.3} call :Tree.SetLeft if $s1{p_node} goto :null59 Error("null pointer") null59: $a0 = $s1{p_node} $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{this} = $a0 $s0{v_key} = $a1 $s1{current_node} = $t0{this} $s2{cont} = 1 $s3{ifound} = 0 while5_top: if0 $s2{cont} goto :while5_end if $s1{current_node} goto :null60 Error("null pointer") null60: $a0 = $s1{current_node} call :Tree.GetKey $t0{key_aux} = $v0 $t1{t.0} = LtS($s0{v_key} $t0{key_aux}) if0 $t1{t.0} goto :if15_else if $s1{current_node} goto :null61 Error("null pointer") null61: $a0 = $s1{current_node} call :Tree.GetHas_Left $t1{t.1} = $v0 if0 $t1{t.1} goto :if16_else if $s1{current_node} goto :null62 Error("null pointer") null62: $a0 = $s1{current_node} call :Tree.GetLeft $s1{current_node} = $v0 goto :if16_end if16_else: $s2{cont} = 0 if16_end: goto :if15_end if15_else: $t0{t.2} = LtS($t0{key_aux} $s0{v_key}) if0 $t0{t.2} goto :if17_else if $s1{current_node} goto :null63 Error("null pointer") null63: $a0 = $s1{current_node} call :Tree.GetHas_Right $t0{t.3} = $v0 if0 $t0{t.3} goto :if18_else if $s1{current_node} goto :null64 Error("null pointer") null64: $a0 = $s1{current_node} call :Tree.GetRight $s1{current_node} = $v0 goto :if18_end if18_else: $s2{cont} = 0 if18_end: goto :if17_end if17_else: $s3{ifound} = 1 $s2{cont} = 0 if17_end: if15_end: goto :while5_top while5_end: $v0 = $s3{ifound} $s0 = local[0] $s1 = local[1] $s2 = local[2] $s3 = local[3] ret func Tree.Print [in 0, out 0, local 0] $t0{this} = $a0 $t1{current_node} = $t0{this} $a0 = $t0{this} $a1 = $t1{current_node} call :Tree.RecPrint $v0 = 1 ret func Tree.RecPrint [in 0, out 0, local 2] local[0] = $s0 local[1] = $s1 $s0{this} = $a0 $s1{node} = $a1 if $s1{node} goto :null65 Error("null pointer") null65: $a0 = $s1{node} call :Tree.GetHas_Left $t0{t.0} = $v0 if0 $t0{t.0} goto :if19_else if $s1{node} goto :null66 Error("null pointer") null66: $a0 = $s1{node} call :Tree.GetLeft $t0{t.1} = $v0 $a0 = $s0{this} $a1 = $t0{t.1} call :Tree.RecPrint goto :if19_end if19_else: if19_end: if $s1{node} goto :null67 Error("null pointer") null67: $a0 = $s1{node} call :Tree.GetKey $t0{t.2} = $v0 PrintIntS($t0{t.2}) if $s1{node} goto :null68 Error("null pointer") null68: $a0 = $s1{node} call :Tree.GetHas_Right $t0{t.3} = $v0 if0 $t0{t.3} goto :if20_else if $s1{node} goto :null69 Error("null pointer") null69: $a0 = $s1{node} call :Tree.GetRight $t0{t.4} = $v0 $a0 = $s0{this} $a1 = $t0{t.4} call :Tree.RecPrint goto :if20_end if20_else: if20_end: $v0 = 1 $s0 = local[0] $s1 = local[1] ret