; 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

declare noundef ptr @_ZN12CDenseMatrix3rowEi(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef) #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

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

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

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

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

29:                                               ; preds = %24
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %72

30:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = load i32, ptr %10, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %31, i64 noundef %33) #4
  %35 = load i32, ptr %34, align 4, !tbaa !9
  store i32 %35, ptr %12, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load i32, ptr %12, align 4, !tbaa !9
  %38 = call noundef ptr @_ZN12CDenseMatrix3rowEi(ptr noundef nonnull align 8 dereferenceable(32) %36, i32 noundef %37)
  store ptr %38, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = call noundef ptr @_ZNK12CDenseMatrix3rowEi(ptr noundef nonnull align 8 dereferenceable(32) %39, i32 noundef %40)
  store ptr %41, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %42

42:                                               ; preds = %65, %30
  %43 = load i32, ptr %15, align 4, !tbaa !9
  %44 = load ptr, ptr %6, align 8, !tbaa !5
  %45 = call noundef i32 @_ZNK12CDenseMatrix18getNumberOfColumnsEv(ptr noundef nonnull align 8 dereferenceable(32) %44)
  %46 = icmp slt i32 %43, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %42
  store i32 5, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %68

48:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = load i32, ptr %15, align 4, !tbaa !9
  %51 = sext i32 %50 to i64
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNKSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %49, i64 noundef %51) #4
  %53 = load i32, ptr %52, align 4, !tbaa !9
  store i32 %53, ptr %16, align 4, !tbaa !9
  %54 = load ptr, ptr %14, align 8, !tbaa !5
  %55 = load i32, ptr %15, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds double, ptr %54, i64 %56
  %58 = load double, ptr %57, align 8, !tbaa !11
  %59 = load ptr, ptr %13, align 8, !tbaa !5
  %60 = load i32, ptr %16, 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 = fadd double %63, %58
  store double %64, ptr %62, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %65

65:                                               ; preds = %48
  %66 = load i32, ptr %15, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %15, align 4, !tbaa !9
  br label %42, !llvm.loop !13

68:                                               ; preds = %47
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %69

69:                                               ; preds = %68
  %70 = load i32, ptr %10, align 4, !tbaa !9
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %10, align 4, !tbaa !9
  br label %24, !llvm.loop !15

72:                                               ; preds = %29
  br label %73

73:                                               ; preds = %72, %4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  ret void
}

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

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

; 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

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

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

.preheader:                                       ; preds = %4
  %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.ph23, label %.loopexit

.lr.ph23:                                         ; preds = %.preheader, %._crit_edge
  %indvars.iv25 = phi i64 [ %indvars.iv.next26, %._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.iv25) #3
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = tail call noundef ptr @_ZN12CDenseMatrix3rowEi(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %10)
  %12 = trunc nuw nsw i64 %indvars.iv25 to i32
  %13 = tail call noundef ptr @_ZNK12CDenseMatrix3rowEi(ptr noundef nonnull align 8 dereferenceable(32) %1, i32 noundef %12)
  %14 = tail call noundef i32 @_ZNK12CDenseMatrix18getNumberOfColumnsEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %15 = icmp sgt i32 %14, 0
  br i1 %15, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph23
  %indvars.iv.next26 = add nuw nsw i64 %indvars.iv25, 1
  %16 = tail call noundef i32 @_ZNK12CDenseMatrix15getNumberOfRowsEv(ptr noundef nonnull align 8 dereferenceable(32) %1)
  %17 = sext i32 %16 to i64
  %18 = icmp slt i64 %indvars.iv.next26, %17
  br i1 %18, label %.lr.ph23, label %.loopexit, !llvm.loop !9

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

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

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