; LLVM IR from dartsim/dart :: dart/external/odelcpsolver/fastdot.ll (ZN4dart8external3ode5_dDotEPKdS3_i)

; 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: mustprogress nounwind uwtable
define dso_local noundef double @_ZN4dart8external3ode5_dDotEPKdS3_i(ptr noundef %0, ptr noundef %1, i32 noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca double, align 8
  %13 = alloca double, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  store double 0.000000e+00, ptr %13, align 8, !tbaa !11
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = sub nsw i32 %14, 2
  store i32 %15, ptr %6, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %19, %3
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = icmp sge i32 %17, 0
  br i1 %18, label %19, label %50

19:                                               ; preds = %16
  %20 = load ptr, ptr %4, align 8, !tbaa !5
  %21 = getelementptr inbounds double, ptr %20, i64 0
  %22 = load double, ptr %21, align 8, !tbaa !11
  store double %22, ptr %7, align 8, !tbaa !11
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds double, ptr %23, i64 0
  %25 = load double, ptr %24, align 8, !tbaa !11
  store double %25, ptr %8, align 8, !tbaa !11
  %26 = load double, ptr %7, align 8, !tbaa !11
  %27 = load double, ptr %8, align 8, !tbaa !11
  %28 = fmul double %26, %27
  store double %28, ptr %9, align 8, !tbaa !11
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds double, ptr %29, i64 1
  %31 = load double, ptr %30, align 8, !tbaa !11
  store double %31, ptr %10, align 8, !tbaa !11
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds double, ptr %32, i64 1
  %34 = load double, ptr %33, align 8, !tbaa !11
  store double %34, ptr %11, align 8, !tbaa !11
  %35 = load double, ptr %10, align 8, !tbaa !11
  %36 = load double, ptr %11, align 8, !tbaa !11
  %37 = fmul double %35, %36
  store double %37, ptr %12, align 8, !tbaa !11
  %38 = load double, ptr %9, align 8, !tbaa !11
  %39 = load double, ptr %13, align 8, !tbaa !11
  %40 = fadd double %39, %38
  store double %40, ptr %13, align 8, !tbaa !11
  %41 = load double, ptr %12, align 8, !tbaa !11
  %42 = load double, ptr %13, align 8, !tbaa !11
  %43 = fadd double %42, %41
  store double %43, ptr %13, align 8, !tbaa !11
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds double, ptr %44, i64 2
  store ptr %45, ptr %4, align 8, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds double, ptr %46, i64 2
  store ptr %47, ptr %5, align 8, !tbaa !5
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = sub nsw i32 %48, 2
  store i32 %49, ptr %6, align 4, !tbaa !9
  br label %16, !llvm.loop !13

50:                                               ; preds = %16
  %51 = load i32, ptr %6, align 4, !tbaa !9
  %52 = add nsw i32 %51, 2
  store i32 %52, ptr %6, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %56, %50
  %54 = load i32, ptr %6, align 4, !tbaa !9
  %55 = icmp sgt i32 %54, 0
  br i1 %55, label %56, label %69

56:                                               ; preds = %53
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load double, ptr %57, align 8, !tbaa !11
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = load double, ptr %59, align 8, !tbaa !11
  %61 = load double, ptr %13, align 8, !tbaa !11
  %62 = call double @llvm.fmuladd.f64(double %58, double %60, double %61)
  store double %62, ptr %13, align 8, !tbaa !11
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds double, ptr %63, i32 1
  store ptr %64, ptr %4, align 8, !tbaa !5
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds double, ptr %65, i32 1
  store ptr %66, ptr %5, align 8, !tbaa !5
  %67 = load i32, ptr %6, align 4, !tbaa !9
  %68 = add nsw i32 %67, -1
  store i32 %68, ptr %6, align 4, !tbaa !9
  br label %53, !llvm.loop !15

69:                                               ; preds = %53
  %70 = load double, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret double %70
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #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) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"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 nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local noundef double @_ZN4dart8external3ode5_dDotEPKdS3_i(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, i32 noundef %2) local_unnamed_addr #0 {
  %.02931 = add i32 %2, -2
  %4 = icmp sgt i32 %2, 1
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %3
  %5 = and i32 %.02931, -2
  %6 = and i32 %.02931, 2
  %lcmp.mod.not.not = icmp eq i32 %6, 0
  br i1 %lcmp.mod.not.not, label %.lr.ph.prol, label %.lr.ph.prol.loopexit

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader
  %7 = load double, ptr %0, align 8, !tbaa !5
  %8 = load double, ptr %1, align 8, !tbaa !5
  %9 = fmul double %7, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = fmul double %11, %13
  %15 = fadd double %9, 0.000000e+00
  %16 = fadd double %15, %14
  %17 = getelementptr inbounds i8, ptr %0, i64 16
  %18 = getelementptr inbounds i8, ptr %1, i64 16
  %.029.prol = add nsw i32 %2, -4
  br label %.lr.ph.prol.loopexit

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader
  %.02935.unr = phi i32 [ %.02931, %.lr.ph.preheader ], [ %.029.prol, %.lr.ph.prol ]
  %.034.unr = phi double [ 0.000000e+00, %.lr.ph.preheader ], [ %16, %.lr.ph.prol ]
  %.02533.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %17, %.lr.ph.prol ]
  %.02732.unr = phi ptr [ %1, %.lr.ph.preheader ], [ %18, %.lr.ph.prol ]
  %.lcssa54.unr = phi double [ poison, %.lr.ph.preheader ], [ %16, %.lr.ph.prol ]
  %.lcssa53.unr = phi ptr [ poison, %.lr.ph.preheader ], [ %17, %.lr.ph.prol ]
  %.lcssa.unr = phi ptr [ poison, %.lr.ph.preheader ], [ %18, %.lr.ph.prol ]
  %19 = icmp ult i32 %.02931, 2
  br i1 %19, label %._crit_edge.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.02935 = phi i32 [ %.029.1, %.lr.ph ], [ %.02935.unr, %.lr.ph.prol.loopexit ]
  %.034 = phi double [ %41, %.lr.ph ], [ %.034.unr, %.lr.ph.prol.loopexit ]
  %.02533 = phi ptr [ %42, %.lr.ph ], [ %.02533.unr, %.lr.ph.prol.loopexit ]
  %.02732 = phi ptr [ %43, %.lr.ph ], [ %.02732.unr, %.lr.ph.prol.loopexit ]
  %20 = load double, ptr %.02533, align 8, !tbaa !5
  %21 = load double, ptr %.02732, align 8, !tbaa !5
  %22 = fmul double %20, %21
  %23 = getelementptr inbounds i8, ptr %.02533, i64 8
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %.02732, i64 8
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = fmul double %24, %26
  %28 = fadd double %.034, %22
  %29 = fadd double %28, %27
  %30 = getelementptr inbounds i8, ptr %.02533, i64 16
  %31 = getelementptr inbounds i8, ptr %.02732, i64 16
  %32 = load double, ptr %30, align 8, !tbaa !5
  %33 = load double, ptr %31, align 8, !tbaa !5
  %34 = fmul double %32, %33
  %35 = getelementptr inbounds i8, ptr %.02533, i64 24
  %36 = load double, ptr %35, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %.02732, i64 24
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = fmul double %36, %38
  %40 = fadd double %29, %34
  %41 = fadd double %40, %39
  %42 = getelementptr inbounds i8, ptr %.02533, i64 32
  %43 = getelementptr inbounds i8, ptr %.02732, i64 32
  %.029.1 = add nsw i32 %.02935, -4
  %44 = and i32 %.02935, -2
  %.not = icmp eq i32 %44, 2
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %.lr.ph, %.lr.ph.prol.loopexit
  %.lcssa54 = phi double [ %.lcssa54.unr, %.lr.ph.prol.loopexit ], [ %41, %.lr.ph ]
  %.lcssa53 = phi ptr [ %.lcssa53.unr, %.lr.ph.prol.loopexit ], [ %42, %.lr.ph ]
  %.lcssa = phi ptr [ %.lcssa.unr, %.lr.ph.prol.loopexit ], [ %43, %.lr.ph ]
  %45 = add nsw i32 %2, -4
  %46 = sub i32 %45, %5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %.027.lcssa = phi ptr [ %1, %3 ], [ %.lcssa, %._crit_edge.loopexit ]
  %.025.lcssa = phi ptr [ %0, %3 ], [ %.lcssa53, %._crit_edge.loopexit ]
  %.0.lcssa = phi double [ 0.000000e+00, %3 ], [ %.lcssa54, %._crit_edge.loopexit ]
  %.029.lcssa = phi i32 [ %.02931, %3 ], [ %46, %._crit_edge.loopexit ]
  %47 = icmp eq i32 %.029.lcssa, -1
  br i1 %47, label %.lr.ph43, label %51

.lr.ph43:                                         ; preds = %._crit_edge
  %48 = load double, ptr %.025.lcssa, align 8, !tbaa !5
  %49 = load double, ptr %.027.lcssa, align 8, !tbaa !5
  %50 = tail call double @llvm.fmuladd.f64(double %48, double %49, double %.0.lcssa)
  br label %51

51:                                               ; preds = %.lr.ph43, %._crit_edge
  %.1.lcssa = phi double [ %50, %.lr.ph43 ], [ %.0.lcssa, %._crit_edge ]
  ret double %.1.lcssa
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass