; 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_linear_resampler_heap_layout = type { i64, i64, i64, i64 }
%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 }

; 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: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; 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) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL35ma_linear_resampler_get_heap_layoutPK26ma_linear_resampler_configP31ma_linear_resampler_heap_layout(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_linear_resampler_init_preallocated(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca %struct.ma_linear_resampler_heap_layout, align 8
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 32, ptr %9) #4
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %14

13:                                               ; preds = %3
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %81

14:                                               ; preds = %3
  %15 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %15, i8 0, i64 136, i1 false)
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = call noundef i32 @_ZL35ma_linear_resampler_get_heap_layoutPK26ma_linear_resampler_configP31ma_linear_resampler_heap_layout(ptr noundef %16, ptr noundef %9)
  store i32 %17, ptr %8, align 4, !tbaa !9
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %22

20:                                               ; preds = %14
  %21 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %21, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %81

22:                                               ; preds = %14
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ma_linear_resampler, ptr %24, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %25, ptr align 8 %23, i64 32, i1 false), !tbaa.struct !11
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ma_linear_resampler, ptr %27, i32 0, i32 8
  store ptr %26, ptr %28, align 8, !tbaa !18
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ma_linear_resampler_heap_layout, ptr %9, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !22
  call void @llvm.memset.p0.i64(ptr align 1 %29, i8 0, i64 %31, i1 false)
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ma_linear_resampler_config, ptr %32, i32 0, i32 0
  %34 = load i32, ptr %33, align 8, !tbaa !25
  %35 = icmp eq i32 %34, 5
  br i1 %35, label %36, label %49

36:                                               ; preds = %22
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ma_linear_resampler_heap_layout, ptr %9, i32 0, i32 1
  %39 = load i64, ptr %38, align 8, !tbaa !26
  %40 = getelementptr inbounds i8, ptr %37, i64 %39
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ma_linear_resampler, ptr %41, i32 0, i32 5
  store ptr %40, ptr %42, align 8, !tbaa !27
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ma_linear_resampler_heap_layout, ptr %9, i32 0, i32 2
  %45 = load i64, ptr %44, align 8, !tbaa !28
  %46 = getelementptr inbounds i8, ptr %43, i64 %45
  %47 = load ptr, ptr %7, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ma_linear_resampler, ptr %47, i32 0, i32 6
  store ptr %46, ptr %48, align 8, !tbaa !27
  br label %62

49:                                               ; preds = %22
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ma_linear_resampler_heap_layout, ptr %9, i32 0, i32 1
  %52 = load i64, ptr %51, align 8, !tbaa !26
  %53 = getelementptr inbounds i8, ptr %50, i64 %52
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.ma_linear_resampler, ptr %54, i32 0, i32 5
  store ptr %53, ptr %55, align 8, !tbaa !27
  %56 = load ptr, ptr %6, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ma_linear_resampler_heap_layout, ptr %9, i32 0, i32 2
  %58 = load i64, ptr %57, align 8, !tbaa !28
  %59 = getelementptr inbounds i8, ptr %56, i64 %58
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ma_linear_resampler, ptr %60, i32 0, i32 6
  store ptr %59, ptr %61, align 8, !tbaa !27
  br label %62

62:                                               ; preds = %49, %36
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ma_linear_resampler_config, ptr %65, i32 0, i32 2
  %67 = load i32, ptr %66, align 8, !tbaa !29
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ma_linear_resampler_config, ptr %68, i32 0, i32 3
  %70 = load i32, ptr %69, align 4, !tbaa !30
  %71 = call noundef i32 @_ZL37ma_linear_resampler_set_rate_internalP19ma_linear_resamplerPvP31ma_linear_resampler_heap_layoutjjj(ptr noundef %63, ptr noundef %64, ptr noundef %9, i32 noundef %67, i32 noundef %70, i32 noundef 0)
  store i32 %71, ptr %8, align 4, !tbaa !9
  %72 = load i32, ptr %8, align 4, !tbaa !9
  %73 = icmp ne i32 %72, 0
  br i1 %73, label %74, label %76

74:                                               ; preds = %62
  %75 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %75, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %81

76:                                               ; preds = %62
  %77 = load ptr, ptr %7, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.ma_linear_resampler, ptr %77, i32 0, i32 3
  store i32 1, ptr %78, align 8, !tbaa !31
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct.ma_linear_resampler, ptr %79, i32 0, i32 4
  store i32 0, ptr %80, align 4, !tbaa !32
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %81

