; LLVM IR from Try/Tempest :: Engine/thirdparty/openal-soft/al/effects (modulator)

; 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.std::optional" = type { %"struct.std::_Optional_base" }
%"struct.std::_Optional_base" = type { %"struct.std::_Optional_payload" }
%"struct.std::_Optional_payload" = type { %"struct.std::_Optional_payload_base.base", [3 x i8] }
%"struct.std::_Optional_payload_base.base" = type <{ %"union.std::_Optional_payload_base<ModulatorWaveform>::_Storage", i8 }>
%"union.std::_Optional_payload_base<ModulatorWaveform>::_Storage" = type { i32 }
%struct.ModulatorProps = type { float, float, i32 }

@.str = external hidden unnamed_addr constant [35 x i8], align 1
@_ZTIN2al13context_errorE = external constant ptr
@.str.1 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN22ModulatorEffectHandler9SetParamiER14ModulatorPropsii(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef %1, i32 noundef %2) #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca %"class.std::optional", align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store i32 %2, ptr %6, align 4, !tbaa !9
  %10 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %10, label %36 [
    i32 1, label %11
    i32 2, label %11
    i32 3, label %16
  ]

11:                                               ; preds = %3, %3
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = sitofp i32 %14 to float
  call void @_ZN22ModulatorEffectHandler9SetParamfER14ModulatorPropsif(ptr noundef nonnull align 4 dereferenceable(12) %12, i32 noundef %13, float noundef %15)
  br label %44

16:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = call i64 @_ZN12_GLOBAL__N_116WaveformFromEmumEi(i32 noundef %17) #5
  %19 = getelementptr inbounds %"class.std::optional", ptr %7, i32 0, i32 0
  %20 = getelementptr inbounds %"struct.std::_Optional_base", ptr %19, i32 0, i32 0
  store i64 %18, ptr %20, align 4
  %21 = call noundef zeroext i1 @_ZNKSt8optionalI17ModulatorWaveformEcvbEv(ptr noundef nonnull align 4 dereferenceable(8) %7) #5
  br i1 %21, label %22, label %27

22:                                               ; preds = %16
  %23 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNRSt8optionalI17ModulatorWaveformEdeEv(ptr noundef nonnull align 4 dereferenceable(8) %7) #5
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ModulatorProps, ptr %25, i32 0, i32 2
  store i32 %24, ptr %26, align 4, !tbaa !13
  br label %35

27:                                               ; preds = %16
  %28 = call ptr @__cxa_allocate_exception(i64 48) #5
  %29 = load i32, ptr %6, align 4, !tbaa !9
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %28, i32 noundef 40963, ptr noundef @.str, i32 noundef %29)
          to label %30 unwind label %31

30:                                               ; preds = %27
  call void @__cxa_throw(ptr %28, ptr @_ZTIN2al13context_errorE, ptr @_ZN2al13context_errorD1Ev) #6
  unreachable

31:                                               ; preds = %27
  %32 = landingpad { ptr, i32 }
          cleanup
  %33 = extractvalue { ptr, i32 } %32, 0
  store ptr %33, ptr %8, align 8
  %34 = extractvalue { ptr, i32 } %32, 1
  store i32 %34, ptr %9, align 4
  call void @__cxa_free_exception(ptr %28) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %45

35:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %44

36:                                               ; preds = %3
  %37 = call ptr @__cxa_allocate_exception(i64 48) #5
  %38 = load i32, ptr %5, align 4, !tbaa !9
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %37, i32 noundef 40962, ptr noundef @.str.1, i32 noundef %38)
          to label %39 unwind label %40

39:                                               ; preds = %36
  call void @__cxa_throw(ptr %37, ptr @_ZTIN2al13context_errorE, ptr @_ZN2al13context_errorD1Ev) #6
  unreachable

40:                                               ; preds = %36
  %41 = landingpad { ptr, i32 }
          cleanup
  %42 = extractvalue { ptr, i32 } %41, 0
  store ptr %42, ptr %8, align 8
  %43 = extractvalue { ptr, i32 } %41, 1
  store i32 %43, ptr %9, align 4
  call void @__cxa_free_exception(ptr %37) #5
  br label %45

44:                                               ; preds = %35, %11
  ret void

45:                                               ; preds = %40, %31
  %46 = load ptr, ptr %8, align 8
  %47 = load i32, ptr %9, align 4
  %48 = insertvalue { ptr, i32 } poison, ptr %46, 0
  %49 = insertvalue { ptr, i32 } %48, i32 %47, 1
  resume { ptr, i32 } %49
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN22ModulatorEffectHandler9SetParamfER14ModulatorPropsif(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, float noundef) #0 align 2

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden i64 @_ZN12_GLOBAL__N_116WaveformFromEmumEi(i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8optionalI17ModulatorWaveformEcvbEv(ptr noundef nonnull align 4 dereferenceable(8)) #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNRSt8optionalI17ModulatorWaveformEdeEv(ptr noundef nonnull align 4 dereferenceable(8)) #2 align 2

declare ptr @__cxa_allocate_exception(i64)

declare void @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, ptr noundef, ...) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr)

