; 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_node_graph = type { %struct.ma_node_base, %struct.ma_node_base, i16, i32 }
%struct.ma_node_base = type { ptr, ptr, ptr, i16, i16, i16, i16, i32, [2 x i64], i64, i32, i32, ptr, ptr, [2 x %struct.ma_node_input_bus], [2 x %struct.ma_node_output_bus], ptr, i32 }
%struct.ma_node_input_bus = type { %struct.ma_node_output_bus, i32, i32, i8 }
%struct.ma_node_output_bus = type { ptr, i8, i8, i8, i32, i32, i32, i32, float, ptr, ptr, 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 uwtable
declare dso_local void @ma_silence_pcm_frames(ptr noundef, i64 noundef, i32 noundef, i32 noundef) #1

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

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

18:                                               ; preds = %4
  %19 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 0, ptr %19, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %18, %4
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %20
  store i32 -2, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %90

24:                                               ; preds = %20
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ma_node_graph, ptr %25, i32 0, i32 1
  %27 = call i32 @ma_node_get_output_channels(ptr noundef %26, i32 noundef 0)
  store i32 %27, ptr %12, align 4, !tbaa !13
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %68, %24
  %29 = load i64, ptr %11, align 8, !tbaa !9
  %30 = load i64, ptr %8, align 8, !tbaa !9
  %31 = icmp ult i64 %29, %30
  br i1 %31, label %32, label %69

32:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #3
  %33 = load i64, ptr %8, align 8, !tbaa !9
  %34 = load i64, ptr %11, align 8, !tbaa !9
  %35 = sub i64 %33, %34
  store i64 %35, ptr %15, align 8, !tbaa !9
  %36 = load i64, ptr %15, align 8, !tbaa !9
  %37 = icmp ugt i64 %36, 4294967295
  br i1 %37, label %38, label %39

38:                                               ; preds = %32
  store i64 4294967295, ptr %15, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %38, %32
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL28ma_node_graph_set_is_readingP13ma_node_graphj(ptr noundef %40, i32 noundef 1)
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ma_node_graph, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = load i64, ptr %11, align 8, !tbaa !9
  %45 = load i32, ptr %12, align 4, !tbaa !13
  %46 = call ptr @ma_offset_pcm_frames_ptr(ptr noundef %43, i64 noundef %44, i32 noundef 5, i32 noundef %45)
  %47 = load i64, ptr %15, align 8, !tbaa !9
  %48 = trunc i64 %47 to i32
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ma_node_graph, ptr %49, i32 0, i32 1
  %51 = call i64 @ma_node_get_time(ptr noundef %50)
  %52 = call noundef i32 @_ZL23ma_node_read_pcm_framesPvjPfjPjy(ptr noundef %42, i32 noundef 0, ptr noundef %46, i32 noundef %48, ptr noundef %14, i64 noundef %51)
  store i32 %52, ptr %10, align 4, !tbaa !11
  %53 = load ptr, ptr %6, align 8, !tbaa !5
  call void @_ZL28ma_node_graph_set_is_readingP13ma_node_graphj(ptr noundef %53, i32 noundef 0)
  %54 = load i32, ptr %14, align 4, !tbaa !13
  %55 = zext i32 %54 to i64
  %56 = load i64, ptr %11, align 8, !tbaa !9
  %57 = add i64 %56, %55
  store i64 %57, ptr %11, align 8, !tbaa !9
  %58 = load i32, ptr %10, align 4, !tbaa !11
  %59 = icmp ne i32 %58, 0
  br i1 %59, label %60, label %61

60:                                               ; preds = %39
  store i32 3, ptr %13, align 4
  br label %66

61:                                               ; preds = %39
  %62 = load i32, ptr %14, align 4, !tbaa !13
  %63 = icmp eq i32 %62, 0
  br i1 %63, label %64, label %65

64:                                               ; preds = %61
  store i32 3, ptr %13, align 4
  br label %66

65:                                               ; preds = %61
  store i32 0, ptr %13, align 4
  br label %66

66:                                               ; preds = %65, %64, %60
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %67 = load i32, ptr %13, align 4
  switch i32 %67, label %92 [
    i32 0, label %68
    i32 3, label %69
  ]

68:                                               ; preds = %66
  br label %28, !llvm.loop !15

69:                                               ; preds = %66, %28
  %70 = load i64, ptr %11, align 8, !tbaa !9
  %71 = load i64, ptr %8, align 8, !tbaa !9
  %72 = icmp ult i64 %70, %71
  br i1 %72, label %73, label %82

73:                                               ; preds = %69
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = load i64, ptr %11, align 8, !tbaa !9
  %76 = load i32, ptr %12, align 4, !tbaa !13
  %77 = call ptr @ma_offset_pcm_frames_ptr(ptr noundef %74, i64 noundef %75, i32 noundef 5, i32 noundef %76)
  %78 = load i64, ptr %8, align 8, !tbaa !9
  %79 = load i64, ptr %11, align 8, !tbaa !9
  %80 = sub i64 %78, %79
  %81 = load i32, ptr %12, align 4, !tbaa !13
  call void @ma_silence_pcm_frames(ptr noundef %77, i64 noundef %80, i32 noundef 5, i32 noundef %81)
  br label %82

82:                                               ; preds = %73, %69
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %88

85:                                               ; preds = %82
  %86 = load i64, ptr %11, align 8, !tbaa !9
  %87 = load ptr, ptr %9, align 8, !tbaa !5
  store i64 %86, ptr %87, align 8, !tbaa !9
  br label %88

88:                                               ; preds = %85, %82
  %89 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %89, ptr %5, align 4
  store i32 1, ptr %13, align 4
  br label %90

90:                                               ; preds = %88, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %91 = load i32, ptr %5, align 4
  ret i32 %91

92:                                               ; preds = %66
  unreachable
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL28ma_node_graph_set_is_readingP13ma_node_graphj(ptr noundef, i32 noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL23ma_node_read_pcm_framesPvjPfjPjy(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i64 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i64 @ma_node_get_time(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #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 long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS9ma_result", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


; 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 uwtable
declare dso_local void @ma_silence_pcm_frames(ptr noundef, i64 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @ma_node_graph_read_pcm_frames(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef writeonly %3) local_unnamed_addr #1 {
  %5 = alloca i32, align 4
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %7, label %6

6:                                                ; preds = %4
  store i64 0, ptr %3, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %6, %4
  %8 = icmp eq ptr %0, null
  br i1 %8, label %28, label %9

9:                                                ; preds = %7
  %10 = getelementptr inbounds i8, ptr %0, i64 360
  %11 = tail call i32 @ma_node_get_output_channels(ptr noundef nonnull %10, i32 noundef 0)
  %.not48 = icmp eq i64 %2, 0
  br i1 %.not48, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %9, %.lr.ph
  %.03443 = phi i64 [ %19, %.lr.ph ], [ 0, %9 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  %12 = sub i64 %2, %.03443
  %spec.store.select = call i64 @llvm.umin.i64(i64 %12, i64 4294967295)
  call void @_ZL28ma_node_graph_set_is_readingP13ma_node_graphj(ptr noundef nonnull %0, i32 noundef 1)
  %13 = call ptr @ma_offset_pcm_frames_ptr(ptr noundef %1, i64 noundef %.03443, i32 noundef 5, i32 noundef %11)
  %14 = trunc nuw i64 %spec.store.select to i32
  %15 = call i64 @ma_node_get_time(ptr noundef nonnull %10)
  %16 = call noundef i32 @_ZL23ma_node_read_pcm_framesPvjPfjPjy(ptr noundef nonnull %10, i32 noundef 0, ptr noundef %13, i32 noundef %14, ptr noundef nonnull %5, i64 noundef %15)
  call void @_ZL28ma_node_graph_set_is_readingP13ma_node_graphj(ptr noundef nonnull %0, i32 noundef 0)
  %17 = load i32, ptr %5, align 4, !tbaa !9
  %18 = zext i32 %17 to i64
  %19 = add i64 %.03443, %18
  %.not41 = icmp eq i32 %16, 0
  %20 = icmp ne i32 %17, 0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  %switch = select i1 %.not41, i1 %20, i1 false
  %21 = icmp ult i64 %19, %2
  %or.cond = select i1 %switch, i1 %21, i1 false
  br i1 %or.cond, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %9
  %.135 = phi i64 [ 0, %9 ], [ %19, %.lr.ph ]
  %.1 = phi i32 [ 0, %9 ], [ %16, %.lr.ph ]
  %22 = icmp ult i64 %.135, %2
  br i1 %22, label %23, label %26

23:                                               ; preds = %._crit_edge
  %24 = call ptr @ma_offset_pcm_frames_ptr(ptr noundef %1, i64 noundef %.135, i32 noundef 5, i32 noundef %11)
  %25 = sub i64 %2, %.135
  call void @ma_silence_pcm_frames(ptr noundef %24, i64 noundef %25, i32 noundef 5, i32 noundef %11)
  br label %26

26:                                               ; preds = %23, %._crit_edge
  br i1 %.not, label %28, label %27

27:                                               ; preds = %26
  store i64 %.135, ptr %3, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %26, %27, %7
  %.0 = phi i32 [ -2, %7 ], [ %.1, %27 ], [ %.1, %26 ]
  ret i32 %.0
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL28ma_node_graph_set_is_readingP13ma_node_graphj(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL23ma_node_read_pcm_framesPvjPfjPjy(ptr noundef, i32 noundef, ptr noundef, i32 noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i64 @ma_node_get_time(ptr noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.umin.i64(i64, i64) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #2 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass