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

; 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: mustprogress nounwind uwtable
define dso_local noundef float @_ZN5daisy13AnalogControl7ProcessEv(ptr noundef nonnull align 8 dereferenceable(36) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca float, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %5 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %4, i32 0, i32 0
  %6 = load ptr, ptr %5, align 8, !tbaa !9
  %7 = load i16, ptr %6, align 2, !tbaa !13
  %8 = uitofp i16 %7 to float
  %9 = fdiv float %8, 6.553600e+04
  store float %9, ptr %3, align 4, !tbaa !15
  %10 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %4, i32 0, i32 6
  %11 = load i8, ptr %10, align 4, !tbaa !16, !range !17, !noundef !18
  %12 = trunc i8 %11 to i1
  br i1 %12, label %13, label %16

13:                                               ; preds = %1
  %14 = load float, ptr %3, align 4, !tbaa !15
  %15 = fsub float 1.000000e+00, %14
  store float %15, ptr %3, align 4, !tbaa !15
  br label %16

16:                                               ; preds = %13, %1
  %17 = load float, ptr %3, align 4, !tbaa !15
  %18 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %4, i32 0, i32 5
  %19 = load float, ptr %18, align 8, !tbaa !19
  %20 = fsub float %17, %19
  %21 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %4, i32 0, i32 4
  %22 = load float, ptr %21, align 4, !tbaa !20
  %23 = fmul float %20, %22
  %24 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %4, i32 0, i32 7
  %25 = load i8, ptr %24, align 1, !tbaa !21, !range !17, !noundef !18
  %26 = trunc i8 %25 to i1
  %27 = zext i1 %26 to i64
  %28 = select i1 %26, float -1.000000e+00, float 1.000000e+00
  %29 = fmul float %23, %28
  store float %29, ptr %3, align 4, !tbaa !15
  %30 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %4, i32 0, i32 1
  %31 = load float, ptr %30, align 8, !tbaa !22
  %32 = load float, ptr %3, align 4, !tbaa !15
  %33 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %4, i32 0, i32 3
  %34 = load float, ptr %33, align 8, !tbaa !23
  %35 = fsub float %32, %34
  %36 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %4, i32 0, i32 3
  %37 = load float, ptr %36, align 8, !tbaa !23
  %38 = call float @llvm.fmuladd.f32(float %31, float %35, float %37)
  store float %38, ptr %36, align 8, !tbaa !23
  %39 = getelementptr inbounds %"class.daisy::AnalogControl", ptr %4, i32 0, i32 3
  %40 = load float, ptr %39, align 8, !tbaa !23
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret float %40
}

; 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #2

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

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


; 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 norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local noundef float @_ZN5daisy13AnalogControl7ProcessEv(ptr nocapture noundef nonnull align 8 dereferenceable(36) %0) local_unnamed_addr #0 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = load i16, ptr %2, align 2, !tbaa !12
  %4 = uitofp i16 %3 to float
  %5 = fmul float %4, 0x3EF0000000000000
  %6 = getelementptr inbounds i8, ptr %0, i64 28
  %7 = load i8, ptr %6, align 4, !tbaa !14, !range !15, !noundef !16
  %8 = trunc nuw i8 %7 to i1
  %9 = fsub float 1.000000e+00, %5
  %.0 = select i1 %8, float %9, float %5
  %10 = getelementptr inbounds i8, ptr %0, i64 24
  %11 = load float, ptr %10, align 8, !tbaa !17
  %12 = fsub float %.0, %11
  %13 = getelementptr inbounds i8, ptr %0, i64 20
  %14 = load float, ptr %13, align 4, !tbaa !18
  %15 = fmul float %14, %12
  %16 = getelementptr inbounds i8, ptr %0, i64 29
  %17 = load i8, ptr %16, align 1, !tbaa !19, !range !15, !noundef !16
  %18 = trunc nuw i8 %17 to i1
  %19 = fneg float %15
  %20 = select i1 %18, float %19, float %15
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %22 = load float, ptr %21, align 8, !tbaa !20
  %23 = getelementptr inbounds i8, ptr %0, i64 16
  %24 = load float, ptr %23, align 8, !tbaa !21
  %25 = fsub float %20, %24
  %26 = tail call float @llvm.fmuladd.f32(float %22, float %25, float %24)
  store float %26, ptr %23, align 8, !tbaa !21
  ret float %26
}

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

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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 speculatable willreturn memory(none) }

!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 0}
!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 = !{!13, !13, i64 0}
!13 = !{!"short", !8, i64 0}
!14 = !{!6, !11, i64 28}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!6, !10, i64 24}
!18 = !{!6, !10, i64 20}
!19 = !{!6, !11, i64 29}
!20 = !{!6, !10, i64 8}
!21 = !{!6, !10, i64 16}


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