; LLVM IR from glaretechnologies/substrata :: resonance-audio/resonance_audio/dsp (gain)

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

%class.NullLogger = type { i8 }

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN7vraudio14LinearGainRampEmffRKNS_11ChannelViewEPS0_b(i64 noundef %0, float noundef %1, float noundef %2, ptr noundef nonnull align 8 dereferenceable(17) %3, ptr noundef %4, i1 noundef zeroext %5) #0 {
  %7 = alloca i64, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i8, align 1
  %13 = alloca %class.NullLogger, align 1
  %14 = alloca %class.NullLogger, align 1
  %15 = alloca %class.NullLogger, align 1
  %16 = alloca i64, align 8
  %17 = alloca i64, align 8
  %18 = alloca float, align 4
  %19 = alloca float, align 4
  %20 = alloca i64, align 8
  %21 = alloca i64, align 8
  store i64 %0, ptr %7, align 8, !tbaa !5
  store float %1, ptr %8, align 4, !tbaa !9
  store float %2, ptr %9, align 4, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !11
  store ptr %4, ptr %11, align 8, !tbaa !11
  %22 = zext i1 %5 to i8
  store i8 %22, ptr %12, align 1, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #5
  %23 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1) %13)
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %14) #5
  %24 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1) %14)
  call void @llvm.lifetime.end.p0(i64 1, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr %15) #5
  %25 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1) %15)
  call void @llvm.lifetime.end.p0(i64 1, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #5
  %26 = load ptr, ptr %10, align 8, !tbaa !11
  %27 = call noundef i64 @_ZNK7vraudio11ChannelView4sizeEv(ptr noundef nonnull align 8 dereferenceable(17) %26)
  store i64 %27, ptr %17, align 8, !tbaa !5
  %28 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %17)
  %29 = load i64, ptr %28, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #5
  store i64 %29, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  %30 = load float, ptr %9, align 4, !tbaa !9
  %31 = load float, ptr %8, align 4, !tbaa !9
  %32 = fsub float %30, %31
  %33 = load i64, ptr %7, align 8, !tbaa !5
  %34 = uitofp i64 %33 to float
  %35 = fdiv float %32, %34
  store float %35, ptr %18, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %36 = load float, ptr %8, align 4, !tbaa !9
  store float %36, ptr %19, align 4, !tbaa !9
  %37 = load i8, ptr %12, align 1, !tbaa !13, !range !15, !noundef !16
  %38 = trunc i8 %37 to i1
  br i1 %38, label %39, label %63

39:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #5
  store i64 0, ptr %20, align 8, !tbaa !5
  br label %40

40:                                               ; preds = %59, %39
  %41 = load i64, ptr %20, align 8, !tbaa !5
  %42 = load i64, ptr %16, align 8, !tbaa !5
  %43 = icmp ult i64 %41, %42
  br i1 %43, label %45, label %44

44:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #5
  br label %62

45:                                               ; preds = %40
  %46 = load float, ptr %19, align 4, !tbaa !9
  %47 = load ptr, ptr %10, align 8, !tbaa !11
  %48 = load i64, ptr %20, align 8, !tbaa !5
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %47, i64 noundef %48)
  %50 = load float, ptr %49, align 4, !tbaa !9
  %51 = load ptr, ptr %11, align 8, !tbaa !11
  %52 = load i64, ptr %20, align 8, !tbaa !5
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %51, i64 noundef %52)
  %54 = load float, ptr %53, align 4, !tbaa !9
  %55 = call float @llvm.fmuladd.f32(float %46, float %50, float %54)
  store float %55, ptr %53, align 4, !tbaa !9
  %56 = load float, ptr %18, align 4, !tbaa !9
  %57 = load float, ptr %19, align 4, !tbaa !9
  %58 = fadd float %57, %56
  store float %58, ptr %19, align 4, !tbaa !9
  br label %59

59:                                               ; preds = %45
  %60 = load i64, ptr %20, align 8, !tbaa !5
  %61 = add i64 %60, 1
  store i64 %61, ptr %20, align 8, !tbaa !5
  br label %40, !llvm.loop !17

62:                                               ; preds = %44
  br label %86

63:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %21) #5
  store i64 0, ptr %21, align 8, !tbaa !5
  br label %64

64:                                               ; preds = %82, %63
  %65 = load i64, ptr %21, align 8, !tbaa !5
  %66 = load i64, ptr %16, align 8, !tbaa !5
  %67 = icmp ult i64 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 8, ptr %21) #5
  br label %85

69:                                               ; preds = %64
  %70 = load float, ptr %19, align 4, !tbaa !9
  %71 = load ptr, ptr %10, align 8, !tbaa !11
  %72 = load i64, ptr %21, align 8, !tbaa !5
  %73 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %71, i64 noundef %72)
  %74 = load float, ptr %73, align 4, !tbaa !9
  %75 = fmul float %70, %74
  %76 = load ptr, ptr %11, align 8, !tbaa !11
  %77 = load i64, ptr %21, align 8, !tbaa !5
  %78 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %76, i64 noundef %77)
  store float %75, ptr %78, align 4, !tbaa !9
  %79 = load float, ptr %18, align 4, !tbaa !9
  %80 = load float, ptr %19, align 4, !tbaa !9
  %81 = fadd float %80, %79
  store float %81, ptr %19, align 4, !tbaa !9
  br label %82