; Function Attrs: nounwind
declare void @_ZN2al13context_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4

declare void @__cxa_throw(ptr, ptr, ptr)

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 #5 = { nounwind }
attributes #6 = { noreturn }

!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, !12, i64 0}
!12 = !{!"_ZTS17ModulatorWaveform", !7, i64 0}
!13 = !{!14, !12, i64 8}
!14 = !{!"_ZTS14ModulatorProps", !15, i64 0, !15, i64 4, !12, i64 8}
!15 = !{!"float", !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"

%"class.std::optional" = type { %"struct.std::_Optional_base" }
%"struct.std::_Optional_base" = type { %"struct.std::_Optional_payload" }
%"struct.std::_Optional_payload" = type { %"struct.std::_Optional_payload_base.base", [3 x i8] }
%"struct.std::_Optional_payload_base.base" = type <{ %"union.std::_Optional_payload_base<ModulatorWaveform>::_Storage", i8 }>
%"union.std::_Optional_payload_base<ModulatorWaveform>::_Storage" = type { i32 }

@.str = external hidden unnamed_addr constant [35 x i8], align 1
@_ZTIN2al13context_errorE = external constant ptr
@.str.1 = external hidden unnamed_addr constant [42 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN22ModulatorEffectHandler9SetParamiER14ModulatorPropsii(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca %"class.std::optional", align 8
  switch i32 %1, label %19 [
    i32 1, label %5
    i32 2, label %5
    i32 3, label %7
  ]

5:                                                ; preds = %3, %3
  %6 = sitofp i32 %2 to float
  tail call void @_ZN22ModulatorEffectHandler9SetParamfER14ModulatorPropsif(ptr noundef nonnull align 4 dereferenceable(12) %0, i32 noundef %1, float noundef %6)
  br label %24

7:                                                ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %8 = tail call i64 @_ZN12_GLOBAL__N_116WaveformFromEmumEi(i32 noundef %2) #5
  store i64 %8, ptr %4, align 8
  %9 = call noundef zeroext i1 @_ZNKSt8optionalI17ModulatorWaveformEcvbEv(ptr noundef nonnull align 4 dereferenceable(8) %4) #5
  br i1 %9, label %10, label %14

10:                                               ; preds = %7
  %11 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNRSt8optionalI17ModulatorWaveformEdeEv(ptr noundef nonnull align 4 dereferenceable(8) %4) #5
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %12, ptr %13, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %24

14:                                               ; preds = %7
  %15 = call ptr @__cxa_allocate_exception(i64 48) #5
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %15, i32 noundef 40963, ptr noundef nonnull @.str, i32 noundef %2)
          to label %16 unwind label %17

16:                                               ; preds = %14
  call void @__cxa_throw(ptr nonnull %15, ptr nonnull @_ZTIN2al13context_errorE, ptr nonnull @_ZN2al13context_errorD1Ev) #6
  unreachable

17:                                               ; preds = %14
  %18 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  br label %25

19:                                               ; preds = %3
  %20 = tail call ptr @__cxa_allocate_exception(i64 48) #5
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %20, i32 noundef 40962, ptr noundef nonnull @.str.1, i32 noundef %1)
          to label %21 unwind label %22

21:                                               ; preds = %19
  tail call void @__cxa_throw(ptr nonnull %20, ptr nonnull @_ZTIN2al13context_errorE, ptr nonnull @_ZN2al13context_errorD1Ev) #6
  unreachable

22:                                               ; preds = %19
  %23 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %20) #5
  br label %25

24:                                               ; preds = %10, %5
  ret void

25:                                               ; preds = %22, %17
  %.pn = phi { ptr, i32 } [ %23, %22 ], [ %18, %17 ]
  resume { ptr, i32 } %.pn
}

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN22ModulatorEffectHandler9SetParamfER14ModulatorPropsif(ptr noundef nonnull align 4 dereferenceable(12), i32 noundef, float noundef) local_unnamed_addr #0 align 2

; 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 nounwind uwtable
declare hidden i64 @_ZN12_GLOBAL__N_116WaveformFromEmumEi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8optionalI17ModulatorWaveformEcvbEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNRSt8optionalI17ModulatorWaveformEdeEv(ptr noundef nonnull align 4 dereferenceable(8)) local_unnamed_addr #2 align 2

declare ptr @__cxa_allocate_exception(i64) local_unnamed_addr

declare void @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48), i32 noundef, ptr noundef, ...) unnamed_addr #3

declare i32 @__gxx_personality_v0(...)

declare void @__cxa_free_exception(ptr) local_unnamed_addr

; Function Attrs: nounwind
declare void @_ZN2al13context_errorD1Ev(ptr noundef nonnull align 8 dereferenceable(48)) unnamed_addr #4

declare void @__cxa_throw(ptr, ptr, ptr) local_unnamed_addr

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

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 #5 = { nounwind }
attributes #6 = { noreturn }

!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 = !{!"_ZTS17ModulatorWaveform", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_ZTS14ModulatorProps", !11, i64 0, !11, i64 4, !6, i64 8}
!11 = !{!"float", !7, i64 0}


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