; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core/soloud_filter.ll (ZN6SoLoud14FilterInstance12updateParamsEd)

; 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.SoLoud::FilterInstance" = type { ptr, i32, i32, ptr, ptr }
%"class.SoLoud::Fader" = type { float, float, float, double, double, double, float, i32 }

; 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 uwtable
define dso_local void @_ZN6SoLoud14FilterInstance12updateParamsEd(ptr noundef nonnull align 8 dereferenceable(32) %0, double noundef %1) unnamed_addr #1 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca double, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store double %1, ptr %4, align 8, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !11
  br label %7

7:                                                ; preds = %40, %2
  %8 = load i32, ptr %5, align 4, !tbaa !11
  %9 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %6, i32 0, i32 1
  %10 = load i32, ptr %9, align 8, !tbaa !13
  %11 = icmp ult i32 %8, %10
  br i1 %11, label %12, label %43

12:                                               ; preds = %7
  %13 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %6, i32 0, i32 4
  %14 = load ptr, ptr %13, align 8, !tbaa !15
  %15 = load i32, ptr %5, align 4, !tbaa !11
  %16 = zext i32 %15 to i64
  %17 = getelementptr inbounds %"class.SoLoud::Fader", ptr %14, i64 %16
  %18 = getelementptr inbounds %"class.SoLoud::Fader", ptr %17, i32 0, i32 7
  %19 = load i32, ptr %18, align 4, !tbaa !16
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %21, label %39

21:                                               ; preds = %12
  %22 = load i32, ptr %5, align 4, !tbaa !11
  %23 = shl i32 1, %22
  %24 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %6, i32 0, i32 2
  %25 = load i32, ptr %24, align 4, !tbaa !19
  %26 = or i32 %25, %23
  store i32 %26, ptr %24, align 4, !tbaa !19
  %27 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %6, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  %29 = load i32, ptr %5, align 4, !tbaa !11
  %30 = zext i32 %29 to i64
  %31 = getelementptr inbounds %"class.SoLoud::Fader", ptr %28, i64 %30
  %32 = load double, ptr %4, align 8, !tbaa !9
  %33 = call noundef float @_ZN6SoLoud5Fader3getEd(ptr noundef nonnull align 8 dereferenceable(48) %31, double noundef %32)
  %34 = getelementptr inbounds %"class.SoLoud::FilterInstance", ptr %6, i32 0, i32 3
  %35 = load ptr, ptr %34, align 8, !tbaa !20
  %36 = load i32, ptr %5, align 4, !tbaa !11
  %37 = zext i32 %36 to i64
  %38 = getelementptr inbounds float, ptr %35, i64 %37
  store float %33, ptr %38, align 4, !tbaa !21
  br label %39

39:                                               ; preds = %21, %12
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %5, align 4, !tbaa !11
  %42 = add i32 %41, 1
  store i32 %42, ptr %5, align 4, !tbaa !11
  br label %7, !llvm.loop !22

43:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

declare noundef float @_ZN6SoLoud5Fader3getEd(ptr noundef nonnull align 8 dereferenceable(48), double noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_ZTSN6SoLoud14FilterInstanceE", !12, i64 8, !12, i64 12, !6, i64 16, !6, i64 24}
!15 = !{!14, !6, i64 24}
!16 = !{!17, !12, i64 44}
!17 = !{!"_ZTSN6SoLoud5FaderE", !18, i64 0, !18, i64 4, !18, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !18, i64 40, !12, i64 44}
!18 = !{!"float", !7, i64 0}
!19 = !{!14, !12, i64 12}
!20 = !{!14, !6, i64 16}
!21 = !{!18, !18, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"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"

%"class.SoLoud::Fader" = type { float, float, float, double, double, double, float, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud14FilterInstance12updateParamsEd(ptr nocapture noundef nonnull align 8 dereferenceable(32) %0, double noundef %1) unnamed_addr #0 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = getelementptr inbounds i8, ptr %0, i64 12
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  br label %8

8:                                                ; preds = %.lr.ph, %23
  %9 = phi i32 [ %4, %.lr.ph ], [ %24, %23 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %23 ]
  %10 = load ptr, ptr %5, align 8, !tbaa !11
  %11 = getelementptr inbounds %"class.SoLoud::Fader", ptr %10, i64 %indvars.iv, i32 7
  %12 = load i32, ptr %11, align 4, !tbaa !12
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %23

14:                                               ; preds = %8
  %15 = trunc nuw i64 %indvars.iv to i32
  %16 = shl nuw i32 1, %15
  %17 = load i32, ptr %6, align 4, !tbaa !16
  %18 = or i32 %17, %16
  store i32 %18, ptr %6, align 4, !tbaa !16
  %19 = getelementptr inbounds %"class.SoLoud::Fader", ptr %10, i64 %indvars.iv
  %20 = tail call noundef float @_ZN6SoLoud5Fader3getEd(ptr noundef nonnull align 8 dereferenceable(48) %19, double noundef %1)
  %21 = load ptr, ptr %7, align 8, !tbaa !17
  %22 = getelementptr inbounds float, ptr %21, i64 %indvars.iv
  store float %20, ptr %22, align 4, !tbaa !18
  %.pre = load i32, ptr %3, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %8, %14
  %24 = phi i32 [ %9, %8 ], [ %.pre, %14 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = zext i32 %24 to i64
  %26 = icmp ult i64 %indvars.iv.next, %25
  br i1 %26, label %8, label %._crit_edge, !llvm.loop !19

._crit_edge:                                      ; preds = %23, %2
  ret void
}

declare noundef float @_ZN6SoLoud5Fader3getEd(ptr noundef nonnull align 8 dereferenceable(48), double noundef) local_unnamed_addr #1

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 = { "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" }

!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 8}
!6 = !{!"_ZTSN6SoLoud14FilterInstanceE", !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!13, !7, i64 44}
!13 = !{!"_ZTSN6SoLoud5FaderE", !14, i64 0, !14, i64 4, !14, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !14, i64 40, !7, i64 44}
!14 = !{!"float", !8, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = !{!6, !7, i64 12}
!17 = !{!6, !10, i64 16}
!18 = !{!14, !14, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


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