; LLVM IR from jmbr/libpme6 :: linear-algebra.ll (ZN5ewald21matrix_matrix_productEPKdS1_Pd)

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5ewald21matrix_matrix_productEPKdS1_Pd(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  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
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %11, i8 0, i64 72, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  store i64 0, ptr %7, align 8, !tbaa !9
  br label %12

12:                                               ; preds = %57, %3
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = icmp ult i64 %13, 3
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 2, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  br label %60

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

17:                                               ; preds = %53, %16
  %18 = load i64, ptr %9, align 8, !tbaa !9
  %19 = icmp ult i64 %18, 3
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  br label %56

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

22:                                               ; preds = %49, %21
  %23 = load i64, ptr %10, align 8, !tbaa !9
  %24 = icmp ult i64 %23, 3
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %52

26:                                               ; preds = %22
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = load i64, ptr %7, align 8, !tbaa !9
  %29 = mul i64 3, %28
  %30 = load i64, ptr %10, align 8, !tbaa !9
  %31 = add i64 %29, %30
  %32 = getelementptr inbounds double, ptr %27, i64 %31
  %33 = load double, ptr %32, align 8, !tbaa !11
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load i64, ptr %10, align 8, !tbaa !9
  %36 = mul i64 3, %35
  %37 = load i64, ptr %9, align 8, !tbaa !9
  %38 = add i64 %36, %37
  %39 = getelementptr inbounds double, ptr %34, i64 %38
  %40 = load double, ptr %39, align 8, !tbaa !11
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i64, ptr %7, align 8, !tbaa !9
  %43 = mul i64 3, %42
  %44 = load i64, ptr %9, align 8, !tbaa !9
  %45 = add i64 %43, %44
  %46 = getelementptr inbounds double, ptr %41, i64 %45
  %47 = load double, ptr %46, align 8, !tbaa !11
  %48 = call double @llvm.fmuladd.f64(double %33, double %40, double %47)
  store double %48, ptr %46, align 8, !tbaa !11
  br label %49

49:                                               ; preds = %26
  %50 = load i64, ptr %10, align 8, !tbaa !9
  %51 = add i64 %50, 1
  store i64 %51, ptr %10, align 8, !tbaa !9
  br label %22, !llvm.loop !13

52:                                               ; preds = %25
  br label %53

53:                                               ; preds = %52
  %54 = load i64, ptr %9, align 8, !tbaa !9
  %55 = add i64 %54, 1
  store i64 %55, ptr %9, align 8, !tbaa !9
  br label %17, !llvm.loop !15

56:                                               ; preds = %20
  br label %57

57:                                               ; preds = %56
  %58 = load i64, ptr %7, align 8, !tbaa !9
  %59 = add i64 %58, 1
  store i64 %59, ptr %7, align 8, !tbaa !9
  br label %12, !llvm.loop !16

60:                                               ; preds = %15
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 #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 = !{!"long", !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}
!16 = distinct !{!16, !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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN5ewald21matrix_matrix_productEPKdS1_Pd(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef %2) local_unnamed_addr #2 {
.preheader17:
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(72) %2, i8 0, i64 72, i1 false)
  %3 = load double, ptr %0, align 8, !tbaa !5
  %4 = load double, ptr %1, align 8, !tbaa !5
  %5 = tail call double @llvm.fmuladd.f64(double %3, double %4, double 0.000000e+00)
  store double %5, ptr %2, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load double, ptr %6, align 8, !tbaa !5
  %gep.1 = getelementptr inbounds i8, ptr %1, i64 24
  %8 = load double, ptr %gep.1, align 8, !tbaa !5
  %9 = tail call double @llvm.fmuladd.f64(double %7, double %8, double %5)
  store double %9, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = load double, ptr %10, align 8, !tbaa !5
  %gep.2 = getelementptr inbounds i8, ptr %1, i64 48
  %12 = load double, ptr %gep.2, align 8, !tbaa !5
  %13 = tail call double @llvm.fmuladd.f64(double %11, double %12, double %9)
  store double %13, ptr %2, align 8, !tbaa !5
  %invariant.gep.1 = getelementptr inbounds i8, ptr %1, i64 8
  %14 = getelementptr inbounds i8, ptr %2, i64 8
  %15 = load double, ptr %0, align 8, !tbaa !5
  %16 = load double, ptr %invariant.gep.1, align 8, !tbaa !5
  %17 = tail call double @llvm.fmuladd.f64(double %15, double %16, double 0.000000e+00)
  store double %17, ptr %14, align 8, !tbaa !5
  %18 = load double, ptr %6, align 8, !tbaa !5
  %gep.1.1 = getelementptr inbounds i8, ptr %1, i64 32
  %19 = load double, ptr %gep.1.1, align 8, !tbaa !5
  %20 = tail call double @llvm.fmuladd.f64(double %18, double %19, double %17)
  store double %20, ptr %14, align 8, !tbaa !5
  %21 = load double, ptr %10, align 8, !tbaa !5
  %gep.2.1 = getelementptr inbounds i8, ptr %1, i64 56
  %22 = load double, ptr %gep.2.1, align 8, !tbaa !5
  %23 = tail call double @llvm.fmuladd.f64(double %21, double %22, double %20)
  store double %23, ptr %14, align 8, !tbaa !5
  %invariant.gep.2 = getelementptr inbounds i8, ptr %1, i64 16
  %24 = getelementptr inbounds i8, ptr %2, i64 16
  %25 = load double, ptr %0, align 8, !tbaa !5
  %26 = load double, ptr %invariant.gep.2, align 8, !tbaa !5
  %27 = tail call double @llvm.fmuladd.f64(double %25, double %26, double 0.000000e+00)
  store double %27, ptr %24, align 8, !tbaa !5
  %28 = load double, ptr %6, align 8, !tbaa !5
  %gep.1.2 = getelementptr inbounds i8, ptr %1, i64 40
  %29 = load double, ptr %gep.1.2, align 8, !tbaa !5
  %30 = tail call double @llvm.fmuladd.f64(double %28, double %29, double %27)
  store double %30, ptr %24, align 8, !tbaa !5
  %31 = load double, ptr %10, align 8, !tbaa !5
  %gep.2.2 = getelementptr inbounds i8, ptr %1, i64 64
  %32 = load double, ptr %gep.2.2, align 8, !tbaa !5
  %33 = tail call double @llvm.fmuladd.f64(double %31, double %32, double %30)
  store double %33, ptr %24, align 8, !tbaa !5
  %34 = getelementptr inbounds i8, ptr %0, i64 24
  %35 = getelementptr inbounds i8, ptr %2, i64 24
  %36 = load double, ptr %34, align 8, !tbaa !5
  %37 = load double, ptr %1, align 8, !tbaa !5
  %38 = tail call double @llvm.fmuladd.f64(double %36, double %37, double 0.000000e+00)
  store double %38, ptr %35, align 8, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %0, i64 32
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = load double, ptr %gep.1, align 8, !tbaa !5
  %42 = tail call double @llvm.fmuladd.f64(double %40, double %41, double %38)
  store double %42, ptr %35, align 8, !tbaa !5
  %43 = getelementptr inbounds i8, ptr %0, i64 40
  %44 = load double, ptr %43, align 8, !tbaa !5
  %45 = load double, ptr %gep.2, align 8, !tbaa !5
  %46 = tail call double @llvm.fmuladd.f64(double %44, double %45, double %42)
  store double %46, ptr %35, align 8, !tbaa !5
  %47 = getelementptr inbounds i8, ptr %2, i64 32
  %48 = load double, ptr %34, align 8, !tbaa !5
  %49 = load double, ptr %invariant.gep.1, align 8, !tbaa !5
  %50 = tail call double @llvm.fmuladd.f64(double %48, double %49, double 0.000000e+00)
  store double %50, ptr %47, align 8, !tbaa !5
  %51 = load double, ptr %39, align 8, !tbaa !5
  %52 = load double, ptr %gep.1.1, align 8, !tbaa !5
  %53 = tail call double @llvm.fmuladd.f64(double %51, double %52, double %50)
  store double %53, ptr %47, align 8, !tbaa !5
  %54 = load double, ptr %43, align 8, !tbaa !5
  %55 = load double, ptr %gep.2.1, align 8, !tbaa !5
  %56 = tail call double @llvm.fmuladd.f64(double %54, double %55, double %53)
  store double %56, ptr %47, align 8, !tbaa !5
  %57 = getelementptr inbounds i8, ptr %2, i64 40
  %58 = load double, ptr %34, align 8, !tbaa !5
  %59 = load double, ptr %invariant.gep.2, align 8, !tbaa !5
  %60 = tail call double @llvm.fmuladd.f64(double %58, double %59, double 0.000000e+00)
  store double %60, ptr %57, align 8, !tbaa !5
  %61 = load double, ptr %39, align 8, !tbaa !5
  %62 = load double, ptr %gep.1.2, align 8, !tbaa !5
  %63 = tail call double @llvm.fmuladd.f64(double %61, double %62, double %60)
  store double %63, ptr %57, align 8, !tbaa !5
  %64 = load double, ptr %43, align 8, !tbaa !5
  %65 = load double, ptr %gep.2.2, align 8, !tbaa !5
  %66 = tail call double @llvm.fmuladd.f64(double %64, double %65, double %63)
  store double %66, ptr %57, align 8, !tbaa !5
  %67 = getelementptr inbounds i8, ptr %0, i64 48
  %68 = getelementptr inbounds i8, ptr %2, i64 48
  %69 = load double, ptr %67, align 8, !tbaa !5
  %70 = load double, ptr %1, align 8, !tbaa !5
  %71 = tail call double @llvm.fmuladd.f64(double %69, double %70, double 0.000000e+00)
  store double %71, ptr %68, align 8, !tbaa !5
  %72 = getelementptr inbounds i8, ptr %0, i64 56
  %73 = load double, ptr %72, align 8, !tbaa !5
  %74 = load double, ptr %gep.1, align 8, !tbaa !5
  %75 = tail call double @llvm.fmuladd.f64(double %73, double %74, double %71)
  store double %75, ptr %68, align 8, !tbaa !5
  %76 = getelementptr inbounds i8, ptr %0, i64 64
  %77 = load double, ptr %76, align 8, !tbaa !5
  %78 = load double, ptr %gep.2, align 8, !tbaa !5
  %79 = tail call double @llvm.fmuladd.f64(double %77, double %78, double %75)
  store double %79, ptr %68, align 8, !tbaa !5
  %80 = getelementptr inbounds i8, ptr %2, i64 56
  %.promoted.1.2 = load double, ptr %80, align 8, !tbaa !5
  %81 = load double, ptr %67, align 8, !tbaa !5
  %82 = load double, ptr %invariant.gep.1, align 8, !tbaa !5
  %83 = tail call double @llvm.fmuladd.f64(double %81, double %82, double %.promoted.1.2)
  store double %83, ptr %80, align 8, !tbaa !5
  %84 = load double, ptr %72, align 8, !tbaa !5
  %85 = load double, ptr %gep.1.1, align 8, !tbaa !5
  %86 = tail call double @llvm.fmuladd.f64(double %84, double %85, double %83)
  store double %86, ptr %80, align 8, !tbaa !5
  %87 = load double, ptr %76, align 8, !tbaa !5
  %88 = load double, ptr %gep.2.1, align 8, !tbaa !5
  %89 = tail call double @llvm.fmuladd.f64(double %87, double %88, double %86)
  store double %89, ptr %80, align 8, !tbaa !5
  %90 = getelementptr inbounds i8, ptr %2, i64 64
  %.promoted.2.2 = load double, ptr %90, align 8, !tbaa !5
  %91 = load double, ptr %67, align 8, !tbaa !5
  %92 = load double, ptr %invariant.gep.2, align 8, !tbaa !5
  %93 = tail call double @llvm.fmuladd.f64(double %91, double %92, double %.promoted.2.2)
  store double %93, ptr %90, align 8, !tbaa !5
  %94 = load double, ptr %72, align 8, !tbaa !5
  %95 = load double, ptr %gep.1.2, align 8, !tbaa !5
  %96 = tail call double @llvm.fmuladd.f64(double %94, double %95, double %93)
  store double %96, ptr %90, align 8, !tbaa !5
  %97 = load double, ptr %76, align 8, !tbaa !5
  %98 = load double, ptr %gep.2.2, align 8, !tbaa !5
  %99 = tail call double @llvm.fmuladd.f64(double %97, double %98, double %96)
  store double %99, ptr %90, align 8, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) 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"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass