; 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_delay_node_config = type { %struct.ma_node_config, %struct.ma_delay_config }
%struct.ma_delay_config = type { i32, i32, i32, i32, float, float, float }
%struct.ma_delay_node = type { %struct.ma_node_base, %struct.ma_delay }
%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 }
%struct.ma_delay = type { %struct.ma_delay_config, i32, i32, ptr }

@_ZL22g_ma_delay_node_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
declare dso_local i32 @ma_delay_init(ptr noundef, ptr noundef, ptr noundef) #3

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

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

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_delay_node_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #3 {
  %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 %struct.ma_node_config, align 8
  %12 = 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) #4
  call void @llvm.lifetime.start.p0(i64 40, ptr %11) #4
  %13 = load ptr, ptr %9, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %4
  store i32 -2, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %54

16:                                               ; preds = %4
  %17 = load ptr, ptr %9, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %17, i8 0, i64 408, i1 false)
  %18 = load ptr, ptr %7, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ma_delay_node_config, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = load ptr, ptr %9, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ma_delay_node, ptr %21, i32 0, i32 1
  %23 = call i32 @ma_delay_init(ptr noundef %19, ptr noundef %20, ptr noundef %22)
  store i32 %23, ptr %10, align 4, !tbaa !9
  %24 = load i32, ptr %10, align 4, !tbaa !9
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %28

26:                                               ; preds = %16
  %27 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %27, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %54

28:                                               ; preds = %16
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ma_delay_node_config, ptr %29, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %11, ptr align 8 %30, i64 40, i1 false), !tbaa.struct !11
  %31 = getelementptr inbounds %struct.ma_node_config, ptr %11, i32 0, i32 0
  store ptr @_ZL22g_ma_delay_node_vtable, ptr %31, align 8, !tbaa !16
  %32 = load ptr, ptr %7, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ma_delay_node_config, ptr %32, i32 0, i32 1
  %34 = getelementptr inbounds %struct.ma_delay_config, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct.ma_node_config, ptr %11, i32 0, i32 4
  store ptr %34, ptr %35, align 8, !tbaa !18
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ma_delay_node_config, ptr %36, i32 0, i32 1
  %38 = getelementptr inbounds %struct.ma_delay_config, ptr %37, i32 0, i32 0
  %39 = getelementptr inbounds %struct.ma_node_config, ptr %11, i32 0, i32 5
  store ptr %38, ptr %39, align 8, !tbaa !19
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr %9, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ma_delay_node, ptr %42, i32 0, i32 0
  %44 = call i32 @ma_node_init(ptr noundef %40, ptr noundef %11, ptr noundef %41, ptr noundef %43)
  store i32 %44, ptr %10, align 4, !tbaa !9
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %52

47:                                               ; preds = %28
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.ma_delay_node, ptr %48, i32 0, i32 1
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  call void @ma_delay_uninit(ptr noundef %49, ptr noundef %50)
  %51 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %51, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %54

52:                                               ; preds = %28
  %53 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %53, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %54

54:                                               ; preds = %52, %47, %26, %15
  call void @llvm.lifetime.end.p0(i64 40, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %55 = load i32, ptr %5, align 4
  ret i32 %55
}

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 = { 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 = !{i64 0, i64 8, !5, i64 8, i64 4, !12, i64 12, i64 4, !14, i64 16, i64 4, !14, i64 24, i64 8, !5, i64 32, i64 8, !5}
!12 = !{!13, !13, i64 0}
!13 = !{!"_ZTS13ma_node_state", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !6, i64 0}
!17 = !{!"_ZTS14ma_node_config", !6, i64 0, !13, i64 8, !15, i64 12, !15, i64 16, !6, i64 24, !6, i64 32}
!18 = !{!17, !6, i64 24}
!19 = !{!17, !6, i64 32}


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

@_ZL22g_ma_delay_node_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 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
declare dso_local i32 @ma_delay_init(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_delay_uninit(ptr noundef, ptr noundef) 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 #3

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_delay_node_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #3 {
  %5 = alloca %struct.ma_node_config, align 8
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #4
  %6 = icmp eq ptr %3, null
  br i1 %6, label %16, label %7

7:                                                ; preds = %4
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(408) %3, i8 0, i64 408, i1 false)
  %8 = getelementptr inbounds i8, ptr %1, i64 40
  %9 = getelementptr inbounds i8, ptr %3, i64 360
  %10 = tail call i32 @ma_delay_init(ptr noundef nonnull %8, ptr noundef %2, ptr noundef nonnull %9)
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %11, label %16

11:                                               ; preds = %7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(40) %5, ptr noundef nonnull align 8 dereferenceable(40) %1, i64 24, i1 false), !tbaa.struct !5
  store ptr @_ZL22g_ma_delay_node_vtable, ptr %5, align 8, !tbaa !14
  %12 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr %8, ptr %12, align 8, !tbaa !16
  %13 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %8, ptr %13, align 8, !tbaa !17
  %14 = call i32 @ma_node_init(ptr noundef %0, ptr noundef nonnull %5, ptr noundef %2, ptr noundef nonnull %3)
  %.not21 = icmp eq i32 %14, 0
  br i1 %.not21, label %16, label %15

15:                                               ; preds = %11
  call void @ma_delay_uninit(ptr noundef nonnull %9, ptr noundef %2)
  br label %16

16:                                               ; preds = %11, %7, %4, %15
  %.0 = phi i32 [ %14, %15 ], [ -2, %4 ], [ %10, %7 ], [ 0, %11 ]
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #4
  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 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 = { 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 = !{i64 0, i64 8, !6, i64 8, i64 4, !10, i64 12, i64 4, !12, i64 16, i64 4, !12, i64 24, i64 8, !6, i64 32, i64 8, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!11, !11, i64 0}
!11 = !{!"_ZTS13ma_node_state", !8, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !8, i64 0}
!14 = !{!15, !7, i64 0}
!15 = !{!"_ZTS14ma_node_config", !7, i64 0, !11, i64 8, !13, i64 12, !13, i64 16, !7, i64 24, !7, i64 32}
!16 = !{!15, !7, i64 24}
!17 = !{!15, !7, i64 32}


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