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

; 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<FShifterDirection>::_Storage", i8 }>
%"union.std::_Optional_payload_base<FShifterDirection>::_Storage" = type { i32 }
%struct.FshifterProps = type { float, i32, i32 }

@.str = external hidden unnamed_addr constant [53 x i8], align 1
@_ZTIN2al13context_errorE = external constant ptr
@.str.1 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21FshifterEffectHandler9SetParamiER13FshifterPropsii(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
  %10 = alloca %"class.std::optional", 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
  %11 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %11, label %52 [
    i32 2, label %12
    i32 3, label %32
  ]

12:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = call i64 @_ZN12_GLOBAL__N_117DirectionFromEmumEi(i32 noundef %13) #5
  %15 = getelementptr inbounds %"class.std::optional", ptr %7, i32 0, i32 0
  %16 = getelementptr inbounds %"struct.std::_Optional_base", ptr %15, i32 0, i32 0
  store i64 %14, ptr %16, align 4
  %17 = call noundef zeroext i1 @_ZNKSt8optionalI17FShifterDirectionEcvbEv(ptr noundef nonnull align 4 dereferenceable(8) %7) #5
  br i1 %17, label %18, label %23

18:                                               ; preds = %12
  %19 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNRSt8optionalI17FShifterDirectionEdeEv(ptr noundef nonnull align 4 dereferenceable(8) %7) #5
  %20 = load i32, ptr %19, align 4, !tbaa !11
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.FshifterProps, ptr %21, i32 0, i32 1
  store i32 %20, ptr %22, align 4, !tbaa !13
  br label %31

23:                                               ; preds = %12
  %24 = call ptr @__cxa_allocate_exception(i64 48) #5
  %25 = load i32, ptr %6, align 4, !tbaa !9
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %24, i32 noundef 40963, ptr noundef @.str, i32 noundef %25)
          to label %26 unwind label %27

26:                                               ; preds = %23
  call void @__cxa_throw(ptr %24, ptr @_ZTIN2al13context_errorE, ptr @_ZN2al13context_errorD1Ev) #6
  unreachable

27:                                               ; preds = %23
  %28 = landingpad { ptr, i32 }
          cleanup
  %29 = extractvalue { ptr, i32 } %28, 0
  store ptr %29, ptr %8, align 8
  %30 = extractvalue { ptr, i32 } %28, 1
  store i32 %30, ptr %9, align 4
  call void @__cxa_free_exception(ptr %24) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  br label %61

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

32:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = call i64 @_ZN12_GLOBAL__N_117DirectionFromEmumEi(i32 noundef %33) #5
  %35 = getelementptr inbounds %"class.std::optional", ptr %10, i32 0, i32 0
  %36 = getelementptr inbounds %"struct.std::_Optional_base", ptr %35, i32 0, i32 0
  store i64 %34, ptr %36, align 4
  %37 = call noundef zeroext i1 @_ZNKSt8optionalI17FShifterDirectionEcvbEv(ptr noundef nonnull align 4 dereferenceable(8) %10) #5
  br i1 %37, label %38, label %43

38:                                               ; preds = %32
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNRSt8optionalI17FShifterDirectionEdeEv(ptr noundef nonnull align 4 dereferenceable(8) %10) #5
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.FshifterProps, ptr %41, i32 0, i32 2
  store i32 %40, ptr %42, align 4, !tbaa !16
  br label %51

43:                                               ; preds = %32
  %44 = call ptr @__cxa_allocate_exception(i64 48) #5
  %45 = load i32, ptr %6, align 4, !tbaa !9
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %44, i32 noundef 40963, ptr noundef @.str.1, i32 noundef %45)
          to label %46 unwind label %47

46:                                               ; preds = %43
  call void @__cxa_throw(ptr %44, ptr @_ZTIN2al13context_errorE, ptr @_ZN2al13context_errorD1Ev) #6
  unreachable

47:                                               ; preds = %43
  %48 = landingpad { ptr, i32 }
          cleanup
  %49 = extractvalue { ptr, i32 } %48, 0
  store ptr %49, ptr %8, align 8
  %50 = extractvalue { ptr, i32 } %48, 1
  store i32 %50, ptr %9, align 4
  call void @__cxa_free_exception(ptr %44) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %61

51:                                               ; preds = %38
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %60

52:                                               ; preds = %3
  %53 = call ptr @__cxa_allocate_exception(i64 48) #5
  %54 = load i32, ptr %5, align 4, !tbaa !9
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %53, i32 noundef 40962, ptr noundef @.str.2, i32 noundef %54)
          to label %55 unwind label %56

