; LLVM IR from lichen-community-systems/signaletic :: hosts/daisy/vendor/libDaisy/src/hid (parameter)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5daisy9Parameter4InitENS_13AnalogControlEffNS0_5CurveE(ptr noundef nonnull align 8 dereferenceable(64) %0, ptr noundef %1, float noundef %2, float noundef %3, i32 noundef %4) #0 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !11
  %11 = load ptr, ptr %6, align 8
  %12 = load float, ptr %8, align 4, !tbaa !9
  %13 = getelementptr inbounds %"class.daisy::Parameter", ptr %11, i32 0, i32 1
  store float %12, ptr %13, align 8, !tbaa !13
  %14 = load float, ptr %9, align 4, !tbaa !9
  %15 = getelementptr inbounds %"class.daisy::Parameter", ptr %11, i32 0, i32 2
  store float %14, ptr %15, align 4, !tbaa !17
  %16 = load i32, ptr %10, align 4, !tbaa !11
  %17 = getelementptr inbounds %"class.daisy::Parameter", ptr %11, i32 0, i32 6
  store i32 %16, ptr %17, align 4, !tbaa !18
  %18 = getelementptr inbounds %"class.daisy::Parameter", ptr %11, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %18, ptr align 8 %1, i64 36, i1 false), !tbaa.struct !19
  %19 = load float, ptr %8, align 4, !tbaa !9
  %20 = fcmp olt float %19, 0x3E7AD7F2A0000000
  br i1 %20, label %21, label %22

21:                                               ; preds = %5
  br label %24

22:                                               ; preds = %5
  %23 = load float, ptr %8, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %22, %21
  %25 = phi float [ 0x3E7AD7F2A0000000, %21 ], [ %23, %22 ]
  %26 = call float @logf(float noundef %25) #3
  %27 = getelementptr inbounds %"class.daisy::Parameter", ptr %11, i32 0, i32 3
  store float %26, ptr %27, align 8, !tbaa !21
  %28 = load float, ptr %9, align 4, !tbaa !9
  %29 = call float @logf(float noundef %28) #3
  %30 = getelementptr inbounds %"class.daisy::Parameter", ptr %11, i32 0, i32 4
  store float %29, ptr %30, align 4, !tbaa !22
  ret void
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: nounwind
declare float @logf(float noundef) #2

attributes #0 = { 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nounwind "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, !12, i64 0}
!12 = !{!"_ZTSN5daisy9Parameter5CurveE", !7, i64 0}
!13 = !{!14, !10, i64 40}
!14 = !{!"_ZTSN5daisy9ParameterE", !15, i64 0, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !10, i64 56, !12, i64 60}
!15 = !{!"_ZTSN5daisy13AnalogControlE", !6, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !16, i64 28, !16, i64 29, !16, i64 30, !10, i64 32}
!16 = !{!"bool", !7, i64 0}
!17 = !{!14, !10, i64 44}
!18 = !{!14, !12, i64 60}
!19 = !{i64 0, i64 8, !5, i64 8, i64 4, !9, i64 12, i64 4, !9, i64 16, i64 4, !9, i64 20, i64 4, !9, i64 24, i64 4, !9, i64 28, i64 1, !20, i64 29, i64 1, !20, i64 30, i64 1, !20, i64 32, i64 4, !9}
!20 = !{!16, !16, i64 0}
!21 = !{!14, !10, i64 48}
!22 = !{!14, !10, i64 52}


; 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 nounwind willreturn memory(write, argmem: readwrite) uwtable
define dso_local void @_ZN5daisy9Parameter4InitENS_13AnalogControlEffNS0_5CurveE(ptr nocapture noundef nonnull writeonly align 8 dereferenceable(64) %0, ptr nocapture noundef readonly %1, float noundef %2, float noundef %3, i32 noundef %4) local_unnamed_addr #0 align 2 {
  %6 = getelementptr inbounds i8, ptr %0, i64 40
  store float %2, ptr %6, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 44
  store float %3, ptr %7, align 4, !tbaa !14
  %8 = getelementptr inbounds i8, ptr %0, i64 60
  store i32 %4, ptr %8, align 4, !tbaa !15
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(36) %0, ptr noundef nonnull align 8 dereferenceable(36) %1, i64 36, i1 false), !tbaa.struct !16
  %9 = fcmp olt float %2, 0x3E7AD7F2A0000000
  %10 = select i1 %9, float 0x3E7AD7F2A0000000, float %2
  %11 = tail call float @logf(float noundef %10) #3
  %12 = getelementptr inbounds i8, ptr %0, i64 48
  store float %11, ptr %12, align 8, !tbaa !20
  %13 = tail call float @logf(float noundef %3) #3
  %14 = getelementptr inbounds i8, ptr %0, i64 52
  store float %13, ptr %14, align 4, !tbaa !21
  ret void
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @logf(float noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nofree nounwind willreturn memory(write, argmem: readwrite) 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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nofree nounwind willreturn memory(write) "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, !11, i64 40}
!6 = !{!"_ZTSN5daisy9ParameterE", !7, i64 0, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !13, i64 60}
!7 = !{!"_ZTSN5daisy13AnalogControlE", !8, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !12, i64 28, !12, i64 29, !12, i64 30, !11, i64 32}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"bool", !9, i64 0}
!13 = !{!"_ZTSN5daisy9Parameter5CurveE", !9, i64 0}
!14 = !{!6, !11, i64 44}
!15 = !{!6, !13, i64 60}
!16 = !{i64 0, i64 8, !17, i64 8, i64 4, !18, i64 12, i64 4, !18, i64 16, i64 4, !18, i64 20, i64 4, !18, i64 24, i64 4, !18, i64 28, i64 1, !19, i64 29, i64 1, !19, i64 30, i64 1, !19, i64 32, i64 4, !18}
!17 = !{!8, !8, i64 0}
!18 = !{!11, !11, i64 0}
!19 = !{!12, !12, i64 0}
!20 = !{!6, !11, i64 48}
!21 = !{!6, !11, i64 52}


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