; LLVM IR from chromia/lichtenberg :: src/model/dlamodel.ll (ZN11lichtenberg5model13DLABreakModel4testEii)

; 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.lichtenberg::model::DLABreakModel" = type { %"class.lichtenberg::model::BreakModel", i32, i32, %"class.std::vector", %"class.std::vector.2" }
%"class.lichtenberg::model::BreakModel" = type { ptr }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<std::vector<lichtenberg::model::DLABreakModel::DLAParticle *>, std::allocator<std::vector<lichtenberg::model::DLABreakModel::DLAParticle *>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<lichtenberg::model::DLABreakModel::DLAParticle *>, std::allocator<std::vector<lichtenberg::model::DLABreakModel::DLAParticle *>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<lichtenberg::model::DLABreakModel::DLAParticle *>, std::allocator<std::vector<lichtenberg::model::DLABreakModel::DLAParticle *>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<lichtenberg::model::DLABreakModel::DLAParticle *>, std::allocator<std::vector<lichtenberg::model::DLABreakModel::DLAParticle *>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.2" = type { %"struct.std::_Vector_base.3" }
%"struct.std::_Vector_base.3" = type { %"struct.std::_Vector_base<lichtenberg::model::DLABreakModel::DLAParticle, std::allocator<lichtenberg::model::DLABreakModel::DLAParticle>>::_Vector_impl" }
%"struct.std::_Vector_base<lichtenberg::model::DLABreakModel::DLAParticle, std::allocator<lichtenberg::model::DLABreakModel::DLAParticle>>::_Vector_impl" = type { %"struct.std::_Vector_base<lichtenberg::model::DLABreakModel::DLAParticle, std::allocator<lichtenberg::model::DLABreakModel::DLAParticle>>::_Vector_impl_data" }
%"struct.std::_Vector_base<lichtenberg::model::DLABreakModel::DLAParticle, std::allocator<lichtenberg::model::DLABreakModel::DLAParticle>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.lichtenberg::model::DLABreakModel::DLAParticle" = type <{ ptr, ptr, %"class.std::tuple", i8, [7 x i8] }>
%"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
%"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.1" }
%"struct.std::_Tuple_impl.0" = type { %"struct.std::_Head_base" }
%"struct.std::_Head_base" = type { double }
%"struct.std::_Head_base.1" = type { double }

; 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(24) ptr @_ZNSt6vectorIS_IPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EESaIS6_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #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 nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN11lichtenberg5model13DLABreakModel4testEii(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %12 = getelementptr inbounds %"class.lichtenberg::model::DLABreakModel", ptr %11, i32 0, i32 3
  %13 = load i32, ptr %7, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EESaIS6_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %14) #2
  %16 = load i32, ptr %6, align 4, !tbaa !9
  %17 = sext i32 %16 to i64
  %18 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %15, i64 noundef %17) #2
  %19 = load ptr, ptr %18, align 8, !tbaa !5
  store ptr %19, ptr %8, align 8, !tbaa !5
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %3
  store i1 false, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %44

23:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %24, ptr %10, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %32, %23
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %29, label %28

28:                                               ; preds = %25
  store i32 2, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %36

29:                                               ; preds = %25
  %30 = load ptr, ptr %10, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.lichtenberg::model::DLABreakModel::DLAParticle", ptr %30, i32 0, i32 3
  store i8 0, ptr %31, align 8, !tbaa !11
  br label %32

32:                                               ; preds = %29
  %33 = load ptr, ptr %10, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.lichtenberg::model::DLABreakModel::DLAParticle", ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !20
  store ptr %35, ptr %10, align 8, !tbaa !5
  br label %25, !llvm.loop !21

36:                                               ; preds = %28
  %37 = getelementptr inbounds %"class.lichtenberg::model::DLABreakModel", ptr %11, i32 0, i32 3
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EESaIS6_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %37, i64 noundef %39) #2
  %41 = load i32, ptr %6, align 4, !tbaa !9
  %42 = sext i32 %41 to i64
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %40, i64 noundef %42) #2
  store ptr null, ptr %43, align 8, !tbaa !5
  store i1 true, ptr %4, align 1
  store i32 1, ptr %9, align 4
  br label %44

44:                                               ; preds = %36, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  %45 = load i1, ptr %4, align 1
  ret i1 %45
}

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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !19, i64 32}
!12 = !{!"_ZTSN11lichtenberg5model13DLABreakModel11DLAParticleE", !6, i64 0, !6, i64 8, !13, i64 16, !19, i64 32}
!13 = !{!"_ZTSSt5tupleIJddEE", !14, i64 0}
!14 = !{!"_ZTSSt11_Tuple_implILm0EJddEE", !15, i64 0, !18, i64 8}
!15 = !{!"_ZTSSt11_Tuple_implILm1EJdEE", !16, i64 0}
!16 = !{!"_ZTSSt10_Head_baseILm1EdLb0EE", !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!"_ZTSSt10_Head_baseILm0EdLb0EE", !17, i64 0}
!19 = !{!"bool", !7, i64 0}
!20 = !{!12, !6, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


; 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 nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EESaIS6_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN11lichtenberg5model13DLABreakModel4testEii(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1, i32 noundef %2) unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 16
  %5 = sext i32 %2 to i64
  %6 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EESaIS6_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %5) #1
  %7 = sext i32 %1 to i64
  %8 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %6, i64 noundef %7) #1
  %9 = load ptr, ptr %8, align 8, !tbaa !5
  %.not = icmp ne ptr %9, null
  br i1 %.not, label %.preheader, label %16

10:                                               ; preds = %.preheader
  %11 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EESaIS6_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %5) #1
  %12 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt6vectorIPN11lichtenberg5model13DLABreakModel11DLAParticleESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %11, i64 noundef %7) #1
  store ptr null, ptr %12, align 8, !tbaa !5
  br label %16

.preheader:                                       ; preds = %3, %.preheader
  %.013 = phi ptr [ %15, %.preheader ], [ %9, %3 ]
  %13 = getelementptr inbounds i8, ptr %.013, i64 32
  store i8 0, ptr %13, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %.013, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !18
  %.not12 = icmp eq ptr %15, null
  br i1 %.not12, label %10, label %.preheader, !llvm.loop !19

16:                                               ; preds = %3, %10
  ret i1 %.not
}

attributes #0 = { 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 #1 = { 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, !17, i64 32}
!10 = !{!"_ZTSN11lichtenberg5model13DLABreakModel11DLAParticleE", !6, i64 0, !6, i64 8, !11, i64 16, !17, i64 32}
!11 = !{!"_ZTSSt5tupleIJddEE", !12, i64 0}
!12 = !{!"_ZTSSt11_Tuple_implILm0EJddEE", !13, i64 0, !16, i64 8}
!13 = !{!"_ZTSSt11_Tuple_implILm1EJdEE", !14, i64 0}
!14 = !{!"_ZTSSt10_Head_baseILm1EdLb0EE", !15, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_ZTSSt10_Head_baseILm0EdLb0EE", !15, i64 0}
!17 = !{!"bool", !7, i64 0}
!18 = !{!10, !6, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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