; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/audiosource/vizsn (soloud_vizsn)

; 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::VizsnInstance" = type { %"class.SoLoud::AudioSourceInstance", ptr, %"struct.SoLoud::VizsnBank", %"struct.SoLoud::VizsnBank", %"struct.SoLoud::VizsnBank", i32, i32, i32, [1024 x i32], i32, i32, float, ptr, [2048 x float], i32, i32, i32, i32, i32, float }
%"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 }
%"struct.SoLoud::VizsnBank" = type { [10 x %"struct.SoLoud::VizsnResonator"], float, float, float, float, float, float }
%"struct.SoLoud::VizsnResonator" = type { float, float, float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZN6SoLoud13VizsnInstance5vcsrcEii(ptr noundef nonnull align 8 dereferenceable(13520) %0, i32 noundef %1, i32 noundef %2) #0 align 2 {
  %4 = alloca float, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %8 = load ptr, ptr %5, align 8
  %9 = load i32, ptr %6, align 4, !tbaa !9
  %10 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %11 = load i32, ptr %10, align 8, !tbaa !11
  %12 = add nsw i32 %11, %9
  store i32 %12, ptr %10, align 8, !tbaa !11
  %13 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 18
  %14 = load i32, ptr %13, align 8, !tbaa !18
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = icmp ne i32 %14, %15
  br i1 %16, label %17, label %22

17:                                               ; preds = %3
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 18
  store i32 %18, ptr %19, align 8, !tbaa !18
  %20 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  store i32 0, ptr %20, align 8, !tbaa !11
  %21 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 17
  store i32 100, ptr %21, align 4, !tbaa !19
  br label %22

22:                                               ; preds = %17, %3
  %23 = load i32, ptr %7, align 4, !tbaa !9
  switch i32 %23, label %117 [
    i32 0, label %24
    i32 1, label %31
    i32 2, label %51
    i32 3, label %59
    i32 4, label %68
    i32 5, label %77
    i32 7, label %94
    i32 8, label %101
    i32 9, label %111
    i32 6, label %116
  ]

24:                                               ; preds = %22
  %25 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %26 = load i32, ptr %25, align 8, !tbaa !11
  %27 = and i32 %26, 416
  %28 = mul nsw i32 %27, 5
  %29 = sitofp i32 %28 to float
  %30 = fmul float %29, 0x3F2A36E2E0000000
  store float %30, ptr %4, align 4
  br label %123

31:                                               ; preds = %22
  %32 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %33 = load i32, ptr %32, align 8, !tbaa !11
  %34 = sitofp i32 %33 to double
  %35 = fmul double %34, 2.000000e-04
  %36 = call double @sin(double noundef %35) #3
  %37 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %38 = load i32, ptr %37, align 8, !tbaa !11
  %39 = sitofp i32 %38 to double
  %40 = fmul double %39, 3.000000e-04
  %41 = call double @cos(double noundef %40) #3
  %42 = fmul double %36, %41
  %43 = call i32 @rand() #3
  %44 = srem i32 %43, 200
  %45 = sub nsw i32 %44, 100
  %46 = sitofp i32 %45 to float
  %47 = fdiv float %46, 3.000000e+02
  %48 = fpext float %47 to double
  %49 = call double @llvm.fmuladd.f64(double %42, double 0x3FC99999A0000000, double %48)
  %50 = fptrunc double %49 to float
  store float %50, ptr %4, align 4
  br label %123

51:                                               ; preds = %22
  %52 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %53 = load i32, ptr %52, align 8, !tbaa !11
  %54 = sitofp i32 %53 to double
  %55 = fmul double %54, 2.000000e-05
  %56 = call double @tan(double noundef %55) #3
  %57 = fptrunc double %56 to float
  %58 = fmul float %57, 0x3F847AE140000000
  store float %58, ptr %4, align 4
  br label %123

59:                                               ; preds = %22
  %60 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %61 = load i32, ptr %60, align 8, !tbaa !11
  %62 = and i32 %61, 65535
  %63 = icmp sgt i32 %62, 32768
  %64 = zext i1 %63 to i64
  %65 = select i1 %63, i32 65535, i32 0
  %66 = sitofp i32 %65 to float
  %67 = fmul float %66, 0x3EE4F8B580000000
  store float %67, ptr %4, align 4
  br label %123

68:                                               ; preds = %22
  %69 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %70 = load i32, ptr %69, align 8, !tbaa !11
  %71 = sitofp i32 %70 to float
  %72 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %73 = load i32, ptr %72, align 8, !tbaa !11
  %74 = sitofp i32 %73 to float
  %75 = fmul float %71, %74
  %76 = fmul float %75, 0x3DEB7CDFE0000000
  store float %76, ptr %4, align 4
  br label %123

77:                                               ; preds = %22
  %78 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %79 = load i32, ptr %78, align 8, !tbaa !11
  %80 = add nsw i32 %79, 3
  store i32 %80, ptr %78, align 8, !tbaa !11
  %81 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 17
  %82 = load i32, ptr %81, align 4, !tbaa !19
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %81, align 4, !tbaa !19
  %84 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %85 = load i32, ptr %84, align 8, !tbaa !11
  %86 = and i32 %85, 255
  %87 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 17
  %88 = load i32, ptr %87, align 4, !tbaa !19
  %89 = ashr i32 %88, 2
  %90 = and i32 %89, 255
  %91 = icmp sgt i32 %86, %90
  %92 = zext i1 %91 to i64
  %93 = select i1 %91, float 0x3FD3333340000000, float 0.000000e+00
  store float %93, ptr %4, align 4
  br label %123

94:                                               ; preds = %22
  %95 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %96 = load i32, ptr %95, align 8, !tbaa !11
  %97 = ashr i32 %96, 8
  %98 = and i32 %97, 384
  %99 = sitofp i32 %98 to float
  %100 = fmul float %99, 0x3F50624DE0000000
  store float %100, ptr %4, align 4
  br label %123

101:                                              ; preds = %22
  %102 = call i32 @rand() #3
  %103 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %104 = load i32, ptr %103, align 8, !tbaa !11
  %105 = and i32 %104, 65535
  %106 = ashr i32 %105, 8
  %107 = add nsw i32 1, %106
  %108 = srem i32 %102, %107
  %109 = sitofp i32 %108 to float
  %110 = fdiv float %109, 2.560000e+02
  store float %110, ptr %4, align 4
  br label %123

111:                                              ; preds = %22
  %112 = call i32 @rand() #3
  %113 = and i32 %112, 32767
  %114 = sitofp i32 %113 to float
  %115 = fdiv float %114, 3.276700e+04
  store float %115, ptr %4, align 4
  br label %123

116:                                              ; preds = %22
  br label %117

117:                                              ; preds = %116, %22
  %118 = getelementptr inbounds %"class.SoLoud::VizsnInstance", ptr %8, i32 0, i32 16
  %119 = load i32, ptr %118, align 8, !tbaa !11
  %120 = and i32 %119, 65535
  %121 = sitofp i32 %120 to float
  %122 = fmul float %121, 0x3ED0624DE0000000
  store float %122, ptr %4, align 4
  br label %123

123:                                              ; preds = %117, %111, %101, %94, %77, %68, %59, %51, %31, %24
  %124 = load float, ptr %4, align 4
  ret float %124
}

; Function Attrs: nounwind
declare double @sin(double noundef) #1

; Function Attrs: nounwind
declare double @cos(double noundef) #1

; Function Attrs: nounwind
declare i32 @rand() #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

; Function Attrs: nounwind
declare double @tan(double noundef) #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 = { 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 #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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 13504}
!12 = !{!"_ZTSN6SoLoud13VizsnInstanceE", !13, i64 0, !6, i64 496, !17, i64 504, !17, i64 728, !17, i64 952, !10, i64 1176, !10, i64 1180, !10, i64 1184, !7, i64 1188, !10, i64 5284, !10, i64 5288, !14, i64 5292, !6, i64 5296, !7, i64 5304, !10, i64 13496, !10, i64 13500, !10, i64 13504, !10, i64 13508, !10, i64 13512, !14, i64 13516}
!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}
!17 = !{!"_ZTSN6SoLoud9VizsnBankE", !7, i64 0, !14, i64 200, !14, i64 204, !14, i64 208, !14, i64 212, !14, i64 216, !14, i64 220}
!18 = !{!12, !10, i64 13512}
!19 = !{!12, !10, i64 13508}


; 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 @_ZN6SoLoud13VizsnInstance5vcsrcEii(ptr nocapture noundef nonnull align 8 dereferenceable(13520) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 {
  %4 = getelementptr inbounds i8, ptr %0, i64 13504
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = add nsw i32 %5, %1
  store i32 %6, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 13512
  %8 = load i32, ptr %7, align 8, !tbaa !16
  %.not = icmp eq i32 %8, %2
  br i1 %.not, label %11, label %9

9:                                                ; preds = %3
  store i32 %2, ptr %7, align 8, !tbaa !16
  store i32 0, ptr %4, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 13508
  store i32 100, ptr %10, align 4, !tbaa !17
  br label %11

11:                                               ; preds = %9, %3
  %12 = phi i32 [ 0, %9 ], [ %6, %3 ]
  switch i32 %2, label %80 [
    i32 0, label %13
    i32 1, label %18
    i32 2, label %35
    i32 3, label %41
    i32 4, label %47
    i32 5, label %51
    i32 7, label %61
    i32 8, label %66
    i32 9, label %75
  ]

13:                                               ; preds = %11
  %14 = and i32 %12, 416
  %15 = mul nuw nsw i32 %14, 5
  %16 = uitofp nneg i32 %15 to float
  %17 = fmul float %16, 0x3F2A36E2E0000000
  br label %84

18:                                               ; preds = %11
  %19 = sitofp i32 %12 to double
  %20 = fmul double %19, 2.000000e-04
  %21 = tail call double @sin(double noundef %20) #4
  %22 = load i32, ptr %4, align 8, !tbaa !5
  %23 = sitofp i32 %22 to double
  %24 = fmul double %23, 3.000000e-04
  %25 = tail call double @cos(double noundef %24) #4
  %26 = fmul double %21, %25
  %27 = tail call i32 @rand() #4
  %28 = srem i32 %27, 200
  %29 = add nsw i32 %28, -100
  %30 = sitofp i32 %29 to float
  %31 = fdiv float %30, 3.000000e+02
  %32 = fpext float %31 to double
  %33 = tail call double @llvm.fmuladd.f64(double %26, double 0x3FC99999A0000000, double %32)
  %34 = fptrunc double %33 to float
  br label %84

35:                                               ; preds = %11
  %36 = sitofp i32 %12 to double
  %37 = fmul double %36, 2.000000e-05
  %38 = tail call double @tan(double noundef %37) #4
  %39 = fptrunc double %38 to float
  %40 = fmul float %39, 0x3F847AE140000000
  br label %84

41:                                               ; preds = %11
  %42 = and i32 %12, 65535
  %43 = icmp ugt i32 %42, 32768
  %44 = select i1 %43, i32 65535, i32 0
  %45 = uitofp nneg i32 %44 to float
  %46 = fmul float %45, 0x3EE4F8B580000000
  br label %84

47:                                               ; preds = %11
  %48 = sitofp i32 %12 to float
  %49 = fmul float %48, %48
  %50 = fmul float %49, 0x3DEB7CDFE0000000
  br label %84

51:                                               ; preds = %11
  %52 = add nsw i32 %12, 3
  store i32 %52, ptr %4, align 8, !tbaa !5
  %53 = getelementptr inbounds i8, ptr %0, i64 13508
  %54 = load i32, ptr %53, align 4, !tbaa !17
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %53, align 4, !tbaa !17
  %56 = and i32 %52, 255
  %57 = lshr i32 %55, 2
  %58 = and i32 %57, 255
  %59 = icmp ugt i32 %56, %58
  %60 = select i1 %59, float 0x3FD3333340000000, float 0.000000e+00
  br label %84

61:                                               ; preds = %11
  %62 = lshr i32 %12, 8
  %63 = and i32 %62, 384
  %64 = uitofp nneg i32 %63 to float
  %65 = fmul float %64, 0x3F50624DE0000000
  br label %84

66:                                               ; preds = %11
  %67 = tail call i32 @rand() #4
  %68 = load i32, ptr %4, align 8, !tbaa !5
  %69 = lshr i32 %68, 8
  %70 = and i32 %69, 255
  %71 = add nuw nsw i32 %70, 1
  %72 = srem i32 %67, %71
  %73 = sitofp i32 %72 to float
  %74 = fmul float %73, 3.906250e-03
  br label %84

75:                                               ; preds = %11
  %76 = tail call i32 @rand() #4
  %77 = and i32 %76, 32767
  %78 = uitofp nneg i32 %77 to float
  %79 = fdiv float %78, 3.276700e+04
  br label %84

80:                                               ; preds = %11
  %81 = and i32 %12, 65535
  %82 = uitofp nneg i32 %81 to float
  %83 = fmul float %82, 0x3ED0624DE0000000
  br label %84

84:                                               ; preds = %80, %75, %66, %61, %51, %47, %41, %35, %18, %13
  %.0 = phi float [ %83, %80 ], [ %79, %75 ], [ %74, %66 ], [ %65, %61 ], [ %60, %51 ], [ %50, %47 ], [ %46, %41 ], [ %40, %35 ], [ %34, %18 ], [ %17, %13 ]
  ret float %.0
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @sin(double noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @cos(double noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i32 @rand() local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare double @tan(double noundef) local_unnamed_addr #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 = { 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 #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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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, !8, i64 13504}
!6 = !{!"_ZTSN6SoLoud13VizsnInstanceE", !7, i64 0, !14, i64 496, !15, i64 504, !15, i64 728, !15, i64 952, !8, i64 1176, !8, i64 1180, !8, i64 1184, !9, i64 1188, !8, i64 5284, !8, i64 5288, !11, i64 5292, !14, i64 5296, !9, i64 5304, !8, i64 13496, !8, i64 13500, !8, i64 13504, !8, i64 13508, !8, i64 13512, !11, i64 13516}
!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}
!15 = !{!"_ZTSN6SoLoud9VizsnBankE", !9, i64 0, !11, i64 200, !11, i64 204, !11, i64 208, !11, i64 212, !11, i64 216, !11, i64 220}
!16 = !{!6, !8, i64 13512}
!17 = !{!6, !8, i64 13508}


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