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

; 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"

%struct.ChorusProps = type { i32, i32, float, float, float, float }

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

declare ptr @__cxa_allocate_exception(i64)

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

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 #1

declare void @__cxa_throw(ptr, ptr, ptr)

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN19ChorusEffectHandler9GetParamfERK11ChorusPropsiPf(ptr noundef nonnull align 4 dereferenceable(24) %0, i32 noundef %1, ptr noundef %2) #2 align 2 personality ptr @__gxx_personality_v0 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %9 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %9, label %30 [
    i32 3, label %10
    i32 4, label %15
    i32 5, label %20
    i32 6, label %25
  ]

10:                                               ; preds = %3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ChorusProps, ptr %11, i32 0, i32 2
  %13 = load float, ptr %12, align 4, !tbaa !11
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  store float %13, ptr %14, align 4, !tbaa !15
  br label %38

15:                                               ; preds = %3
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.ChorusProps, ptr %16, i32 0, i32 3
  %18 = load float, ptr %17, align 4, !tbaa !16
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  store float %18, ptr %19, align 4, !tbaa !15
  br label %38

20:                                               ; preds = %3
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ChorusProps, ptr %21, i32 0, i32 4
  %23 = load float, ptr %22, align 4, !tbaa !17
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  store float %23, ptr %24, align 4, !tbaa !15
  br label %38

25:                                               ; preds = %3
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ChorusProps, ptr %26, i32 0, i32 5
  %28 = load float, ptr %27, align 4, !tbaa !18
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  store float %28, ptr %29, align 4, !tbaa !15
  br label %38

30:                                               ; preds = %3
  %31 = call ptr @__cxa_allocate_exception(i64 48) #3
  %32 = load i32, ptr %5, align 4, !tbaa !9
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %31, i32 noundef 40962, ptr noundef @.str.7, i32 noundef %32)
          to label %33 unwind label %34

33:                                               ; preds = %30
  call void @__cxa_throw(ptr %31, ptr @_ZTIN2al13context_errorE, ptr @_ZN2al13context_errorD1Ev) #4
  unreachable

34:                                               ; preds = %30
  %35 = landingpad { ptr, i32 }
          cleanup
  %36 = extractvalue { ptr, i32 } %35, 0
  store ptr %36, ptr %7, align 8
  %37 = extractvalue { ptr, i32 } %35, 1
  store i32 %37, ptr %8, align 4
  call void @__cxa_free_exception(ptr %31) #3
  br label %39

38:                                               ; preds = %25, %20, %15, %10
  ret void

39:                                               ; preds = %34
  %40 = load ptr, ptr %7, align 8
  %41 = load i32, ptr %8, align 4
  %42 = insertvalue { ptr, i32 } poison, ptr %40, 0
  %43 = insertvalue { ptr, i32 } %42, i32 %41, 1
  resume { ptr, i32 } %43
}

attributes #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 = { 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 #3 = { nounwind }
attributes #4 = { 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, !14, i64 8}
!12 = !{!"_ZTS11ChorusProps", !13, i64 0, !10, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20}
!13 = !{!"_ZTS14ChorusWaveform", !7, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = !{!14, !14, i64 0}
!16 = !{!12, !14, i64 12}
!17 = !{!12, !14, i64 16}
!18 = !{!12, !14, i64 20}


; 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"

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

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 #0

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 #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN19ChorusEffectHandler9GetParamfERK11ChorusPropsiPf(ptr nocapture noundef nonnull readonly align 4 dereferenceable(24) %0, i32 noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 align 2 personality ptr @__gxx_personality_v0 {
  %switch.tableidx = add i32 %1, -3
  %4 = icmp ult i32 %switch.tableidx, 4
  br i1 %4, label %switch.lookup, label %5

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

7:                                                ; preds = %5
  tail call void @__cxa_throw(ptr nonnull %6, ptr nonnull @_ZTIN2al13context_errorE, ptr nonnull @_ZN2al13context_errorD1Ev) #4
  unreachable

8:                                                ; preds = %5
  %9 = landingpad { ptr, i32 }
          cleanup
  tail call void @__cxa_free_exception(ptr %6) #3
  resume { ptr, i32 } %9

switch.lookup:                                    ; preds = %3
  %10 = shl nuw nsw i32 %switch.tableidx, 2
  %11 = zext nneg i32 %10 to i64
  %12 = getelementptr inbounds i8, ptr %0, i64 %11
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  %14 = load float, ptr %13, align 4, !tbaa !5
  store float %14, ptr %2, align 4, !tbaa !5
  ret void
}

attributes #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 = { 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 #3 = { nounwind }
attributes #4 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


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