; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core/soloud_core_setters.ll (ZN6SoLoud6Soloud11setAutoStopEjb)

; 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.SoLoud::Soloud" = type <{ ptr, ptr, i8, [7 x i8], ptr, ptr, ptr, i32, i32, %"class.SoLoud::AlignedFloatBuffer", i32, [4 x i8], %"class.SoLoud::AlignedFloatBuffer", ptr, %"class.SoLoud::AlignedFloatBuffer", ptr, [1024 x ptr], i32, i32, i32, i32, ptr, i32, i32, float, float, i32, i32, %"class.SoLoud::Fader", double, double, [8 x ptr], [8 x ptr], [8 x float], [256 x float], [256 x float], [256 x float], [3 x float], [3 x float], [3 x float], [3 x float], float, [24 x float], [4 x i8], [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr, i32, [1024 x i32], i32, i8, [7 x i8] }>
%"class.SoLoud::AlignedFloatBuffer" = type <{ ptr, ptr, i32, [4 x i8] }>
%"class.SoLoud::Fader" = type { float, float, float, double, double, double, float, i32 }
%"class.SoLoud::AudioSourceInstance3dData" = type <{ [3 x float], [3 x float], float, float, float, i32, float, [4 x i8], ptr, ptr, i32, float, float, [8 x float], i32, i32, [4 x i8] }>
%"class.SoLoud::AudioSourceInstance" = type { ptr, i32, i32, i32, float, [8 x float], float, float, float, float, i32, float, float, double, double, %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", %"class.SoLoud::Fader", i32, [8 x float], i32, i32, [8 x ptr], [2 x ptr], i32, i32, i32, double }

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

declare void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833)) #1

declare noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) #1

declare noundef i32 @_ZNK6SoLoud6Soloud27getVoiceFromHandle_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) #1

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

declare void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud6Soloud11setAutoStopEjb(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1, i1 noundef zeroext %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i8, align 1
  %7 = alloca ptr, align 8
  %8 = alloca [2 x i32], align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %10 = zext i1 %2 to i8
  store i8 %10, ptr %6, align 1, !tbaa !11
  %11 = load ptr, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  store ptr null, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %12 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %12, ptr %8, align 4, !tbaa !9
  %13 = getelementptr inbounds i32, ptr %8, i64 1
  store i32 0, ptr %13, align 4, !tbaa !9
  call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %11)
  %14 = load i32, ptr %5, align 4, !tbaa !9
  %15 = call noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %11, i32 noundef %14)
  store ptr %15, ptr %7, align 8, !tbaa !5
  %16 = load ptr, ptr %7, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %20

18:                                               ; preds = %3
  %19 = getelementptr inbounds [2 x i32], ptr %8, i64 0, i64 0
  store ptr %19, ptr %7, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %18, %3
  br label %21

21:                                               ; preds = %53, %20
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = load i32, ptr %22, align 4, !tbaa !9
  %24 = icmp ne i32 %23, 0
  br i1 %24, label %25, label %56

25:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = call noundef i32 @_ZNK6SoLoud6Soloud27getVoiceFromHandle_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %11, i32 noundef %27)
  store i32 %28, ptr %9, align 4, !tbaa !9
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = icmp ne i32 %29, -1
  br i1 %30, label %31, label %53

31:                                               ; preds = %25
  %32 = load i8, ptr %6, align 1, !tbaa !11, !range !13, !noundef !14
  %33 = trunc i8 %32 to i1
  br i1 %33, label %34, label %43

34:                                               ; preds = %31
  %35 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %11, i32 0, i32 16
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [1024 x ptr], ptr %35, i64 0, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance", ptr %39, i32 0, i32 3
  %41 = load i32, ptr %40, align 8, !tbaa !15
  %42 = and i32 %41, -257
  store i32 %42, ptr %40, align 8, !tbaa !15
  br label %52

43:                                               ; preds = %31
  %44 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %11, i32 0, i32 16
  %45 = load i32, ptr %9, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [1024 x ptr], ptr %44, i64 0, i64 %46
  %48 = load ptr, ptr %47, align 8, !tbaa !5
  %49 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance", ptr %48, i32 0, i32 3
  %50 = load i32, ptr %49, align 8, !tbaa !15
  %51 = or i32 %50, 256
  store i32 %51, ptr %49, align 8, !tbaa !15
  br label %52

52:                                               ; preds = %43, %34
  br label %53

53:                                               ; preds = %52, %25
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds i32, ptr %54, i32 1
  store ptr %55, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %21, !llvm.loop !20

56:                                               ; preds = %21
  call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %11)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  ret void
}

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

!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 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !10, i64 16}
!16 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !10, i64 8, !10, i64 12, !10, i64 16, !17, i64 20, !7, i64 24, !17, i64 56, !17, i64 60, !17, i64 64, !17, i64 68, !10, i64 72, !17, i64 76, !17, i64 80, !18, i64 88, !18, i64 96, !19, i64 104, !19, i64 152, !19, i64 200, !19, i64 248, !19, i64 296, !10, i64 344, !7, i64 348, !10, i64 380, !10, i64 384, !7, i64 392, !7, i64 456, !10, i64 472, !10, i64 476, !10, i64 480, !18, i64 488}
!17 = !{!"float", !7, i64 0}
!18 = !{!"double", !7, i64 0}
!19 = !{!"_ZTSN6SoLoud5FaderE", !17, i64 0, !17, i64 4, !17, i64 8, !18, i64 16, !18, i64 24, !18, i64 32, !17, i64 40, !10, i64 44}
!20 = distinct !{!20, !21}
!21 = !{!"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"

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

declare void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833)) local_unnamed_addr #1

declare noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) local_unnamed_addr #1

declare noundef i32 @_ZNK6SoLoud6Soloud27getVoiceFromHandle_internalEj(ptr noundef nonnull align 8 dereferenceable(138833), i32 noundef) local_unnamed_addr #1

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

declare void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud6Soloud11setAutoStopEjb(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1, i1 noundef zeroext %2) local_unnamed_addr #2 align 2 {
  %4 = alloca [2 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 4
  store i32 0, ptr %5, align 4, !tbaa !5
  tail call void @_ZN6SoLoud6Soloud23lockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %0)
  %6 = tail call noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1)
  %7 = icmp eq ptr %6, null
  %spec.select = select i1 %7, ptr %4, ptr %6
  %8 = load i32, ptr %spec.select, align 4, !tbaa !5
  %.not14 = icmp eq i32 %8, 0
  br i1 %.not14, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 152
  br i1 %2, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph, %19
  %10 = phi i32 [ %21, %19 ], [ %8, %.lr.ph ]
  %.115.us = phi ptr [ %20, %19 ], [ %spec.select, %.lr.ph ]
  %11 = tail call noundef i32 @_ZNK6SoLoud6Soloud27getVoiceFromHandle_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %10)
  %.not13.us = icmp eq i32 %11, -1
  br i1 %.not13.us, label %19, label %12

12:                                               ; preds = %.lr.ph.split.us
  %13 = sext i32 %11 to i64
  %14 = getelementptr inbounds [1024 x ptr], ptr %9, i64 0, i64 %13
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = and i32 %17, -257
  store i32 %18, ptr %16, align 8, !tbaa !11
  br label %19

19:                                               ; preds = %12, %.lr.ph.split.us
  %20 = getelementptr inbounds i8, ptr %.115.us, i64 4
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %.not.us = icmp eq i32 %21, 0
  br i1 %.not.us, label %._crit_edge, label %.lr.ph.split.us, !llvm.loop !16

.lr.ph.split:                                     ; preds = %.lr.ph, %31
  %22 = phi i32 [ %33, %31 ], [ %8, %.lr.ph ]
  %.115 = phi ptr [ %32, %31 ], [ %spec.select, %.lr.ph ]
  %23 = tail call noundef i32 @_ZNK6SoLoud6Soloud27getVoiceFromHandle_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %22)
  %.not13 = icmp eq i32 %23, -1
  br i1 %.not13, label %31, label %24

24:                                               ; preds = %.lr.ph.split
  %25 = sext i32 %23 to i64
  %26 = getelementptr inbounds [1024 x ptr], ptr %9, i64 0, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !9
  %28 = getelementptr inbounds i8, ptr %27, i64 16
  %29 = load i32, ptr %28, align 8, !tbaa !11
  %30 = or i32 %29, 256
  store i32 %30, ptr %28, align 8, !tbaa !11
  br label %31

31:                                               ; preds = %24, %.lr.ph.split
  %32 = getelementptr inbounds i8, ptr %.115, i64 4
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %.not = icmp eq i32 %33, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.split, !llvm.loop !16

._crit_edge:                                      ; preds = %31, %19, %3
  tail call void @_ZN6SoLoud6Soloud25unlockAudioMutex_internalEv(ptr noundef nonnull align 8 dereferenceable(138833) %0)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  ret void
}

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

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTSN6SoLoud19AudioSourceInstanceE", !6, i64 8, !6, i64 12, !6, i64 16, !13, i64 20, !7, i64 24, !13, i64 56, !13, i64 60, !13, i64 64, !13, i64 68, !6, i64 72, !13, i64 76, !13, i64 80, !14, i64 88, !14, i64 96, !15, i64 104, !15, i64 152, !15, i64 200, !15, i64 248, !15, i64 296, !6, i64 344, !7, i64 348, !6, i64 380, !6, i64 384, !7, i64 392, !7, i64 456, !6, i64 472, !6, i64 476, !6, i64 480, !14, i64 488}
!13 = !{!"float", !7, i64 0}
!14 = !{!"double", !7, i64 0}
!15 = !{!"_ZTSN6SoLoud5FaderE", !13, i64 0, !13, i64 4, !13, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !13, i64 40, !6, i64 44}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass