; 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_engine = type { %struct.ma_node_graph, ptr, ptr, ptr, i32, i32, [4 x %struct.ma_spatializer_listener], %struct.ma_allocation_callbacks, i8, i8, i32, ptr, i32, i32, i32 }
%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 }
%struct.ma_spatializer_listener = type { %struct.ma_spatializer_listener_config, %struct.ma_vec3f, %struct.ma_vec3f, %struct.ma_vec3f, i32, i32, ptr }
%struct.ma_spatializer_listener_config = type { i32, ptr, i32, float, float, float, float, %struct.ma_vec3f }
%struct.ma_vec3f = type { float, float, float }
%struct.ma_allocation_callbacks = type { ptr, 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_device_start(ptr noundef) #1

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

8:                                                ; preds = %1
  store i32 -2, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %26

9:                                                ; preds = %1
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.ma_engine, ptr %10, i32 0, i32 2
  %12 = load ptr, ptr %11, align 8, !tbaa !9
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %19

14:                                               ; preds = %9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ma_engine, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = call i32 @ma_device_start(ptr noundef %17)
  store i32 %18, ptr %4, align 4, !tbaa !19
  br label %20

19:                                               ; preds = %9
  store i32 -3, ptr %4, align 4, !tbaa !19
  br label %20

20:                                               ; preds = %19, %14
  %21 = load i32, ptr %4, align 4, !tbaa !19
  %22 = icmp ne i32 %21, 0
  br i1 %22, label %23, label %25

23:                                               ; preds = %20
  %24 = load i32, ptr %4, align 4, !tbaa !19
  store i32 %24, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %26

25:                                               ; preds = %20
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %26

26:                                               ; preds = %25, %23, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %27 = load i32, ptr %2, align 4
  ret i32 %27
}

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 = { 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, !6, i64 736}
!10 = !{!"_ZTS9ma_engine", !11, i64 0, !6, i64 728, !6, i64 736, !6, i64 744, !16, i64 752, !16, i64 756, !7, i64 760, !17, i64 1176, !7, i64 1208, !7, i64 1209, !16, i64 1212, !6, i64 1216, !16, i64 1224, !16, i64 1228, !18, i64 1232}
!11 = !{!"_ZTS13ma_node_graph", !12, i64 0, !12, i64 360, !13, i64 720, !16, i64 724}
!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, !16, i64 64, !16, i64 68, !6, i64 72, !6, i64 80, !7, i64 88, !7, i64 232, !6, i64 344, !16, i64 352}
!13 = !{!"short", !7, i64 0}
!14 = !{!"_ZTS13ma_node_state", !7, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!"_ZTS23ma_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!18 = !{!"_ZTS22ma_mono_expansion_mode", !7, i64 0}
!19 = !{!20, !20, i64 0}
!20 = !{!"_ZTS9ma_result", !7, i64 0}


; 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 uwtable
declare dso_local i32 @ma_device_start(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_engine_start(ptr noundef readonly %0) local_unnamed_addr #0 {
  %2 = icmp eq ptr %0, null
  br i1 %2, label %8, label %3

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 736
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %8, label %6

6:                                                ; preds = %3
  %7 = tail call i32 @ma_device_start(ptr noundef nonnull %5)
  br label %8

8:                                                ; preds = %6, %3, %1
  %.05 = phi i32 [ -2, %1 ], [ %7, %6 ], [ -3, %3 ]
  ret i32 %.05
}

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

!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, !9, i64 736}
!6 = !{!"_ZTS9ma_engine", !7, i64 0, !9, i64 728, !9, i64 736, !9, i64 744, !15, i64 752, !15, i64 756, !10, i64 760, !16, i64 1176, !10, i64 1208, !10, i64 1209, !15, i64 1212, !9, i64 1216, !15, i64 1224, !15, i64 1228, !17, i64 1232}
!7 = !{!"_ZTS13ma_node_graph", !8, i64 0, !8, i64 360, !12, i64 720, !15, i64 724}
!8 = !{!"_ZTS12ma_node_base", !9, i64 0, !9, i64 8, !9, i64 16, !12, i64 24, !12, i64 26, !12, i64 28, !12, i64 30, !13, i64 32, !10, i64 40, !14, i64 56, !15, i64 64, !15, i64 68, !9, i64 72, !9, i64 80, !10, i64 88, !10, i64 232, !9, i64 344, !15, i64 352}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C++ TBAA"}
!12 = !{!"short", !10, i64 0}
!13 = !{!"_ZTS13ma_node_state", !10, i64 0}
!14 = !{!"long long", !10, i64 0}
!15 = !{!"int", !10, i64 0}
!16 = !{!"_ZTS23ma_allocation_callbacks", !9, i64 0, !9, i64 8, !9, i64 16, !9, i64 24}
!17 = !{!"_ZTS22ma_mono_expansion_mode", !10, i64 0}


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