; LLVM IR from dartsim/dart :: dart/external/odelcpsolver/matrix.ll (ZN4dart8external3ode11_dMultiply0EPdPKdS4_iii)

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

@.str = external hidden unnamed_addr constant [24 x i8], align 1
@__FUNCTION__._ZN4dart8external3ode11_dMultiply0EPdPKdS4_iii = external hidden unnamed_addr constant [12 x i8], align 1

declare void @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef, ptr noundef, ...) #0

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dart8external3ode11_dMultiply0EPdPKdS4_iii(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca ptr, align 8
  %20 = alloca ptr, align 8
  %21 = alloca double, align 8
  %22 = alloca ptr, align 8
  %23 = alloca ptr, align 8
  %24 = alloca ptr, align 8
  store ptr %0, ptr %7, align 8, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !5
  store ptr %2, ptr %9, align 8, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !9
  store i32 %4, ptr %11, align 4, !tbaa !9
  store i32 %5, ptr %12, align 4, !tbaa !9
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = icmp ne ptr %25, null
  br i1 %26, label %27, label %42

27:                                               ; preds = %6
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %42

30:                                               ; preds = %27
  %31 = load ptr, ptr %9, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %42

33:                                               ; preds = %30
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = icmp sgt i32 %34, 0
  br i1 %35, label %36, label %42

36:                                               ; preds = %33
  %37 = load i32, ptr %11, align 4, !tbaa !9
  %38 = icmp sgt i32 %37, 0
  br i1 %38, label %39, label %42

39:                                               ; preds = %36
  %40 = load i32, ptr %12, align 4, !tbaa !9
  %41 = icmp sgt i32 %40, 0
  br i1 %41, label %43, label %42

42:                                               ; preds = %39, %36, %33, %30, %27, %6
  call void (i32, ptr, ...) @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef 2, ptr noundef @.str, ptr noundef @__FUNCTION__._ZN4dart8external3ode11_dMultiply0EPdPKdS4_iii)
  br label %43

43:                                               ; preds = %42, %39
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = icmp sgt i32 %44, 1
  br i1 %45, label %46, label %51

46:                                               ; preds = %43
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = sub nsw i32 %47, 1
  %49 = or i32 %48, 3
  %50 = add nsw i32 %49, 1
  br label %53

51:                                               ; preds = %43
  %52 = load i32, ptr %11, align 4, !tbaa !9
  br label %53

53:                                               ; preds = %51, %46
  %54 = phi i32 [ %50, %46 ], [ %52, %51 ]
  store i32 %54, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %55 = load i32, ptr %12, align 4, !tbaa !9
  %56 = icmp sgt i32 %55, 1
  br i1 %56, label %57, label %62

57:                                               ; preds = %53
  %58 = load i32, ptr %12, align 4, !tbaa !9
  %59 = sub nsw i32 %58, 1
  %60 = or i32 %59, 3
  %61 = add nsw i32 %60, 1
  br label %64

62:                                               ; preds = %53
  %63 = load i32, ptr %12, align 4, !tbaa !9
  br label %64

64:                                               ; preds = %62, %57
  %65 = phi i32 [ %61, %57 ], [ %63, %62 ]
  store i32 %65, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %66 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %66, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %67, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %68 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %68, ptr %17, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %118, %64
  %70 = load i32, ptr %17, align 4, !tbaa !9
  %71 = icmp ne i32 %70, 0
  br i1 %71, label %73, label %72

72:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br label %129

73:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #4
  %74 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %74, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #4
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %75, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load i32, ptr %12, align 4, !tbaa !9
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds double, ptr %76, i64 %78
  store ptr %79, ptr %20, align 8, !tbaa !5
  br label %80

80:                                               ; preds = %112, %73
  %81 = load ptr, ptr %19, align 8, !tbaa !5
  %82 = load ptr, ptr %20, align 8, !tbaa !5
  %83 = icmp ne ptr %81, %82
  br i1 %83, label %84, label %117

84:                                               ; preds = %80
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #4
  store double 0.000000e+00, ptr %21, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %22) #4
  %85 = load ptr, ptr %19, align 8, !tbaa !5
  store ptr %85, ptr %22, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %23) #4
  %86 = load ptr, ptr %16, align 8, !tbaa !5
  store ptr %86, ptr %23, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %24) #4
  %87 = load ptr, ptr %16, align 8, !tbaa !5
  %88 = load i32, ptr %11, align 4, !tbaa !9
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds double, ptr %87, i64 %89
  store ptr %90, ptr %24, align 8, !tbaa !5
  br label %91

