; LLVM IR from SelfishOlex/MiniAudioO3DE :: MiniAudio/Code/Source/Clients (MiniAudioImplementation)

; 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.ma_vec3f = type { float, float, float }
%struct.ma_sound = type { %struct.ma_engine_node, ptr, i64, i32, i8, ptr }
%struct.ma_engine_node = type { %struct.ma_node_base, ptr, i32, %struct.ma_fader, %struct.ma_linear_resampler, %struct.ma_spatializer, %struct.ma_panner, float, float, float, i32, i32, i32, i8, ptr }
%struct.ma_node_base = type { ptr, ptr, ptr, i16, i16, i16, i16, i32, [2 x i64], i64, i32, i32, ptr, ptr, [2 x %struct.ma_node_input_bus], [2 x %struct.ma_node_output_bus], ptr, i32 }
%struct.ma_node_input_bus = type { %struct.ma_node_output_bus, i32, i32, i8 }
%struct.ma_node_output_bus = type { ptr, i8, i8, i8, i32, i32, i32, i32, float, ptr, ptr, ptr }
%struct.ma_fader = type { %struct.ma_fader_config, float, float, i64, i64 }
%struct.ma_fader_config = type { i32, i32, i32 }
%struct.ma_linear_resampler = type { %struct.ma_linear_resampler_config, i32, i32, i32, i32, %union.anon.29, %union.anon.30, %struct.ma_lpf, ptr, i32 }
%struct.ma_linear_resampler_config = type { i32, i32, i32, i32, i32, double }
%union.anon.29 = type { ptr }
%union.anon.30 = type { ptr }
%struct.ma_lpf = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, i32 }
%struct.ma_spatializer = type { i32, i32, ptr, i32, i32, i32, float, float, float, float, float, float, float, float, float, float, i32, %struct.ma_vec3f, %struct.ma_vec3f, %struct.ma_vec3f, float, %struct.ma_gainer, ptr, ptr, i32 }
%struct.ma_gainer = type { %struct.ma_gainer_config, i32, ptr, ptr, ptr, i32 }
%struct.ma_gainer_config = type { i32, i32 }
%struct.ma_panner = type { i32, i32, i32, float }
%struct.ma_engine = type { %struct.ma_node_graph, ptr, ptr, ptr, i32, i32, [4 x %struct.ma_spatializer_listener], %struct.ma_allocation_callbacks, i8, i8, i32, ptr, i32, i32, i32 }
%struct.ma_node_graph = type { %struct.ma_node_base, %struct.ma_node_base, i16, i32 }
%struct.ma_spatializer_listener = type { %struct.ma_spatializer_listener_config, %struct.ma_vec3f, %struct.ma_vec3f, %struct.ma_vec3f, i32, i32, ptr }
%struct.ma_spatializer_listener_config = type { i32, ptr, i32, float, float, float, float, %struct.ma_vec3f }
%struct.ma_allocation_callbacks = type { ptr, ptr, ptr, ptr }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_Z16ma_vec3f_init_3ffff(float noundef, float noundef, float noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_Z12ma_vec3f_neg8ma_vec3f(<2 x float>, float) #3

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_Z18ma_vec3f_normalize8ma_vec3f(<2 x float>, float) #4

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_spatializer_get_relative_position_and_direction(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #4

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @ma_sound_get_engine(ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare dso_local i32 @ma_sound_get_listener_index(ptr noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @ma_sound_get_direction_to_listener(ptr noundef %0) #4 {
  %2 = alloca %struct.ma_vec3f, align 4
  %3 = alloca ptr, align 8
  %4 = alloca %struct.ma_vec3f, align 4
  %5 = alloca ptr, align 8
  %6 = alloca { <2 x float>, float }, align 8
  %7 = alloca i32, align 4
  %8 = alloca { <2 x float>, float }, align 8
  %9 = alloca %struct.ma_vec3f, align 4
  %10 = alloca %struct.ma_vec3f, align 4
  %11 = alloca { <2 x float>, float }, align 4
  %12 = alloca { <2 x float>, float }, align 8
  %13 = alloca { <2 x float>, float }, align 4
  %14 = alloca { <2 x float>, float }, align 8
  %15 = alloca { <2 x float>, float }, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 12, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %20

18:                                               ; preds = %1
  %19 = call { <2 x float>, float } @_Z16ma_vec3f_init_3ffff(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef -1.000000e+00)
  store { <2 x float>, float } %19, ptr %6, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 8 %6, i64 12, i1 false)
  store i32 1, ptr %7, align 4
  br label %47

20:                                               ; preds = %1
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = call ptr @ma_sound_get_engine(ptr noundef %21)
  store ptr %22, ptr %5, align 8, !tbaa !5
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = icmp eq ptr %23, null
  br i1 %24, label %25, label %27

25:                                               ; preds = %20
  %26 = call { <2 x float>, float } @_Z16ma_vec3f_init_3ffff(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef -1.000000e+00)
  store { <2 x float>, float } %26, ptr %8, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 8 %8, i64 12, i1 false)
  store i32 1, ptr %7, align 4
  br label %47

27:                                               ; preds = %20
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ma_sound, ptr %28, i32 0, i32 0
  %30 = getelementptr inbounds %struct.ma_engine_node, ptr %29, i32 0, i32 5
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ma_engine, ptr %31, i32 0, i32 6
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = call i32 @ma_sound_get_listener_index(ptr noundef %33)
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds [4 x %struct.ma_spatializer_listener], ptr %32, i64 0, i64 %35
  call void @ma_spatializer_get_relative_position_and_direction(ptr noundef %30, ptr noundef %36, ptr noundef %4, ptr noundef null)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 4 %4, i64 12, i1 false), !tbaa.struct !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %11, ptr align 4 %10, i64 12, i1 false)
  %37 = getelementptr inbounds { <2 x float>, float }, ptr %11, i32 0, i32 0
  %38 = load <2 x float>, ptr %37, align 4
  %39 = getelementptr inbounds { <2 x float>, float }, ptr %11, i32 0, i32 1
  %40 = load float, ptr %39, align 4
  %41 = call { <2 x float>, float } @_Z12ma_vec3f_neg8ma_vec3f(<2 x float> %38, float %40)
  store { <2 x float>, float } %41, ptr %12, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %9, ptr align 8 %12, i64 12, i1 false)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %13, ptr align 4 %9, i64 12, i1 false)
  %42 = getelementptr inbounds { <2 x float>, float }, ptr %13, i32 0, i32 0
  %43 = load <2 x float>, ptr %42, align 4
  %44 = getelementptr inbounds { <2 x float>, float }, ptr %13, i32 0, i32 1
  %45 = load float, ptr %44, align 4
  %46 = call { <2 x float>, float } @_Z18ma_vec3f_normalize8ma_vec3f(<2 x float> %43, float %45)
  store { <2 x float>, float } %46, ptr %14, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %2, ptr align 8 %14, i64 12, i1 false)
  store i32 1, ptr %7, align 4
  br label %47

