; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/CMSIS/DSP/Source/MatrixFunctions (arm_mat_solve_upper_triangular_f32)

; 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"

%struct.arm_matrix_instance_f32 = type { i16, i16, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_mat_solve_upper_triangular_f32(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca float, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.arm_matrix_instance_f32, ptr %20, i32 0, i32 0
  %22 = load i16, ptr %21, align 8, !tbaa !9
  %23 = zext i16 %22 to i32
  store i32 %23, ptr %12, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.arm_matrix_instance_f32, ptr %24, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  store ptr %26, ptr %13, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.arm_matrix_instance_f32, ptr %27, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !14
  store ptr %29, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.arm_matrix_instance_f32, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !14
  store ptr %32, ptr %15, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  store i32 0, ptr %10, align 4, !tbaa !12
  br label %33

33:                                               ; preds = %120, %3
  %34 = load i32, ptr %10, align 4, !tbaa !12
  %35 = load i32, ptr %12, align 4, !tbaa !12
  %36 = icmp slt i32 %34, %35
  br i1 %36, label %37, label %123

37:                                               ; preds = %33
  %38 = load ptr, ptr %15, align 8, !tbaa !5
  %39 = load i32, ptr %10, align 4, !tbaa !12
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds float, ptr %38, i64 %40
  store ptr %41, ptr %17, align 8, !tbaa !5
  %42 = load i32, ptr %12, align 4, !tbaa !12
  %43 = sub nsw i32 %42, 1
  store i32 %43, ptr %9, align 4, !tbaa !12
  br label %44

44:                                               ; preds = %116, %37
  %45 = load i32, ptr %9, align 4, !tbaa !12
  %46 = icmp sge i32 %45, 0
  br i1 %46, label %47, label %119

47:                                               ; preds = %44
  %48 = load ptr, ptr %14, align 8, !tbaa !5
  %49 = load i32, ptr %12, align 4, !tbaa !12
  %50 = load i32, ptr %9, align 4, !tbaa !12
  %51 = mul nsw i32 %49, %50
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds float, ptr %48, i64 %52
  store ptr %53, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %54 = load ptr, ptr %17, align 8, !tbaa !5
  %55 = load i32, ptr %9, align 4, !tbaa !12
  %56 = load i32, ptr %12, align 4, !tbaa !12
  %57 = mul nsw i32 %55, %56
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds float, ptr %54, i64 %58
  %60 = load float, ptr %59, align 4, !tbaa !15
  store float %60, ptr %18, align 4, !tbaa !15
  %61 = load i32, ptr %12, align 4, !tbaa !12
  %62 = sub nsw i32 %61, 1
  store i32 %62, ptr %11, align 4, !tbaa !12
  br label %63

63:                                               ; preds = %85, %47
  %64 = load i32, ptr %11, align 4, !tbaa !12
  %65 = load i32, ptr %9, align 4, !tbaa !12
  %66 = icmp sgt i32 %64, %65
  br i1 %66, label %67, label %88

67:                                               ; preds = %63
  %68 = load ptr, ptr %16, align 8, !tbaa !5
  %69 = load i32, ptr %11, align 4, !tbaa !12
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds float, ptr %68, i64 %70
  %72 = load float, ptr %71, align 4, !tbaa !15
  %73 = load ptr, ptr %13, align 8, !tbaa !5
  %74 = load i32, ptr %12, align 4, !tbaa !12
  %75 = load i32, ptr %11, align 4, !tbaa !12
  %76 = mul nsw i32 %74, %75
  %77 = load i32, ptr %10, align 4, !tbaa !12
  %78 = add nsw i32 %76, %77
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds float, ptr %73, i64 %79
  %81 = load float, ptr %80, align 4, !tbaa !15
  %82 = load float, ptr %18, align 4, !tbaa !15
  %83 = fneg float %72
  %84 = call float @llvm.fmuladd.f32(float %83, float %81, float %82)
  store float %84, ptr %18, align 4, !tbaa !15
  br label %85

85:                                               ; preds = %67
  %86 = load i32, ptr %11, align 4, !tbaa !12
  %87 = add nsw i32 %86, -1
  store i32 %87, ptr %11, align 4, !tbaa !12
  br label %63, !llvm.loop !17

88:                                               ; preds = %63
  %89 = load ptr, ptr %16, align 8, !tbaa !5
  %90 = load i32, ptr %9, align 4, !tbaa !12
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds float, ptr %89, i64 %91
  %93 = load float, ptr %92, align 4, !tbaa !15
  %94 = fcmp oeq float %93, 0.000000e+00
  br i1 %94, label %95, label %96

95:                                               ; preds = %88
  store i32 -5, ptr %4, align 4
  store i32 1, ptr %19, align 4
  br label %113

96:                                               ; preds = %88
  %97 = load float, ptr %18, align 4, !tbaa !15
  %98 = load ptr, ptr %16, align 8, !tbaa !5
  %99 = load i32, ptr %9, align 4, !tbaa !12
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds float, ptr %98, i64 %100
  %102 = load float, ptr %101, align 4, !tbaa !15
  %103 = fdiv float %97, %102
  store float %103, ptr %18, align 4, !tbaa !15
  %104 = load float, ptr %18, align 4, !tbaa !15
  %105 = load ptr, ptr %13, align 8, !tbaa !5
  %106 = load i32, ptr %9, align 4, !tbaa !12
  %107 = load i32, ptr %12, align 4, !tbaa !12
  %108 = mul nsw i32 %106, %107
  %109 = load i32, ptr %10, align 4, !tbaa !12
  %110 = add nsw i32 %108, %109
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds float, ptr %105, i64 %111
  store float %104, ptr %112, align 4, !tbaa !15
  store i32 0, ptr %19, align 4
  br label %113

113:                                              ; preds = %96, %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  %114 = load i32, ptr %19, align 4
  switch i32 %114, label %124 [
    i32 0, label %115
  ]

115:                                              ; preds = %113
  br label %116

116:                                              ; preds = %115
  %117 = load i32, ptr %9, align 4, !tbaa !12
  %118 = add nsw i32 %117, -1
  store i32 %118, ptr %9, align 4, !tbaa !12
  br label %44, !llvm.loop !19

119:                                              ; preds = %44
  br label %120

120:                                              ; preds = %119
  %121 = load i32, ptr %10, align 4, !tbaa !12
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %10, align 4, !tbaa !12
  br label %33, !llvm.loop !20

123:                                              ; preds = %33
  store i32 0, ptr %8, align 4, !tbaa !12
  store i32 0, ptr %19, align 4
  br label %124

124:                                              ; preds = %123, %113
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %125 = load i32, ptr %19, align 4
  switch i32 %125, label %128 [
    i32 0, label %126
  ]

126:                                              ; preds = %124
  %127 = load i32, ptr %8, align 4, !tbaa !12
  store i32 %127, ptr %4, align 4
  store i32 1, ptr %19, align 4
  br label %128

128:                                              ; preds = %126, %124
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %129 = load i32, ptr %4, align 4
  ret i32 %129
}

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 2, !6, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}
!14 = !{!10, !6, i64 8}
!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}


; 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 noundef i32 @arm_mat_solve_upper_triangular_f32(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = load i16, ptr %2, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %2, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !11
  %7 = getelementptr inbounds i8, ptr %0, i64 8
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = getelementptr inbounds i8, ptr %1, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %.not55.not = icmp eq i16 %4, 0
  br i1 %.not55.not, label %.critedge, label %.lr.ph58

.lr.ph58:                                         ; preds = %3
  %11 = zext i16 %4 to i64
  %12 = add nuw nsw i64 %11, 4294967295
  %13 = zext i16 %4 to i64
  %14 = add nsw i64 %13, -1
  %15 = zext i16 %4 to i64
  %16 = and i64 %12, 4294967295
  %wide.trip.count = zext i16 %4 to i64
  br label %17

17:                                               ; preds = %.lr.ph58, %38
  %indvars.iv64 = phi i64 [ 0, %.lr.ph58 ], [ %indvars.iv.next65, %38 ]
  %18 = getelementptr inbounds float, ptr %10, i64 %indvars.iv64
  %invariant.gep = getelementptr float, ptr %6, i64 %indvars.iv64
  %invariant.gep68 = getelementptr float, ptr %6, i64 %indvars.iv64
  br label %19

19:                                               ; preds = %17, %35
  %indvars.iv61 = phi i64 [ %14, %17 ], [ %indvars.iv.next62, %35 ]
  %20 = mul nuw nsw i64 %indvars.iv61, %15
  %21 = getelementptr inbounds float, ptr %8, i64 %20
  %22 = getelementptr inbounds float, ptr %18, i64 %20
  %23 = load float, ptr %22, align 4, !tbaa !12
  %24 = icmp slt i64 %indvars.iv61, %16
  br i1 %24, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %19, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %14, %19 ]
  %.04353 = phi float [ %30, %.lr.ph ], [ %23, %19 ]
  %25 = getelementptr inbounds float, ptr %21, i64 %indvars.iv
  %26 = load float, ptr %25, align 4, !tbaa !12
  %27 = mul nuw nsw i64 %indvars.iv, %15
  %gep = getelementptr float, ptr %invariant.gep, i64 %27
  %28 = load float, ptr %gep, align 4, !tbaa !12
  %29 = fneg float %26
  %30 = tail call float @llvm.fmuladd.f32(float %29, float %28, float %.04353)
  %indvars.iv.next = add nsw i64 %indvars.iv, -1
  %31 = icmp sgt i64 %indvars.iv.next, %indvars.iv61
  br i1 %31, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %19
  %.043.lcssa = phi float [ %23, %19 ], [ %30, %.lr.ph ]
  %32 = getelementptr inbounds float, ptr %21, i64 %indvars.iv61
  %33 = load float, ptr %32, align 4, !tbaa !12
  %34 = fcmp une float %33, 0.000000e+00
  br i1 %34, label %35, label %.critedge

35:                                               ; preds = %._crit_edge
  %36 = fdiv float %.043.lcssa, %33
  %gep69 = getelementptr float, ptr %invariant.gep68, i64 %20
  store float %36, ptr %gep69, align 4, !tbaa !12
  %indvars.iv.next62 = add nsw i64 %indvars.iv61, -1
  %37 = icmp sgt i64 %indvars.iv61, 0
  br i1 %37, label %19, label %38, !llvm.loop !16

38:                                               ; preds = %35
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next65, %wide.trip.count
  br i1 %exitcond.not, label %.critedge, label %17, !llvm.loop !17

.critedge:                                        ; preds = %38, %._crit_edge, %3
  %spec.select = phi i32 [ 0, %3 ], [ -5, %._crit_edge ], [ 0, %38 ]
  ret i32 %spec.select
}

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

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) }

!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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 2, !10, i64 8}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !8, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


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