91:                                               ; preds = %102, %84
  %92 = load ptr, ptr %23, align 8, !tbaa !5
  %93 = load ptr, ptr %24, align 8, !tbaa !5
  %94 = icmp ne ptr %92, %93
  br i1 %94, label %95, label %109

95:                                               ; preds = %91
  %96 = load ptr, ptr %23, align 8, !tbaa !5
  %97 = load double, ptr %96, align 8, !tbaa !11
  %98 = load ptr, ptr %22, align 8, !tbaa !5
  %99 = load double, ptr %98, align 8, !tbaa !11
  %100 = load double, ptr %21, align 8, !tbaa !11
  %101 = call double @llvm.fmuladd.f64(double %97, double %99, double %100)
  store double %101, ptr %21, align 8, !tbaa !11
  br label %102

102:                                              ; preds = %95
  %103 = load i32, ptr %14, align 4, !tbaa !9
  %104 = load ptr, ptr %22, align 8, !tbaa !5
  %105 = sext i32 %103 to i64
  %106 = getelementptr inbounds double, ptr %104, i64 %105
  store ptr %106, ptr %22, align 8, !tbaa !5
  %107 = load ptr, ptr %23, align 8, !tbaa !5
  %108 = getelementptr inbounds double, ptr %107, i32 1
  store ptr %108, ptr %23, align 8, !tbaa !5
  br label %91, !llvm.loop !13

109:                                              ; preds = %91
  %110 = load double, ptr %21, align 8, !tbaa !11
  %111 = load ptr, ptr %18, align 8, !tbaa !5
  store double %110, ptr %111, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %24) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #4
  br label %112

112:                                              ; preds = %109
  %113 = load ptr, ptr %18, align 8, !tbaa !5
  %114 = getelementptr inbounds double, ptr %113, i32 1
  store ptr %114, ptr %18, align 8, !tbaa !5
  %115 = load ptr, ptr %19, align 8, !tbaa !5
  %116 = getelementptr inbounds double, ptr %115, i32 1
  store ptr %116, ptr %19, align 8, !tbaa !5
  br label %80, !llvm.loop !15

117:                                              ; preds = %80
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #4
  br label %118

118:                                              ; preds = %117
  %119 = load i32, ptr %14, align 4, !tbaa !9
  %120 = load ptr, ptr %15, align 8, !tbaa !5
  %121 = sext i32 %119 to i64
  %122 = getelementptr inbounds double, ptr %120, i64 %121
  store ptr %122, ptr %15, align 8, !tbaa !5
  %123 = load i32, ptr %13, align 4, !tbaa !9
  %124 = load ptr, ptr %16, align 8, !tbaa !5
  %125 = sext i32 %123 to i64
  %126 = getelementptr inbounds double, ptr %124, i64 %125
  store ptr %126, ptr %16, align 8, !tbaa !5
  %127 = load i32, ptr %17, align 4, !tbaa !9
  %128 = add nsw i32 %127, -1
  store i32 %128, ptr %17, align 4, !tbaa !9
  br label %69, !llvm.loop !16

129:                                              ; preds = %72
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  ret void
}

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

attributes #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 = { 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 = { 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 = !{!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}
!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"

@.str = external hidden unnamed_addr constant [24 x i8], align 1
@__FUNCTION__._ZN4dart8external3ode11_dMultiply0EPdPKdS4_iii = external hidden unnamed_addr constant [12 x i8], align 1

