; LLVM IR from dartsim/dart :: dart/external/odelcpsolver/matrix.ll (ZN4dart8external3ode11_dMultiply2EPdPKdS4_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_dMultiply2EPdPKdS4_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: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dart8external3ode11_dMultiply2EPdPKdS4_iii(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #3 {
  %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_dMultiply2EPdPKdS4_iii)
  br label %43

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

46:                                               ; preds = %43
  %47 = load i32, ptr %12, 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 %12, 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 %11, align 4, !tbaa !9
  %56 = icmp sgt i32 %55, 1
  br i1 %56, label %57, label %62

57:                                               ; preds = %53
  %58 = load i32, ptr %11, 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 %11, 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 %15, align 8, !tbaa !5
  %76 = load i32, ptr %12, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds double, ptr %75, i64 %77
  store ptr %78, ptr %19, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #4
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %79, ptr %20, align 8, !tbaa !5
  br label %80

80:                                               ; preds = %110, %73
  %81 = load ptr, ptr %18, align 8, !tbaa !5
  %82 = load ptr, ptr %19, 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 %16, 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 %20, 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 %20, 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 %107

95:                                               ; preds = %91
  %96 = load ptr, ptr %22, align 8, !tbaa !5
  %97 = load double, ptr %96, align 8, !tbaa !11
  %98 = load ptr, ptr %23, 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 ptr, ptr %22, align 8, !tbaa !5
  %104 = getelementptr inbounds double, ptr %103, i32 1
  store ptr %104, ptr %22, align 8, !tbaa !5
  %105 = load ptr, ptr %23, align 8, !tbaa !5
  %106 = getelementptr inbounds double, ptr %105, i32 1
  store ptr %106, ptr %23, align 8, !tbaa !5
  br label %91, !llvm.loop !13

107:                                              ; preds = %91
  %108 = load double, ptr %21, align 8, !tbaa !11
  %109 = load ptr, ptr %18, align 8, !tbaa !5
  store double %108, ptr %109, 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 %110

110:                                              ; preds = %107
  %111 = load i32, ptr %14, align 4, !tbaa !9
  %112 = load ptr, ptr %20, align 8, !tbaa !5
  %113 = sext i32 %111 to i64
  %114 = getelementptr inbounds double, ptr %112, i64 %113
  store ptr %114, ptr %20, align 8, !tbaa !5
  %115 = load ptr, ptr %18, align 8, !tbaa !5
  %116 = getelementptr inbounds double, ptr %115, i32 1
  store ptr %116, ptr %18, 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 %13, 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 %14, 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
}

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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}
!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_dMultiply2EPdPKdS4_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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4dart8external3ode11_dMultiply2EPdPKdS4_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 #2 {
  %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.ph78, label %13

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

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

._crit_edge79:                                    ; preds = %._crit_edge72, %13
  ret void

28:                                               ; preds = %.lr.ph78, %._crit_edge72
  %.076 = phi ptr [ %0, %.lr.ph78 ], [ %38, %._crit_edge72 ]
  %.05575 = phi ptr [ %1, %.lr.ph78 ], [ %39, %._crit_edge72 ]
  %.05774 = phi i32 [ %3, %.lr.ph78 ], [ %40, %._crit_edge72 ]
  %29 = getelementptr inbounds double, ptr %.076, i64 %24
  br i1 %.not6167, label %._crit_edge72, label %.lr.ph71

.lr.ph71:                                         ; preds = %28, %._crit_edge
  %.05469 = phi ptr [ %36, %._crit_edge ], [ %2, %28 ]
  %.05668 = phi ptr [ %37, %._crit_edge ], [ %.076, %28 ]
  %30 = getelementptr inbounds double, ptr %.05469, i64 %25
  br i1 %.not6263, label %._crit_edge, label %.lr.ph

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

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph71
  %.053.lcssa = phi double [ 0.000000e+00, %.lr.ph71 ], [ %33, %.lr.ph ]
  store double %.053.lcssa, ptr %.05668, align 8, !tbaa !5
  %36 = getelementptr inbounds double, ptr %.05469, i64 %26
  %37 = getelementptr inbounds i8, ptr %.05668, i64 8
  %.not61 = icmp eq ptr %37, %29
  br i1 %.not61, label %._crit_edge72, label %.lr.ph71, !llvm.loop !11

._crit_edge72:                                    ; preds = %._crit_edge, %28
  %38 = getelementptr inbounds double, ptr %.076, i64 %27
  %39 = getelementptr inbounds double, ptr %.05575, i64 %26
  %40 = add nsw i32 %.05774, -1
  %.not = icmp eq i32 %40, 0
  br i1 %.not, label %._crit_edge79, label %28, !llvm.loop !12
}

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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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" }

!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,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass