; 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_vtable = type { ptr, ptr, i8, i8, i32 }
%struct.ma_node_config = type { ptr, i32, i32, i32, ptr, ptr }
%struct.ma_node_graph_config = type { i32, i16 }
%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 }

@_ZL24g_node_graph_node_vtable = external hidden global %struct.ma_node_vtable, align 8
@_ZL28g_node_graph_endpoint_vtable = external hidden global %struct.ma_node_vtable, align 8

; 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: 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) #2

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

16:                                               ; preds = %3
  store i32 -2, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %67

17:                                               ; preds = %3
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %18, i8 0, i64 728, i1 false)
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ma_node_graph_config, ptr %19, i32 0, i32 1
  %21 = load i16, ptr %20, align 4, !tbaa !9
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ma_node_graph, ptr %22, i32 0, i32 2
  store i16 %21, ptr %23, align 8, !tbaa !13
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ma_node_graph, ptr %24, i32 0, i32 2
  %26 = load i16, ptr %25, align 8, !tbaa !13
  %27 = zext i16 %26 to i32
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %32

29:                                               ; preds = %17
  %30 = load ptr, ptr %7, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ma_node_graph, ptr %30, i32 0, i32 2
  store i16 480, ptr %31, align 8, !tbaa !13
  br label %32

32:                                               ; preds = %29, %17
  call void @llvm.lifetime.start.p0(i64 40, ptr %12) #5
  call void @ma_node_config_init(ptr dead_on_unwind writable sret(%struct.ma_node_config) align 8 %12)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 %12, i64 40, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 40, ptr %12) #5
  %33 = getelementptr inbounds %struct.ma_node_config, ptr %9, i32 0, i32 0
  store ptr @_ZL24g_node_graph_node_vtable, ptr %33, align 8, !tbaa !21
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ma_node_graph_config, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.ma_node_config, ptr %9, i32 0, i32 5
  store ptr %35, ptr %36, align 8, !tbaa !23
  %37 = load ptr, ptr %7, align 8, !tbaa !5
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load ptr, ptr %7, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ma_node_graph, ptr %39, i32 0, i32 0
  %41 = call i32 @ma_node_init(ptr noundef %37, ptr noundef %9, ptr noundef %38, ptr noundef %40)
  store i32 %41, ptr %8, align 4, !tbaa !24
  %42 = load i32, ptr %8, align 4, !tbaa !24
  %43 = icmp ne i32 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %32
  %45 = load i32, ptr %8, align 4, !tbaa !24
  store i32 %45, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %67

46:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 40, ptr %13) #5
  call void @ma_node_config_init(ptr dead_on_unwind writable sret(%struct.ma_node_config) align 8 %13)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %10, ptr align 8 %13, i64 40, i1 false), !tbaa.struct !18
  call void @llvm.lifetime.end.p0(i64 40, ptr %13) #5
  %47 = getelementptr inbounds %struct.ma_node_config, ptr %10, i32 0, i32 0
  store ptr @_ZL28g_node_graph_endpoint_vtable, ptr %47, align 8, !tbaa !21
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ma_node_graph_config, ptr %48, i32 0, i32 0
  %50 = getelementptr inbounds %struct.ma_node_config, ptr %10, i32 0, i32 4
  store ptr %49, ptr %50, align 8, !tbaa !26
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ma_node_graph_config, ptr %51, i32 0, i32 0
  %53 = getelementptr inbounds %struct.ma_node_config, ptr %10, i32 0, i32 5
  store ptr %52, ptr %53, align 8, !tbaa !23
  %54 = load ptr, ptr %7, align 8, !tbaa !5
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ma_node_graph, ptr %56, i32 0, i32 1
  %58 = call i32 @ma_node_init(ptr noundef %54, ptr noundef %10, ptr noundef %55, ptr noundef %57)
  store i32 %58, ptr %8, align 4, !tbaa !24
  %59 = load i32, ptr %8, align 4, !tbaa !24
  %60 = icmp ne i32 %59, 0
  br i1 %60, label %61, label %66

61:                                               ; preds = %46
  %62 = load ptr, ptr %7, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ma_node_graph, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  call void @ma_node_uninit(ptr noundef %63, ptr noundef %64)
  %65 = load i32, ptr %8, align 4, !tbaa !24
  store i32 %65, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %67

66:                                               ; preds = %46
  store i32 0, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %67

67:                                               ; preds = %66, %61, %44, %16
  call void @llvm.lifetime.end.p0(i64 40, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  %68 = load i32, ptr %4, align 4
  ret i32 %68
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ma_node_config_init(ptr dead_on_unwind noalias writable sret(%struct.ma_node_config) align 8) #4

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

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_node_uninit(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 #5 = { 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, !12, i64 4}
!10 = !{!"_ZTS20ma_node_graph_config", !11, i64 0, !12, i64 4}
!11 = !{!"int", !7, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = !{!14, !12, i64 720}
!14 = !{!"_ZTS13ma_node_graph", !15, i64 0, !15, i64 360, !12, i64 720, !11, i64 724}
!15 = !{!"_ZTS12ma_node_base", !6, i64 0, !6, i64 8, !6, i64 16, !12, i64 24, !12, i64 26, !12, i64 28, !12, i64 30, !16, i64 32, !7, i64 40, !17, i64 56, !11, i64 64, !11, i64 68, !6, i64 72, !6, i64 80, !7, i64 88, !7, i64 232, !6, i64 344, !11, i64 352}
!16 = !{!"_ZTS13ma_node_state", !7, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = !{i64 0, i64 8, !5, i64 8, i64 4, !19, i64 12, i64 4, !20, i64 16, i64 4, !20, i64 24, i64 8, !5, i64 32, i64 8, !5}
!19 = !{!16, !16, i64 0}
!20 = !{!11, !11, i64 0}
!21 = !{!22, !6, i64 0}
!22 = !{!"_ZTS14ma_node_config", !6, i64 0, !16, i64 8, !11, i64 12, !11, i64 16, !6, i64 24, !6, i64 32}
!23 = !{!22, !6, i64 32}
!24 = !{!25, !25, i64 0}
!25 = !{!"_ZTS9ma_result", !7, i64 0}
!26 = !{!22, !6, i64 24}


; 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.ma_node_vtable = type { ptr, ptr, i8, i8, i32 }
%struct.ma_node_config = type { ptr, i32, i32, i32, ptr, ptr }

@_ZL24g_node_graph_node_vtable = external hidden global %struct.ma_node_vtable, align 8
@_ZL28g_node_graph_endpoint_vtable = external hidden global %struct.ma_node_vtable, align 8

; 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 i32 @ma_node_graph_init(ptr noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca %struct.ma_node_config, align 8
  %5 = alloca %struct.ma_node_config, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #4
  %6 = icmp eq ptr %2, null
  br i1 %6, label %20, label %7

7:                                                ; preds = %3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(728) %2, i8 0, i64 728, i1 false)
  %8 = getelementptr inbounds i8, ptr %0, i64 4
  %9 = load i16, ptr %8, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %2, i64 720
  %11 = icmp eq i16 %9, 0
  %spec.select = select i1 %11, i16 480, i16 %9
  store i16 %spec.select, ptr %10, align 8, !tbaa !11
  call void @ma_node_config_init(ptr dead_on_unwind nonnull writable sret(%struct.ma_node_config) align 8 %4)
  store ptr @_ZL24g_node_graph_node_vtable, ptr %4, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %4, i64 32
  store ptr %0, ptr %12, align 8, !tbaa !19
  %13 = call i32 @ma_node_init(ptr noundef nonnull %2, ptr noundef nonnull %4, ptr noundef %1, ptr noundef nonnull %2)
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %14, label %20

14:                                               ; preds = %7
  call void @ma_node_config_init(ptr dead_on_unwind nonnull writable sret(%struct.ma_node_config) align 8 %5)
  store ptr @_ZL28g_node_graph_endpoint_vtable, ptr %5, align 8, !tbaa !17
  %15 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr %0, ptr %15, align 8, !tbaa !20
  %16 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %0, ptr %16, align 8, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %2, i64 360
  %18 = call i32 @ma_node_init(ptr noundef nonnull %2, ptr noundef nonnull %5, ptr noundef %1, ptr noundef nonnull %17)
  %.not24 = icmp eq i32 %18, 0
  br i1 %.not24, label %20, label %19

19:                                               ; preds = %14
  call void @ma_node_uninit(ptr noundef nonnull %2, ptr noundef %1)
  br label %20

20:                                               ; preds = %14, %7, %3, %19
  %.0 = phi i32 [ %18, %19 ], [ -2, %3 ], [ %13, %7 ], [ 0, %14 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #4
  ret i32 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @ma_node_config_init(ptr dead_on_unwind noalias writable sret(%struct.ma_node_config) align 8) local_unnamed_addr #3

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

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

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 = { 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, !10, i64 4}
!6 = !{!"_ZTS20ma_node_graph_config", !7, i64 0, !10, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = !{!12, !10, i64 720}
!12 = !{!"_ZTS13ma_node_graph", !13, i64 0, !13, i64 360, !10, i64 720, !7, i64 724}
!13 = !{!"_ZTS12ma_node_base", !14, i64 0, !14, i64 8, !14, i64 16, !10, i64 24, !10, i64 26, !10, i64 28, !10, i64 30, !15, i64 32, !8, i64 40, !16, i64 56, !7, i64 64, !7, i64 68, !14, i64 72, !14, i64 80, !8, i64 88, !8, i64 232, !14, i64 344, !7, i64 352}
!14 = !{!"any pointer", !8, i64 0}
!15 = !{!"_ZTS13ma_node_state", !8, i64 0}
!16 = !{!"long long", !8, i64 0}
!17 = !{!18, !14, i64 0}
!18 = !{!"_ZTS14ma_node_config", !14, i64 0, !15, i64 8, !7, i64 12, !7, i64 16, !14, i64 24, !14, i64 32}
!19 = !{!18, !14, i64 32}
!20 = !{!18, !14, i64 24}


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