; 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_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 nounwind uwtable
declare dso_local i32 @ma_node_get_output_bus_count(ptr noundef) #1

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

13:                                               ; preds = %2
  store i32 -2, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %65

14:                                               ; preds = %2
  %15 = load i32, ptr %5, align 4, !tbaa !9
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = call i32 @ma_node_get_output_bus_count(ptr noundef %16)
  %18 = icmp uge i32 %15, %17
  br i1 %18, label %19, label %20

19:                                               ; preds = %14
  store i32 -2, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %65

20:                                               ; preds = %14
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ma_node_base, ptr %21, i32 0, i32 13
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = zext i32 %24 to i64
  %26 = getelementptr inbounds %struct.ma_node_output_bus, ptr %23, i64 %25
  call void @_ZL23ma_node_output_bus_lockP18ma_node_output_bus(ptr noundef %26)
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.ma_node_base, ptr %27, i32 0, i32 13
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = zext i32 %30 to i64
  %32 = getelementptr inbounds %struct.ma_node_output_bus, ptr %29, i64 %31
  %33 = getelementptr inbounds %struct.ma_node_output_bus, ptr %32, i32 0, i32 11
  %34 = load ptr, ptr %33, align 8, !tbaa !18
  store ptr %34, ptr %8, align 8, !tbaa !5
  %35 = load ptr, ptr %8, align 8, !tbaa !5
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %57

37:                                               ; preds = %20
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ma_node_base, ptr %38, i32 0, i32 12
  %40 = load ptr, ptr %39, align 8, !tbaa !21
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ma_node_base, ptr %41, i32 0, i32 13
  %43 = load ptr, ptr %42, align 8, !tbaa !13
  %44 = load i32, ptr %5, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds %struct.ma_node_output_bus, ptr %43, i64 %45
  %47 = getelementptr inbounds %struct.ma_node_output_bus, ptr %46, i32 0, i32 3
  %48 = load i8, ptr %47, align 2, !tbaa !22
  %49 = zext i8 %48 to i64
  %50 = getelementptr inbounds %struct.ma_node_input_bus, ptr %40, i64 %49
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ma_node_base, ptr %51, i32 0, i32 13
  %53 = load ptr, ptr %52, align 8, !tbaa !13
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = zext i32 %54 to i64
  %56 = getelementptr inbounds %struct.ma_node_output_bus, ptr %53, i64 %55
  call void @_ZL44ma_node_input_bus_detach__no_output_bus_lockP17ma_node_input_busP18ma_node_output_bus(ptr noundef %50, ptr noundef %56)
  br label %57

57:                                               ; preds = %37, %20
  %58 = load ptr, ptr %7, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ma_node_base, ptr %58, i32 0, i32 13
  %60 = load ptr, ptr %59, align 8, !tbaa !13
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = zext i32 %61 to i64
  %63 = getelementptr inbounds %struct.ma_node_output_bus, ptr %60, i64 %62
  call void @_ZL25ma_node_output_bus_unlockP18ma_node_output_bus(ptr noundef %63)
  %64 = load i32, ptr %6, align 4, !tbaa !11
  store i32 %64, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %65

65:                                               ; preds = %57, %19, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  %66 = load i32, ptr %3, align 4
  ret i32 %66
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL23ma_node_output_bus_lockP18ma_node_output_bus(ptr noundef) #2

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL25ma_node_output_bus_unlockP18ma_node_output_bus(ptr noundef) #1

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 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_ZTS9ma_result", !7, i64 0}
!13 = !{!14, !6, i64 80}
!14 = !{!"_ZTS12ma_node_base", !6, i64 0, !6, i64 8, !6, i64 16, !15, i64 24, !15, i64 26, !15, i64 28, !15, i64 30, !16, i64 32, !7, i64 40, !17, i64 56, !10, i64 64, !10, i64 68, !6, i64 72, !6, i64 80, !7, i64 88, !7, i64 232, !6, i64 344, !10, i64 352}
!15 = !{!"short", !7, i64 0}
!16 = !{!"_ZTS13ma_node_state", !7, i64 0}
!17 = !{!"long long", !7, i64 0}
!18 = !{!19, !6, i64 48}
!19 = !{!"_ZTS18ma_node_output_bus", !6, i64 0, !7, i64 8, !7, i64 9, !7, i64 10, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !20, i64 28, !6, i64 32, !6, i64 40, !6, i64 48}
!20 = !{!"float", !7, i64 0}
!21 = !{!14, !6, i64 72}
!22 = !{!19, !7, i64 10}


; 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_output_bus = type { ptr, i8, i8, i8, i32, i32, i32, i32, float, ptr, ptr, ptr }
%struct.ma_node_input_bus = type { %struct.ma_node_output_bus, i32, i32, i8 }

; Function Attrs: mustprogress nounwind uwtable
declare dso_local i32 @ma_node_get_output_bus_count(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local range(i32 -2, 1) i32 @ma_node_detach_output_bus(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %0, null
  br i1 %3, label %25, label %4

4:                                                ; preds = %2
  %5 = tail call i32 @ma_node_get_output_bus_count(ptr noundef nonnull %0)
  %.not = icmp ugt i32 %5, %1
  br i1 %.not, label %6, label %25

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 80
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = zext i32 %1 to i64
  %10 = getelementptr inbounds %struct.ma_node_output_bus, ptr %8, i64 %9
  tail call void @_ZL23ma_node_output_bus_lockP18ma_node_output_bus(ptr noundef %10)
  %11 = load ptr, ptr %7, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.ma_node_output_bus, ptr %11, i64 %9
  %13 = getelementptr inbounds i8, ptr %12, i64 48
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %.not20 = icmp eq ptr %14, null
  br i1 %.not20, label %22, label %15

15:                                               ; preds = %6
  %16 = getelementptr inbounds i8, ptr %14, i64 72
  %17 = load ptr, ptr %16, align 8, !tbaa !17
  %18 = getelementptr inbounds i8, ptr %12, i64 10
  %19 = load i8, ptr %18, align 2, !tbaa !18
  %20 = zext i8 %19 to i64
  %21 = getelementptr inbounds %struct.ma_node_input_bus, ptr %17, i64 %20
  tail call void @_ZL44ma_node_input_bus_detach__no_output_bus_lockP17ma_node_input_busP18ma_node_output_bus(ptr noundef %21, ptr noundef nonnull %12)
  %.pre = load ptr, ptr %7, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %15, %6
  %23 = phi ptr [ %.pre, %15 ], [ %11, %6 ]
  %24 = getelementptr inbounds %struct.ma_node_output_bus, ptr %23, i64 %9
  tail call void @_ZL25ma_node_output_bus_unlockP18ma_node_output_bus(ptr noundef %24)
  br label %25

25:                                               ; preds = %4, %2, %22
  %.0 = phi i32 [ 0, %22 ], [ -2, %2 ], [ -2, %4 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL23ma_node_output_bus_lockP18ma_node_output_bus(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL44ma_node_input_bus_detach__no_output_bus_lockP17ma_node_input_busP18ma_node_output_bus(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden void @_ZL25ma_node_output_bus_unlockP18ma_node_output_bus(ptr noundef) local_unnamed_addr #0

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


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