; LLVM IR from kacperks/Fractal_Engine :: Engine/Thirdparty/cmake/Engine/Thirdparty/cmake/openal-soft/al (effect)

; 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.EffectSubList = type { i64, ptr }
%struct.ALeffect = type <{ i32, %union.EffectProps, ptr, i32, [4 x i8] }>
%union.EffectProps = type { %struct.anon }
%struct.anon = type { float, float, float, float, float, float, float, float, float, float, float, float, i8, float, float, [3 x float], [3 x float], float, float, float, float, float, float }

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN13EffectSubListD2Ev(ptr noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  %6 = getelementptr inbounds %struct.EffectSubList, ptr %5, i32 0, i32 0
  %7 = load i64, ptr %6, align 8, !tbaa !9
  %8 = xor i64 %7, -1
  store i64 %8, ptr %3, align 8, !tbaa !12
  br label %9

9:                                                ; preds = %12, %1
  %10 = load i64, ptr %3, align 8, !tbaa !12
  %11 = icmp ne i64 %10, 0
  br i1 %11, label %12, label %27

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %13 = load i64, ptr %3, align 8, !tbaa !12
  %14 = call noundef i32 @_ZN2al11countr_zeroImEENSt9enable_ifIXaasr3std11is_integralIT_EE5valuesr3std11is_unsignedIS2_EE5valueEiE4typeES2_(i64 noundef %13) #4
  store i32 %14, ptr %4, align 4, !tbaa !13
  %15 = getelementptr inbounds %struct.EffectSubList, ptr %5, i32 0, i32 1
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %17 = load i32, ptr %4, align 4, !tbaa !13
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds %struct.ALeffect, ptr %16, i64 %18
  call void @_ZN2al10destroy_atI8ALeffectEENSt9enable_ifIXntsr3std8is_arrayIT_EE5valueEvE4typeEPS3_(ptr noundef %19) #4
  %20 = call noundef i64 @_Zli4_u64y(i64 noundef 1) #4
  %21 = load i32, ptr %4, align 4, !tbaa !13
  %22 = zext i32 %21 to i64
  %23 = shl i64 %20, %22
  %24 = xor i64 %23, -1
  %25 = load i64, ptr %3, align 8, !tbaa !12
  %26 = and i64 %25, %24
  store i64 %26, ptr %3, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %9, !llvm.loop !16

27:                                               ; preds = %9
  %28 = load i64, ptr %3, align 8, !tbaa !12
  %29 = xor i64 %28, -1
  %30 = getelementptr inbounds %struct.EffectSubList, ptr %5, i32 0, i32 0
  store i64 %29, ptr %30, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct.EffectSubList, ptr %5, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  call void @_Z7al_freePv(ptr noundef %32) #4
  %33 = getelementptr inbounds %struct.EffectSubList, ptr %5, i32 0, i32 1
  store ptr null, ptr %33, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2al11countr_zeroImEENSt9enable_ifIXaasr3std11is_integralIT_EE5valuesr3std11is_unsignedIS2_EE5valueEiE4typeES2_(i64 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2al10destroy_atI8ALeffectEENSt9enable_ifIXntsr3std8is_arrayIT_EE5valueEvE4typeEPS3_(ptr noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Zli4_u64y(i64 noundef) #2

; Function Attrs: nounwind
declare void @_Z7al_freePv(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { inlinehint 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 = { 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 #4 = { nounwind }

!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, !11, i64 0}
!10 = !{!"_ZTS13EffectSubList", !11, i64 0, !6, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!10, !6, i64 8}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


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

%struct.ALeffect = type <{ i32, %union.EffectProps, ptr, i32, [4 x i8] }>
%union.EffectProps = type { %struct.anon }
%struct.anon = type { float, float, float, float, float, float, float, float, float, float, float, float, i8, float, float, [3 x float], [3 x float], float, float, float, float, float, float }

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN13EffectSubListD2Ev(ptr nocapture noundef nonnull align 8 dereferenceable(16) %0) unnamed_addr #0 align 2 {
  %2 = load i64, ptr %0, align 8, !tbaa !5
  %.not6 = icmp eq i64 %2, -1
  br i1 %.not6, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %3 = xor i64 %2, -1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  br label %5

5:                                                ; preds = %.lr.ph, %5
  %.07 = phi i64 [ %3, %.lr.ph ], [ %14, %5 ]
  %6 = tail call noundef i32 @_ZN2al11countr_zeroImEENSt9enable_ifIXaasr3std11is_integralIT_EE5valuesr3std11is_unsignedIS2_EE5valueEiE4typeES2_(i64 noundef %.07) #3
  %7 = load ptr, ptr %4, align 8, !tbaa !11
  %8 = sext i32 %6 to i64
  %9 = getelementptr inbounds %struct.ALeffect, ptr %7, i64 %8
  tail call void @_ZN2al10destroy_atI8ALeffectEENSt9enable_ifIXntsr3std8is_arrayIT_EE5valueEvE4typeEPS3_(ptr noundef %9) #3
  %10 = tail call noundef i64 @_Zli4_u64y(i64 noundef 1) #3
  %11 = zext nneg i32 %6 to i64
  %12 = shl i64 %10, %11
  %13 = xor i64 %12, -1
  %14 = and i64 %.07, %13
  %.not = icmp eq i64 %14, 0
  br i1 %.not, label %._crit_edge, label %5, !llvm.loop !12

._crit_edge:                                      ; preds = %5, %1
  store i64 -1, ptr %0, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  tail call void @_Z7al_freePv(ptr noundef %16) #3
  store ptr null, ptr %15, align 8, !tbaa !11
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN2al11countr_zeroImEENSt9enable_ifIXaasr3std11is_integralIT_EE5valuesr3std11is_unsignedIS2_EE5valueEiE4typeES2_(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN2al10destroy_atI8ALeffectEENSt9enable_ifIXntsr3std8is_arrayIT_EE5valueEvE4typeEPS3_(ptr noundef) local_unnamed_addr #0

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Zli4_u64y(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare void @_Z7al_freePv(ptr noundef) local_unnamed_addr #2

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" }
attributes #1 = { inlinehint 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 #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 }

!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 = !{!"_ZTS13EffectSubList", !7, i64 0, !10, i64 8}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass