; 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 @_Z22ma_stbvorbis_init_filePKcPK26ma_decoding_backend_configPK23ma_allocation_callbacksP12ma_stbvorbis(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  %13 = load ptr, ptr %9, align 8, !tbaa !5
  %14 = call noundef i32 @_ZL26ma_stbvorbis_init_internalPK26ma_decoding_backend_configP12ma_stbvorbis(ptr noundef %12, ptr noundef %13)
  store i32 %14, ptr %10, align 4, !tbaa !9
  %15 = load i32, ptr %10, align 4, !tbaa !9
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %19

17:                                               ; preds = %4
  %18 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %18, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %42

19:                                               ; preds = %4
  %20 = load ptr, ptr %6, align 8, !tbaa !5
  %21 = call ptr @stb_vorbis_open_filename(ptr noundef %20, ptr noundef null, ptr noundef null)
  %22 = load ptr, ptr %9, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ma_stbvorbis, ptr %22, i32 0, i32 10
  store ptr %21, ptr %23, align 8, !tbaa !11
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ma_stbvorbis, ptr %24, i32 0, i32 10
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = icmp eq ptr %26, null
  br i1 %27, label %28, label %29

28:                                               ; preds = %19
  store i32 -10, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %42

29:                                               ; preds = %19
  %30 = load ptr, ptr %9, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ma_stbvorbis, ptr %30, i32 0, i32 11
  store i32 0, ptr %31, align 8, !tbaa !20
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = call noundef i32 @_ZL22ma_stbvorbis_post_initP12ma_stbvorbis(ptr noundef %32)
  store i32 %33, ptr %10, align 4, !tbaa !9
  %34 = load i32, ptr %10, align 4, !tbaa !9
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %41

36:                                               ; preds = %29
  %37 = load ptr, ptr %9, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ma_stbvorbis, ptr %37, i32 0, i32 10
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  call void @stb_vorbis_close(ptr noundef %39)
  %40 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %40, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %42

41:                                               ; preds = %29
  store i32 0, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %42

42:                                               ; preds = %41, %36, %28, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %43 = load i32, ptr %5, align 4
  ret i32 %43
}

; Function Attrs: mustprogress uwtable
declare dso_local ptr @stb_vorbis_open_filename(ptr 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 = !{!"_ZTS9ma_result", !7, i64 0}
!11 = !{!12, !6, i64 160}
!12 = !{!"_ZTS12ma_stbvorbis", !13, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !16, i64 104, !17, i64 136, !15, i64 140, !15, i64 144, !14, i64 152, !6, i64 160, !15, i64 168, !18, i64 176}
!13 = !{!"_ZTS19ma_data_source_base", !6, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !15, i64 64}
!14 = !{!"long long", !7, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!"_ZTS23ma_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!17 = !{!"_ZTS9ma_format", !7, i64 0}
!18 = !{!"_ZTSN12ma_stbvorbisUt_E", !6, i64 0, !19, i64 8, !19, i64 16, !15, i64 24, !15, i64 28, !6, i64 32}
!19 = !{!"long", !7, i64 0}
!20 = !{!12, !15, 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 @_Z22ma_stbvorbis_init_filePKcPK26ma_decoding_backend_configPK23ma_allocation_callbacksP12ma_stbvorbis(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readnone %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = tail call noundef i32 @_ZL26ma_stbvorbis_init_internalPK26ma_decoding_backend_configP12ma_stbvorbis(ptr noundef %1, ptr noundef %3)
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %6, label %15

6:                                                ; preds = %4
  %7 = tail call ptr @stb_vorbis_open_filename(ptr noundef %0, ptr noundef null, ptr noundef null)
  %8 = getelementptr inbounds i8, ptr %3, i64 160
  store ptr %7, ptr %8, align 8, !tbaa !5
  %9 = icmp eq ptr %7, null
  br i1 %9, label %15, label %10

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %3, i64 168
  store i32 0, ptr %11, align 8, !tbaa !17
  %12 = tail call noundef i32 @_ZL22ma_stbvorbis_post_initP12ma_stbvorbis(ptr noundef nonnull %3)
  %.not14 = icmp eq i32 %12, 0
  br i1 %.not14, label %15, label %13

13:                                               ; preds = %10
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  tail call void @stb_vorbis_close(ptr noundef %14)
  br label %15

15:                                               ; preds = %10, %6, %4, %13
  %.0 = phi i32 [ %12, %13 ], [ %5, %4 ], [ -10, %6 ], [ 0, %10 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare dso_local ptr @stb_vorbis_open_filename(ptr 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,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass