; 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 @ForwardSubst(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 0
  %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 0
  %16 = getelementptr inbounds [5 x double], ptr %15, i64 0, i64 0
  %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 0
  store double %18, ptr %20, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 1, ptr %7, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %71, %3
  %22 = load i32, ptr %7, align 4, !tbaa !11
  %23 = icmp slt i32 %22, 5
  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 %74

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
  store i32 0, ptr %10, align 4, !tbaa !11
  br label %31

31:                                               ; preds = %53, %25
  %32 = load i32, ptr %10, align 4, !tbaa !11
  %33 = load i32, ptr %7, align 4, !tbaa !11
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %36, label %35

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

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

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

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

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

74:                                               ; 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 @ForwardSubst(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #1 {
  %4 = load double, ptr %1, align 8, !tbaa !5
  %5 = load double, ptr %0, align 8, !tbaa !5
  %6 = fdiv double %4, %5
  store double %6, ptr %2, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %1, i64 8
  %8 = load double, ptr %7, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 40
  %10 = load double, ptr %9, align 8, !tbaa !5
  %11 = fneg double %10
  %12 = tail call double @llvm.fmuladd.f64(double %11, double %6, double %8)
  %13 = getelementptr inbounds i8, ptr %0, i64 48
  %14 = load double, ptr %13, align 8, !tbaa !5
  %15 = fdiv double %12, %14
  %16 = getelementptr inbounds i8, ptr %2, i64 8
  store double %15, ptr %16, align 8, !tbaa !5
  %17 = getelementptr inbounds i8, ptr %1, i64 16
  %18 = load double, ptr %17, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %0, i64 80
  %20 = load double, ptr %19, align 8, !tbaa !5
  %21 = fneg double %20
  %22 = tail call double @llvm.fmuladd.f64(double %21, double %6, double %18)
  %23 = getelementptr inbounds i8, ptr %0, i64 88
  %24 = load double, ptr %23, align 8, !tbaa !5
  %25 = fneg double %24
  %26 = tail call double @llvm.fmuladd.f64(double %25, double %15, double %22)
  %27 = getelementptr inbounds i8, ptr %0, i64 96
  %28 = load double, ptr %27, align 8, !tbaa !5
  %29 = fdiv double %26, %28
  %30 = getelementptr inbounds i8, ptr %2, i64 16
  store double %29, ptr %30, align 8, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %1, i64 24
  %32 = load double, ptr %31, align 8, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 120
  %34 = load double, ptr %33, align 8, !tbaa !5
  %35 = fneg double %34
  %36 = tail call double @llvm.fmuladd.f64(double %35, double %6, double %32)
  %37 = getelementptr inbounds i8, ptr %0, i64 128
  %38 = load double, ptr %37, align 8, !tbaa !5
  %39 = fneg double %38
  %40 = tail call double @llvm.fmuladd.f64(double %39, double %15, double %36)
  %41 = getelementptr inbounds i8, ptr %0, i64 136
  %42 = load double, ptr %41, align 8, !tbaa !5
  %43 = fneg double %42
  %44 = tail call double @llvm.fmuladd.f64(double %43, double %29, double %40)
  %45 = getelementptr inbounds i8, ptr %0, i64 144
  %46 = load double, ptr %45, align 8, !tbaa !5
  %47 = fdiv double %44, %46
  %48 = getelementptr inbounds i8, ptr %2, i64 24
  store double %47, ptr %48, align 8, !tbaa !5
  %49 = getelementptr inbounds i8, ptr %1, i64 32
  %50 = load double, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %0, i64 160
  %52 = load double, ptr %51, align 8, !tbaa !5
  %53 = fneg double %52
  %54 = tail call double @llvm.fmuladd.f64(double %53, double %6, double %50)
  %55 = getelementptr inbounds i8, ptr %0, i64 168
  %56 = load double, ptr %55, align 8, !tbaa !5
  %57 = fneg double %56
  %58 = tail call double @llvm.fmuladd.f64(double %57, double %15, double %54)
  %59 = getelementptr inbounds i8, ptr %0, i64 176
  %60 = load double, ptr %59, align 8, !tbaa !5
  %61 = fneg double %60
  %62 = tail call double @llvm.fmuladd.f64(double %61, double %29, double %58)
  %63 = getelementptr inbounds i8, ptr %0, i64 184
  %64 = load double, ptr %63, align 8, !tbaa !5
  %65 = fneg double %64
  %66 = tail call double @llvm.fmuladd.f64(double %65, double %47, double %62)
  %67 = getelementptr inbounds i8, ptr %0, i64 192
  %68 = load double, ptr %67, align 8, !tbaa !5
  %69 = fdiv double %66, %68
  %70 = getelementptr inbounds i8, ptr %2, i64 32
  store double %69, ptr %70, 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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass