; LLVM IR from VeloxChem/VeloxChem :: src/dft_func (DftSubMatrix)

; 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"

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(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

declare noundef i32 @_ZNK12CDenseMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(32)) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9dftsubmat29distributeSubMatrixToKohnShamER17CAOKohnShamMatrixRK12CDenseMatrixRKSt6vectorIiSaIiEE(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %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 ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call noundef i32 @_ZNK17CAOKohnShamMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(48) %16)
  store i32 %17, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %18) #4
  %20 = trunc i64 %19 to i32
  store i32 %20, ptr %8, align 4, !tbaa !9
  %21 = load i32, ptr %8, align 4, !tbaa !9
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = icmp sle i32 %21, %22
  br i1 %23, label %24, label %78

24:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %25

25:                                               ; preds = %74, %24
  %26 = load i32, ptr %9, align 4, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = call noundef i32 @_ZNK12CDenseMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(32) %27)
  %29 = icmp slt i32 %26, %28
  br i1 %29, label %31, label %30

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

31:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %32, i64 noundef %34) #4
  %36 = load i32, ptr %35, align 4, !tbaa !9
  store i32 %36, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = call noundef ptr @_ZN17CAOKohnShamMatrix11alphaValuesEv(ptr noundef nonnull align 8 dereferenceable(48) %37)
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = load i32, ptr %7, align 4, !tbaa !9
  %41 = mul nsw i32 %39, %40
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds double, ptr %38, i64 %42
  store ptr %43, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = call noundef ptr @_ZNK12CDenseMatrix3rowEi(ptr noundef nonnull align 8 dereferenceable(32) %44, i32 noundef %45)
  store ptr %46, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !9
  br label %47

47:                                               ; preds = %70, %31
  %48 = load i32, ptr %14, align 4, !tbaa !9
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = call noundef i32 @_ZNK12CDenseMatrix18getNumberOfColumnsEv(ptr noundef nonnull align 8 dereferenceable(32) %49)
  %51 = icmp slt i32 %48, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %47
  store i32 5, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %73

53:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = load i32, ptr %14, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %54, i64 noundef %56) #4
  %58 = load i32, ptr %57, align 4, !tbaa !9
  store i32 %58, ptr %15, align 4, !tbaa !9
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load i32, ptr %14, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds double, ptr %59, i64 %61
  %63 = load double, ptr %62, align 8, !tbaa !11
  %64 = load ptr, ptr %12, align 8, !tbaa !5
  %65 = load i32, ptr %15, align 4, !tbaa !9
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds double, ptr %64, i64 %66
  %68 = load double, ptr %67, align 8, !tbaa !11
  %69 = fadd double %68, %63
  store double %69, ptr %67, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %70

70:                                               ; preds = %53
  %71 = load i32, ptr %14, align 4, !tbaa !9
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %14, align 4, !tbaa !9
  br label %47, !llvm.loop !13

73:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %9, align 4, !tbaa !9
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %9, align 4, !tbaa !9
  br label %25, !llvm.loop !15

77:                                               ; preds = %30
  br label %78

78:                                               ; preds = %77, %3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret void
}

declare noundef i32 @_ZNK17CAOKohnShamMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(48)) #2

declare noundef ptr @_ZN17CAOKohnShamMatrix11alphaValuesEv(ptr noundef nonnull align 8 dereferenceable(48)) #2

declare noundef ptr @_ZNK12CDenseMatrix3rowEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #2

declare noundef i32 @_ZNK12CDenseMatrix18getNumberOfColumnsEv(ptr noundef nonnull align 8 dereferenceable(32)) #2

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 = { "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 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 = { 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 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

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

declare noundef i32 @_ZNK12CDenseMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN9dftsubmat29distributeSubMatrixToKohnShamER17CAOKohnShamMatrixRK12CDenseMatrixRKSt6vectorIiSaIiEE(ptr noundef nonnull align 8 dereferenceable(48) %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull align 8 dereferenceable(24) %2) local_unnamed_addr #2 {
  %4 = tail call noundef i32 @_ZNK17CAOKohnShamMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %5 = tail call noundef i64 @_ZNKSt6vectorIiSaIiEE4sizeEv(ptr noundef nonnull align 8 dereferenceable(24) %2) #3
  %6 = trunc i64 %5 to i32
  %.not = icmp slt i32 %4, %6
  br i1 %.not, label %.loopexit, label %.preheader

.preheader:                                       ; preds = %3
  %7 = tail call noundef i32 @_ZNK12CDenseMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph26, label %.loopexit

.lr.ph26:                                         ; preds = %.preheader, %._crit_edge
  %indvars.iv28 = phi i64 [ %indvars.iv.next29, %._crit_edge ], [ 0, %.preheader ]
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %indvars.iv28) #3
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = tail call noundef ptr @_ZN17CAOKohnShamMatrix11alphaValuesEv(ptr noundef nonnull align 8 dereferenceable(48) %0)
  %12 = mul nsw i32 %10, %4
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds double, ptr %11, i64 %13
  %15 = trunc nuw nsw i64 %indvars.iv28 to i32
  %16 = tail call noundef ptr @_ZNK12CDenseMatrix3rowEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %15)
  %17 = tail call noundef i32 @_ZNK12CDenseMatrix18getNumberOfColumnsEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %18 = icmp sgt i32 %17, 0
  br i1 %18, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph26
  %indvars.iv.next29 = add nuw nsw i64 %indvars.iv28, 1
  %19 = tail call noundef i32 @_ZNK12CDenseMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %20 = sext i32 %19 to i64
  %21 = icmp slt i64 %indvars.iv.next29, %20
  br i1 %21, label %.lr.ph26, label %.loopexit, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph26, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph26 ]
  %22 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %2, i64 noundef %indvars.iv) #3
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = getelementptr inbounds double, ptr %16, i64 %indvars.iv
  %25 = load double, ptr %24, align 8, !tbaa !11
  %26 = sext i32 %23 to i64
  %27 = getelementptr inbounds double, ptr %14, i64 %26
  %28 = load double, ptr %27, align 8, !tbaa !11
  %29 = fadd double %25, %28
  store double %29, ptr %27, align 8, !tbaa !11
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = tail call noundef i32 @_ZNK12CDenseMatrix18getNumberOfColumnsEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %31 = sext i32 %30 to i64
  %32 = icmp slt i64 %indvars.iv.next, %31
  br i1 %32, label %.lr.ph, label %._crit_edge, !llvm.loop !13

.loopexit:                                        ; preds = %._crit_edge, %.preheader, %3
  ret void
}

declare noundef i32 @_ZNK17CAOKohnShamMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1

declare noundef ptr @_ZN17CAOKohnShamMatrix11alphaValuesEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #1

declare noundef ptr @_ZNK12CDenseMatrix3rowEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) local_unnamed_addr #1

declare noundef i32 @_ZNK12CDenseMatrix18getNumberOfColumnsEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

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 = { "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 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 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !10}


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