; 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_data_source_base = type { ptr, i64, i64, i64, i64, ptr, ptr, ptr, i32 }
%struct.ma_data_source_vtable = type { ptr, ptr, ptr, 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: mustprogress uwtable
define dso_local i32 @ma_data_source_get_data_format(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i64 noundef %5) #2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i64, align 8
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store i64 %5, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %20, ptr %14, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #3
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %25

23:                                               ; preds = %6
  %24 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 0, ptr %24, align 4, !tbaa !11
  br label %25

25:                                               ; preds = %23, %6
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %30

28:                                               ; preds = %25
  %29 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 0, ptr %29, align 4, !tbaa !13
  br label %30

30:                                               ; preds = %28, %25
  %31 = load ptr, ptr %11, align 8, !tbaa !5
  %32 = icmp ne ptr %31, null
  br i1 %32, label %33, label %35

33:                                               ; preds = %30
  %34 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 0, ptr %34, align 4, !tbaa !13
  br label %35

35:                                               ; preds = %33, %30
  %36 = load ptr, ptr %12, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %42

38:                                               ; preds = %35
  %39 = load ptr, ptr %12, align 8, !tbaa !5
  %40 = load i64, ptr %13, align 8, !tbaa !9
  %41 = mul i64 1, %40
  call void @llvm.memset.p0.i64(ptr align 1 %39, i8 0, i64 %41, i1 false)
  br label %42

42:                                               ; preds = %38, %35
  %43 = load ptr, ptr %14, align 8, !tbaa !5
  %44 = icmp eq ptr %43, null
  br i1 %44, label %45, label %46

45:                                               ; preds = %42
  store i32 -2, ptr %7, align 4
  store i32 1, ptr %19, align 4
  br label %87

46:                                               ; preds = %42
  %47 = load ptr, ptr %14, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ma_data_source_base, ptr %47, i32 0, i32 0
  %49 = load ptr, ptr %48, align 8, !tbaa !15
  %50 = getelementptr inbounds %struct.ma_data_source_vtable, ptr %49, i32 0, i32 2
  %51 = load ptr, ptr %50, align 8, !tbaa !18
  %52 = icmp eq ptr %51, null
  br i1 %52, label %53, label %54

53:                                               ; preds = %46
  store i32 -29, ptr %7, align 4
  store i32 1, ptr %19, align 4
  br label %87

54:                                               ; preds = %46
  %55 = load ptr, ptr %14, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.ma_data_source_base, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  %58 = getelementptr inbounds %struct.ma_data_source_vtable, ptr %57, i32 0, i32 2
  %59 = load ptr, ptr %58, align 8, !tbaa !18
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = load ptr, ptr %12, align 8, !tbaa !5
  %62 = load i64, ptr %13, align 8, !tbaa !9
  %63 = call noundef i32 %59(ptr noundef %60, ptr noundef %16, ptr noundef %17, ptr noundef %18, ptr noundef %61, i64 noundef %62)
  store i32 %63, ptr %15, align 4, !tbaa !20
  %64 = load i32, ptr %15, align 4, !tbaa !20
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %68

66:                                               ; preds = %54
  %67 = load i32, ptr %15, align 4, !tbaa !20
  store i32 %67, ptr %7, align 4
  store i32 1, ptr %19, align 4
  br label %87

68:                                               ; preds = %54
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = icmp ne ptr %69, null
  br i1 %70, label %71, label %74

71:                                               ; preds = %68
  %72 = load i32, ptr %16, align 4, !tbaa !11
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  store i32 %72, ptr %73, align 4, !tbaa !11
  br label %74

74:                                               ; preds = %71, %68
  %75 = load ptr, ptr %10, align 8, !tbaa !5
  %76 = icmp ne ptr %75, null
  br i1 %76, label %77, label %80

77:                                               ; preds = %74
  %78 = load i32, ptr %17, align 4, !tbaa !13
  %79 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %78, ptr %79, align 4, !tbaa !13
  br label %80

80:                                               ; preds = %77, %74
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  %82 = icmp ne ptr %81, null
  br i1 %82, label %83, label %86

83:                                               ; preds = %80
  %84 = load i32, ptr %18, align 4, !tbaa !13
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  store i32 %84, ptr %85, align 4, !tbaa !13
  br label %86

86:                                               ; preds = %83, %80
  store i32 0, ptr %7, align 4
  store i32 1, ptr %19, align 4
  br label %87

87:                                               ; preds = %86, %66, %53, %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  %88 = load i32, ptr %7, align 4
  ret i32 %88
}

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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS9ma_format", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTS19ma_data_source_base", !6, i64 0, !17, i64 8, !17, i64 16, !17, i64 24, !17, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !14, i64 64}
!17 = !{!"long long", !7, i64 0}
!18 = !{!19, !6, i64 16}
!19 = !{!"_ZTS21ma_data_source_vtable", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !14, i64 48}
!20 = !{!21, !21, i64 0}
!21 = !{!"_ZTS9ma_result", !7, i64 0}


; 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 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
define dso_local noundef i32 @ma_data_source_get_data_format(ptr noundef %0, ptr noundef writeonly %1, ptr noundef writeonly %2, ptr noundef writeonly %3, ptr noundef %4, i64 noundef %5) local_unnamed_addr #2 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #3
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %11, label %10

10:                                               ; preds = %6
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %10, %6
  %.not33 = icmp eq ptr %2, null
  br i1 %.not33, label %13, label %12

12:                                               ; preds = %11
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %12, %11
  %.not34 = icmp eq ptr %3, null
  br i1 %.not34, label %15, label %14

14:                                               ; preds = %13
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %15

15:                                               ; preds = %14, %13
  %.not35 = icmp eq ptr %4, null
  br i1 %.not35, label %17, label %16

16:                                               ; preds = %15
  tail call void @llvm.memset.p0.i64(ptr nonnull align 1 %4, i8 0, i64 %5, i1 false)
  br label %17

17:                                               ; preds = %16, %15
  %18 = icmp eq ptr %0, null
  br i1 %18, label %35, label %19

19:                                               ; preds = %17
  %20 = load ptr, ptr %0, align 8, !tbaa !11
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  %22 = load ptr, ptr %21, align 8, !tbaa !15
  %23 = icmp eq ptr %22, null
  br i1 %23, label %35, label %24

24:                                               ; preds = %19
  %25 = call noundef i32 %22(ptr noundef nonnull %0, ptr noundef nonnull %7, ptr noundef nonnull %8, ptr noundef nonnull %9, ptr noundef %4, i64 noundef %5)
  %.not36 = icmp eq i32 %25, 0
  br i1 %.not36, label %26, label %35

26:                                               ; preds = %24
  br i1 %.not, label %29, label %27

27:                                               ; preds = %26
  %28 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %28, ptr %1, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %27, %26
  br i1 %.not33, label %32, label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %31, ptr %2, align 4, !tbaa !9
  br label %32

32:                                               ; preds = %30, %29
  br i1 %.not34, label %35, label %33

33:                                               ; preds = %32
  %34 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %34, ptr %3, align 4, !tbaa !9
  br label %35

35:                                               ; preds = %32, %33, %24, %19, %17
  %.0 = phi i32 [ -2, %17 ], [ -29, %19 ], [ %25, %24 ], [ 0, %33 ], [ 0, %32 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #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, !6, i64 0}
!6 = !{!"_ZTS9ma_format", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 0}
!12 = !{!"_ZTS19ma_data_source_base", !13, i64 0, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !10, i64 64}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!"long long", !7, i64 0}
!15 = !{!16, !13, i64 16}
!16 = !{!"_ZTS21ma_data_source_vtable", !13, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !10, i64 48}


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