; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/audiosource/ay/soloud_ay.ll (ZN6SoLoud10AyInstance7getInfoEj)

; 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::AyInstance" = type <{ %"class.SoLoud::AudioSourceInstance", ptr, ptr, i32, [4 x i8] }>
%"class.SoLoud::AudioSourceInstance" = type { ptr, i32, i32, i32, float, [8 x float], float, float, float, float, i32, float, float, double, double, %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", i32, [8 x float], i32, i32, [8 x ptr], [2 x ptr], i32, i32, i32, double }
%"class.SoLoud::Fader" = type { float, float, float, double, double, double, float, i32 }
%class.ChipPlayer = type { ptr, %class.SNDBUFFER, %class.SNDCHIP, %class.SNDCHIP, i32, i32, i32, i32 }
%class.SNDBUFFER = type <{ ptr, i32, i32, i32, [4 x i8] }>
%class.SNDCHIP = type <{ %class.SNDRENDER, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, i8, [2 x i8], [6 x [32 x i32]], i32, %union.anon, i32, i32, i32, i32, %struct.SNDCHIP_VOLTAB, %struct.SNDCHIP_PANTAB, [4 x i8] }>
%class.SNDRENDER = type { ptr, i32, i32, i32, i32, ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 }
%union.anon = type { [16 x i8] }
%struct.SNDCHIP_VOLTAB = type { [32 x i32] }
%struct.SNDCHIP_PANTAB = type { [6 x i32] }

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZN6SoLoud10AyInstance7getInfoEj(ptr noundef nonnull align 8 dereferenceable(516) %0, i32 noundef %1) unnamed_addr #0 align 2 {
  %3 = alloca float, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %4, align 8
  %7 = load i32, ptr %5, align 4, !tbaa !9
  %8 = and i32 %7, 15
  %9 = icmp ule i32 %8, 13
  br i1 %9, label %10, label %33

10:                                               ; preds = %2
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = icmp ult i32 %11, 16
  br i1 %12, label %13, label %20

13:                                               ; preds = %10
  %14 = getelementptr inbounds %"class.SoLoud::AyInstance", ptr %6, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = getelementptr inbounds %class.ChipPlayer, ptr %15, i32 0, i32 2
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = call noundef zeroext i8 @_ZN7SNDCHIP7get_regEj(ptr noundef nonnull align 8 dereferenceable(1164) %16, i32 noundef %17)
  %19 = uitofp i8 %18 to float
  store float %19, ptr %3, align 4
  br label %34

20:                                               ; preds = %10
  %21 = load i32, ptr %5, align 4, !tbaa !9
  %22 = and i32 %21, 16
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %32

24:                                               ; preds = %20
  %25 = getelementptr inbounds %"class.SoLoud::AyInstance", ptr %6, i32 0, i32 2
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %class.ChipPlayer, ptr %26, i32 0, i32 3
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = and i32 %28, 15
  %30 = call noundef zeroext i8 @_ZN7SNDCHIP7get_regEj(ptr noundef nonnull align 8 dereferenceable(1164) %27, i32 noundef %29)
  %31 = uitofp i8 %30 to float
  store float %31, ptr %3, align 4
  br label %34

32:                                               ; preds = %20
  br label %33

33:                                               ; preds = %32, %2
  store float 0.000000e+00, ptr %3, align 4
  br label %34

34:                                               ; preds = %33, %24, %13
  %35 = load float, ptr %3, align 4
  ret float %35
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZN7SNDCHIP7get_regEj(ptr noundef nonnull align 8 dereferenceable(1164), i32 noundef) #1 align 2

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 = { 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, !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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 504}
!12 = !{!"_ZTSN6SoLoud10AyInstanceE", !13, i64 0, !6, i64 496, !6, i64 504, !10, i64 512}
!13 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !10, i64 8, !10, i64 12, !10, i64 16, !14, i64 20, !7, i64 24, !14, i64 56, !14, i64 60, !14, i64 64, !14, i64 68, !10, i64 72, !14, i64 76, !14, i64 80, !15, i64 88, !15, i64 96, !16, i64 104, !16, i64 152, !16, i64 200, !16, i64 248, !16, i64 296, !10, i64 344, !7, i64 348, !10, i64 380, !10, i64 384, !7, i64 392, !7, i64 456, !10, i64 472, !10, i64 476, !10, i64 480, !15, i64 488}
!14 = !{!"float", !7, i64 0}
!15 = !{!"double", !7, i64 0}
!16 = !{!"_ZTSN6SoLoud5FaderE", !14, i64 0, !14, i64 4, !14, i64 8, !15, i64 16, !15, i64 24, !15, i64 32, !14, i64 40, !10, i64 44}


; 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 nounwind uwtable
define dso_local noundef float @_ZN6SoLoud10AyInstance7getInfoEj(ptr nocapture noundef nonnull readonly align 8 dereferenceable(516) %0, i32 noundef %1) unnamed_addr #0 align 2 {
  %3 = and i32 %1, 15
  %4 = icmp ult i32 %3, 14
  br i1 %4, label %5, label %14

5:                                                ; preds = %2
  %6 = icmp ult i32 %1, 16
  br i1 %6, label %.sink.split, label %7

7:                                                ; preds = %5
  %8 = and i32 %1, 16
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %14, label %.sink.split

.sink.split:                                      ; preds = %7, %5
  %.sink10 = phi i64 [ 32, %5 ], [ 1200, %7 ]
  %.sink9 = phi i32 [ %1, %5 ], [ %3, %7 ]
  %9 = getelementptr inbounds i8, ptr %0, i64 504
  %10 = load ptr, ptr %9, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 %.sink10
  %12 = tail call noundef zeroext i8 @_ZN7SNDCHIP7get_regEj(ptr noundef nonnull align 8 dereferenceable(1164) %11, i32 noundef %.sink9)
  %13 = uitofp i8 %12 to float
  br label %14

14:                                               ; preds = %.sink.split, %2, %7
  %.0 = phi float [ 0.000000e+00, %7 ], [ 0.000000e+00, %2 ], [ %13, %.sink.split ]
  ret float %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i8 @_ZN7SNDCHIP7get_regEj(ptr noundef nonnull align 8 dereferenceable(1164), i32 noundef) local_unnamed_addr #0 align 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" }

!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, !14, i64 504}
!6 = !{!"_ZTSN6SoLoud10AyInstanceE", !7, i64 0, !14, i64 496, !14, i64 504, !8, i64 512}
!7 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !8, i64 8, !8, i64 12, !8, i64 16, !11, i64 20, !9, i64 24, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !8, i64 72, !11, i64 76, !11, i64 80, !12, i64 88, !12, i64 96, !13, i64 104, !13, i64 152, !13, i64 200, !13, i64 248, !13, i64 296, !8, i64 344, !9, i64 348, !8, i64 380, !8, i64 384, !9, i64 392, !9, i64 456, !8, i64 472, !8, i64 476, !8, i64 480, !12, i64 488}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"float", !9, i64 0}
!12 = !{!"double", !9, i64 0}
!13 = !{!"_ZTSN6SoLoud5FaderE", !11, i64 0, !11, i64 4, !11, i64 8, !12, i64 16, !12, i64 24, !12, i64 32, !11, i64 40, !8, i64 44}
!14 = !{!"any pointer", !9, i64 0}


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