82:                                               ; preds = %69
  %83 = load i64, ptr %21, align 8, !tbaa !5
  %84 = add i64 %83, 1
  store i64 %84, ptr %21, align 8, !tbaa !5
  br label %64, !llvm.loop !19

85:                                               ; preds = %68
  br label %86

86:                                               ; preds = %85, %62
  %87 = load float, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  ret float %87
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1)) #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7vraudio11ChannelView4sizeEv(ptr noundef nonnull align 8 dereferenceable(17)) #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17), i64 noundef) #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17), i64 noundef) #0 align 2

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

attributes #0 = { mustprogress 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 = { inlinehint 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 #3 = { 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 #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !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"

%class.NullLogger = type { i8 }

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN7vraudio14LinearGainRampEmffRKNS_11ChannelViewEPS0_b(i64 noundef %0, float noundef %1, float noundef %2, ptr noundef nonnull align 8 dereferenceable(17) %3, ptr noundef %4, i1 noundef zeroext %5) local_unnamed_addr #0 {
  %7 = alloca i64, align 8
  %8 = alloca %class.NullLogger, align 1
  %9 = alloca %class.NullLogger, align 1
  %10 = alloca %class.NullLogger, align 1
  %11 = alloca i64, align 8
  store i64 %0, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %8) #5
  %12 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1) %8)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %9) #5
  %13 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1) %9)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %9) #5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %10) #5
  %14 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1) %10)
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %11) #5
  %15 = call noundef i64 @_ZNK7vraudio11ChannelView4sizeEv(ptr noundef nonnull align 8 dereferenceable(17) %3)
  store i64 %15, ptr %11, align 8, !tbaa !5
  %16 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %7, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %17 = load i64, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %11) #5
  %18 = fsub float %2, %1
  %19 = load i64, ptr %7, align 8, !tbaa !5
  %20 = uitofp i64 %19 to float
  %21 = fdiv float %18, %20
  %.not35 = icmp eq i64 %17, 0
  br i1 %5, label %.preheader, label %.preheader27

.preheader27:                                     ; preds = %6
  br i1 %.not35, label %.loopexit, label %.lr.ph

.preheader:                                       ; preds = %6
  br i1 %.not35, label %.loopexit, label %.lr.ph33

.lr.ph33:                                         ; preds = %.preheader, %.lr.ph33
  %.02532 = phi i64 [ %28, %.lr.ph33 ], [ 0, %.preheader ]
  %.02631 = phi float [ %27, %.lr.ph33 ], [ %1, %.preheader ]
  %22 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %3, i64 noundef %.02532)
  %23 = load float, ptr %22, align 4, !tbaa !9
  %24 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %4, i64 noundef %.02532)
  %25 = load float, ptr %24, align 4, !tbaa !9
  %26 = call float @llvm.fmuladd.f32(float %.02631, float %23, float %25)
  store float %26, ptr %24, align 4, !tbaa !9
  %27 = fadd float %21, %.02631
  %28 = add nuw i64 %.02532, 1
  %exitcond38.not = icmp eq i64 %28, %17
  br i1 %exitcond38.not, label %.loopexit, label %.lr.ph33, !llvm.loop !11

.lr.ph:                                           ; preds = %.preheader27, %.lr.ph
  %.030 = phi i64 [ %34, %.lr.ph ], [ 0, %.preheader27 ]
  %.129 = phi float [ %33, %.lr.ph ], [ %1, %.preheader27 ]
  %29 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %3, i64 noundef %.030)
  %30 = load float, ptr %29, align 4, !tbaa !9
  %31 = fmul float %.129, %30
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17) %4, i64 noundef %.030)
  store float %31, ptr %32, align 4, !tbaa !9
  %33 = fadd float %21, %.129
  %34 = add nuw i64 %.030, 1
  %exitcond.not = icmp eq i64 %34, %17
  br i1 %exitcond.not, label %.loopexit, label %.lr.ph, !llvm.loop !13

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph33, %.preheader27, %.preheader
  %.2 = phi float [ %1, %.preheader ], [ %1, %.preheader27 ], [ %27, %.lr.ph33 ], [ %33, %.lr.ph ]
  ret float %.2
}

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZN10NullLogger9GetStreamEv(ptr noundef nonnull align 1 dereferenceable(1)) local_unnamed_addr #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minImERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZNK7vraudio11ChannelView4sizeEv(ptr noundef nonnull align 8 dereferenceable(17)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17), i64 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN7vraudio11ChannelViewixEm(ptr noundef nonnull align 8 dereferenceable(17), i64 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) #4

attributes #0 = { mustprogress 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 willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint 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 #3 = { 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 #4 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


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