; LLVM IR from AlgoGenesis/C :: Machine_Learning_Algorithms/Ridge Regression (Program)

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

; Function Attrs: nounwind uwtable
define dso_local void @multiplyMatrices(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #1 {
  %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 i32, align 4
  %16 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %79, %6
  %18 = load i32, ptr %13, align 4, !tbaa !9
  %19 = load i32, ptr %10, align 4, !tbaa !9
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %17
  store i32 2, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %82

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

23:                                               ; preds = %75, %22
  %24 = load i32, ptr %15, align 4, !tbaa !9
  %25 = load i32, ptr %12, align 4, !tbaa !9
  %26 = icmp slt i32 %24, %25
  br i1 %26, label %28, label %27

27:                                               ; preds = %23
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %78

28:                                               ; preds = %23
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds ptr, ptr %29, i64 %31
  %33 = load ptr, ptr %32, align 8, !tbaa !5
  %34 = load i32, ptr %15, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds double, ptr %33, i64 %35
  store double 0.000000e+00, ptr %36, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  store i32 0, ptr %16, align 4, !tbaa !9
  br label %37

37:                                               ; preds = %71, %28
  %38 = load i32, ptr %16, align 4, !tbaa !9
  %39 = load i32, ptr %11, align 4, !tbaa !9
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %74

42:                                               ; preds = %37
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i32, ptr %13, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds ptr, ptr %43, i64 %45
  %47 = load ptr, ptr %46, align 8, !tbaa !5
  %48 = load i32, ptr %16, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds double, ptr %47, i64 %49
  %51 = load double, ptr %50, align 8, !tbaa !11
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load i32, ptr %16, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds ptr, ptr %52, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = load i32, ptr %15, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds double, ptr %56, i64 %58
  %60 = load double, ptr %59, align 8, !tbaa !11
  %61 = load ptr, ptr %9, align 8, !tbaa !5
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds ptr, ptr %61, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !5
  %66 = load i32, ptr %15, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds double, ptr %65, i64 %67
  %69 = load double, ptr %68, align 8, !tbaa !11
  %70 = call double @llvm.fmuladd.f64(double %51, double %60, double %69)
  store double %70, ptr %68, align 8, !tbaa !11
  br label %71

71:                                               ; preds = %42
  %72 = load i32, ptr %16, align 4, !tbaa !9
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %16, align 4, !tbaa !9
  br label %37, !llvm.loop !13

74:                                               ; preds = %41
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %15, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %15, align 4, !tbaa !9
  br label %23, !llvm.loop !15

78:                                               ; preds = %27
  br label %79

79:                                               ; preds = %78
  %80 = load i32, ptr %13, align 4, !tbaa !9
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %13, align 4, !tbaa !9
  br label %17, !llvm.loop !16

82:                                               ; preds = %21
  ret void
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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/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"

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @multiplyMatrices(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = icmp sgt i32 %3, 0
  %8 = icmp sgt i32 %5, 0
  %or.cond = and i1 %7, %8
  br i1 %or.cond, label %.preheader.lr.ph.split.us, label %._crit_edge

.preheader.lr.ph.split.us:                        ; preds = %6
  %9 = icmp sgt i32 %4, 0
  br i1 %9, label %.preheader.us.us.preheader, label %.preheader.us.preheader

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph.split.us
  %10 = zext nneg i32 %5 to i64
  %11 = shl nuw nsw i64 %10, 3
  %wide.trip.count = zext nneg i32 %3 to i64
  %xtraiter = and i64 %wide.trip.count, 7
  %12 = icmp ult i32 %3, 8
  br i1 %12, label %._crit_edge.loopexit51.unr-lcssa, label %.preheader.us.preheader.new

.preheader.us.preheader.new:                      ; preds = %.preheader.us.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483640
  br label %.preheader.us

.preheader.us.us.preheader:                       ; preds = %.preheader.lr.ph.split.us
  %wide.trip.count47 = zext nneg i32 %3 to i64
  %wide.trip.count42 = zext nneg i32 %5 to i64
  %wide.trip.count37 = zext nneg i32 %4 to i64
  %xtraiter52 = and i64 %wide.trip.count37, 1
  %13 = icmp eq i32 %4, 1
  %unroll_iter55 = and i64 %wide.trip.count37, 2147483646
  %lcmp.mod54.not = icmp eq i64 %xtraiter52, 0
  br label %.preheader.us.us

.preheader.us.us:                                 ; preds = %.preheader.us.us.preheader, %._crit_edge25.split.us.us.us
  %indvars.iv44 = phi i64 [ 0, %.preheader.us.us.preheader ], [ %indvars.iv.next45, %._crit_edge25.split.us.us.us ]
  %14 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv44
  %15 = load ptr, ptr %14, align 8, !tbaa !5
  %16 = getelementptr inbounds ptr, ptr %0, i64 %indvars.iv44
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  br label %.lr.ph.us.us.us

.lr.ph.us.us.us:                                  ; preds = %._crit_edge.us.us.us, %.preheader.us.us
  %indvars.iv39 = phi i64 [ %indvars.iv.next40, %._crit_edge.us.us.us ], [ 0, %.preheader.us.us ]
  %18 = getelementptr inbounds double, ptr %15, i64 %indvars.iv39
  store double 0.000000e+00, ptr %18, align 8, !tbaa !9
  br i1 %13, label %._crit_edge.us.us.us.unr-lcssa, label %.lr.ph.us.us.us.new

.lr.ph.us.us.us.new:                              ; preds = %.lr.ph.us.us.us, %.lr.ph.us.us.us.new
  %indvars.iv34 = phi i64 [ %indvars.iv.next35.1, %.lr.ph.us.us.us.new ], [ 0, %.lr.ph.us.us.us ]
  %19 = phi double [ %33, %.lr.ph.us.us.us.new ], [ 0.000000e+00, %.lr.ph.us.us.us ]
  %niter56 = phi i64 [ %niter56.next.1, %.lr.ph.us.us.us.new ], [ 0, %.lr.ph.us.us.us ]
  %20 = getelementptr inbounds double, ptr %17, i64 %indvars.iv34
  %21 = load double, ptr %20, align 8, !tbaa !9
  %22 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv34
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = getelementptr inbounds double, ptr %23, i64 %indvars.iv39
  %25 = load double, ptr %24, align 8, !tbaa !9
  %26 = tail call double @llvm.fmuladd.f64(double %21, double %25, double %19)
  store double %26, ptr %18, align 8, !tbaa !9
  %indvars.iv.next35 = or disjoint i64 %indvars.iv34, 1
  %27 = getelementptr inbounds double, ptr %17, i64 %indvars.iv.next35
  %28 = load double, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv.next35
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds double, ptr %30, i64 %indvars.iv39
  %32 = load double, ptr %31, align 8, !tbaa !9
  %33 = tail call double @llvm.fmuladd.f64(double %28, double %32, double %26)
  store double %33, ptr %18, align 8, !tbaa !9
  %indvars.iv.next35.1 = add nuw nsw i64 %indvars.iv34, 2
  %niter56.next.1 = add i64 %niter56, 2
  %niter56.ncmp.1 = icmp eq i64 %niter56.next.1, %unroll_iter55
  br i1 %niter56.ncmp.1, label %._crit_edge.us.us.us.unr-lcssa, label %.lr.ph.us.us.us.new, !llvm.loop !11

._crit_edge.us.us.us.unr-lcssa:                   ; preds = %.lr.ph.us.us.us.new, %.lr.ph.us.us.us
  %indvars.iv34.unr = phi i64 [ 0, %.lr.ph.us.us.us ], [ %indvars.iv.next35.1, %.lr.ph.us.us.us.new ]
  %.unr = phi double [ 0.000000e+00, %.lr.ph.us.us.us ], [ %33, %.lr.ph.us.us.us.new ]
  br i1 %lcmp.mod54.not, label %._crit_edge.us.us.us, label %._crit_edge.us.us.us.epilog-lcssa

._crit_edge.us.us.us.epilog-lcssa:                ; preds = %._crit_edge.us.us.us.unr-lcssa
  %34 = getelementptr inbounds double, ptr %17, i64 %indvars.iv34.unr
  %35 = load double, ptr %34, align 8, !tbaa !9
  %36 = getelementptr inbounds ptr, ptr %1, i64 %indvars.iv34.unr
  %37 = load ptr, ptr %36, align 8, !tbaa !5
  %38 = getelementptr inbounds double, ptr %37, i64 %indvars.iv39
  %39 = load double, ptr %38, align 8, !tbaa !9
  %40 = tail call double @llvm.fmuladd.f64(double %35, double %39, double %.unr)
  store double %40, ptr %18, align 8, !tbaa !9
  br label %._crit_edge.us.us.us

._crit_edge.us.us.us:                             ; preds = %._crit_edge.us.us.us.unr-lcssa, %._crit_edge.us.us.us.epilog-lcssa
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %exitcond43.not = icmp eq i64 %indvars.iv.next40, %wide.trip.count42
  br i1 %exitcond43.not, label %._crit_edge25.split.us.us.us, label %.lr.ph.us.us.us, !llvm.loop !13

._crit_edge25.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %indvars.iv.next45 = add nuw nsw i64 %indvars.iv44, 1
  %exitcond48.not = icmp eq i64 %indvars.iv.next45, %wide.trip.count47
  br i1 %exitcond48.not, label %._crit_edge, label %.preheader.us.us, !llvm.loop !14

.preheader.us:                                    ; preds = %.preheader.us, %.preheader.us.preheader.new
  %indvars.iv = phi i64 [ 0, %.preheader.us.preheader.new ], [ %indvars.iv.next.7, %.preheader.us ]
  %niter = phi i64 [ 0, %.preheader.us.preheader.new ], [ %niter.next.7, %.preheader.us ]
  %41 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv
  %42 = load ptr, ptr %41, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %42, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %43 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv.next
  %44 = load ptr, ptr %43, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %44, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %45 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv.next.1
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %46, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %47 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv.next.2
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %48, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next.3 = or disjoint i64 %indvars.iv, 4
  %49 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv.next.3
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %50, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next.4 = or disjoint i64 %indvars.iv, 5
  %51 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv.next.4
  %52 = load ptr, ptr %51, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %52, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next.5 = or disjoint i64 %indvars.iv, 6
  %53 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv.next.5
  %54 = load ptr, ptr %53, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %54, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next.6 = or disjoint i64 %indvars.iv, 7
  %55 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv.next.6
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %56, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next.7 = add nuw nsw i64 %indvars.iv, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %._crit_edge.loopexit51.unr-lcssa, label %.preheader.us, !llvm.loop !14

._crit_edge.loopexit51.unr-lcssa:                 ; preds = %.preheader.us, %.preheader.us.preheader
  %indvars.iv.unr = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next.7, %.preheader.us ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.preheader.us.epil

.preheader.us.epil:                               ; preds = %._crit_edge.loopexit51.unr-lcssa, %.preheader.us.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.preheader.us.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit51.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader.us.epil ], [ 0, %._crit_edge.loopexit51.unr-lcssa ]
  %57 = getelementptr inbounds ptr, ptr %2, i64 %indvars.iv.epil
  %58 = load ptr, ptr %57, align 8, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr align 8 %58, i8 0, i64 %11, i1 false), !tbaa !9
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.preheader.us.epil, !llvm.loop !15

._crit_edge:                                      ; preds = %._crit_edge.loopexit51.unr-lcssa, %.preheader.us.epil, %._crit_edge25.split.us.us.us, %6
  ret void
}

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

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

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, 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) }
attributes #2 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.unroll.disable"}


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