; LLVM IR from AllAlgorithms/c :: algorithms (lu_decomposition)

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

; Function Attrs: nounwind uwtable
define dso_local void @BackwardSubst(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca double, align 8
  %10 = alloca i32, align 4
  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 %5, align 8, !tbaa !5
  %12 = getelementptr inbounds double, ptr %11, i64 4
  %13 = load double, ptr %12, align 8, !tbaa !9
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  %15 = getelementptr inbounds [5 x double], ptr %14, i64 4
  %16 = getelementptr inbounds [5 x double], ptr %15, i64 0, i64 4
  %17 = load double, ptr %16, align 8, !tbaa !9
  %18 = fdiv double %13, %17
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds double, ptr %19, i64 4
  store double %18, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 3, ptr %7, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %72, %3
  %22 = load i32, ptr %7, align 4, !tbaa !11
  %23 = icmp sge i32 %22, 0
  br i1 %23, label %25, label %24

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

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load i32, ptr %7, align 4, !tbaa !11
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds double, ptr %26, i64 %28
  %30 = load double, ptr %29, align 8, !tbaa !9
  store double %30, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %31 = load i32, ptr %7, align 4, !tbaa !11
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %10, align 4, !tbaa !11
  br label %33

33:                                               ; preds = %54, %25
  %34 = load i32, ptr %10, align 4, !tbaa !11
  %35 = icmp slt i32 %34, 5
  br i1 %35, label %37, label %36

36:                                               ; preds = %33
  store i32 5, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %57

37:                                               ; preds = %33
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !11
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [5 x double], ptr %38, i64 %40
  %42 = load i32, ptr %10, align 4, !tbaa !11
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [5 x double], ptr %41, i64 0, i64 %43
  %45 = load double, ptr %44, align 8, !tbaa !9
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = load i32, ptr %10, align 4, !tbaa !11
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds double, ptr %46, i64 %48
  %50 = load double, ptr %49, align 8, !tbaa !9
  %51 = load double, ptr %9, align 8, !tbaa !9
  %52 = fneg double %45
  %53 = call double @llvm.fmuladd.f64(double %52, double %50, double %51)
  store double %53, ptr %9, align 8, !tbaa !9
  br label %54

54:                                               ; preds = %37
  %55 = load i32, ptr %10, align 4, !tbaa !11
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %10, align 4, !tbaa !11
  br label %33, !llvm.loop !13

57:                                               ; preds = %36
  %58 = load double, ptr %9, align 8, !tbaa !9
  %59 = load ptr, ptr %4, align 8, !tbaa !5
  %60 = load i32, ptr %7, align 4, !tbaa !11
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [5 x double], ptr %59, i64 %61
  %63 = load i32, ptr %7, align 4, !tbaa !11
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [5 x double], ptr %62, i64 0, i64 %64
  %66 = load double, ptr %65, align 8, !tbaa !9
  %67 = fdiv double %58, %66
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = load i32, ptr %7, align 4, !tbaa !11
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds double, ptr %68, i64 %70
  store double %67, ptr %71, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  br label %72

72:                                               ; preds = %57
  %73 = load i32, ptr %7, align 4, !tbaa !11
  %74 = add nsw i32 %73, -1
  store i32 %74, ptr %7, align 4, !tbaa !11
  br label %21, !llvm.loop !15

75:                                               ; preds = %24
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 #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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @BackwardSubst(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
._crit_edge.3:
  %3 = getelementptr inbounds i8, ptr %1, i64 32
  %4 = load double, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 192
  %6 = load double, ptr %5, align 8, !tbaa !5
  %7 = fdiv double %4, %6
  %8 = getelementptr inbounds i8, ptr %2, i64 32
  store double %7, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 152
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fneg double %10
  %12 = getelementptr inbounds i8, ptr %1, i64 24
  %13 = load double, ptr %12, align 8, !tbaa !5
  %14 = tail call double @llvm.fmuladd.f64(double %11, double %7, double %13)
  %15 = getelementptr inbounds i8, ptr %0, i64 144
  %16 = load double, ptr %15, align 8, !tbaa !5
  %17 = fdiv double %14, %16
  %18 = getelementptr inbounds i8, ptr %2, i64 24
  store double %17, ptr %18, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 112
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = fneg double %20
  %22 = getelementptr inbounds i8, ptr %0, i64 104
  %23 = load double, ptr %22, align 8, !tbaa !5
  %24 = fneg double %23
  %25 = getelementptr inbounds i8, ptr %1, i64 16
  %26 = load double, ptr %25, align 8, !tbaa !5
  %27 = tail call double @llvm.fmuladd.f64(double %24, double %17, double %26)
  %28 = tail call double @llvm.fmuladd.f64(double %21, double %7, double %27)
  %29 = getelementptr inbounds i8, ptr %0, i64 96
  %30 = load double, ptr %29, align 8, !tbaa !5
  %31 = fdiv double %28, %30
  %32 = getelementptr inbounds i8, ptr %2, i64 16
  store double %31, ptr %32, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 72
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = fneg double %34
  %36 = getelementptr inbounds i8, ptr %0, i64 64
  %37 = load double, ptr %36, align 8, !tbaa !5
  %38 = fneg double %37
  %39 = getelementptr inbounds i8, ptr %0, i64 56
  %40 = load double, ptr %39, align 8, !tbaa !5
  %41 = fneg double %40
  %42 = getelementptr inbounds i8, ptr %1, i64 8
  %43 = load double, ptr %42, align 8, !tbaa !5
  %44 = tail call double @llvm.fmuladd.f64(double %41, double %31, double %43)
  %45 = tail call double @llvm.fmuladd.f64(double %38, double %17, double %44)
  %46 = tail call double @llvm.fmuladd.f64(double %35, double %7, double %45)
  %47 = getelementptr inbounds i8, ptr %0, i64 48
  %48 = load double, ptr %47, align 8, !tbaa !5
  %49 = fdiv double %46, %48
  %50 = getelementptr inbounds i8, ptr %2, i64 8
  store double %49, ptr %50, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %0, i64 32
  %52 = load double, ptr %51, align 8, !tbaa !5
  %53 = fneg double %52
  %54 = getelementptr inbounds i8, ptr %0, i64 24
  %55 = load double, ptr %54, align 8, !tbaa !5
  %56 = fneg double %55
  %57 = getelementptr inbounds i8, ptr %0, i64 16
  %58 = load double, ptr %57, align 8, !tbaa !5
  %59 = fneg double %58
  %60 = getelementptr inbounds i8, ptr %0, i64 8
  %61 = load double, ptr %60, align 8, !tbaa !5
  %62 = fneg double %61
  %63 = load double, ptr %1, align 8, !tbaa !5
  %64 = tail call double @llvm.fmuladd.f64(double %62, double %49, double %63)
  %65 = tail call double @llvm.fmuladd.f64(double %59, double %31, double %64)
  %66 = tail call double @llvm.fmuladd.f64(double %56, double %17, double %65)
  %67 = tail call double @llvm.fmuladd.f64(double %53, double %7, double %66)
  %68 = load double, ptr %0, align 8, !tbaa !5
  %69 = fdiv double %67, %68
  store double %69, ptr %2, align 8, !tbaa !5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { 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/C++ TBAA"}


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