; LLVM IR from VeloxChem/VeloxChem :: src/dft_func/DensityGrid.ll (ZN12CDensityGridC2Eii5xcfun7dengrid)

; 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.CDensityGridData2D = type <{ %"class.std::vector", %"class.std::vector.0", %"class.std::vector.0", %"class.std::vector.0", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%class.CDensityGrid = type { i32, i32, %class.CDensityGridData2D }

declare void @_ZN18CDensityGridData2DC1Ev(ptr noundef nonnull align 8 dereferenceable(100)) unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12CDensityGridC2Eii5xcfun7dengrid(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %class.CDensityGridData2D, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !11
  store i32 %4, ptr %10, align 4, !tbaa !13
  %15 = load ptr, ptr %6, align 8
  %16 = getelementptr inbounds %class.CDensityGrid, ptr %15, i32 0, i32 2
  call void @_ZN18CDensityGridData2DC1Ev(ptr noundef nonnull align 8 dereferenceable(100) %16)
  %17 = load i32, ptr %10, align 4, !tbaa !13
  %18 = getelementptr inbounds %class.CDensityGrid, ptr %15, i32 0, i32 0
  store i32 %17, ptr %18, align 8, !tbaa !15
  %19 = load i32, ptr %8, align 4, !tbaa !9
  %20 = getelementptr inbounds %class.CDensityGrid, ptr %15, i32 0, i32 1
  store i32 %19, ptr %20, align 4, !tbaa !26
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !9
  %21 = getelementptr inbounds %class.CDensityGrid, ptr %15, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !15
  %23 = icmp eq i32 %22, 0
  br i1 %23, label %24, label %37

24:                                               ; preds = %5
  %25 = load i32, ptr %9, align 4, !tbaa !11
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  store i32 2, ptr %11, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %27, %24
  %29 = load i32, ptr %9, align 4, !tbaa !11
  %30 = icmp eq i32 %29, 1
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  store i32 11, ptr %11, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %31, %28
  %33 = load i32, ptr %9, align 4, !tbaa !11
  %34 = icmp eq i32 %33, 2
  br i1 %34, label %35, label %36

35:                                               ; preds = %32
  store i32 15, ptr %11, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %35, %32
  br label %37

37:                                               ; preds = %36, %5
  call void @llvm.lifetime.start.p0(i64 104, ptr %12) #4
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = getelementptr inbounds %class.CDensityGrid, ptr %15, i32 0, i32 1
  %40 = load i32, ptr %39, align 4, !tbaa !26
  %41 = load i32, ptr %11, align 4, !tbaa !9
  %42 = mul nsw i32 %40, %41
  invoke void @_ZN18CDensityGridData2DC1Eii(ptr noundef nonnull align 8 dereferenceable(100) %12, i32 noundef %38, i32 noundef %42)
          to label %43 unwind label %46

43:                                               ; preds = %37
  %44 = getelementptr inbounds %class.CDensityGrid, ptr %15, i32 0, i32 2
  %45 = call noundef nonnull align 8 dereferenceable(100) ptr @_ZN18CDensityGridData2DaSEOS_(ptr noundef nonnull align 8 dereferenceable(100) %44, ptr noundef nonnull align 8 dereferenceable(100) %12) #4
  call void @_ZN18CDensityGridData2DD1Ev(ptr noundef nonnull align 8 dereferenceable(100) %12) #4
  call void @llvm.lifetime.end.p0(i64 104, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret void

46:                                               ; preds = %37
  %47 = landingpad { ptr, i32 }
          cleanup
  %48 = extractvalue { ptr, i32 } %47, 0
  store ptr %48, ptr %13, align 8
  %49 = extractvalue { ptr, i32 } %47, 1
  store i32 %49, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 104, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @_ZN18CDensityGridData2DD1Ev(ptr noundef nonnull align 8 dereferenceable(100) %16) #4
  br label %50

50:                                               ; preds = %46
  %51 = load ptr, ptr %13, align 8
  %52 = load i32, ptr %14, align 4
  %53 = insertvalue { ptr, i32 } poison, ptr %51, 0
  %54 = insertvalue { ptr, i32 } %53, i32 %52, 1
  resume { ptr, i32 } %54
}

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

declare void @_ZN18CDensityGridData2DC1Eii(ptr noundef nonnull align 8 dereferenceable(100), i32 noundef, i32 noundef) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare noundef nonnull align 8 dereferenceable(100) ptr @_ZN18CDensityGridData2DaSEOS_(ptr noundef nonnull align 8 dereferenceable(100), ptr noundef nonnull align 8 dereferenceable(100)) #3

; Function Attrs: nounwind
declare void @_ZN18CDensityGridData2DD1Ev(ptr noundef nonnull align 8 dereferenceable(100)) unnamed_addr #3

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

attributes #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind "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 = { 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, !12, i64 0}
!12 = !{!"_ZTS5xcfun", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_ZTS7dengrid", !7, i64 0}
!15 = !{!16, !14, i64 0}
!16 = !{!"_ZTS12CDensityGrid", !14, i64 0, !10, i64 4, !17, i64 8}
!17 = !{!"_ZTS18CDensityGridData2D", !18, i64 0, !22, i64 24, !22, i64 48, !22, i64 72, !10, i64 96}
!18 = !{!"_ZTSSt6vectorIdSaIdEE", !19, i64 0}
!19 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !21, i64 0}
!21 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!22 = !{!"_ZTSSt6vectorIiSaIiEE", !23, i64 0}
!23 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !24, i64 0}
!24 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !25, i64 0}
!25 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!26 = !{!16, !10, i64 4}


; 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.CDensityGridData2D = type <{ %"class.std::vector", %"class.std::vector.0", %"class.std::vector.0", %"class.std::vector.0", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl" = type { %"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" }
%"struct.std::_Vector_base<double, std::allocator<double>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

declare void @_ZN18CDensityGridData2DC1Ev(ptr noundef nonnull align 8 dereferenceable(100)) unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN12CDensityGridC2Eii5xcfun7dengrid(ptr noundef nonnull align 8 dereferenceable(112) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %6 = alloca %class.CDensityGridData2D, align 8
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  tail call void @_ZN18CDensityGridData2DC1Ev(ptr noundef nonnull align 8 dereferenceable(100) %7)
  store i32 %4, ptr %0, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 %2, ptr %8, align 4, !tbaa !21
  %9 = icmp eq i32 %4, 0
  br i1 %9, label %10, label %14

10:                                               ; preds = %5
  %11 = icmp eq i32 %3, 0
  %spec.select = select i1 %11, i32 2, i32 0
  %12 = icmp eq i32 %3, 1
  %.1 = select i1 %12, i32 11, i32 %spec.select
  %13 = icmp eq i32 %3, 2
  %spec.select9 = select i1 %13, i32 15, i32 %.1
  br label %14

14:                                               ; preds = %10, %5
  %.2 = phi i32 [ 0, %5 ], [ %spec.select9, %10 ]
  call void @llvm.lifetime.start.p0(i64 104, ptr nonnull %6) #4
  %15 = mul nsw i32 %.2, %2
  invoke void @_ZN18CDensityGridData2DC1Eii(ptr noundef nonnull align 8 dereferenceable(100) %6, i32 noundef %1, i32 noundef %15)
          to label %16 unwind label %18

16:                                               ; preds = %14
  %17 = call noundef nonnull align 8 dereferenceable(100) ptr @_ZN18CDensityGridData2DaSEOS_(ptr noundef nonnull align 8 dereferenceable(100) %7, ptr noundef nonnull align 8 dereferenceable(100) %6) #4
  call void @_ZN18CDensityGridData2DD1Ev(ptr noundef nonnull align 8 dereferenceable(100) %6) #4
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %6) #4
  ret void

18:                                               ; preds = %14
  %19 = landingpad { ptr, i32 }
          cleanup
  call void @llvm.lifetime.end.p0(i64 104, ptr nonnull %6) #4
  call void @_ZN18CDensityGridData2DD1Ev(ptr noundef nonnull align 8 dereferenceable(100) %7) #4
  resume { ptr, i32 } %19
}

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

declare void @_ZN18CDensityGridData2DC1Eii(ptr noundef nonnull align 8 dereferenceable(100), i32 noundef, i32 noundef) unnamed_addr #0

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare noundef nonnull align 8 dereferenceable(100) ptr @_ZN18CDensityGridData2DaSEOS_(ptr noundef nonnull align 8 dereferenceable(100), ptr noundef nonnull align 8 dereferenceable(100)) local_unnamed_addr #3

; Function Attrs: nounwind
declare void @_ZN18CDensityGridData2DD1Ev(ptr noundef nonnull align 8 dereferenceable(100)) unnamed_addr #3

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

attributes #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind "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 = { 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 = !{!"_ZTS12CDensityGrid", !7, i64 0, !10, i64 4, !11, i64 8}
!7 = !{!"_ZTS7dengrid", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_ZTS18CDensityGridData2D", !12, i64 0, !17, i64 24, !17, i64 48, !17, i64 72, !10, i64 96}
!12 = !{!"_ZTSSt6vectorIdSaIdEE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIdSaIdEE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIdSaIdEE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"any pointer", !8, i64 0}
!17 = !{!"_ZTSSt6vectorIiSaIiEE", !18, i64 0}
!18 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !19, i64 0}
!19 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !20, i64 0}
!20 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !16, i64 0, !16, i64 8, !16, i64 16}
!21 = !{!6, !10, i64 4}


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