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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

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

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

; 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 @_ZN5daisy16MappedFloatValue11SetFrom0to1Ef(ptr noundef nonnull align 8 dereferenceable(42) %0, float noundef %1) unnamed_addr #3 align 2 {
  %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 i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  %9 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %10 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 5
  %11 = load i32, ptr %10, align 8, !tbaa !11
  switch i32 %11, label %50 [
    i32 0, label %12
    i32 1, label %22
    i32 2, label %37
  ]

12:                                               ; preds = %2
  %13 = load float, ptr %4, align 4, !tbaa !9
  %14 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 3
  %15 = load float, ptr %14, align 8, !tbaa !16
  %16 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 2
  %17 = load float, ptr %16, align 4, !tbaa !17
  %18 = fsub float %15, %17
  %19 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 2
  %20 = load float, ptr %19, align 4, !tbaa !17
  %21 = call float @llvm.fmuladd.f32(float %13, float %18, float %20)
  store float %21, ptr %5, align 4, !tbaa !9
  br label %52

22:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %23 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 3
  %24 = load float, ptr %23, align 8, !tbaa !16
  %25 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 2
  %26 = load float, ptr %25, align 4, !tbaa !17
  %27 = fdiv float %24, %26
  %28 = call float @log10f(float noundef %27) #5
  %29 = fdiv float 1.000000e+00, %28
  store float %29, ptr %6, align 4, !tbaa !9
  %30 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 2
  %31 = load float, ptr %30, align 4, !tbaa !17
  %32 = load float, ptr %4, align 4, !tbaa !9
  %33 = load float, ptr %6, align 4, !tbaa !9
  %34 = fdiv float %32, %33
  %35 = call float @powf(float noundef 1.000000e+01, float noundef %34) #5
  %36 = fmul float %31, %35
  store float %36, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %52

37:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %38 = load float, ptr %4, align 4, !tbaa !9
  %39 = load float, ptr %4, align 4, !tbaa !9
  %40 = fmul float %38, %39
  store float %40, ptr %7, align 4, !tbaa !9
  %41 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 2
  %42 = load float, ptr %41, align 4, !tbaa !17
  %43 = load float, ptr %7, align 4, !tbaa !9
  %44 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 3
  %45 = load float, ptr %44, align 8, !tbaa !16
  %46 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 2
  %47 = load float, ptr %46, align 4, !tbaa !17
  %48 = fsub float %45, %47
  %49 = call float @llvm.fmuladd.f32(float %43, float %48, float %42)
  store float %49, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %52

50:                                               ; preds = %2
  %51 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 1
  store float 0.000000e+00, ptr %51, align 8, !tbaa !18
  store i32 1, ptr %8, align 4
  br label %59

52:                                               ; preds = %37, %22, %12
  %53 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 2
  %54 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 3
  %55 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %54, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %56 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %53, ptr noundef nonnull align 4 dereferenceable(4) %55)
  %57 = load float, ptr %56, align 4, !tbaa !9
  %58 = getelementptr inbounds %"class.daisy::MappedFloatValue", ptr %9, i32 0, i32 1
  store float %57, ptr %58, align 8, !tbaa !18
  store i32 0, ptr %8, align 4
  br label %59

59:                                               ; preds = %52, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  %60 = load i32, ptr %8, align 4
  switch i32 %60, label %62 [
    i32 0, label %61
    i32 1, label %61
  ]

61:                                               ; preds = %59, %59
  ret void

62:                                               ; preds = %59
  unreachable
}

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

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

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 = { 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 = { 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 #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 = !{!"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, !14, i64 24}
!12 = !{!"_ZTSN5daisy16MappedFloatValueE", !13, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !14, i64 24, !6, i64 32, !7, i64 40, !15, i64 41}
!13 = !{!"_ZTSN5daisy11MappedValueE"}
!14 = !{!"_ZTSN5daisy16MappedFloatValue7MappingE", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!12, !10, i64 16}
!17 = !{!12, !10, i64 12}
!18 = !{!12, !10, i64 8}


; 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 noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #0

; 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 nofree nounwind willreturn memory(write)
declare float @log10f(float noundef) local_unnamed_addr #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: mustprogress nounwind uwtable
define dso_local void @_ZN5daisy16MappedFloatValue11SetFrom0to1Ef(ptr noundef nonnull align 8 dereferenceable(42) %0, float noundef %1) unnamed_addr #3 align 2 {
  %3 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %4 = getelementptr inbounds i8, ptr %0, i64 24
  %5 = load i32, ptr %4, align 8, !tbaa !5
  switch i32 %5, label %39 [
    i32 0, label %6
    i32 1, label %13
    i32 2, label %25
  ]

6:                                                ; preds = %2
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load float, ptr %7, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %0, i64 12
  %10 = load float, ptr %9, align 4, !tbaa !15
  %11 = fsub float %8, %10
  %12 = tail call float @llvm.fmuladd.f32(float %1, float %11, float %10)
  store float %12, ptr %3, align 4, !tbaa !16
  br label %33

13:                                               ; preds = %2
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  %15 = load float, ptr %14, align 8, !tbaa !14
  %16 = getelementptr inbounds i8, ptr %0, i64 12
  %17 = load float, ptr %16, align 4, !tbaa !15
  %18 = fdiv float %15, %17
  %19 = tail call float @log10f(float noundef %18) #5
  %20 = fdiv float 1.000000e+00, %19
  %21 = load float, ptr %16, align 4, !tbaa !15
  %22 = fdiv float %1, %20
  %23 = tail call float @powf(float noundef 1.000000e+01, float noundef %22) #5
  %24 = fmul float %21, %23
  store float %24, ptr %3, align 4, !tbaa !16
  br label %33

25:                                               ; preds = %2
  %26 = fmul float %1, %1
  %27 = getelementptr inbounds i8, ptr %0, i64 12
  %28 = load float, ptr %27, align 4, !tbaa !15
  %29 = getelementptr inbounds i8, ptr %0, i64 16
  %30 = load float, ptr %29, align 8, !tbaa !14
  %31 = fsub float %30, %28
  %32 = tail call float @llvm.fmuladd.f32(float %26, float %31, float %28)
  store float %32, ptr %3, align 4, !tbaa !16
  br label %33

33:                                               ; preds = %25, %13, %6
  %34 = getelementptr inbounds i8, ptr %0, i64 12
  %35 = getelementptr inbounds i8, ptr %0, i64 16
  %36 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %35, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %37 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIfERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %34, ptr noundef nonnull align 4 dereferenceable(4) %36)
  %38 = load float, ptr %37, align 4, !tbaa !16
  br label %39

39:                                               ; preds = %2, %33
  %.sink = phi float [ %38, %33 ], [ 0.000000e+00, %2 ]
  %40 = getelementptr inbounds i8, ptr %0, i64 8
  store float %.sink, ptr %40, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  ret void
}

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

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

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 nocallback nofree nosync 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 = { 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, !11, i64 24}
!6 = !{!"_ZTSN5daisy16MappedFloatValueE", !7, i64 0, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !11, i64 24, !12, i64 32, !9, i64 40, !13, i64 41}
!7 = !{!"_ZTSN5daisy11MappedValueE"}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTSN5daisy16MappedFloatValue7MappingE", !9, i64 0}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"bool", !9, i64 0}
!14 = !{!6, !8, i64 16}
!15 = !{!6, !8, i64 12}
!16 = !{!8, !8, i64 0}
!17 = !{!6, !8, i64 8}


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