; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/CMSIS/DSP/Source/InterpolationFunctions (arm_linear_interp_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_linear_interp_instance_f32 = type { i32, float, float, ptr }

; Function Attrs: nounwind uwtable
define dso_local float @arm_linear_interp_f32(ptr noundef %0, float noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = alloca float, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  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
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.arm_linear_interp_instance_f32, ptr %13, i32 0, i32 2
  %15 = load float, ptr %14, align 8, !tbaa !11
  store float %15, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.arm_linear_interp_instance_f32, ptr %16, i32 0, i32 3
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  store ptr %18, ptr %12, align 8, !tbaa !5
  %19 = load float, ptr %4, align 4, !tbaa !9
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.arm_linear_interp_instance_f32, ptr %20, i32 0, i32 1
  %22 = load float, ptr %21, align 4, !tbaa !15
  %23 = fsub float %19, %22
  %24 = load float, ptr %10, align 4, !tbaa !9
  %25 = fdiv float %23, %24
  %26 = fptosi float %25 to i32
  store i32 %26, ptr %11, align 4, !tbaa !16
  %27 = load i32, ptr %11, align 4, !tbaa !16
  %28 = icmp slt i32 %27, 0
  br i1 %28, label %29, label %33

29:                                               ; preds = %2
  %30 = load ptr, ptr %12, align 8, !tbaa !5
  %31 = getelementptr inbounds float, ptr %30, i64 0
  %32 = load float, ptr %31, align 4, !tbaa !9
  store float %32, ptr %5, align 4, !tbaa !9
  br label %89

33:                                               ; preds = %2
  %34 = load i32, ptr %11, align 4, !tbaa !16
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.arm_linear_interp_instance_f32, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !17
  %38 = sub i32 %37, 1
  %39 = icmp uge i32 %34, %38
  br i1 %39, label %40, label %49

40:                                               ; preds = %33
  %41 = load ptr, ptr %12, align 8, !tbaa !5
  %42 = load ptr, ptr %3, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.arm_linear_interp_instance_f32, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !17
  %45 = sub i32 %44, 1
  %46 = zext i32 %45 to i64
  %47 = getelementptr inbounds float, ptr %41, i64 %46
  %48 = load float, ptr %47, align 4, !tbaa !9
  store float %48, ptr %5, align 4, !tbaa !9
  br label %88

49:                                               ; preds = %33
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.arm_linear_interp_instance_f32, ptr %50, i32 0, i32 1
  %52 = load float, ptr %51, align 4, !tbaa !15
  %53 = load i32, ptr %11, align 4, !tbaa !16
  %54 = sitofp i32 %53 to float
  %55 = load float, ptr %10, align 4, !tbaa !9
  %56 = call float @llvm.fmuladd.f32(float %54, float %55, float %52)
  store float %56, ptr %6, align 4, !tbaa !9
  %57 = load ptr, ptr %3, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.arm_linear_interp_instance_f32, ptr %57, i32 0, i32 1
  %59 = load float, ptr %58, align 4, !tbaa !15
  %60 = load i32, ptr %11, align 4, !tbaa !16
  %61 = add nsw i32 %60, 1
  %62 = sitofp i32 %61 to float
  %63 = load float, ptr %10, align 4, !tbaa !9
  %64 = call float @llvm.fmuladd.f32(float %62, float %63, float %59)
  store float %64, ptr %7, align 4, !tbaa !9
  %65 = load ptr, ptr %12, align 8, !tbaa !5
  %66 = load i32, ptr %11, align 4, !tbaa !16
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !9
  store float %69, ptr %8, align 4, !tbaa !9
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = load i32, ptr %11, align 4, !tbaa !16
  %72 = add nsw i32 %71, 1
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds float, ptr %70, i64 %73
  %75 = load float, ptr %74, align 4, !tbaa !9
  store float %75, ptr %9, align 4, !tbaa !9
  %76 = load float, ptr %8, align 4, !tbaa !9
  %77 = load float, ptr %4, align 4, !tbaa !9
  %78 = load float, ptr %6, align 4, !tbaa !9
  %79 = fsub float %77, %78
  %80 = load float, ptr %9, align 4, !tbaa !9
  %81 = load float, ptr %8, align 4, !tbaa !9
  %82 = fsub float %80, %81
  %83 = load float, ptr %7, align 4, !tbaa !9
  %84 = load float, ptr %6, align 4, !tbaa !9
  %85 = fsub float %83, %84
  %86 = fdiv float %82, %85
  %87 = call float @llvm.fmuladd.f32(float %79, float %86, float %76)
  store float %87, ptr %5, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %49, %40
  br label %89

89:                                               ; preds = %88, %29
  %90 = load float, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, 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
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret float %90
}

; 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, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"", !13, i64 0, !10, i64 4, !10, i64 8, !6, i64 16}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !10, i64 4}
!16 = !{!13, !13, i64 0}
!17 = !{!12, !13, i64 0}


; 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 nofree norecurse nosync nounwind willreturn memory(read, inaccessiblemem: none) uwtable
define dso_local float @arm_linear_interp_f32(ptr nocapture noundef readonly %0, float noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load float, ptr %3, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %8 = load float, ptr %7, align 4, !tbaa !13
  %9 = fsub float %1, %8
  %10 = fdiv float %9, %4
  %11 = fptosi float %10 to i32
  %12 = icmp slt i32 %11, 0
  br i1 %12, label %13, label %15

13:                                               ; preds = %2
  %14 = load float, ptr %6, align 4, !tbaa !14
  br label %39

15:                                               ; preds = %2
  %16 = load i32, ptr %0, align 8, !tbaa !15
  %17 = add i32 %16, -1
  %.not = icmp ugt i32 %17, %11
  br i1 %.not, label %22, label %18

18:                                               ; preds = %15
  %19 = zext nneg i32 %17 to i64
  %20 = getelementptr inbounds float, ptr %6, i64 %19
  %21 = load float, ptr %20, align 4, !tbaa !14
  br label %39

22:                                               ; preds = %15
  %23 = uitofp nneg i32 %11 to float
  %24 = tail call float @llvm.fmuladd.f32(float %23, float %4, float %8)
  %25 = add nuw nsw i32 %11, 1
  %26 = uitofp nneg i32 %25 to float
  %27 = tail call float @llvm.fmuladd.f32(float %26, float %4, float %8)
  %28 = zext nneg i32 %11 to i64
  %29 = getelementptr inbounds float, ptr %6, i64 %28
  %30 = load float, ptr %29, align 4, !tbaa !14
  %31 = zext nneg i32 %25 to i64
  %32 = getelementptr inbounds float, ptr %6, i64 %31
  %33 = load float, ptr %32, align 4, !tbaa !14
  %34 = fsub float %1, %24
  %35 = fsub float %33, %30
  %36 = fsub float %27, %24
  %37 = fdiv float %35, %36
  %38 = tail call float @llvm.fmuladd.f32(float %34, float %37, float %30)
  br label %39

39:                                               ; preds = %18, %22, %13
  %.0 = phi float [ %14, %13 ], [ %21, %18 ], [ %38, %22 ]
  ret float %.0
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, 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, !10, i64 8}
!6 = !{!"", !7, i64 0, !10, i64 4, !10, i64 8, !11, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!6, !11, i64 16}
!13 = !{!6, !10, i64 4}
!14 = !{!10, !10, i64 0}
!15 = !{!6, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass