; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/CMSIS/DSP/Source/StatisticsFunctions (arm_absmax_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"

; Function Attrs: nounwind uwtable
define dso_local void @arm_absmax_f32(ptr noundef %0, i32 noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  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
  store i32 0, ptr %12, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds float, ptr %13, i32 1
  store ptr %14, ptr %5, align 8, !tbaa !5
  %15 = load float, ptr %13, align 4, !tbaa !11
  %16 = call float @llvm.fabs.f32(float %15)
  store float %16, ptr %10, align 4, !tbaa !11
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = sub i32 %17, 1
  store i32 %18, ptr %11, align 4, !tbaa !9
  br label %19

19:                                               ; preds = %35, %4
  %20 = load i32, ptr %11, align 4, !tbaa !9
  %21 = icmp ugt i32 %20, 0
  br i1 %21, label %22, label %38

22:                                               ; preds = %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds float, ptr %23, i32 1
  store ptr %24, ptr %5, align 8, !tbaa !5
  %25 = load float, ptr %23, align 4, !tbaa !11
  %26 = call float @llvm.fabs.f32(float %25)
  store float %26, ptr %9, align 4, !tbaa !11
  %27 = load float, ptr %10, align 4, !tbaa !11
  %28 = load float, ptr %9, align 4, !tbaa !11
  %29 = fcmp olt float %27, %28
  br i1 %29, label %30, label %35

30:                                               ; preds = %22
  %31 = load float, ptr %9, align 4, !tbaa !11
  store float %31, ptr %10, align 4, !tbaa !11
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = load i32, ptr %11, align 4, !tbaa !9
  %34 = sub i32 %32, %33
  store i32 %34, ptr %12, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %30, %22
  %36 = load i32, ptr %11, align 4, !tbaa !9
  %37 = add i32 %36, -1
  store i32 %37, ptr %11, align 4, !tbaa !9
  br label %19, !llvm.loop !13

38:                                               ; preds = %19
  %39 = load float, ptr %10, align 4, !tbaa !11
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  store float %39, ptr %40, align 4, !tbaa !11
  %41 = load i32, ptr %12, align 4, !tbaa !9
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  store i32 %41, ptr %42, align 4, !tbaa !9
  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
  ret void
}

; 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.fabs.f32(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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @arm_absmax_f32(ptr nocapture noundef readonly %0, i32 noundef %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = load float, ptr %0, align 4, !tbaa !5
  %6 = tail call float @llvm.fabs.f32(float %5)
  %.01318 = add i32 %1, -1
  %.not19 = icmp eq i32 %.01318, 0
  br i1 %.not19, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %xtraiter = and i32 %.01318, 1
  %7 = icmp eq i32 %1, 2
  br i1 %7, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %.01318, -2
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.01323 = phi i32 [ %.01318, %.lr.ph.preheader.new ], [ %.013.1, %.lr.ph ]
  %.022 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %.1.1, %.lr.ph ]
  %.01421 = phi float [ %6, %.lr.ph.preheader.new ], [ %.115.1, %.lr.ph ]
  %.pn20 = phi ptr [ %0, %.lr.ph.preheader.new ], [ %.016.1, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %.016 = getelementptr inbounds i8, ptr %.pn20, i64 4
  %8 = load float, ptr %.016, align 4, !tbaa !5
  %9 = tail call float @llvm.fabs.f32(float %8)
  %10 = fcmp olt float %.01421, %9
  %11 = sub i32 %1, %.01323
  %.115 = select i1 %10, float %9, float %.01421
  %.1 = select i1 %10, i32 %11, i32 %.022
  %.013 = add i32 %.01323, -1
  %.016.1 = getelementptr inbounds i8, ptr %.pn20, i64 8
  %12 = load float, ptr %.016.1, align 4, !tbaa !5
  %13 = tail call float @llvm.fabs.f32(float %12)
  %14 = fcmp olt float %.115, %13
  %15 = sub i32 %1, %.013
  %.115.1 = select i1 %14, float %13, float %.115
  %.1.1 = select i1 %14, i32 %15, i32 %.1
  %.013.1 = add i32 %.01323, -2
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %.115.lcssa.ph = phi float [ poison, %.lr.ph.preheader ], [ %.115.1, %.lr.ph ]
  %.1.lcssa.ph = phi i32 [ poison, %.lr.ph.preheader ], [ %.1.1, %.lr.ph ]
  %.01323.unr = phi i32 [ %.01318, %.lr.ph.preheader ], [ %.013.1, %.lr.ph ]
  %.022.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %.1.1, %.lr.ph ]
  %.01421.unr = phi float [ %6, %.lr.ph.preheader ], [ %.115.1, %.lr.ph ]
  %.pn20.unr = phi ptr [ %0, %.lr.ph.preheader ], [ %.016.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %.016.epil = getelementptr inbounds i8, ptr %.pn20.unr, i64 4
  %16 = load float, ptr %.016.epil, align 4, !tbaa !5
  %17 = tail call float @llvm.fabs.f32(float %16)
  %18 = fcmp olt float %.01421.unr, %17
  %19 = sub i32 %1, %.01323.unr
  %.115.epil = select i1 %18, float %17, float %.01421.unr
  %.1.epil = select i1 %18, i32 %19, i32 %.022.unr
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %4
  %.014.lcssa = phi float [ %6, %4 ], [ %.115.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.115.epil, %.lr.ph.epil ]
  %.0.lcssa = phi i32 [ 0, %4 ], [ %.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.1.epil, %.lr.ph.epil ]
  store float %.014.lcssa, ptr %2, align 4, !tbaa !5
  store i32 %.0.lcssa, ptr %3, align 4, !tbaa !11
  ret void
}

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

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: 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, !6, i64 0}
!6 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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