; LLVM IR from frol/completely-unscientific-benchmarks :: c++/main-naive-raw.ll (ZN4Tree5splitEPNS_4NodeERS1_S2_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"

%"struct.Tree::Node" = type { i32, i32, ptr, ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Tree5splitEPNS_4NodeERS1_S2_i(ptr noundef %0, ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2, i32 noundef %3) #0 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  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
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %14, label %11

11:                                               ; preds = %4
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr null, ptr %12, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr null, ptr %13, align 8, !tbaa !5
  br label %44

14:                                               ; preds = %4
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.Tree::Node", ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %20, label %32

20:                                               ; preds = %14
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %21, ptr %22, align 8, !tbaa !5
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds %"struct.Tree::Node", ptr %24, i32 0, i32 3
  %26 = load ptr, ptr %25, align 8, !tbaa !13
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %27, align 8, !tbaa !5
  %29 = getelementptr inbounds %"struct.Tree::Node", ptr %28, i32 0, i32 3
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !9
  call void @_ZN4Tree5splitEPNS_4NodeERS1_S2_i(ptr noundef %26, ptr noundef nonnull align 8 dereferenceable(8) %29, ptr noundef nonnull align 8 dereferenceable(8) %30, i32 noundef %31)
  br label %44

32:                                               ; preds = %14
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %33, ptr %34, align 8, !tbaa !5
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = getelementptr inbounds %"struct.Tree::Node", ptr %36, i32 0, i32 2
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = getelementptr inbounds %"struct.Tree::Node", ptr %41, i32 0, i32 2
  %43 = load i32, ptr %8, align 4, !tbaa !9
  call void @_ZN4Tree5splitEPNS_4NodeERS1_S2_i(ptr noundef %38, ptr noundef nonnull align 8 dereferenceable(8) %39, ptr noundef nonnull align 8 dereferenceable(8) %42, i32 noundef %43)
  br label %44

44:                                               ; preds = %32, %20, %11
  ret void
}

attributes #0 = { 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" }

!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, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 16}
!14 = !{!12, !6, i64 8}


; 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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @_ZN4Tree5splitEPNS_4NodeERS1_S2_i(ptr noundef %0, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %1, ptr nocapture noundef nonnull writeonly align 8 dereferenceable(8) %2, i32 noundef %3) local_unnamed_addr #0 align 2 {
  %.not2228 = icmp eq ptr %0, null
  br i1 %.not2228, label %tailrecurse.outer._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4, %tailrecurse.outer
  %.tr18.ph31 = phi ptr [ %.tr1824, %tailrecurse.outer ], [ %2, %4 ]
  %.tr17.ph30 = phi ptr [ %8, %tailrecurse.outer ], [ %1, %4 ]
  %.tr.ph29 = phi ptr [ %9, %tailrecurse.outer ], [ %0, %4 ]
  br label %5

tailrecurse.outer._crit_edge:                     ; preds = %tailrecurse.outer, %tailrecurse, %4
  %.tr17.ph.lcssa = phi ptr [ %1, %4 ], [ %.tr17.ph30, %tailrecurse ], [ %8, %tailrecurse.outer ]
  %.tr18.lcssa = phi ptr [ %2, %4 ], [ %10, %tailrecurse ], [ %.tr1824, %tailrecurse.outer ]
  store ptr null, ptr %.tr18.lcssa, align 8, !tbaa !5
  store ptr null, ptr %.tr17.ph.lcssa, align 8, !tbaa !5
  ret void

5:                                                ; preds = %.lr.ph, %tailrecurse
  %.tr1824 = phi ptr [ %.tr18.ph31, %.lr.ph ], [ %10, %tailrecurse ]
  %.tr23 = phi ptr [ %.tr.ph29, %.lr.ph ], [ %11, %tailrecurse ]
  %6 = load i32, ptr %.tr23, align 8, !tbaa !9
  %7 = icmp slt i32 %6, %3
  br i1 %7, label %tailrecurse.outer, label %tailrecurse

tailrecurse.outer:                                ; preds = %5
  store ptr %.tr23, ptr %.tr17.ph30, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %.tr23, i64 16
  %9 = load ptr, ptr %8, align 8, !tbaa !12
  %.not22 = icmp eq ptr %9, null
  br i1 %.not22, label %tailrecurse.outer._crit_edge, label %.lr.ph

tailrecurse:                                      ; preds = %5
  store ptr %.tr23, ptr %.tr1824, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %.tr23, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %tailrecurse.outer._crit_edge, label %5
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) 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" }

!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, !11, i64 0}
!10 = !{!"_ZTSN4Tree4NodeE", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 16}
!13 = !{!10, !6, i64 8}


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