81:                                               ; preds = %76, %74, %20, %13
  call void @llvm.lifetime.end.p0(i64 32, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %82 = load i32, ptr %4, align 4
  ret i32 %82
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL37ma_linear_resampler_set_rate_internalP19ma_linear_resamplerPvP31ma_linear_resampler_heap_layoutjjj(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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, !10, i64 0}
!10 = !{!"_ZTS9ma_result", !7, i64 0}
!11 = !{i64 0, i64 4, !12, i64 4, i64 4, !14, i64 8, i64 4, !14, i64 12, i64 4, !14, i64 16, i64 4, !14, i64 24, i64 8, !16}
!12 = !{!13, !13, i64 0}
!13 = !{!"_ZTS9ma_format", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!19, !6, i64 120}
!19 = !{!"_ZTS19ma_linear_resampler", !20, i64 0, !15, i64 32, !15, i64 36, !15, i64 40, !15, i64 44, !7, i64 48, !7, i64 56, !21, i64 64, !6, i64 120, !15, i64 128}
!20 = !{!"_ZTS26ma_linear_resampler_config", !13, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !17, i64 24}
!21 = !{!"_ZTS6ma_lpf", !13, i64 0, !15, i64 4, !15, i64 8, !15, i64 12, !15, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !15, i64 48}
!22 = !{!23, !24, i64 0}
!23 = !{!"_ZTS31ma_linear_resampler_heap_layout", !24, i64 0, !24, i64 8, !24, i64 16, !24, i64 24}
!24 = !{!"long", !7, i64 0}
!25 = !{!20, !13, i64 0}
!26 = !{!23, !24, i64 8}
!27 = !{!7, !7, i64 0}
!28 = !{!23, !24, i64 16}
!29 = !{!20, !15, i64 8}
!30 = !{!20, !15, i64 12}
!31 = !{!19, !15, i64 40}
!32 = !{!19, !15, i64 44}


; 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_linear_resampler_heap_layout = type { i64, i64, i64, i64 }

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

; Function Attrs: mustprogress 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) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL35ma_linear_resampler_get_heap_layoutPK26ma_linear_resampler_configP31ma_linear_resampler_heap_layout(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @ma_linear_resampler_init_preallocated(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #3 {
  %4 = alloca %struct.ma_linear_resampler_heap_layout, align 8
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %4) #4
  %5 = icmp eq ptr %2, null
  br i1 %5, label %25, label %6

6:                                                ; preds = %3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(136) %2, i8 0, i64 136, i1 false)
  %7 = call noundef i32 @_ZL35ma_linear_resampler_get_heap_layoutPK26ma_linear_resampler_configP31ma_linear_resampler_heap_layout(ptr noundef %0, ptr noundef nonnull %4)
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %8, label %25

8:                                                ; preds = %6
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(32) %2, ptr noundef nonnull align 8 dereferenceable(32) %0, i64 32, i1 false), !tbaa.struct !5
  %9 = getelementptr inbounds i8, ptr %2, i64 120
  store ptr %1, ptr %9, align 8, !tbaa !14
  %10 = load i64, ptr %4, align 8, !tbaa !19
  call void @llvm.memset.p0.i64(ptr align 1 %1, i8 0, i64 %10, i1 false)
  %11 = getelementptr inbounds i8, ptr %4, i64 8
  %12 = load i64, ptr %11, align 8, !tbaa !22
  %13 = getelementptr inbounds i8, ptr %4, i64 16
  %14 = load i64, ptr %13, align 8, !tbaa !23
  %.sink = getelementptr inbounds i8, ptr %1, i64 %14
  %.sink31 = getelementptr inbounds i8, ptr %1, i64 %12
  %15 = getelementptr inbounds i8, ptr %2, i64 48
  store ptr %.sink31, ptr %15, align 8
  %16 = getelementptr inbounds i8, ptr %2, i64 56
  store ptr %.sink, ptr %16, align 8
  %17 = getelementptr inbounds i8, ptr %0, i64 8
  %18 = load i32, ptr %17, align 8, !tbaa !24
  %19 = getelementptr inbounds i8, ptr %0, i64 12
  %20 = load i32, ptr %19, align 4, !tbaa !25
  %21 = call noundef i32 @_ZL37ma_linear_resampler_set_rate_internalP19ma_linear_resamplerPvP31ma_linear_resampler_heap_layoutjjj(ptr noundef nonnull %2, ptr noundef %1, ptr noundef nonnull %4, i32 noundef %18, i32 noundef %20, i32 noundef 0)
  %.not30 = icmp eq i32 %21, 0
  br i1 %.not30, label %22, label %25

22:                                               ; preds = %8
  %23 = getelementptr inbounds i8, ptr %2, i64 40
  store i32 1, ptr %23, align 8, !tbaa !26
  %24 = getelementptr inbounds i8, ptr %2, i64 44
  store i32 0, ptr %24, align 4, !tbaa !27
  br label %25

25:                                               ; preds = %8, %6, %3, %22
  %.0 = phi i32 [ 0, %22 ], [ -2, %3 ], [ %7, %6 ], [ %21, %8 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %4) #4
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL37ma_linear_resampler_set_rate_internalP19ma_linear_resamplerPvP31ma_linear_resampler_heap_layoutjjj(ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #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 = !{i64 0, i64 4, !6, i64 4, i64 4, !10, i64 8, i64 4, !10, i64 12, i64 4, !10, i64 16, i64 4, !10, i64 24, i64 8, !12}
!6 = !{!7, !7, i64 0}
!7 = !{!"_ZTS9ma_format", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"double", !8, i64 0}
!14 = !{!15, !18, i64 120}
!15 = !{!"_ZTS19ma_linear_resampler", !16, i64 0, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !8, i64 48, !8, i64 56, !17, i64 64, !18, i64 120, !11, i64 128}
!16 = !{!"_ZTS26ma_linear_resampler_config", !7, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !13, i64 24}
!17 = !{!"_ZTS6ma_lpf", !7, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !18, i64 24, !18, i64 32, !18, i64 40, !11, i64 48}
!18 = !{!"any pointer", !8, i64 0}
!19 = !{!20, !21, i64 0}
!20 = !{!"_ZTS31ma_linear_resampler_heap_layout", !21, i64 0, !21, i64 8, !21, i64 16, !21, i64 24}
!21 = !{!"long", !8, i64 0}
!22 = !{!20, !21, i64 8}
!23 = !{!20, !21, i64 16}
!24 = !{!16, !11, i64 8}
!25 = !{!16, !11, i64 12}
!26 = !{!15, !11, i64 40}
!27 = !{!15, !11, i64 44}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass