; LLVM IR from VeloxChem/VeloxChem :: src/dft_func/AOKohnShamMatrix.ll (ZNK17CAOKohnShamMatrixeqERKS_)

; 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.CAOKohnShamMatrix = type { %"class.std::vector", i8, double, double }
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<CDenseMatrix, std::allocator<CDenseMatrix>>::_Vector_impl" }
%"struct.std::_Vector_base<CDenseMatrix, std::allocator<CDenseMatrix>>::_Vector_impl" = type { %"struct.std::_Vector_base<CDenseMatrix, std::allocator<CDenseMatrix>>::_Vector_impl_data" }
%"struct.std::_Vector_base<CDenseMatrix, std::allocator<CDenseMatrix>>::_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: 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 noundef zeroext i1 @_ZNK17CAOKohnShamMatrixeqERKS_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(48) %1) #1 align 2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %8, i32 0, i32 0
  %10 = call noundef i64 @_ZNKSt6vectorI12CDenseMatrixSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %9) #5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %11, i32 0, i32 0
  %13 = call noundef i64 @_ZNKSt6vectorI12CDenseMatrixSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %12) #5
  %14 = icmp ne i64 %10, %13
  br i1 %14, label %15, label %16

15:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  br label %72

16:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %17

17:                                               ; preds = %34, %16
  %18 = load i64, ptr %6, align 8, !tbaa !9
  %19 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %8, i32 0, i32 0
  %20 = call noundef i64 @_ZNKSt6vectorI12CDenseMatrixSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %19) #5
  %21 = icmp ult i64 %18, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  store i32 2, ptr %7, align 4
  br label %37

23:                                               ; preds = %17
  %24 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %8, i32 0, i32 0
  %25 = load i64, ptr %6, align 8, !tbaa !9
  %26 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNKSt6vectorI12CDenseMatrixSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %24, i64 noundef %25) #5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %27, i32 0, i32 0
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNKSt6vectorI12CDenseMatrixSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %28, i64 noundef %29) #5
  %31 = call noundef zeroext i1 @_ZNK12CDenseMatrixneERKS_(ptr noundef nonnull align 8 dereferenceable(32) %26, ptr noundef nonnull align 8 dereferenceable(32) %30)
  br i1 %31, label %32, label %33

32:                                               ; preds = %23
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %37

33:                                               ; preds = %23
  br label %34

34:                                               ; preds = %33
  %35 = load i64, ptr %6, align 8, !tbaa !9
  %36 = add i64 %35, 1
  store i64 %36, ptr %6, align 8, !tbaa !9
  br label %17, !llvm.loop !11

37:                                               ; preds = %32, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %38 = load i32, ptr %7, align 4
  switch i32 %38, label %74 [
    i32 2, label %39
    i32 1, label %72
  ]

39:                                               ; preds = %37
  %40 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %8, i32 0, i32 1
  %41 = load i8, ptr %40, align 8, !tbaa !13, !range !21, !noundef !22
  %42 = trunc i8 %41 to i1
  %43 = zext i1 %42 to i32
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %44, i32 0, i32 1
  %46 = load i8, ptr %45, align 8, !tbaa !13, !range !21, !noundef !22
  %47 = trunc i8 %46 to i1
  %48 = zext i1 %47 to i32
  %49 = icmp ne i32 %43, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %39
  store i1 false, ptr %3, align 1
  br label %72

51:                                               ; preds = %39
  %52 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %8, i32 0, i32 2
  %53 = load double, ptr %52, align 8, !tbaa !23
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %54, i32 0, i32 2
  %56 = load double, ptr %55, align 8, !tbaa !23
  %57 = fsub double %53, %56
  %58 = call double @llvm.fabs.f64(double %57)
  %59 = fcmp ogt double %58, 1.000000e-13
  br i1 %59, label %60, label %61

60:                                               ; preds = %51
  store i1 false, ptr %3, align 1
  br label %72

61:                                               ; preds = %51
  %62 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %8, i32 0, i32 3
  %63 = load double, ptr %62, align 8, !tbaa !24
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %class.CAOKohnShamMatrix, ptr %64, i32 0, i32 3
  %66 = load double, ptr %65, align 8, !tbaa !24
  %67 = fsub double %63, %66
  %68 = call double @llvm.fabs.f64(double %67)
  %69 = fcmp ogt double %68, 1.000000e-13
  br i1 %69, label %70, label %71

70:                                               ; preds = %61
  store i1 false, ptr %3, align 1
  br label %72

71:                                               ; preds = %61
  store i1 true, ptr %3, align 1
  br label %72

72:                                               ; preds = %71, %70, %60, %50, %37, %15
  %73 = load i1, ptr %3, align 1
  ret i1 %73

74:                                               ; preds = %37
  unreachable
}

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

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

