; LLVM IR from vsoftco/garbage_collector :: garbage_collector.ll (ZN2GC12clear_memoryEv)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<void *, std::pair<void *const, std::pair<unsigned long, bool>>, std::_Select1st<std::pair<void *const, std::pair<unsigned long, bool>>>, std::less<void *>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<void *, std::pair<void *const, std::pair<unsigned long, bool>>, std::_Select1st<std::pair<void *const, std::pair<unsigned long, bool>>>, std::less<void *>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.GC::collect_t" = type { i8 }
%"struct.std::pair.0" = type { ptr, %"struct.std::pair" }
%"struct.std::pair" = type <{ i64, i8, [7 x i8] }>

@_ZN2GC7memory_E = external dso_local global %"class.std::map", align 8

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEES7_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2GC12clear_memoryEv() #1 align 2 {
  %1 = alloca ptr, align 8
  %2 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %3 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"struct.GC::collect_t", align 1
  %6 = alloca %"struct.GC::collect_t", align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #2
  store ptr @_ZN2GC7memory_E, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #2
  %7 = call ptr @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @_ZN2GC7memory_E) #2
  %8 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %2, i32 0, i32 0
  store ptr %7, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %9 = call ptr @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @_ZN2GC7memory_E) #2
  %10 = getelementptr inbounds %"struct.std::_Rb_tree_iterator", ptr %3, i32 0, i32 0
  store ptr %9, ptr %10, align 8
  br label %11

11:                                               ; preds = %30, %0
  %12 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEES7_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3) #2
  br i1 %12, label %14, label %13

13:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #2
  br label %32

14:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %15 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #2
  store ptr %15, ptr %4, align 8, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %"struct.std::pair.0", ptr %16, i32 0, i32 1
  %18 = getelementptr inbounds %"struct.std::pair", ptr %17, i32 0, i32 1
  %19 = load i8, ptr %18, align 8, !tbaa !9, !range !14, !noundef !15
  %20 = trunc i8 %19 to i1
  br i1 %20, label %21, label %25

21:                                               ; preds = %14
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.std::pair.0", ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #2
  call void @_ZdlPvRKN2GC9collect_tE(ptr noundef %24, ptr noundef nonnull align 1 dereferenceable(1) %5) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #2
  br label %29

25:                                               ; preds = %14
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.std::pair.0", ptr %26, i32 0, i32 0
  %28 = load ptr, ptr %27, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 1, ptr %6) #2
  call void @_ZdaPvRKN2GC9collect_tE(ptr noundef %28, ptr noundef nonnull align 1 dereferenceable(1) %6) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr %6) #2
  br label %29

29:                                               ; preds = %25, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %30

30:                                               ; preds = %29
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %2) #2
  br label %11

32:                                               ; preds = %13
  call void @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @_ZN2GC7memory_E) #2
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZdlPvRKN2GC9collect_tE(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZdaPvRKN2GC9collect_tE(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !13, i64 16}
!10 = !{!"_ZTSSt4pairIKPvS_ImbEE", !6, i64 0, !11, i64 8}
!11 = !{!"_ZTSSt4pairImbE", !12, i64 0, !13, i64 8}
!12 = !{!"long", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !6, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::map" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<void *, std::pair<void *const, std::pair<unsigned long, bool>>, std::_Select1st<std::pair<void *const, std::pair<unsigned long, bool>>>, std::less<void *>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<void *, std::pair<void *const, std::pair<unsigned long, bool>>, std::_Select1st<std::pair<void *const, std::pair<unsigned long, bool>>>, std::less<void *>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"struct.std::_Rb_tree_iterator" = type { ptr }
%"struct.GC::collect_t" = type { i8 }

@_ZN2GC7memory_E = external dso_local global %"class.std::map", align 8

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEES7_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEEppEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN2GC12clear_memoryEv() local_unnamed_addr #1 align 2 {
  %1 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %2 = alloca %"struct.std::_Rb_tree_iterator", align 8
  %3 = alloca %"struct.GC::collect_t", align 1
  %4 = alloca %"struct.GC::collect_t", align 1
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #2
  %5 = tail call ptr @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @_ZN2GC7memory_E) #2
  store ptr %5, ptr %1, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #2
  %6 = tail call ptr @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @_ZN2GC7memory_E) #2
  store ptr %6, ptr %2, align 8
  %7 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEES7_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2) #2
  br i1 %7, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %15, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #2
  call void @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48) @_ZN2GC7memory_E) #2
  ret void

.lr.ph:                                           ; preds = %0, %15
  %8 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNKSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %1) #2
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  %10 = load i8, ptr %9, align 8, !tbaa !5, !range !13, !noundef !14
  %11 = trunc nuw i8 %10 to i1
  %12 = load ptr, ptr %8, align 8, !tbaa !15
  br i1 %11, label %13, label %14

13:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %3) #2
  call void @_ZdlPvRKN2GC9collect_tE(ptr noundef %12, ptr noundef nonnull align 1 dereferenceable(1) %3) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %3) #2
  br label %15

14:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %4) #2
  call void @_ZdaPvRKN2GC9collect_tE(ptr noundef %12, ptr noundef nonnull align 1 dereferenceable(1) %4) #2
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %4) #2
  br label %15

15:                                               ; preds = %14, %13
  %16 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %1) #2
  %17 = call noundef zeroext i1 @_ZStneRKSt17_Rb_tree_iteratorISt4pairIKPvS0_ImbEEES7_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2) #2
  br i1 %17, label %.lr.ph, label %._crit_edge
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZdlPvRKN2GC9collect_tE(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZdaPvRKN2GC9collect_tE(ptr noundef, ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt3mapIPvSt4pairImbESt4lessIS0_ESaIS1_IKS0_S2_EEE5clearEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !12, i64 16}
!6 = !{!"_ZTSSt4pairIKPvS_ImbEE", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt4pairImbE", !11, i64 0, !12, i64 8}
!11 = !{!"long", !8, i64 0}
!12 = !{!"bool", !8, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass