; LLVM IR from moarseniy/CudaFEMproject :: deprecated/Linal2/src/Linal2.ll (ZN6Matrix19Solve_Gauss_reverseES_7MyArrayRS0_ib)

; 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: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6Matrix19Solve_Gauss_reverseES_7MyArrayRS0_ib(ptr noundef nonnull align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %4, i1 noundef zeroext %5) #1 align 2 {
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca float, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca float, align 4
  %19 = 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 ptr %3, ptr %10, align 8, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !9
  %20 = zext i1 %5 to i8
  store i8 %20, ptr %12, align 1, !tbaa !11
  %21 = load ptr, ptr %7, align 8
  %22 = load i8, ptr %12, align 1, !tbaa !11, !range !13, !noundef !14
  %23 = trunc i8 %22 to i1
  br i1 %23, label %71, label %24

24:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = sub nsw i32 %25, 1
  store i32 %26, ptr %13, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %67, %24
  %28 = load i32, ptr %13, align 4, !tbaa !9
  %29 = icmp sge i32 %28, 0
  br i1 %29, label %31, label %30

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

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  store float 0.000000e+00, ptr %15, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %32 = load i32, ptr %13, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %16, align 4, !tbaa !9
  br label %34

34:                                               ; preds = %50, %31
  %35 = load i32, ptr %16, align 4, !tbaa !9
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = icmp slt i32 %35, %36
  br i1 %37, label %39, label %38

38:                                               ; preds = %34
  store i32 5, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %53

39:                                               ; preds = %34
  %40 = load i32, ptr %13, align 4, !tbaa !9
  %41 = load i32, ptr %16, align 4, !tbaa !9
  %42 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %40, i32 noundef %41)
  %43 = load float, ptr %42, align 4, !tbaa !15
  %44 = load ptr, ptr %10, align 8, !tbaa !5
  %45 = load i32, ptr %16, align 4, !tbaa !9
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %44, i32 noundef %45)
  %47 = load float, ptr %46, align 4, !tbaa !15
  %48 = load float, ptr %15, align 4, !tbaa !15
  %49 = call float @llvm.fmuladd.f32(float %43, float %47, float %48)
  store float %49, ptr %15, align 4, !tbaa !15
  br label %50

50:                                               ; preds = %39
  %51 = load i32, ptr %16, align 4, !tbaa !9
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %16, align 4, !tbaa !9
  br label %34, !llvm.loop !17

53:                                               ; preds = %38
  %54 = load i32, ptr %13, align 4, !tbaa !9
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %54)
  %56 = load float, ptr %55, align 4, !tbaa !15
  %57 = load float, ptr %15, align 4, !tbaa !15
  %58 = fsub float %56, %57
  %59 = load i32, ptr %13, align 4, !tbaa !9
  %60 = load i32, ptr %13, align 4, !tbaa !9
  %61 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %59, i32 noundef %60)
  %62 = load float, ptr %61, align 4, !tbaa !15
  %63 = fdiv float %58, %62
  %64 = load ptr, ptr %10, align 8, !tbaa !5
  %65 = load i32, ptr %13, align 4, !tbaa !9
  %66 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %64, i32 noundef %65)
  store float %63, ptr %66, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %67

67:                                               ; preds = %53
  %68 = load i32, ptr %13, align 4, !tbaa !9
  %69 = add nsw i32 %68, -1
  store i32 %69, ptr %13, align 4, !tbaa !9
  br label %27, !llvm.loop !19

70:                                               ; preds = %30
  br label %116

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

72:                                               ; preds = %112, %71
  %73 = load i32, ptr %17, align 4, !tbaa !9
  %74 = load i32, ptr %11, align 4, !tbaa !9
  %75 = icmp slt i32 %73, %74
  br i1 %75, label %77, label %76

76:                                               ; preds = %72
  store i32 8, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  br label %115

77:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  store float 0.000000e+00, ptr %18, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #3
  %78 = load i32, ptr %17, align 4, !tbaa !9
  %79 = sub nsw i32 %78, 1
  store i32 %79, ptr %19, align 4, !tbaa !9
  br label %80

80:                                               ; preds = %95, %77
  %81 = load i32, ptr %19, align 4, !tbaa !9
  %82 = icmp sge i32 %81, 0
  br i1 %82, label %84, label %83

83:                                               ; preds = %80
  store i32 11, ptr %14, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #3
  br label %98

84:                                               ; preds = %80
  %85 = load i32, ptr %17, align 4, !tbaa !9
  %86 = load i32, ptr %19, align 4, !tbaa !9
  %87 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %85, i32 noundef %86)
  %88 = load float, ptr %87, align 4, !tbaa !15
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = load i32, ptr %19, align 4, !tbaa !9
  %91 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %89, i32 noundef %90)
  %92 = load float, ptr %91, align 4, !tbaa !15
  %93 = load float, ptr %18, align 4, !tbaa !15
  %94 = call float @llvm.fmuladd.f32(float %88, float %92, float %93)
  store float %94, ptr %18, align 4, !tbaa !15
  br label %95

95:                                               ; preds = %84
  %96 = load i32, ptr %19, align 4, !tbaa !9
  %97 = add nsw i32 %96, -1
  store i32 %97, ptr %19, align 4, !tbaa !9
  br label %80, !llvm.loop !20

98:                                               ; preds = %83
  %99 = load i32, ptr %17, align 4, !tbaa !9
  %100 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %99)
  %101 = load float, ptr %100, align 4, !tbaa !15
  %102 = load float, ptr %18, align 4, !tbaa !15
  %103 = fsub float %101, %102
  %104 = load i32, ptr %17, align 4, !tbaa !9
  %105 = load i32, ptr %17, align 4, !tbaa !9
  %106 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %104, i32 noundef %105)
  %107 = load float, ptr %106, align 4, !tbaa !15
  %108 = fdiv float %103, %107
  %109 = load ptr, ptr %10, align 8, !tbaa !5
  %110 = load i32, ptr %17, align 4, !tbaa !9
  %111 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %109, i32 noundef %110)
  store float %108, ptr %111, align 4, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  br label %112

112:                                              ; preds = %98
  %113 = load i32, ptr %17, align 4, !tbaa !9
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %17, align 4, !tbaa !9
  br label %72, !llvm.loop !21

115:                                              ; preds = %76
  br label %116

116:                                              ; preds = %115, %70
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"float", !7, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = distinct !{!20, !18}
!21 = distinct !{!21, !18}


; 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 nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16), i32 noundef) local_unnamed_addr #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24), i32 noundef, i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN6Matrix19Solve_Gauss_reverseES_7MyArrayRS0_ib(ptr nocapture noundef nonnull readnone align 8 dereferenceable(24) %0, ptr noundef %1, ptr noundef %2, ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %4, i1 noundef zeroext %5) local_unnamed_addr #0 align 2 {
  %7 = icmp sgt i32 %4, 0
  br i1 %5, label %.preheader41, label %.preheader43

.preheader43:                                     ; preds = %6
  br i1 %7, label %.preheader42, label %.loopexit

.preheader41:                                     ; preds = %6
  br i1 %7, label %.preheader, label %.loopexit

.preheader42:                                     ; preds = %.preheader43, %._crit_edge
  %.040.in48 = phi i32 [ %.04049, %._crit_edge ], [ %4, %.preheader43 ]
  %.04049 = add nsw i32 %.040.in48, -1
  %8 = icmp slt i32 %.040.in48, %4
  br i1 %8, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.preheader42
  %.039.lcssa = phi float [ 0.000000e+00, %.preheader42 ], [ %21, %.lr.ph ]
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %.04049)
  %10 = load float, ptr %9, align 4, !tbaa !5
  %11 = fsub float %10, %.039.lcssa
  %12 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.04049, i32 noundef %.04049)
  %13 = load float, ptr %12, align 4, !tbaa !5
  %14 = fdiv float %11, %13
  %15 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %.04049)
  store float %14, ptr %15, align 4, !tbaa !5
  %16 = icmp sgt i32 %.040.in48, 1
  br i1 %16, label %.preheader42, label %.loopexit, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader42, %.lr.ph
  %.03846 = phi i32 [ %22, %.lr.ph ], [ %.040.in48, %.preheader42 ]
  %.03945 = phi float [ %21, %.lr.ph ], [ 0.000000e+00, %.preheader42 ]
  %17 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.04049, i32 noundef %.03846)
  %18 = load float, ptr %17, align 4, !tbaa !5
  %19 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %.03846)
  %20 = load float, ptr %19, align 4, !tbaa !5
  %21 = tail call float @llvm.fmuladd.f32(float %18, float %20, float %.03945)
  %22 = add i32 %.03846, 1
  %exitcond.not = icmp eq i32 %22, %4
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !11

.preheader:                                       ; preds = %.preheader41, %._crit_edge53
  %.03755 = phi i32 [ %30, %._crit_edge53 ], [ 0, %.preheader41 ]
  %.not = icmp eq i32 %.03755, 0
  br i1 %.not, label %._crit_edge53, label %.lr.ph52

._crit_edge53:                                    ; preds = %.lr.ph52, %.preheader
  %.036.lcssa = phi float [ 0.000000e+00, %.preheader ], [ %35, %.lr.ph52 ]
  %23 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %2, i32 noundef %.03755)
  %24 = load float, ptr %23, align 4, !tbaa !5
  %25 = fsub float %24, %.036.lcssa
  %26 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.03755, i32 noundef %.03755)
  %27 = load float, ptr %26, align 4, !tbaa !5
  %28 = fdiv float %25, %27
  %29 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %.03755)
  store float %28, ptr %29, align 4, !tbaa !5
  %30 = add nuw nsw i32 %.03755, 1
  %exitcond58.not = icmp eq i32 %30, %4
  br i1 %exitcond58.not, label %.loopexit, label %.preheader, !llvm.loop !12

.lr.ph52:                                         ; preds = %.preheader, %.lr.ph52
  %.0.in51 = phi i32 [ %.0, %.lr.ph52 ], [ %.03755, %.preheader ]
  %.03650 = phi float [ %35, %.lr.ph52 ], [ 0.000000e+00, %.preheader ]
  %.0 = add nsw i32 %.0.in51, -1
  %31 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN6MatrixclEii(ptr noundef nonnull align 8 dereferenceable(24) %1, i32 noundef %.03755, i32 noundef %.0)
  %32 = load float, ptr %31, align 4, !tbaa !5
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7MyArrayixEi(ptr noundef nonnull align 8 dereferenceable(16) %3, i32 noundef %.0)
  %34 = load float, ptr %33, align 4, !tbaa !5
  %35 = tail call float @llvm.fmuladd.f32(float %32, float %34, float %.03650)
  %36 = icmp sgt i32 %.0.in51, 1
  br i1 %36, label %.lr.ph52, label %._crit_edge53, !llvm.loop !13

.loopexit:                                        ; preds = %._crit_edge, %._crit_edge53, %.preheader43, %.preheader41
  ret void
}

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

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


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