55:                                               ; preds = %52
  call void @__cxa_throw(ptr %53, ptr @_ZTIN2al13context_errorE, ptr @_ZN2al13context_errorD1Ev) #6
  unreachable

56:                                               ; preds = %52
  %57 = landingpad { ptr, i32 }
          cleanup
  %58 = extractvalue { ptr, i32 } %57, 0
  store ptr %58, ptr %8, align 8
  %59 = extractvalue { ptr, i32 } %57, 1
  store i32 %59, ptr %9, align 4
  call void @__cxa_free_exception(ptr %53) #5
  br label %61

60:                                               ; preds = %51, %31
  ret void

61:                                               ; preds = %56, %47, %27
  %62 = load ptr, ptr %8, align 8
  %63 = load i32, ptr %9, align 4
  %64 = insertvalue { ptr, i32 } poison, ptr %62, 0
  %65 = insertvalue { ptr, i32 } %64, i32 %63, 1
  resume { ptr, i32 } %65
}

; 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_117DirectionFromEmumEi(i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8optionalI17FShifterDirectionEcvbEv(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 @_ZNRSt8optionalI17FShifterDirectionEdeEv(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 = !{!"_ZTS17FShifterDirection", !7, i64 0}
!13 = !{!14, !12, i64 4}
!14 = !{!"_ZTS13FshifterProps", !15, i64 0, !12, i64 4, !12, i64 8}
!15 = !{!"float", !7, i64 0}
!16 = !{!14, !12, i64 8}


; 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<FShifterDirection>::_Storage", i8 }>
%"union.std::_Optional_payload_base<FShifterDirection>::_Storage" = type { i32 }

@.str = external hidden unnamed_addr constant [53 x i8], align 1
@_ZTIN2al13context_errorE = external constant ptr
@.str.1 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [50 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN21FshifterEffectHandler9SetParamiER13FshifterPropsii(ptr nocapture noundef nonnull writeonly 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
  %5 = alloca %"class.std::optional", align 8
  switch i32 %1, label %30 [
    i32 2, label %6
    i32 3, label %18
  ]

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

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

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

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

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

18:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #5
  %19 = tail call i64 @_ZN12_GLOBAL__N_117DirectionFromEmumEi(i32 noundef %2) #5
  store i64 %19, ptr %5, align 8
  %20 = call noundef zeroext i1 @_ZNKSt8optionalI17FShifterDirectionEcvbEv(ptr noundef nonnull align 4 dereferenceable(8) %5) #5
  br i1 %20, label %21, label %25

21:                                               ; preds = %18
  %22 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNRSt8optionalI17FShifterDirectionEdeEv(ptr noundef nonnull align 4 dereferenceable(8) %5) #5
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 %23, ptr %24, align 4, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br label %35

25:                                               ; preds = %18
  %26 = call ptr @__cxa_allocate_exception(i64 48) #5
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %26, i32 noundef 40963, ptr noundef nonnull @.str.1, i32 noundef %2)
          to label %27 unwind label %28

27:                                               ; preds = %25
  call void @__cxa_throw(ptr nonnull %26, ptr nonnull @_ZTIN2al13context_errorE, ptr nonnull @_ZN2al13context_errorD1Ev) #6
  unreachable

28:                                               ; preds = %25
  %29 = landingpad { ptr, i32 }
          cleanup
  call void @__cxa_free_exception(ptr %26) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #5
  br label %36

30:                                               ; preds = %3
  %31 = tail call ptr @__cxa_allocate_exception(i64 48) #5
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %31, i32 noundef 40962, ptr noundef nonnull @.str.2, i32 noundef %1)
          to label %32 unwind label %33

32:                                               ; preds = %30
  tail call void @__cxa_throw(ptr nonnull %31, ptr nonnull @_ZTIN2al13context_errorE, ptr nonnull @_ZN2al13context_errorD1Ev) #6
  unreachable

33:                                               ; preds = %30
  %34 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %31) #5
  br label %36

35:                                               ; preds = %21, %9
  ret void

36:                                               ; preds = %33, %28, %16
  %.pn = phi { ptr, i32 } [ %34, %33 ], [ %29, %28 ], [ %17, %16 ]
  resume { ptr, i32 } %.pn
}

; 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_117DirectionFromEmumEi(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt8optionalI17FShifterDirectionEcvbEv(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 @_ZNRSt8optionalI17FShifterDirectionEdeEv(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 = !{!"_ZTS17FShifterDirection", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 4}
!10 = !{!"_ZTS13FshifterProps", !11, i64 0, !6, i64 4, !6, i64 8}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !6, i64 8}


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