declare void @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dart8external3ode11_dMultiply0EPdPKdS4_iii(ptr noundef writeonly %0, ptr noundef readonly %1, ptr noundef readonly %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #1 {
  %7 = icmp ne ptr %0, null
  %8 = icmp ne ptr %1, null
  %or.cond = and i1 %7, %8
  %9 = icmp ne ptr %2, null
  %or.cond3 = and i1 %or.cond, %9
  %10 = icmp sgt i32 %3, 0
  %or.cond5 = and i1 %or.cond3, %10
  %11 = icmp sgt i32 %4, 0
  %or.cond7 = and i1 %or.cond5, %11
  %12 = icmp sgt i32 %5, 0
  %or.cond9 = and i1 %or.cond7, %12
  br i1 %or.cond9, label %.lr.ph80, label %13

13:                                               ; preds = %6
  tail call void (i32, ptr, ...) @_ZN4dart8external3ode6dDebugEiPKcz(i32 noundef 2, ptr noundef nonnull @.str, ptr noundef nonnull @__FUNCTION__._ZN4dart8external3ode11_dMultiply0EPdPKdS4_iii)
  %.not73 = icmp eq i32 %3, 0
  br i1 %.not73, label %._crit_edge81, label %.lr.ph80

.lr.ph80:                                         ; preds = %6, %13
  %14 = icmp sgt i32 %5, 1
  %15 = add nsw i32 %5, -1
  %16 = or i32 %15, 3
  %17 = add nuw nsw i32 %16, 1
  %18 = select i1 %14, i32 %17, i32 %5
  %19 = icmp sgt i32 %4, 1
  %20 = add nsw i32 %4, -1
  %21 = or i32 %20, 3
  %22 = add nuw nsw i32 %21, 1
  %23 = select i1 %19, i32 %22, i32 %4
  %24 = sext i32 %5 to i64
  %25 = getelementptr inbounds double, ptr %2, i64 %24
  %.not6167 = icmp eq i32 %5, 0
  %26 = sext i32 %4 to i64
  %27 = sext i32 %18 to i64
  %28 = sext i32 %23 to i64
  br i1 %.not6167, label %._crit_edge81, label %.lr.ph71.preheader

.lr.ph71.preheader:                               ; preds = %.lr.ph80
  %29 = shl nsw i64 %24, 3
  %.not6263 = icmp eq i32 %4, 0
  br label %.lr.ph71

._crit_edge81:                                    ; preds = %._crit_edge72, %.lr.ph80, %13
  ret void

.lr.ph71:                                         ; preds = %.lr.ph71.preheader, %._crit_edge72
  %.077 = phi ptr [ %39, %._crit_edge72 ], [ %0, %.lr.ph71.preheader ]
  %.05475 = phi ptr [ %40, %._crit_edge72 ], [ %1, %.lr.ph71.preheader ]
  %.05774 = phi i32 [ %41, %._crit_edge72 ], [ %3, %.lr.ph71.preheader ]
  %30 = getelementptr inbounds double, ptr %.05475, i64 %26
  br i1 %.not6263, label %.lr.ph71.split.us.preheader, label %.lr.ph

.lr.ph71.split.us.preheader:                      ; preds = %.lr.ph71
  tail call void @llvm.memset.p0.i64(ptr align 8 %.077, i8 0, i64 %29, i1 false), !tbaa !5
  br label %._crit_edge72

.lr.ph:                                           ; preds = %.lr.ph71, %._crit_edge
  %.05569 = phi ptr [ %38, %._crit_edge ], [ %2, %.lr.ph71 ]
  %.05668 = phi ptr [ %37, %._crit_edge ], [ %.077, %.lr.ph71 ]
  br label %31

31:                                               ; preds = %.lr.ph, %31
  %.05166 = phi ptr [ %.05475, %.lr.ph ], [ %36, %31 ]
  %.05265 = phi ptr [ %.05569, %.lr.ph ], [ %35, %31 ]
  %.05364 = phi double [ 0.000000e+00, %.lr.ph ], [ %34, %31 ]
  %32 = load double, ptr %.05166, align 8, !tbaa !5
  %33 = load double, ptr %.05265, align 8, !tbaa !5
  %34 = tail call double @llvm.fmuladd.f64(double %32, double %33, double %.05364)
  %35 = getelementptr inbounds double, ptr %.05265, i64 %27
  %36 = getelementptr inbounds i8, ptr %.05166, i64 8
  %.not62 = icmp eq ptr %36, %30
  br i1 %.not62, label %._crit_edge, label %31, !llvm.loop !9

._crit_edge:                                      ; preds = %31
  store double %34, ptr %.05668, align 8, !tbaa !5
  %37 = getelementptr inbounds i8, ptr %.05668, i64 8
  %38 = getelementptr inbounds i8, ptr %.05569, i64 8
  %.not61 = icmp eq ptr %38, %25
  br i1 %.not61, label %._crit_edge72, label %.lr.ph, !llvm.loop !11

._crit_edge72:                                    ; preds = %._crit_edge, %.lr.ph71.split.us.preheader
  %39 = getelementptr double, ptr %.077, i64 %27
  %40 = getelementptr inbounds double, ptr %.05475, i64 %28
  %41 = add nsw i32 %.05774, -1
  %.not = icmp eq i32 %41, 0
  br i1 %.not, label %._crit_edge81, label %.lr.ph71, !llvm.loop !12
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

attributes #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 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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!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"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass