; LLVM IR from VeloxChem/VeloxChem :: src/dft_func/MolecularGrid.ll (ZNK14CMolecularGrid16getSpatialExtentEv)

; 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.std::array" = type { [6 x double] }

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

; 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
declare dso_local noundef i32 @_ZNK14CMolecularGrid21getNumberOfGridPointsEv(ptr noundef nonnull align 8 dereferenceable(148)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14CMolecularGrid15getCoordinatesXEv(ptr noundef nonnull align 8 dereferenceable(148)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14CMolecularGrid15getCoordinatesYEv(ptr noundef nonnull align 8 dereferenceable(148)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14CMolecularGrid15getCoordinatesZEv(ptr noundef nonnull align 8 dereferenceable(148)) #1 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK14CMolecularGrid16getSpatialExtentEv(ptr dead_on_unwind noalias writable sret(%"struct.std::array") align 8 %0, ptr noundef nonnull align 8 dereferenceable(148) %1) #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca double, align 8
  %6 = alloca double, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %1, ptr %3, align 8, !tbaa !5
  %15 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store double 0.000000e+00, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  store double 0.000000e+00, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  store double 0.000000e+00, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  store double 0.000000e+00, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  store double 0.000000e+00, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  store double 0.000000e+00, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  %16 = call noundef i32 @_ZNK14CMolecularGrid21getNumberOfGridPointsEv(ptr noundef nonnull align 8 dereferenceable(148) %15)
  store i32 %16, ptr %10, align 4, !tbaa !11
  %17 = load i32, ptr %10, align 4, !tbaa !11
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %19, label %135

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  %20 = call noundef ptr @_ZNK14CMolecularGrid15getCoordinatesXEv(ptr noundef nonnull align 8 dereferenceable(148) %15)
  store ptr %20, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #2
  %21 = call noundef ptr @_ZNK14CMolecularGrid15getCoordinatesYEv(ptr noundef nonnull align 8 dereferenceable(148) %15)
  store ptr %21, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #2
  %22 = call noundef ptr @_ZNK14CMolecularGrid15getCoordinatesZEv(ptr noundef nonnull align 8 dereferenceable(148) %15)
  store ptr %22, ptr %13, align 8, !tbaa !5
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = getelementptr inbounds double, ptr %23, i64 0
  %25 = load double, ptr %24, align 8, !tbaa !9
  store double %25, ptr %4, align 8, !tbaa !9
  %26 = load ptr, ptr %11, align 8, !tbaa !5
  %27 = getelementptr inbounds double, ptr %26, i64 0
  %28 = load double, ptr %27, align 8, !tbaa !9
  store double %28, ptr %7, align 8, !tbaa !9
  %29 = load ptr, ptr %12, align 8, !tbaa !5
  %30 = getelementptr inbounds double, ptr %29, i64 0
  %31 = load double, ptr %30, align 8, !tbaa !9
  store double %31, ptr %5, align 8, !tbaa !9
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i64 0
  %34 = load double, ptr %33, align 8, !tbaa !9
  store double %34, ptr %8, align 8, !tbaa !9
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %35, i64 0
  %37 = load double, ptr %36, align 8, !tbaa !9
  store double %37, ptr %6, align 8, !tbaa !9
  %38 = load ptr, ptr %13, align 8, !tbaa !5
  %39 = getelementptr inbounds double, ptr %38, i64 0
  %40 = load double, ptr %39, align 8, !tbaa !9
  store double %40, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #2
  store i32 0, ptr %14, align 4, !tbaa !11
  br label %41

41:                                               ; preds = %131, %19
  %42 = load i32, ptr %14, align 4, !tbaa !11
  %43 = load i32, ptr %10, align 4, !tbaa !11
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #2
  br label %134

46:                                               ; preds = %41
  %47 = load double, ptr %4, align 8, !tbaa !9
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = load i32, ptr %14, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds double, ptr %48, i64 %50
  %52 = load double, ptr %51, align 8, !tbaa !9
  %53 = fcmp ogt double %47, %52
  br i1 %53, label %54, label %60

54:                                               ; preds = %46
  %55 = load ptr, ptr %11, align 8, !tbaa !5
  %56 = load i32, ptr %14, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds double, ptr %55, i64 %57
  %59 = load double, ptr %58, align 8, !tbaa !9
  store double %59, ptr %4, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %54, %46
  %61 = load double, ptr %5, align 8, !tbaa !9
  %62 = load ptr, ptr %12, align 8, !tbaa !5
  %63 = load i32, ptr %14, align 4, !tbaa !11
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds double, ptr %62, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = fcmp ogt double %61, %66
  br i1 %67, label %68, label %74

68:                                               ; preds = %60
  %69 = load ptr, ptr %12, align 8, !tbaa !5
  %70 = load i32, ptr %14, align 4, !tbaa !11
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds double, ptr %69, i64 %71
  %73 = load double, ptr %72, align 8, !tbaa !9
  store double %73, ptr %5, align 8, !tbaa !9
  br label %74

74:                                               ; preds = %68, %60
  %75 = load double, ptr %6, align 8, !tbaa !9
  %76 = load ptr, ptr %13, align 8, !tbaa !5
  %77 = load i32, ptr %14, align 4, !tbaa !11
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds double, ptr %76, i64 %78
  %80 = load double, ptr %79, align 8, !tbaa !9
  %81 = fcmp ogt double %75, %80
  br i1 %81, label %82, label %88

82:                                               ; preds = %74
  %83 = load ptr, ptr %13, align 8, !tbaa !5
  %84 = load i32, ptr %14, align 4, !tbaa !11
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds double, ptr %83, i64 %85
  %87 = load double, ptr %86, align 8, !tbaa !9
  store double %87, ptr %6, align 8, !tbaa !9
  br label %88

88:                                               ; preds = %82, %74
  %89 = load double, ptr %7, align 8, !tbaa !9
  %90 = load ptr, ptr %11, align 8, !tbaa !5
  %91 = load i32, ptr %14, align 4, !tbaa !11
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds double, ptr %90, i64 %92
  %94 = load double, ptr %93, align 8, !tbaa !9
  %95 = fcmp olt double %89, %94
  br i1 %95, label %96, label %102

96:                                               ; preds = %88
  %97 = load ptr, ptr %11, align 8, !tbaa !5
  %98 = load i32, ptr %14, align 4, !tbaa !11
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds double, ptr %97, i64 %99
  %101 = load double, ptr %100, align 8, !tbaa !9
  store double %101, ptr %7, align 8, !tbaa !9
  br label %102

102:                                              ; preds = %96, %88
  %103 = load double, ptr %8, align 8, !tbaa !9
  %104 = load ptr, ptr %12, align 8, !tbaa !5
  %105 = load i32, ptr %14, align 4, !tbaa !11
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds double, ptr %104, i64 %106
  %108 = load double, ptr %107, align 8, !tbaa !9
  %109 = fcmp olt double %103, %108
  br i1 %109, label %110, label %116

110:                                              ; preds = %102
  %111 = load ptr, ptr %12, align 8, !tbaa !5
  %112 = load i32, ptr %14, align 4, !tbaa !11
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds double, ptr %111, i64 %113
  %115 = load double, ptr %114, align 8, !tbaa !9
  store double %115, ptr %8, align 8, !tbaa !9
  br label %116

116:                                              ; preds = %110, %102
  %117 = load double, ptr %9, align 8, !tbaa !9
  %118 = load ptr, ptr %13, align 8, !tbaa !5
  %119 = load i32, ptr %14, align 4, !tbaa !11
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds double, ptr %118, i64 %120
  %122 = load double, ptr %121, align 8, !tbaa !9
  %123 = fcmp olt double %117, %122
  br i1 %123, label %124, label %130

124:                                              ; preds = %116
  %125 = load ptr, ptr %13, align 8, !tbaa !5
  %126 = load i32, ptr %14, align 4, !tbaa !11
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds double, ptr %125, i64 %127
  %129 = load double, ptr %128, align 8, !tbaa !9
  store double %129, ptr %9, align 8, !tbaa !9
  br label %130

130:                                              ; preds = %124, %116
  br label %131

131:                                              ; preds = %130
  %132 = load i32, ptr %14, align 4, !tbaa !11
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %14, align 4, !tbaa !11
  br label %41, !llvm.loop !13

134:                                              ; preds = %45
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  br label %135

135:                                              ; preds = %134, %2
  %136 = getelementptr inbounds %"struct.std::array", ptr %0, i32 0, i32 0
  %137 = load double, ptr %4, align 8, !tbaa !9
  store double %137, ptr %136, align 8, !tbaa !9
  %138 = getelementptr inbounds double, ptr %136, i64 1
  %139 = load double, ptr %5, align 8, !tbaa !9
  store double %139, ptr %138, align 8, !tbaa !9
  %140 = getelementptr inbounds double, ptr %136, i64 2
  %141 = load double, ptr %6, align 8, !tbaa !9
  store double %141, ptr %140, align 8, !tbaa !9
  %142 = getelementptr inbounds double, ptr %136, i64 3
  %143 = load double, ptr %7, align 8, !tbaa !9
  store double %143, ptr %142, align 8, !tbaa !9
  %144 = getelementptr inbounds double, ptr %136, i64 4
  %145 = load double, ptr %8, align 8, !tbaa !9
  store double %145, ptr %144, align 8, !tbaa !9
  %146 = getelementptr inbounds double, ptr %136, i64 5
  %147 = load double, ptr %9, align 8, !tbaa !9
  store double %147, ptr %146, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

%"struct.std::array" = type { [6 x double] }

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_ZNK14CMolecularGrid21getNumberOfGridPointsEv(ptr noundef nonnull align 8 dereferenceable(148)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14CMolecularGrid15getCoordinatesXEv(ptr noundef nonnull align 8 dereferenceable(148)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14CMolecularGrid15getCoordinatesYEv(ptr noundef nonnull align 8 dereferenceable(148)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef ptr @_ZNK14CMolecularGrid15getCoordinatesZEv(ptr noundef nonnull align 8 dereferenceable(148)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZNK14CMolecularGrid16getSpatialExtentEv(ptr dead_on_unwind noalias nocapture writable writeonly sret(%"struct.std::array") align 8 %0, ptr noundef nonnull align 8 dereferenceable(148) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i32 @_ZNK14CMolecularGrid21getNumberOfGridPointsEv(ptr noundef nonnull align 8 dereferenceable(148) %1)
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %5, label %.loopexit

5:                                                ; preds = %2
  %6 = tail call noundef ptr @_ZNK14CMolecularGrid15getCoordinatesXEv(ptr noundef nonnull align 8 dereferenceable(148) %1)
  %7 = tail call noundef ptr @_ZNK14CMolecularGrid15getCoordinatesYEv(ptr noundef nonnull align 8 dereferenceable(148) %1)
  %8 = tail call noundef ptr @_ZNK14CMolecularGrid15getCoordinatesZEv(ptr noundef nonnull align 8 dereferenceable(148) %1)
  %9 = load double, ptr %6, align 8, !tbaa !5
  %10 = load double, ptr %7, align 8, !tbaa !5
  %11 = load double, ptr %8, align 8, !tbaa !5
  %wide.trip.count = zext nneg i32 %3 to i64
  br label %12

12:                                               ; preds = %5, %12
  %indvars.iv = phi i64 [ 0, %5 ], [ %indvars.iv.next, %12 ]
  %.04674 = phi double [ %9, %5 ], [ %.1, %12 ]
  %.04773 = phi double [ %10, %5 ], [ %.148, %12 ]
  %.05072 = phi double [ %11, %5 ], [ %.151, %12 ]
  %.05371 = phi double [ %9, %5 ], [ %.154, %12 ]
  %.05670 = phi double [ %11, %5 ], [ %.157, %12 ]
  %.05969 = phi double [ %10, %5 ], [ %.160, %12 ]
  %13 = getelementptr inbounds double, ptr %6, i64 %indvars.iv
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = fcmp ogt double %.04674, %14
  %.1 = select i1 %15, double %14, double %.04674
  %16 = getelementptr inbounds double, ptr %7, i64 %indvars.iv
  %17 = load double, ptr %16, align 8, !tbaa !5
  %18 = fcmp ogt double %.04773, %17
  %.148 = select i1 %18, double %17, double %.04773
  %19 = getelementptr inbounds double, ptr %8, i64 %indvars.iv
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = fcmp ogt double %.05072, %20
  %.151 = select i1 %21, double %20, double %.05072
  %22 = fcmp olt double %.05371, %14
  %.154 = select i1 %22, double %14, double %.05371
  %23 = fcmp olt double %.05969, %17
  %.160 = select i1 %23, double %17, double %.05969
  %24 = fcmp olt double %.05670, %20
  %.157 = select i1 %24, double %20, double %.05670
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %12, !llvm.loop !9

.loopexit:                                        ; preds = %12, %2
  %.261 = phi double [ 0.000000e+00, %2 ], [ %.160, %12 ]
  %.258 = phi double [ 0.000000e+00, %2 ], [ %.157, %12 ]
  %.255 = phi double [ 0.000000e+00, %2 ], [ %.154, %12 ]
  %.252 = phi double [ 0.000000e+00, %2 ], [ %.151, %12 ]
  %.249 = phi double [ 0.000000e+00, %2 ], [ %.148, %12 ]
  %.2 = phi double [ 0.000000e+00, %2 ], [ %.1, %12 ]
  store double %.2, ptr %0, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  store double %.249, ptr %25, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 16
  store double %.252, ptr %26, align 8, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %0, i64 24
  store double %.255, ptr %27, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %0, i64 32
  store double %.261, ptr %28, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %0, i64 40
  store double %.258, ptr %29, align 8, !tbaa !5
  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 = !{!"double", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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