47:                                               ; preds = %27, %25, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 12, ptr %4) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %15, ptr align 4 %2, i64 12, i1 false)
  %48 = load { <2 x float>, float }, ptr %15, align 8
  ret { <2 x float>, float } %48
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 = { mustprogress uwtable "min-legal-vector-width"="64" "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 #5 = { 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 = !{i64 0, i64 4, !10, i64 4, i64 4, !10, i64 8, i64 4, !10}
!10 = !{!11, !11, i64 0}
!11 = !{!"float", !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"

%struct.ma_vec3f = type { float, float, float }
%struct.ma_spatializer_listener = type { %struct.ma_spatializer_listener_config, %struct.ma_vec3f, %struct.ma_vec3f, %struct.ma_vec3f, i32, i32, ptr }
%struct.ma_spatializer_listener_config = type { i32, ptr, i32, float, float, float, float, %struct.ma_vec3f }

; 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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_Z16ma_vec3f_init_3ffff(float noundef, float noundef, float noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local { <2 x float>, float } @_Z12ma_vec3f_neg8ma_vec3f(<2 x float>, float) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local { <2 x float>, float } @_Z18ma_vec3f_normalize8ma_vec3f(<2 x float>, float) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_spatializer_get_relative_position_and_direction(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: mustprogress uwtable
declare dso_local i32 @ma_sound_get_listener_index(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local { <2 x float>, float } @ma_sound_get_direction_to_listener(ptr noundef %0) local_unnamed_addr #3 {
  %2 = alloca %struct.ma_vec3f, align 8
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #4
  %3 = icmp eq ptr %0, null
  br i1 %3, label %4, label %6

4:                                                ; preds = %1
  %5 = tail call { <2 x float>, float } @_Z16ma_vec3f_init_3ffff(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef -1.000000e+00)
  br label %19

6:                                                ; preds = %1
  %7 = tail call ptr @ma_sound_get_engine(ptr noundef nonnull %0)
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %11

9:                                                ; preds = %6
  %10 = tail call { <2 x float>, float } @_Z16ma_vec3f_init_3ffff(float noundef 0.000000e+00, float noundef 0.000000e+00, float noundef -1.000000e+00)
  br label %19

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 552
  %13 = getelementptr inbounds i8, ptr %7, i64 760
  %14 = tail call i32 @ma_sound_get_listener_index(ptr noundef nonnull %0)
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [4 x %struct.ma_spatializer_listener], ptr %13, i64 0, i64 %15
  call void @ma_spatializer_get_relative_position_and_direction(ptr noundef nonnull %12, ptr noundef nonnull %16, ptr noundef nonnull %2, ptr noundef null)
  %.sroa.011.0.copyload = load <2 x float>, ptr %2, align 8
  %.sroa.212.0..sroa_idx = getelementptr inbounds i8, ptr %2, i64 8
  %.sroa.212.0.copyload = load float, ptr %.sroa.212.0..sroa_idx, align 8, !tbaa !5
  %17 = call { <2 x float>, float } @_Z12ma_vec3f_neg8ma_vec3f(<2 x float> %.sroa.011.0.copyload, float %.sroa.212.0.copyload)
  %.fca.0.extract5 = extractvalue { <2 x float>, float } %17, 0
  %.fca.1.extract6 = extractvalue { <2 x float>, float } %17, 1
  %18 = call { <2 x float>, float } @_Z18ma_vec3f_normalize8ma_vec3f(<2 x float> %.fca.0.extract5, float %.fca.1.extract6)
  br label %19

19:                                               ; preds = %11, %9, %4
  %.pn = phi { <2 x float>, float } [ %5, %4 ], [ %10, %9 ], [ %18, %11 ]
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #4
  ret { <2 x float>, float } %.pn
}

attributes #0 = { mustprogress 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 = { mustprogress nounwind uwtable "min-legal-vector-width"="64" "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 = { mustprogress uwtable "min-legal-vector-width"="64" "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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass