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

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

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

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

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

17:                                               ; preds = %4
  %18 = load ptr, ptr %11, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %17, %4
  store i32 -2, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %61

21:                                               ; preds = %17
  %22 = load ptr, ptr %10, align 8, !tbaa !5
  %23 = load ptr, ptr %11, align 8, !tbaa !5
  %24 = icmp eq ptr %22, %23
  br i1 %24, label %25, label %26

25:                                               ; preds = %21
  store i32 -3, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %61

26:                                               ; preds = %21
  %27 = load i32, ptr %7, align 4, !tbaa !9
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call i32 @ma_node_get_output_bus_count(ptr noundef %28)
  %30 = icmp uge i32 %27, %29
  br i1 %30, label %36, label %31

31:                                               ; preds = %26
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = call i32 @ma_node_get_input_bus_count(ptr noundef %33)
  %35 = icmp uge i32 %32, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %31, %26
  store i32 -3, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %61

37:                                               ; preds = %31
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = load i32, ptr %7, align 4, !tbaa !9
  %40 = call i32 @ma_node_get_output_channels(ptr noundef %38, i32 noundef %39)
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = call i32 @ma_node_get_input_channels(ptr noundef %41, i32 noundef %42)
  %44 = icmp ne i32 %40, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %37
  store i32 -3, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %61

46:                                               ; preds = %37
  %47 = load ptr, ptr %11, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ma_node_base, ptr %47, i32 0, i32 12
  %49 = load ptr, ptr %48, align 8, !tbaa !11
  %50 = load i32, ptr %9, align 4, !tbaa !9
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds %struct.ma_node_input_bus, ptr %49, i64 %51
  %53 = load ptr, ptr %10, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ma_node_base, ptr %53, i32 0, i32 13
  %55 = load ptr, ptr %54, align 8, !tbaa !16
  %56 = load i32, ptr %7, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds %struct.ma_node_output_bus, ptr %55, i64 %57
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = load i32, ptr %9, align 4, !tbaa !9
  call void @_ZL24ma_node_input_bus_attachP17ma_node_input_busP18ma_node_output_busPvj(ptr noundef %52, ptr noundef %58, ptr noundef %59, i32 noundef %60)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %61

61:                                               ; preds = %46, %45, %36, %25, %20
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %62 = load i32, ptr %5, align 4
  ret i32 %62
}

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

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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 72}
!12 = !{!"_ZTS12ma_node_base", !6, i64 0, !6, i64 8, !6, i64 16, !13, i64 24, !13, i64 26, !13, i64 28, !13, i64 30, !14, i64 32, !7, i64 40, !15, 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}
!13 = !{!"short", !7, i64 0}
!14 = !{!"_ZTS13ma_node_state", !7, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = !{!12, !6, i64 80}


; 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_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: mustprogress uwtable
declare dso_local i32 @ma_node_get_output_channels(ptr noundef, i32 noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local range(i32 -3, 1) i32 @ma_node_attach_output_bus(ptr noundef %0, i32 noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = icmp eq ptr %0, null
  %6 = icmp eq ptr %2, null
  %or.cond = or i1 %5, %6
  br i1 %or.cond, label %25, label %7

7:                                                ; preds = %4
  %8 = icmp eq ptr %0, %2
  br i1 %8, label %25, label %9

9:                                                ; preds = %7
  %10 = tail call i32 @ma_node_get_output_bus_count(ptr noundef nonnull %0)
  %.not = icmp ugt i32 %10, %1
  br i1 %.not, label %11, label %25

11:                                               ; preds = %9
  %12 = tail call i32 @ma_node_get_input_bus_count(ptr noundef nonnull %2)
  %.not25 = icmp ugt i32 %12, %3
  br i1 %.not25, label %13, label %25

13:                                               ; preds = %11
  %14 = tail call i32 @ma_node_get_output_channels(ptr noundef nonnull %0, i32 noundef %1)
  %15 = tail call i32 @ma_node_get_input_channels(ptr noundef nonnull %2, i32 noundef %3)
  %.not26 = icmp eq i32 %14, %15
  br i1 %.not26, label %16, label %25

16:                                               ; preds = %13
  %17 = getelementptr inbounds i8, ptr %2, i64 72
  %18 = load ptr, ptr %17, align 8, !tbaa !5
  %19 = zext i32 %3 to i64
  %20 = getelementptr inbounds %struct.ma_node_input_bus, ptr %18, i64 %19
  %21 = getelementptr inbounds i8, ptr %0, i64 80
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  %23 = zext i32 %1 to i64
  %24 = getelementptr inbounds %struct.ma_node_output_bus, ptr %22, i64 %23
  tail call void @_ZL24ma_node_input_bus_attachP17ma_node_input_busP18ma_node_output_busPvj(ptr noundef %20, ptr noundef %24, ptr noundef nonnull %2, i32 noundef %3)
  br label %25

25:                                               ; preds = %13, %9, %11, %7, %4, %16
  %.0 = phi i32 [ 0, %16 ], [ -2, %4 ], [ -3, %7 ], [ -3, %11 ], [ -3, %9 ], [ -3, %13 ]
  ret i32 %.0
}

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL24ma_node_input_bus_attachP17ma_node_input_busP18ma_node_output_busPvj(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

attributes #0 = { 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 #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" }

!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 72}
!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 = !{!6, !7, i64 80}


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