declare noundef zeroext i1 @_ZNK12CDenseMatrixneERKS_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #4

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 = { 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 #3 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !19, i64 24}
!14 = !{!"_ZTS17CAOKohnShamMatrix", !15, i64 0, !19, i64 24, !20, i64 32, !20, i64 40}
!15 = !{!"_ZTSSt6vectorI12CDenseMatrixSaIS0_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseI12CDenseMatrixSaIS0_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseI12CDenseMatrixSaIS0_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseI12CDenseMatrixSaIS0_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!"bool", !7, i64 0}
!20 = !{!"double", !7, i64 0}
!21 = !{i8 0, i8 2}
!22 = !{}
!23 = !{!14, !20, i64 32}
!24 = !{!14, !20, i64 40}


; 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 uwtable
define dso_local noundef zeroext i1 @_ZNK17CAOKohnShamMatrixeqERKS_(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(48) %1) local_unnamed_addr #0 align 2 {
  %3 = tail call noundef i64 @_ZNKSt6vectorI12CDenseMatrixSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %4 = tail call noundef i64 @_ZNKSt6vectorI12CDenseMatrixSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %1) #4
  %.not = icmp eq i64 %3, %4
  br i1 %.not, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2
  %5 = tail call noundef i64 @_ZNKSt6vectorI12CDenseMatrixSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %.not18 = icmp eq i64 %5, 0
  br i1 %.not18, label %._crit_edge, label %.lr.ph

6:                                                ; preds = %.lr.ph
  %7 = add nuw i64 %.01117, 1
  %8 = tail call noundef i64 @_ZNKSt6vectorI12CDenseMatrixSaIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %0) #4
  %9 = icmp ult i64 %7, %8
  br i1 %9, label %.lr.ph, label %._crit_edge, !llvm.loop !5

.lr.ph:                                           ; preds = %.preheader, %6
  %.01117 = phi i64 [ %7, %6 ], [ 0, %.preheader ]
  %10 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNKSt6vectorI12CDenseMatrixSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %.01117) #4
  %11 = tail call noundef nonnull align 8 dereferenceable(32) ptr @_ZNKSt6vectorI12CDenseMatrixSaIS0_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %1, i64 noundef %.01117) #4
  %12 = tail call noundef zeroext i1 @_ZNK12CDenseMatrixneERKS_(ptr noundef nonnull align 8 dereferenceable(32) %10, ptr noundef nonnull align 8 dereferenceable(32) %11)
  br i1 %12, label %.loopexit, label %6

._crit_edge:                                      ; preds = %6, %.preheader
  %13 = getelementptr inbounds i8, ptr %0, i64 24
  %14 = load i8, ptr %13, align 8, !tbaa !7, !range !18, !noundef !19
  %15 = getelementptr inbounds i8, ptr %1, i64 24
  %16 = load i8, ptr %15, align 8, !tbaa !7, !range !18, !noundef !19
  %.not13 = icmp eq i8 %14, %16
  br i1 %.not13, label %17, label %.loopexit

17:                                               ; preds = %._crit_edge
  %18 = getelementptr inbounds i8, ptr %0, i64 32
  %19 = load double, ptr %18, align 8, !tbaa !20
  %20 = getelementptr inbounds i8, ptr %1, i64 32
  %21 = load double, ptr %20, align 8, !tbaa !20
  %22 = fsub double %19, %21
  %23 = tail call double @llvm.fabs.f64(double %22)
  %24 = fcmp ogt double %23, 1.000000e-13
  br i1 %24, label %.loopexit, label %25

25:                                               ; preds = %17
  %26 = getelementptr inbounds i8, ptr %0, i64 40
  %27 = load double, ptr %26, align 8, !tbaa !21
  %28 = getelementptr inbounds i8, ptr %1, i64 40
  %29 = load double, ptr %28, align 8, !tbaa !21
  %30 = fsub double %27, %29
  %31 = tail call double @llvm.fabs.f64(double %30)
  %32 = fcmp ule double %31, 1.000000e-13
  br label %.loopexit

.loopexit:                                        ; preds = %.lr.ph, %25, %17, %._crit_edge, %2
  %.1 = phi i1 [ false, %2 ], [ false, %._crit_edge ], [ false, %17 ], [ %32, %25 ], [ false, %.lr.ph ]
  ret i1 %.1
}

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

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

declare noundef zeroext i1 @_ZNK12CDenseMatrixneERKS_(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fabs.f64(double) #3

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" }
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 = { "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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !16, i64 24}
!8 = !{!"_ZTS17CAOKohnShamMatrix", !9, i64 0, !16, i64 24, !17, i64 32, !17, i64 40}
!9 = !{!"_ZTSSt6vectorI12CDenseMatrixSaIS0_EE", !10, i64 0}
!10 = !{!"_ZTSSt12_Vector_baseI12CDenseMatrixSaIS0_EE", !11, i64 0}
!11 = !{!"_ZTSNSt12_Vector_baseI12CDenseMatrixSaIS0_EE12_Vector_implE", !12, i64 0}
!12 = !{!"_ZTSNSt12_Vector_baseI12CDenseMatrixSaIS0_EE17_Vector_impl_dataE", !13, i64 0, !13, i64 8, !13, i64 16}
!13 = !{!"any pointer", !14, i64 0}
!14 = !{!"omnipotent char", !15, i64 0}
!15 = !{!"Simple C++ TBAA"}
!16 = !{!"bool", !14, i64 0}
!17 = !{!"double", !14, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = !{!8, !17, i64 32}
!21 = !{!8, !17, i64 40}


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