; LLVM IR from frol/completely-unscientific-benchmarks :: c++/main-naive-shared_ptr.ll (ZN4Tree5splitERKSt10shared_ptrINS_4NodeEERS2_S5_i)

; 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::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }
%"struct.Tree::Node" = type { i32, i32, %"class.std::shared_ptr", %"class.std::shared_ptr" }

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

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

; 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 noundef zeroext i1 @_ZNKSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Tree5splitERKSt10shared_ptrINS_4NodeEERS2_S5_i(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %3) #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %"class.std::shared_ptr", align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store i32 %3, ptr %8, align 4, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = call noundef zeroext i1 @_ZNKSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %10) #3
  br i1 %11, label %17, label %12

12:                                               ; preds = %4
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #3
  call void @_ZNSt10shared_ptrIN4Tree4NodeEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr null) #3
  %13 = load ptr, ptr %7, align 8, !tbaa !5
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN4Tree4NodeEEaSEOS2_(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 8 dereferenceable(16) %9) #3
  %15 = load ptr, ptr %6, align 8, !tbaa !5
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN4Tree4NodeEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(16) %14) #3
  call void @_ZNSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %9) #3
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #3
  br label %48

17:                                               ; preds = %4
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %18) #3
  %20 = getelementptr inbounds %"struct.Tree::Node", ptr %19, i32 0, i32 0
  %21 = load i32, ptr %20, align 8, !tbaa !11
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %36

24:                                               ; preds = %17
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN4Tree4NodeEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 8 dereferenceable(16) %25) #3
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %28) #3
  %30 = getelementptr inbounds %"struct.Tree::Node", ptr %29, i32 0, i32 3
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %31) #3
  %33 = getelementptr inbounds %"struct.Tree::Node", ptr %32, i32 0, i32 3
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !9
  call void @_ZN4Tree5splitERKSt10shared_ptrINS_4NodeEERS2_S5_i(ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 8 dereferenceable(16) %33, ptr noundef nonnull align 8 dereferenceable(16) %34, i32 noundef %35)
  br label %48

36:                                               ; preds = %17
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN4Tree4NodeEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %38, ptr noundef nonnull align 8 dereferenceable(16) %37) #3
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %40) #3
  %42 = getelementptr inbounds %"struct.Tree::Node", ptr %41, i32 0, i32 2
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %44) #3
  %46 = getelementptr inbounds %"struct.Tree::Node", ptr %45, i32 0, i32 2
  %47 = load i32, ptr %8, align 4, !tbaa !9
  call void @_ZN4Tree5splitERKSt10shared_ptrINS_4NodeEERS2_S5_i(ptr noundef nonnull align 8 dereferenceable(16) %42, ptr noundef nonnull align 8 dereferenceable(16) %43, ptr noundef nonnull align 8 dereferenceable(16) %46, i32 noundef %47)
  br label %48

48:                                               ; preds = %36, %24, %12
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrIN4Tree4NodeEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16), ptr) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) unnamed_addr #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 = { mustprogress 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 #3 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"_ZTSN4Tree4NodeE", !10, i64 0, !10, i64 4, !13, i64 8, !13, i64 24}
!13 = !{!"_ZTSSt10shared_ptrIN4Tree4NodeEE", !14, i64 0}
!14 = !{!"_ZTSSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EE", !6, i64 0, !15, i64 8}
!15 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !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::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; 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 nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN4Tree4NodeEEaSEOS2_(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

; 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 noundef zeroext i1 @_ZNKSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN4Tree5splitERKSt10shared_ptrINS_4NodeEERS2_S5_i(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 8 dereferenceable(16) %1, ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %3) local_unnamed_addr #1 align 2 {
  %5 = alloca %"class.std::shared_ptr", align 8
  %6 = tail call noundef zeroext i1 @_ZNKSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %0) #2
  br i1 %6, label %.lr.ph, label %tailrecurse.outer._crit_edge

.lr.ph:                                           ; preds = %4, %tailrecurse.outer
  %.tr17.ph28 = phi ptr [ %.tr1722, %tailrecurse.outer ], [ %2, %4 ]
  %.tr16.ph27 = phi ptr [ %17, %tailrecurse.outer ], [ %1, %4 ]
  %.tr.ph26 = phi ptr [ %15, %tailrecurse.outer ], [ %0, %4 ]
  br label %9

tailrecurse.outer._crit_edge:                     ; preds = %tailrecurse.outer, %tailrecurse, %4
  %.tr16.ph.lcssa = phi ptr [ %1, %4 ], [ %.tr16.ph27, %tailrecurse ], [ %17, %tailrecurse.outer ]
  %.tr17.lcssa = phi ptr [ %2, %4 ], [ %23, %tailrecurse ], [ %.tr1722, %tailrecurse.outer ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #2
  call void @_ZNSt10shared_ptrIN4Tree4NodeEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr null) #2
  %7 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN4Tree4NodeEEaSEOS2_(ptr noundef nonnull align 8 dereferenceable(16) %.tr17.lcssa, ptr noundef nonnull align 8 dereferenceable(16) %5) #2
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN4Tree4NodeEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %.tr16.ph.lcssa, ptr noundef nonnull align 8 dereferenceable(16) %7) #2
  call void @_ZNSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16) %5) #2
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #2
  ret void

9:                                                ; preds = %.lr.ph, %tailrecurse
  %.tr1722 = phi ptr [ %.tr17.ph28, %.lr.ph ], [ %23, %tailrecurse ]
  %.tr21 = phi ptr [ %.tr.ph26, %.lr.ph ], [ %21, %tailrecurse ]
  %10 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %.tr21) #2
  %11 = load i32, ptr %10, align 8, !tbaa !5
  %12 = icmp slt i32 %11, %3
  br i1 %12, label %tailrecurse.outer, label %tailrecurse

tailrecurse.outer:                                ; preds = %9
  %13 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN4Tree4NodeEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %.tr16.ph27, ptr noundef nonnull align 8 dereferenceable(16) %.tr21) #2
  %14 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %.tr16.ph27) #2
  %15 = getelementptr inbounds i8, ptr %14, i64 24
  %16 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %.tr16.ph27) #2
  %17 = getelementptr inbounds i8, ptr %16, i64 24
  %18 = tail call noundef zeroext i1 @_ZNKSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %15) #2
  br i1 %18, label %.lr.ph, label %tailrecurse.outer._crit_edge

tailrecurse:                                      ; preds = %9
  %19 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt10shared_ptrIN4Tree4NodeEEaSERKS2_(ptr noundef nonnull align 8 dereferenceable(16) %.tr1722, ptr noundef nonnull align 8 dereferenceable(16) %.tr21) #2
  %20 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %.tr1722) #2
  %21 = getelementptr inbounds i8, ptr %20, i64 8
  %22 = tail call noundef ptr @_ZNKSt19__shared_ptr_accessIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2ELb0ELb0EEptEv(ptr noundef nonnull align 1 dereferenceable(1) %.tr1722) #2
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = tail call noundef zeroext i1 @_ZNKSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EEcvbEv(ptr noundef nonnull align 8 dereferenceable(16) %21) #2
  br i1 %24, label %9, label %tailrecurse.outer._crit_edge
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt10shared_ptrIN4Tree4NodeEEC2EDn(ptr noundef nonnull align 8 dereferenceable(16), ptr) unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EED2Ev(ptr noundef nonnull align 8 dereferenceable(16)) 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, !7, i64 0}
!6 = !{!"_ZTSN4Tree4NodeE", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTSSt10shared_ptrIN4Tree4NodeEE", !11, i64 0}
!11 = !{!"_ZTSSt12__shared_ptrIN4Tree4NodeELN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0, !13, i64 8}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!"_ZTSSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EE", !12, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass