; 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_slot_allocator_heap_layout = type { i64, i64, i64 }
%struct.ma_slot_allocator = type { ptr, ptr, i32, i32, i32, ptr }
%struct.ma_slot_allocator_config = type { 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: mustprogress uwtable
declare hidden noundef i32 @_ZL33ma_slot_allocator_get_heap_layoutPK24ma_slot_allocator_configP29ma_slot_allocator_heap_layout(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_slot_allocator_init_preallocated(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %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_slot_allocator_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) #3
  call void @llvm.lifetime.start.p0(i64 24, ptr %9) #3
  %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 %50

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 40, i1 false)
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = icmp eq ptr %16, null
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %50

19:                                               ; preds = %14
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = call noundef i32 @_ZL33ma_slot_allocator_get_heap_layoutPK24ma_slot_allocator_configP29ma_slot_allocator_heap_layout(ptr noundef %20, ptr noundef %9)
  store i32 %21, ptr %8, align 4, !tbaa !9
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %26

24:                                               ; preds = %19
  %25 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %25, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %50

26:                                               ; preds = %19
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.ma_slot_allocator, ptr %28, i32 0, i32 5
  store ptr %27, ptr %29, align 8, !tbaa !11
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ma_slot_allocator_heap_layout, ptr %9, i32 0, i32 0
  %32 = load i64, ptr %31, align 8, !tbaa !14
  call void @llvm.memset.p0.i64(ptr align 1 %30, i8 0, i64 %32, i1 false)
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ma_slot_allocator_heap_layout, ptr %9, i32 0, i32 1
  %35 = load i64, ptr %34, align 8, !tbaa !17
  %36 = getelementptr inbounds i8, ptr %33, i64 %35
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ma_slot_allocator, ptr %37, i32 0, i32 0
  store ptr %36, ptr %38, align 8, !tbaa !18
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ma_slot_allocator_heap_layout, ptr %9, i32 0, i32 2
  %41 = load i64, ptr %40, align 8, !tbaa !19
  %42 = getelementptr inbounds i8, ptr %39, i64 %41
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ma_slot_allocator, ptr %43, i32 0, i32 1
  store ptr %42, ptr %44, align 8, !tbaa !20
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ma_slot_allocator_config, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 4, !tbaa !21
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ma_slot_allocator, ptr %48, i32 0, i32 3
  store i32 %47, ptr %49, align 4, !tbaa !23
  store i32 0, ptr %4, align 4
  store i32 1, ptr %10, align 4
  br label %50

50:                                               ; preds = %26, %24, %18, %13
  call void @llvm.lifetime.end.p0(i64 24, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %51 = load i32, ptr %4, align 4
  ret i32 %51
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"_ZTS9ma_result", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTS17ma_slot_allocator", !6, i64 0, !6, i64 8, !13, i64 16, !13, i64 20, !13, i64 24, !6, i64 32}
!13 = !{!"int", !7, i64 0}
!14 = !{!15, !16, i64 0}
!15 = !{!"_ZTS29ma_slot_allocator_heap_layout", !16, i64 0, !16, i64 8, !16, i64 16}
!16 = !{!"long", !7, i64 0}
!17 = !{!15, !16, i64 8}
!18 = !{!12, !6, i64 0}
!19 = !{!15, !16, i64 16}
!20 = !{!12, !6, i64 8}
!21 = !{!22, !13, i64 0}
!22 = !{!"_ZTS24ma_slot_allocator_config", !13, i64 0}
!23 = !{!12, !13, i64 20}


; 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_slot_allocator_heap_layout = type { 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 uwtable
declare hidden noundef i32 @_ZL33ma_slot_allocator_get_heap_layoutPK24ma_slot_allocator_configP29ma_slot_allocator_heap_layout(ptr noundef, ptr noundef) local_unnamed_addr #2

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

6:                                                ; preds = %3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %2, i8 0, i64 40, i1 false)
  %7 = icmp eq ptr %1, null
  br i1 %7, label %22, label %8

8:                                                ; preds = %6
  %9 = call noundef i32 @_ZL33ma_slot_allocator_get_heap_layoutPK24ma_slot_allocator_configP29ma_slot_allocator_heap_layout(ptr noundef %0, ptr noundef nonnull %4)
  %.not = icmp eq i32 %9, 0
  br i1 %.not, label %10, label %22

10:                                               ; preds = %8
  %11 = getelementptr inbounds i8, ptr %2, i64 32
  store ptr %1, ptr %11, align 8, !tbaa !5
  %12 = load i64, ptr %4, align 8, !tbaa !11
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %1, i8 0, i64 %12, i1 false)
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  %14 = load i64, ptr %13, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %1, i64 %14
  store ptr %15, ptr %2, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %4, i64 16
  %17 = load i64, ptr %16, align 8, !tbaa !16
  %18 = getelementptr inbounds i8, ptr %1, i64 %17
  %19 = getelementptr inbounds i8, ptr %2, i64 8
  store ptr %18, ptr %19, align 8, !tbaa !17
  %20 = load i32, ptr %0, align 4, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %2, i64 20
  store i32 %20, ptr %21, align 4, !tbaa !20
  br label %22

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !7, i64 32}
!6 = !{!"_ZTS17ma_slot_allocator", !7, i64 0, !7, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !7, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS29ma_slot_allocator_heap_layout", !13, i64 0, !13, i64 8, !13, i64 16}
!13 = !{!"long", !8, i64 0}
!14 = !{!12, !13, i64 8}
!15 = !{!6, !7, i64 0}
!16 = !{!12, !13, i64 16}
!17 = !{!6, !7, i64 8}
!18 = !{!19, !10, i64 0}
!19 = !{!"_ZTS24ma_slot_allocator_config", !10, i64 0}
!20 = !{!6, !10, i64 20}


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