; 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 @_ZN6SoLoud6Soloud19set3dSourcePositionEjfff(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1, float noundef %2, float noundef %3, float noundef %4) #2 align 2 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca float, align 4
  %11 = alloca ptr, align 8
  %12 = alloca [2 x i32], align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !9
  store float %2, ptr %8, align 4, !tbaa !11
  store float %3, ptr %9, align 4, !tbaa !11
  store float %4, ptr %10, align 4, !tbaa !11
  %14 = load ptr, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #3
  store ptr null, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %15 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %15, ptr %12, align 4, !tbaa !9
  %16 = getelementptr inbounds i32, ptr %12, i64 1
  store i32 0, ptr %16, align 4, !tbaa !9
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = call noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %14, i32 noundef %17)
  store ptr %18, ptr %11, align 8, !tbaa !5
  %19 = load ptr, ptr %11, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %23

21:                                               ; preds = %5
  %22 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 0
  store ptr %22, ptr %11, align 8, !tbaa !5
  br label %23

23:                                               ; preds = %21, %5
  br label %24

24:                                               ; preds = %67, %23
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = load i32, ptr %25, align 4, !tbaa !9
  %27 = icmp ne i32 %26, 0
  br i1 %27, label %28, label %70

28:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = and i32 %30, 4095
  %32 = sub i32 %31, 1
  store i32 %32, ptr %13, align 4, !tbaa !9
  %33 = load i32, ptr %13, align 4, !tbaa !9
  %34 = icmp ne i32 %33, -1
  br i1 %34, label %35, label %67

35:                                               ; preds = %28
  %36 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %14, i32 0, i32 44
  %37 = load i32, ptr %13, align 4, !tbaa !9
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr %36, i64 0, i64 %38
  %40 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance3dData", ptr %39, i32 0, i32 15
  %41 = load i32, ptr %40, align 8, !tbaa !13
  %42 = load ptr, ptr %11, align 8, !tbaa !5
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = icmp eq i32 %41, %43
  br i1 %44, label %45, label %67

45:                                               ; preds = %35
  %46 = load float, ptr %8, align 4, !tbaa !11
  %47 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %14, i32 0, i32 44
  %48 = load i32, ptr %13, align 4, !tbaa !9
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr %47, i64 0, i64 %49
  %51 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance3dData", ptr %50, i32 0, i32 0
  %52 = getelementptr inbounds [3 x float], ptr %51, i64 0, i64 0
  store float %46, ptr %52, align 8, !tbaa !11
  %53 = load float, ptr %9, align 4, !tbaa !11
  %54 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %14, i32 0, i32 44
  %55 = load i32, ptr %13, align 4, !tbaa !9
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr %54, i64 0, i64 %56
  %58 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance3dData", ptr %57, i32 0, i32 0
  %59 = getelementptr inbounds [3 x float], ptr %58, i64 0, i64 1
  store float %53, ptr %59, align 4, !tbaa !11
  %60 = load float, ptr %10, align 4, !tbaa !11
  %61 = getelementptr inbounds %"class.SoLoud::Soloud", ptr %14, i32 0, i32 44
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [1024 x %"class.SoLoud::AudioSourceInstance3dData"], ptr %61, i64 0, i64 %63
  %65 = getelementptr inbounds %"class.SoLoud::AudioSourceInstance3dData", ptr %64, i32 0, i32 0
  %66 = getelementptr inbounds [3 x float], ptr %65, i64 0, i64 2
  store float %60, ptr %66, align 8, !tbaa !11
  br label %67

67:                                               ; preds = %45, %35, %28
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = getelementptr inbounds i32, ptr %68, i32 1
  store ptr %69, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %24, !llvm.loop !15

70:                                               ; preds = %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #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 = distinct !{!15, !16}
!16 = !{!"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 @_ZN6SoLoud6Soloud19set3dSourcePositionEjfff(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1, float noundef %2, float noundef %3, float noundef %4) local_unnamed_addr #2 align 2 {
  %6 = alloca [2 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  store i32 %1, ptr %6, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 4
  store i32 0, ptr %7, align 4, !tbaa !5
  %8 = tail call noundef ptr @_ZNK6SoLoud6Soloud32voiceGroupHandleToArray_internalEj(ptr noundef nonnull align 8 dereferenceable(138833) %0, i32 noundef %1)
  %9 = icmp eq ptr %8, null
  %spec.select = select i1 %9, ptr %6, ptr %8
  %10 = load i32, ptr %spec.select, align 4, !tbaa !5
  %.not19 = icmp eq i32 %10, 0
  br i1 %.not19, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5
  %11 = getelementptr inbounds i8, ptr %0, i64 11840
  br label %12

12:                                               ; preds = %.lr.ph, %25
  %13 = phi i32 [ %10, %.lr.ph ], [ %27, %25 ]
  %.120 = phi ptr [ %spec.select, %.lr.ph ], [ %26, %25 ]
  %14 = and i32 %13, 4095
  %.not18 = icmp eq i32 %14, 0
  br i1 %.not18, label %25, label %15

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

22:                                               ; preds = %15
  store float %2, ptr %18, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %18, i64 4
  store float %3, ptr %23, align 4, !tbaa !13
  %24 = getelementptr inbounds i8, ptr %18, i64 8
  store float %4, ptr %24, align 8, !tbaa !13
  br label %25

25:                                               ; preds = %22, %15, %12
  %26 = getelementptr inbounds i8, ptr %.120, i64 4
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %.not = icmp eq i32 %27, 0
  br i1 %.not, label %._crit_edge, label %12, !llvm.loop !14

._crit_edge:                                      ; preds = %25, %5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #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 = !{!11, !11, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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