; 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_stbvorbis = type { %struct.ma_data_source_base, ptr, ptr, ptr, ptr, %struct.ma_allocation_callbacks, i32, i32, i32, i64, ptr, i32, %struct.anon.60 }
%struct.ma_data_source_base = type { ptr, i64, i64, i64, i64, ptr, ptr, ptr, i32 }
%struct.ma_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%struct.anon.60 = type { ptr, i64, i64, i32, i32, 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: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL26ma_stbvorbis_init_internalPK26ma_decoding_backend_configP12ma_stbvorbis(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL22ma_stbvorbis_post_initP12ma_stbvorbis(ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @stb_vorbis_close(ptr noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z24ma_stbvorbis_init_memoryPKvmPK26ma_decoding_backend_configPK23ma_allocation_callbacksP12ma_stbvorbis(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4) #2 {
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store ptr %0, ptr %7, align 8, !tbaa !5
  store i64 %1, ptr %8, align 8, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !5
  store ptr %3, ptr %10, align 8, !tbaa !5
  store ptr %4, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #3
  %14 = load ptr, ptr %9, align 8, !tbaa !5
  %15 = load ptr, ptr %11, align 8, !tbaa !5
  %16 = call noundef i32 @_ZL26ma_stbvorbis_init_internalPK26ma_decoding_backend_configP12ma_stbvorbis(ptr noundef %14, ptr noundef %15)
  store i32 %16, ptr %12, align 4, !tbaa !11
  %17 = load i32, ptr %12, align 4, !tbaa !11
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %19, label %21

19:                                               ; preds = %5
  %20 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %20, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %50

21:                                               ; preds = %5
  %22 = load i64, ptr %8, align 8, !tbaa !9
  %23 = icmp ugt i64 %22, 2147483647
  br i1 %23, label %24, label %25

24:                                               ; preds = %21
  store i32 -11, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %50

25:                                               ; preds = %21
  %26 = load ptr, ptr %7, align 8, !tbaa !5
  %27 = load i64, ptr %8, align 8, !tbaa !9
  %28 = trunc i64 %27 to i32
  %29 = call ptr @stb_vorbis_open_memory(ptr noundef %26, i32 noundef %28, ptr noundef null, ptr noundef null)
  %30 = load ptr, ptr %11, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ma_stbvorbis, ptr %30, i32 0, i32 10
  store ptr %29, ptr %31, align 8, !tbaa !13
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ma_stbvorbis, ptr %32, i32 0, i32 10
  %34 = load ptr, ptr %33, align 8, !tbaa !13
  %35 = icmp eq ptr %34, null
  br i1 %35, label %36, label %37

36:                                               ; preds = %25
  store i32 -10, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %50

37:                                               ; preds = %25
  %38 = load ptr, ptr %11, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ma_stbvorbis, ptr %38, i32 0, i32 11
  store i32 0, ptr %39, align 8, !tbaa !21
  %40 = load ptr, ptr %11, align 8, !tbaa !5
  %41 = call noundef i32 @_ZL22ma_stbvorbis_post_initP12ma_stbvorbis(ptr noundef %40)
  store i32 %41, ptr %12, align 4, !tbaa !11
  %42 = load i32, ptr %12, align 4, !tbaa !11
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %49

44:                                               ; preds = %37
  %45 = load ptr, ptr %11, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.ma_stbvorbis, ptr %45, i32 0, i32 10
  %47 = load ptr, ptr %46, align 8, !tbaa !13
  call void @stb_vorbis_close(ptr noundef %47)
  %48 = load i32, ptr %12, align 4, !tbaa !11
  store i32 %48, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %50

49:                                               ; preds = %37
  store i32 0, ptr %6, align 4
  store i32 1, ptr %13, align 4
  br label %50

50:                                               ; preds = %49, %44, %36, %24, %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  %51 = load i32, ptr %6, align 4
  ret i32 %51
}

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

attributes #0 = { 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 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS9ma_result", !7, i64 0}
!13 = !{!14, !6, i64 160}
!14 = !{!"_ZTS12ma_stbvorbis", !15, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !18, i64 104, !19, i64 136, !17, i64 140, !17, i64 144, !16, i64 152, !6, i64 160, !17, i64 168, !20, i64 176}
!15 = !{!"_ZTS19ma_data_source_base", !6, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !16, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !17, i64 64}
!16 = !{!"long long", !7, i64 0}
!17 = !{!"int", !7, i64 0}
!18 = !{!"_ZTS23ma_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!19 = !{!"_ZTS9ma_format", !7, i64 0}
!20 = !{!"_ZTSN12ma_stbvorbisUt_E", !6, i64 0, !10, i64 8, !10, i64 16, !17, i64 24, !17, i64 28, !6, i64 32}
!21 = !{!14, !17, i64 168}


; 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"

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL26ma_stbvorbis_init_internalPK26ma_decoding_backend_configP12ma_stbvorbis(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL22ma_stbvorbis_post_initP12ma_stbvorbis(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z24ma_stbvorbis_init_memoryPKvmPK26ma_decoding_backend_configPK23ma_allocation_callbacksP12ma_stbvorbis(ptr noundef %0, i64 noundef %1, ptr noundef %2, ptr nocapture noundef readnone %3, ptr noundef %4) local_unnamed_addr #1 {
  %6 = tail call noundef i32 @_ZL26ma_stbvorbis_init_internalPK26ma_decoding_backend_configP12ma_stbvorbis(ptr noundef %2, ptr noundef %4)
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %7, label %19

7:                                                ; preds = %5
  %8 = icmp ugt i64 %1, 2147483647
  br i1 %8, label %19, label %9

9:                                                ; preds = %7
  %10 = trunc nuw nsw i64 %1 to i32
  %11 = tail call ptr @stb_vorbis_open_memory(ptr noundef %0, i32 noundef %10, ptr noundef null, ptr noundef null)
  %12 = getelementptr inbounds i8, ptr %4, i64 160
  store ptr %11, ptr %12, align 8, !tbaa !5
  %13 = icmp eq ptr %11, null
  br i1 %13, label %19, label %14

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %4, i64 168
  store i32 0, ptr %15, align 8, !tbaa !17
  %16 = tail call noundef i32 @_ZL22ma_stbvorbis_post_initP12ma_stbvorbis(ptr noundef nonnull %4)
  %.not17 = icmp eq i32 %16, 0
  br i1 %.not17, label %19, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %12, align 8, !tbaa !5
  tail call void @stb_vorbis_close(ptr noundef %18)
  br label %19

19:                                               ; preds = %14, %9, %7, %5, %17
  %.0 = phi i32 [ %16, %17 ], [ %6, %5 ], [ -11, %7 ], [ -10, %9 ], [ 0, %14 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local ptr @stb_vorbis_open_memory(ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { 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" }

!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, !8, i64 160}
!6 = !{!"_ZTS12ma_stbvorbis", !7, i64 0, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !13, i64 104, !14, i64 136, !12, i64 140, !12, i64 144, !11, i64 152, !8, i64 160, !12, i64 168, !15, i64 176}
!7 = !{!"_ZTS19ma_data_source_base", !8, i64 0, !11, i64 8, !11, i64 16, !11, i64 24, !11, i64 32, !8, i64 40, !8, i64 48, !8, i64 56, !12, i64 64}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long long", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!"_ZTS23ma_allocation_callbacks", !8, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!14 = !{!"_ZTS9ma_format", !9, i64 0}
!15 = !{!"_ZTSN12ma_stbvorbisUt_E", !8, i64 0, !16, i64 8, !16, i64 16, !12, i64 24, !12, i64 28, !8, i64 32}
!16 = !{!"long", !9, i64 0}
!17 = !{!6, !12, i64 168}


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