; 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.drflac__memory_stream = type { ptr, i64, i64 }
%struct.drflac = type { ptr, ptr, %struct.drflac_allocation_callbacks, i32, i8, i8, i16, i64, i32, i32, %struct.drflac_frame, i64, i64, %struct.drflac__memory_stream, ptr, ptr, ptr, i8, %struct.drflac_bs, [1 x i8] }
%struct.drflac_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%struct.drflac_frame = type { %struct.drflac_frame_header, i32, [8 x %struct.drflac_subframe] }
%struct.drflac_frame_header = type { i64, i32, i32, i16, i8, i8, i8 }
%struct.drflac_subframe = type { i8, i8, i8, ptr }
%struct.drflac_bs = type { ptr, ptr, ptr, i64, i64, i32, i32, [512 x i64], i64, i16, i64, i32 }
%struct.drflac_oggbs = type { ptr, ptr, ptr, i64, i64, i32, %struct.drflac_ogg_page_header, %struct.drflac_ogg_page_header, i32, i32, [65307 x i8] }
%struct.drflac_ogg_page_header = type { [4 x i8], i8, i8, i64, i32, i32, i32, i8, [255 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

; 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 uwtable
declare dso_local ptr @drflac_open(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local ptr @drflac_open_memory(ptr noundef %0, i64 noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca %struct.drflac__memory_stream, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 24, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.drflac__memory_stream, ptr %8, i32 0, i32 0
  store ptr %12, ptr %13, align 8, !tbaa !11
  %14 = load i64, ptr %6, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.drflac__memory_stream, ptr %8, i32 0, i32 1
  store i64 %14, ptr %15, align 8, !tbaa !13
  %16 = getelementptr inbounds %struct.drflac__memory_stream, ptr %8, i32 0, i32 2
  store i64 0, ptr %16, align 8, !tbaa !14
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = call ptr @drflac_open(ptr noundef @_ZL22drflac__on_read_memoryPvS_m, ptr noundef @_ZL22drflac__on_seek_memoryPvi18drflac_seek_origin, ptr noundef %8, ptr noundef %17)
  store ptr %18, ptr %9, align 8, !tbaa !5
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  %20 = icmp eq ptr %19, null
  br i1 %20, label %21, label %22

21:                                               ; preds = %3
  store ptr null, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %45

22:                                               ; preds = %3
  %23 = load ptr, ptr %9, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.drflac, ptr %23, i32 0, i32 13
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %24, ptr align 8 %8, i64 24, i1 false), !tbaa.struct !15
  %25 = load ptr, ptr %9, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.drflac, ptr %25, i32 0, i32 8
  %27 = load i32, ptr %26, align 8, !tbaa !16
  %28 = icmp eq i32 %27, 1
  br i1 %28, label %29, label %37

29:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.drflac, ptr %30, i32 0, i32 16
  %32 = load ptr, ptr %31, align 8, !tbaa !26
  store ptr %32, ptr %11, align 8, !tbaa !5
  %33 = load ptr, ptr %9, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.drflac, ptr %33, i32 0, i32 13
  %35 = load ptr, ptr %11, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.drflac_oggbs, ptr %35, i32 0, i32 2
  store ptr %34, ptr %36, align 8, !tbaa !27
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %43

37:                                               ; preds = %22
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.drflac, ptr %38, i32 0, i32 13
  %40 = load ptr, ptr %9, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.drflac, ptr %40, i32 0, i32 18
  %42 = getelementptr inbounds %struct.drflac_bs, ptr %41, i32 0, i32 2
  store ptr %39, ptr %42, align 8, !tbaa !30
  br label %43

43:                                               ; preds = %37, %29
  %44 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %44, ptr %4, align 8
  store i32 1, ptr %10, align 4
  br label %45

45:                                               ; preds = %43, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %8) #4
  %46 = load ptr, ptr %4, align 8
  ret ptr %46
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL22drflac__on_read_memoryPvS_m(ptr noundef, ptr noundef, i64 noundef) #3

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS21drflac__memory_stream", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !10, i64 16}
!15 = !{i64 0, i64 8, !5, i64 8, i64 8, !9, i64 16, i64 8, !9}
!16 = !{!17, !22, i64 64}
!17 = !{!"_ZTS6drflac", !6, i64 0, !6, i64 8, !18, i64 16, !19, i64 48, !7, i64 52, !7, i64 53, !20, i64 54, !21, i64 56, !22, i64 64, !19, i64 68, !23, i64 72, !21, i64 232, !21, i64 240, !12, i64 248, !6, i64 272, !6, i64 280, !6, i64 288, !19, i64 296, !19, i64 296, !19, i64 296, !25, i64 304, !7, i64 4480}
!18 = !{!"_ZTS27drflac_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{!"int", !7, i64 0}
!20 = !{!"short", !7, i64 0}
!21 = !{!"long long", !7, i64 0}
!22 = !{!"_ZTS16drflac_container", !7, i64 0}
!23 = !{!"_ZTS12drflac_frame", !24, i64 0, !19, i64 24, !7, i64 32}
!24 = !{!"_ZTS19drflac_frame_header", !21, i64 0, !19, i64 8, !19, i64 12, !20, i64 16, !7, i64 18, !7, i64 19, !7, i64 20}
!25 = !{!"_ZTS9drflac_bs", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !21, i64 32, !19, i64 40, !19, i64 44, !7, i64 48, !21, i64 4144, !20, i64 4152, !21, i64 4160, !19, i64 4168}
!26 = !{!17, !6, i64 288}
!27 = !{!28, !6, i64 16}
!28 = !{!"_ZTS12drflac_oggbs", !6, i64 0, !6, i64 8, !6, i64 16, !21, i64 24, !21, i64 32, !19, i64 40, !29, i64 48, !29, i64 336, !19, i64 624, !19, i64 628, !7, i64 632}
!29 = !{!"_ZTS22drflac_ogg_page_header", !7, i64 0, !7, i64 4, !7, i64 5, !21, i64 8, !19, i64 16, !19, i64 20, !19, i64 24, !7, i64 28, !7, i64 29}
!30 = !{!17, !6, i64 320}


; 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.drflac__memory_stream = type { ptr, 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: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

; Function Attrs: mustprogress uwtable
declare dso_local ptr @drflac_open(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local ptr @drflac_open_memory(ptr noundef %0, i64 noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct.drflac__memory_stream, align 8
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %4) #4
  store ptr %0, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %1, ptr %5, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %4, i64 16
  store i64 0, ptr %6, align 8, !tbaa !12
  %7 = call ptr @drflac_open(ptr noundef nonnull @_ZL22drflac__on_read_memoryPvS_m, ptr noundef nonnull @_ZL22drflac__on_seek_memoryPvi18drflac_seek_origin, ptr noundef nonnull %4, ptr noundef %2)
  %8 = icmp eq ptr %7, null
  br i1 %8, label %20, label %9

9:                                                ; preds = %3
  %10 = getelementptr inbounds i8, ptr %7, i64 248
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %10, ptr noundef nonnull align 8 dereferenceable(24) %4, i64 24, i1 false), !tbaa.struct !13
  %11 = getelementptr inbounds i8, ptr %7, i64 64
  %12 = load i32, ptr %11, align 8, !tbaa !16
  %13 = icmp eq i32 %12, 1
  br i1 %13, label %14, label %18

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %7, i64 288
  %16 = load ptr, ptr %15, align 8, !tbaa !26
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  br label %.sink.split

18:                                               ; preds = %9
  %19 = getelementptr inbounds i8, ptr %7, i64 320
  br label %.sink.split

.sink.split:                                      ; preds = %18, %14
  %.sink = phi ptr [ %17, %14 ], [ %19, %18 ]
  store ptr %10, ptr %.sink, align 8, !tbaa !14
  br label %20

20:                                               ; preds = %.sink.split, %3
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %4) #4
  ret ptr %7
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i64 @_ZL22drflac__on_read_memoryPvS_m(ptr noundef, ptr noundef, i64 noundef) #3

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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, !7, i64 0}
!6 = !{!"_ZTS21drflac__memory_stream", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{!6, !10, i64 16}
!13 = !{i64 0, i64 8, !14, i64 8, i64 8, !15, i64 16, i64 8, !15}
!14 = !{!7, !7, i64 0}
!15 = !{!10, !10, i64 0}
!16 = !{!17, !22, i64 64}
!17 = !{!"_ZTS6drflac", !7, i64 0, !7, i64 8, !18, i64 16, !19, i64 48, !8, i64 52, !8, i64 53, !20, i64 54, !21, i64 56, !22, i64 64, !19, i64 68, !23, i64 72, !21, i64 232, !21, i64 240, !6, i64 248, !7, i64 272, !7, i64 280, !7, i64 288, !19, i64 296, !19, i64 296, !19, i64 296, !25, i64 304, !8, i64 4480}
!18 = !{!"_ZTS27drflac_allocation_callbacks", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!19 = !{!"int", !8, i64 0}
!20 = !{!"short", !8, i64 0}
!21 = !{!"long long", !8, i64 0}
!22 = !{!"_ZTS16drflac_container", !8, i64 0}
!23 = !{!"_ZTS12drflac_frame", !24, i64 0, !19, i64 24, !8, i64 32}
!24 = !{!"_ZTS19drflac_frame_header", !21, i64 0, !19, i64 8, !19, i64 12, !20, i64 16, !8, i64 18, !8, i64 19, !8, i64 20}
!25 = !{!"_ZTS9drflac_bs", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !21, i64 32, !19, i64 40, !19, i64 44, !8, i64 48, !21, i64 4144, !20, i64 4152, !21, i64 4160, !19, i64 4168}
!26 = !{!17, !7, i64 288}


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