; LLVM IR from Overload-Technologies/Overload :: Dependencies/soloud/src/core (soloud_core_3d)

; 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] }>

; 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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud6Soloud24set3dSourceDopplerFactorEjf(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1, float noundef %2) #2 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca float, align 4
  %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
  store float %2, ptr %6, align 4, !tbaa !11
  %10 = 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
  %11 = load i32, ptr %5, align 4, !tbaa !9
  store i32 %11, ptr %8, align 4, !tbaa !9
  %12 = getelementptr inbounds i32, ptr %8, i64 1
  store i32 0, ptr %12, align 4, !tbaa !9
  %13 = load i32, ptr %5, align 4, !tbaa !9
  %14 = call noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %10, i32 noundef %13)
  store ptr %14, ptr %7, align 8, !tbaa !5
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  %16 = icmp eq ptr %15, null
  br i1 %16, label %17, label %19

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

19:                                               ; preds = %17, %3
  br label %20

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

24:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = and i32 %26, 4095
  %28 = sub i32 %27, 1
  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 %48

31:                                               ; preds = %24
  %32 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %10, i32 0, i32 44
  %33 = load i32, ptr %9, align 4, !tbaa !9
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr %32, i64 0, i64 %34
  %36 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance3dData", ptr %35, i32 0, i32 15
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = icmp eq i32 %37, %39
  br i1 %40, label %41, label %48

41:                                               ; preds = %31
  %42 = load float, ptr %6, align 4, !tbaa !11
  %43 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %10, i32 0, i32 44
  %44 = load i32, ptr %9, align 4, !tbaa !9
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr %43, i64 0, i64 %45
  %47 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance3dData", ptr %46, i32 0, i32 6
  store float %42, ptr %47, align 8, !tbaa !15
  br label %48

48:                                               ; preds = %41, %31, %24
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds i32, ptr %49, i32 1
  store ptr %50, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %20, !llvm.loop !16

51:                                               ; preds = %20
  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 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 112}
!14 = !{!"_ZTSN6SoLoud25AudioSourceInstance3dDataE", !7, i64 0, !7, i64 12, !12, i64 24, !12, i64 28, !12, i64 32, !10, i64 36, !12, i64 40, !6, i64 48, !6, i64 56, !10, i64 64, !12, i64 68, !12, i64 72, !7, i64 76, !10, i64 108, !10, i64 112}
!15 = !{!14, !12, i64 40}
!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"

%"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] }>

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN6SoLoud6Soloud24set3dSourceDopplerFactorEjf(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1, float noundef %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
  %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
  %.not15 = icmp eq i32 %8, 0
  br i1 %.not15, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %9 = getelementptr inbounds i8, ptr %0, i64 11840
  br label %10

10:                                               ; preds = %.lr.ph, %22
  %11 = phi i32 [ %8, %.lr.ph ], [ %24, %22 ]
  %.116 = phi ptr [ %spec.select, %.lr.ph ], [ %23, %22 ]
  %12 = and i32 %11, 4095
  %.not14 = icmp eq i32 %12, 0
  br i1 %.not14, label %22, label %13

13:                                               ; preds = %10
  %14 = add nsw i32 %12, -1
  %15 = zext nneg i32 %14 to i64
  %16 = getelementptr inbounds [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr %9, i64 0, i64 %15
  %17 = getelementptr inbounds i8, ptr %16, i64 112
  %18 = load i32, ptr %17, align 8, !tbaa !9
  %19 = icmp eq i32 %18, %11
  br i1 %19, label %20, label %22

20:                                               ; preds = %13
  %21 = getelementptr inbounds i8, ptr %16, i64 40
  store float %2, ptr %21, align 8, !tbaa !13
  br label %22

22:                                               ; preds = %20, %13, %10
  %23 = getelementptr inbounds i8, ptr %.116, i64 4
  %24 = load i32, ptr %23, align 4, !tbaa !5
  %.not = icmp eq i32 %24, 0
  br i1 %.not, label %._crit_edge, label %10, !llvm.loop !14

._crit_edge:                                      ; preds = %22, %3
  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, !6, i64 112}
!10 = !{!"_ZTSN6SoLoud25AudioSourceInstance3dDataE", !7, i64 0, !7, i64 12, !11, i64 24, !11, i64 28, !11, i64 32, !6, i64 36, !11, i64 40, !12, i64 48, !12, i64 56, !6, i64 64, !11, i64 68, !11, i64 72, !7, i64 76, !6, i64 108, !6, i64 112}
!11 = !{!"float", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!10, !11, i64 40}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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