; LLVM IR from chromia/lichtenberg :: src/model (dbmmodel)

; 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.lichtenberg::model::DBMCell" = type <{ double, i8, [7 x i8] }>
%"class.lichtenberg::model::DielectricBreakModel" = type { %"class.lichtenberg::model::BreakModel", i32, i32, i8, double, double, %"class.std::vector", double }
%"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::DBMCell>, std::allocator<std::vector<lichtenberg::model::DBMCell>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::vector<lichtenberg::model::DBMCell>, std::allocator<std::vector<lichtenberg::model::DBMCell>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::vector<lichtenberg::model::DBMCell>, std::allocator<std::vector<lichtenberg::model::DBMCell>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::vector<lichtenberg::model::DBMCell>, std::allocator<std::vector<lichtenberg::model::DBMCell>>>::_Vector_impl_data" = type { ptr, ptr, 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(24) ptr @_ZNSt6vectorIS_IN11lichtenberg5model7DBMCellESaIS2_EESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #1 align 2

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #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 uwtable
define dso_local void @_ZN11lichtenberg5model20DielectricBreakModel9init_gridERKNS_10CellList2DE(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) #3 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %"struct.lichtenberg::model::DBMCell", align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %12 = getelementptr inbounds %"class.lichtenberg::model::DielectricBreakModel", ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 8, !tbaa !9
  store i32 %13, ptr %5, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %14 = getelementptr inbounds %"class.lichtenberg::model::DielectricBreakModel", ptr %11, i32 0, i32 2
  %15 = load i32, ptr %14, align 4, !tbaa !20
  store i32 %15, ptr %6, align 4, !tbaa !19
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !19
  br label %16

16:                                               ; preds = %49, %2
  %17 = load i32, ptr %7, align 4, !tbaa !19
  %18 = load i32, ptr %6, align 4, !tbaa !19
  %19 = icmp slt i32 %17, %18
  br i1 %19, label %21, label %20

20:                                               ; preds = %16
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %52

21:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !19
  br label %22

22:                                               ; preds = %45, %21
  %23 = load i32, ptr %9, align 4, !tbaa !19
  %24 = load i32, ptr %5, align 4, !tbaa !19
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %48

27:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #5
  %28 = getelementptr inbounds %"class.lichtenberg::model::DielectricBreakModel", ptr %11, i32 0, i32 6
  %29 = load i32, ptr %7, align 4, !tbaa !19
  %30 = add nsw i32 %29, 1
  %31 = sext i32 %30 to i64
  %32 = call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IN11lichtenberg5model7DBMCellESaIS2_EESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %31) #5
  %33 = load i32, ptr %9, align 4, !tbaa !19
  %34 = add nsw i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorIN11lichtenberg5model7DBMCellESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %35) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %36, i64 16, i1 false), !tbaa.struct !21
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = load i32, ptr %9, align 4, !tbaa !19
  %39 = load i32, ptr %7, align 4, !tbaa !19
  %40 = call noundef zeroext i1 @_ZNK11lichtenberg10CellList2D10get_brokenEii(ptr noundef nonnull align 8 dereferenceable(16) %37, i32 noundef %38, i32 noundef %39)
  br i1 %40, label %41, label %44

41:                                               ; preds = %27
  %42 = getelementptr inbounds %"struct.lichtenberg::model::DBMCell", ptr %10, i32 0, i32 0
  store double 0.000000e+00, ptr %42, align 8, !tbaa !24
  %43 = getelementptr inbounds %"struct.lichtenberg::model::DBMCell", ptr %10, i32 0, i32 1
  store i8 1, ptr %43, align 8, !tbaa !26
  br label %44

44:                                               ; preds = %41, %27
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %9, align 4, !tbaa !19
  %47 = add nsw i32 %46, 1
  store i32 %47, ptr %9, align 4, !tbaa !19
  br label %22, !llvm.loop !27

48:                                               ; preds = %26
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %7, align 4, !tbaa !19
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %7, align 4, !tbaa !19
  br label %16, !llvm.loop !29

52:                                               ; preds = %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

declare noundef zeroext i1 @_ZNK11lichtenberg10CellList2D10get_brokenEii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) #4

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { "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 #5 = { 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, !12, i64 8}
!10 = !{!"_ZTSN11lichtenberg5model20DielectricBreakModelE", !11, i64 0, !12, i64 8, !12, i64 12, !13, i64 16, !14, i64 24, !14, i64 32, !15, i64 40, !14, i64 64}
!11 = !{!"_ZTSN11lichtenberg5model10BreakModelE"}
!12 = !{!"int", !7, i64 0}
!13 = !{!"bool", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTSSt6vectorIS_IN11lichtenberg5model7DBMCellESaIS2_EESaIS4_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseISt6vectorIN11lichtenberg5model7DBMCellESaIS3_EESaIS5_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN11lichtenberg5model7DBMCellESaIS3_EESaIS5_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN11lichtenberg5model7DBMCellESaIS3_EESaIS5_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!12, !12, i64 0}
!20 = !{!10, !12, i64 12}
!21 = !{i64 0, i64 8, !22, i64 8, i64 1, !23}
!22 = !{!14, !14, i64 0}
!23 = !{!13, !13, i64 0}
!24 = !{!25, !14, i64 0}
!25 = !{!"_ZTSN11lichtenberg5model7DBMCellE", !14, i64 0, !13, i64 8}
!26 = !{!25, !13, i64 8}
!27 = distinct !{!27, !28}
!28 = !{!"llvm.loop.mustprogress"}
!29 = distinct !{!29, !28}


; 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_IN11lichtenberg5model7DBMCellESaIS2_EESaIS4_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(9) ptr @_ZNSt6vectorIN11lichtenberg5model7DBMCellESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11lichtenberg5model20DielectricBreakModel9init_gridERKNS_10CellList2DE(ptr noundef nonnull align 8 dereferenceable(72) %0, ptr noundef nonnull align 8 dereferenceable(16) %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 12
  %6 = load i32, ptr %5, align 4, !tbaa !18
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.preheader.lr.ph, label %._crit_edge14

.preheader.lr.ph:                                 ; preds = %2
  %8 = icmp sgt i32 %4, 0
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  br i1 %8, label %.preheader.us.preheader, label %._crit_edge14

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %wide.trip.count20 = zext nneg i32 %6 to i64
  %wide.trip.count = zext nneg i32 %4 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %._crit_edge.us
  %indvars.iv17 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next18, %._crit_edge.us ]
  %indvars.iv.next18 = add nuw nsw i64 %indvars.iv17, 1
  %10 = trunc nuw nsw i64 %indvars.iv17 to i32
  br label %11

11:                                               ; preds = %.preheader.us, %11
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %11 ]
  %12 = tail call noundef nonnull align 8 dereferenceable(24) ptr @_ZNSt6vectorIS_IN11lichtenberg5model7DBMCellESaIS2_EESaIS4_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %9, i64 noundef %indvars.iv.next18) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = tail call noundef nonnull align 8 dereferenceable(9) ptr @_ZNSt6vectorIN11lichtenberg5model7DBMCellESaIS2_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %12, i64 noundef %indvars.iv.next) #3
  %14 = trunc nuw nsw i64 %indvars.iv to i32
  %15 = tail call noundef zeroext i1 @_ZNK11lichtenberg10CellList2D10get_brokenEii(ptr noundef nonnull align 8 dereferenceable(16) %1, i32 noundef %14, i32 noundef %10)
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge.us, label %11, !llvm.loop !19

._crit_edge.us:                                   ; preds = %11
  %exitcond21.not = icmp eq i64 %indvars.iv.next18, %wide.trip.count20
  br i1 %exitcond21.not, label %._crit_edge14, label %.preheader.us, !llvm.loop !21

._crit_edge14:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %2
  ret void
}

declare noundef zeroext i1 @_ZNK11lichtenberg10CellList2D10get_brokenEii(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef, i32 noundef) local_unnamed_addr #2

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 = { 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 #2 = { "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, !8, i64 8}
!6 = !{!"_ZTSN11lichtenberg5model20DielectricBreakModelE", !7, i64 0, !8, i64 8, !8, i64 12, !11, i64 16, !12, i64 24, !12, i64 32, !13, i64 40, !12, i64 64}
!7 = !{!"_ZTSN11lichtenberg5model10BreakModelE"}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"bool", !9, i64 0}
!12 = !{!"double", !9, i64 0}
!13 = !{!"_ZTSSt6vectorIS_IN11lichtenberg5model7DBMCellESaIS2_EESaIS4_EE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseISt6vectorIN11lichtenberg5model7DBMCellESaIS3_EESaIS5_EE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN11lichtenberg5model7DBMCellESaIS3_EESaIS5_EE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseISt6vectorIN11lichtenberg5model7DBMCellESaIS3_EESaIS5_EE17_Vector_impl_dataE", !17, i64 0, !17, i64 8, !17, i64 16}
!17 = !{!"any pointer", !9, i64 0}
!18 = !{!6, !8, i64 12}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass