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

; 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.CompressorProps = type { i8 }

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN23CompressorEffectHandler9SetParamiER15CompressorPropsii(ptr noundef nonnull align 1 dereferenceable(1) %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 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 i32 %2, ptr %6, align 4, !tbaa !9
  %9 = load i32, ptr %5, align 4, !tbaa !9
  switch i32 %9, label %29 [
    i32 1, label %10
  ]

10:                                               ; preds = %3
  %11 = load i32, ptr %6, align 4, !tbaa !9
  %12 = icmp sge i32 %11, 0
  br i1 %12, label %13, label %16

13:                                               ; preds = %10
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = icmp sle i32 %14, 1
  br i1 %15, label %23, label %16

16:                                               ; preds = %13, %10
  %17 = call ptr @__cxa_allocate_exception(i64 48) #3
  invoke void (ptr, i32, ptr, ...) @_ZN2al13context_errorC1EiPKcz(ptr noundef nonnull align 8 dereferenceable(48) %17, i32 noundef 40963, ptr noundef @.str)
          to label %18 unwind label %19

18:                                               ; preds = %16
  call void @__cxa_throw(ptr %17, ptr @_ZTIN2al13context_errorE, ptr @_ZN2al13context_errorD1Ev) #4
  unreachable

19:                                               ; preds = %16
  %20 = landingpad { ptr, i32 }
          cleanup
  %21 = extractvalue { ptr, i32 } %20, 0
  store ptr %21, ptr %7, align 8
  %22 = extractvalue { ptr, i32 } %20, 1
  store i32 %22, ptr %8, align 4
  call void @__cxa_free_exception(ptr %17) #3
  br label %38

23:                                               ; preds = %13
  %24 = load i32, ptr %6, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.CompressorProps, ptr %26, i32 0, i32 0
  %28 = zext i1 %25 to i8
  store i8 %28, ptr %27, align 1, !tbaa !11
  br label %37

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

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

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

37:                                               ; preds = %23
  ret void

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

declare ptr @__cxa_allocate_exception(i64)

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

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

declare void @__cxa_throw(ptr, ptr, ptr)

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 = { "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 = { 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, !13, i64 0}
!12 = !{!"_ZTS15CompressorProps", !13, i64 0}
!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"

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN23CompressorEffectHandler9SetParamiER15CompressorPropsii(ptr nocapture noundef nonnull writeonly align 1 dereferenceable(1) %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %cond = icmp eq i32 %1, 1
  br i1 %cond, label %4, label %12

4:                                                ; preds = %3
  %or.cond = icmp ult i32 %2, 2
  br i1 %or.cond, label %10, label %5

5:                                                ; preds = %4
  %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 40963, ptr noundef nonnull @.str)
          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
  br label %17

10:                                               ; preds = %4
  %11 = trunc nuw i32 %2 to i8
  store i8 %11, ptr %0, align 1, !tbaa !5
  ret void

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

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

15:                                               ; preds = %12
  %16 = landingpad { ptr, i32 }
          cleanup
  br label %17

17:                                               ; preds = %15, %8
  %.sink = phi ptr [ %13, %15 ], [ %6, %8 ]
  %.pn = phi { ptr, i32 } [ %16, %15 ], [ %9, %8 ]
  tail call void @__cxa_free_exception(ptr %.sink) #3
  resume { ptr, i32 } %.pn
}

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

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

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

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 = { "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 = { 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, !7, i64 0}
!6 = !{!"_ZTS15CompressorProps", !7, i64 0}
!7 = !{!"bool", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


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