; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/audiosource/tedsid/sid.ll (ZN8SIDsound12setFrequencyEj)

; 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.SIDsound = type <{ ptr, i32, i32, i32, i32, i32, i32, i32, i32, i32, [4 x i8], [3 x %"class.SIDsound::SIDVoice"], i8, [3 x i8], i32, i8, [7 x i8], [2048 x double], i32, i32, i32, i32, i32, i8, [3 x i8], i32, i8, [3 x i8], i32, [4 x i8] }>
%"class.SIDsound::SIDVoice" = type { i32, i32, ptr, ptr, i32, i32, i32, i32, i16, i16, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i8, i32 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN8SIDsound17calcEnvelopeTableEv(ptr noundef nonnull align 8 dereferenceable(16796)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8SIDsound12setFrequencyEj(ptr noundef nonnull align 8 dereferenceable(16796) %0, i32 noundef %1) #0 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load ptr, ptr %3, align 8
  %6 = load i32, ptr %4, align 4, !tbaa !9
  switch i32 %6, label %9 [
    i32 0, label %7
  ]

7:                                                ; preds = %2
  %8 = getelementptr inbounds %class.SIDsound, ptr %5, i32 0, i32 2
  store i32 886720, ptr %8, align 4, !tbaa !11
  br label %11

9:                                                ; preds = %2
  %10 = getelementptr inbounds %class.SIDsound, ptr %5, i32 0, i32 2
  store i32 985248, ptr %10, align 4, !tbaa !11
  br label %11

11:                                               ; preds = %9, %7
  call void @_ZN8SIDsound17calcEnvelopeTableEv(ptr noundef nonnull align 8 dereferenceable(16796) %5)
  ret void
}

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, !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 12}
!12 = !{!"_ZTS8SIDsound", !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !7, i64 48, !7, i64 360, !10, i64 364, !7, i64 368, !7, i64 376, !10, i64 16760, !10, i64 16764, !10, i64 16768, !10, i64 16772, !10, i64 16776, !7, i64 16780, !10, i64 16784, !13, i64 16788, !10, i64 16792}
!13 = !{!"bool", !7, i64 0}


; 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
declare dso_local void @_ZN8SIDsound17calcEnvelopeTableEv(ptr noundef nonnull align 8 dereferenceable(16796)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN8SIDsound12setFrequencyEj(ptr noundef nonnull align 8 dereferenceable(16796) %0, i32 noundef %1) local_unnamed_addr #0 align 2 {
  %cond = icmp eq i32 %1, 0
  %spec.select = select i1 %cond, i32 886720, i32 985248
  %3 = getelementptr inbounds i8, ptr %0, i64 12
  store i32 %spec.select, ptr %3, align 4
  tail call void @_ZN8SIDsound17calcEnvelopeTableEv(ptr noundef nonnull align 8 dereferenceable(16796) %0)
  ret void
}

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)"}


; Effective O3 passes: GlobalOptPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass