; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/src/hid/ctrl.ll (ZN5daisy13AnalogControl13SetSampleRateEf)

; 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.daisy::AnalogControl" = type <{ ptr, float, float, float, float, float, i8, i8, i8, i8, float, [4 x i8] }>

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5daisy13AnalogControl8SetCoeffEf(ptr noundef nonnull align 8 dereferenceable(36), float noundef) #0 align 2

; 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 willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN5daisy13AnalogControl13SetSampleRateEf(ptr noundef nonnull align 8 dereferenceable(36) %0, float noundef %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  %7 = load float, ptr %4, align 4, !tbaa !9
  %8 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %6, i32 0, i32 2
  store float %7, ptr %8, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %9 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %6, i32 0, i32 8
  %10 = load i8, ptr %9, align 2, !tbaa !14, !range !15, !noundef !16
  %11 = trunc i8 %10 to i1
  br i1 %11, label %12, label %13

12:                                               ; preds = %2
  br label %16

13:                                               ; preds = %2
  %14 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %6, i32 0, i32 10
  %15 = load float, ptr %14, align 8, !tbaa !17
  br label %16

16:                                               ; preds = %13, %12
  %17 = phi float [ 0x3F60624DE0000000, %12 ], [ %15, %13 ]
  store float %17, ptr %5, align 4, !tbaa !9
  %18 = load float, ptr %5, align 4, !tbaa !9
  %19 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %6, i32 0, i32 2
  %20 = load float, ptr %19, align 4, !tbaa !11
  %21 = fmul float %18, %20
  %22 = fmul float %21, 5.000000e-01
  %23 = fdiv float 1.000000e+00, %22
  call void @_ZN5daisy13AnalogControl8SetCoeffEf(ptr noundef nonnull align 8 dereferenceable(36) %6, float noundef %23)
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"float", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"_ZTSN5daisy13AnalogControlE", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !13, i64 28, !13, i64 29, !13, i64 30, !10, i64 32}
!13 = !{!"bool", !7, i64 0}
!14 = !{!12, !13, i64 30}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!12, !10, i64 32}


; 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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZN5daisy13AnalogControl8SetCoeffEf(ptr noundef nonnull align 8 dereferenceable(36), float noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5daisy13AnalogControl13SetSampleRateEf(ptr noundef nonnull align 8 dereferenceable(36) %0, float noundef %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  store float %1, ptr %3, align 4, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 30
  %5 = load i8, ptr %4, align 2, !tbaa !12, !range !13, !noundef !14
  %6 = trunc nuw i8 %5 to i1
  %7 = getelementptr inbounds i8, ptr %0, i64 32
  %8 = load float, ptr %7, align 8
  %9 = select i1 %6, float 0x3F60624DE0000000, float %8
  %10 = fmul float %9, %1
  %11 = fmul float %10, 5.000000e-01
  %12 = fdiv float 1.000000e+00, %11
  tail call void @_ZN5daisy13AnalogControl8SetCoeffEf(ptr noundef nonnull align 8 dereferenceable(36) %0, float noundef %12)
  ret void
}

attributes #0 = { 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 #1 = { 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" }

!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 12}
!6 = !{!"_ZTSN5daisy13AnalogControlE", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !11, i64 28, !11, i64 29, !11, i64 30, !10, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"bool", !8, i64 0}
!12 = !{!6, !11, i64 30}
!13 = !{i8 0, i8 2}
!14 = !{}


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