; 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_device = type { ptr, i32, i32, i32, ptr, ptr, ptr, ptr, %union.pthread_mutex_t, %struct.ma_event, %struct.ma_event, %struct.ma_event, i64, i32, i8, i8, i8, i8, i8, float, %struct.ma_duplex_rb, %struct.anon.24, %struct.anon.26, %struct.anon.31, %union.anon.32 }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%struct.ma_event = type { i32, %union.pthread_mutex_t, %union.pthread_cond_t }
%union.pthread_cond_t = type { %struct.__pthread_cond_s }
%struct.__pthread_cond_s = type { %union.__atomic_wide_counter, %union.__atomic_wide_counter, [2 x i32], [2 x i32], i32, i32, [2 x i32] }
%union.__atomic_wide_counter = type { i64 }
%struct.ma_duplex_rb = type { %struct.ma_pcm_rb }
%struct.ma_pcm_rb = type { %struct.ma_rb, i32, i32 }
%struct.ma_rb = type { ptr, i32, i32, i32, i32, i32, i8, i8, %struct.ma_allocation_callbacks }
%struct.ma_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%struct.anon.24 = type { i32, ptr, ptr, %struct.anon.25 }
%struct.anon.25 = type { i32 }
%struct.anon.26 = type { ptr, %union.ma_device_id, [256 x i8], i32, i32, i32, [254 x i8], i32, i32, i32, [254 x i8], i32, i32, i32, %struct.ma_data_converter, ptr, i32, i32, ptr, i64, i64, i64 }
%union.ma_device_id = type { %union.anon.17 }
%union.anon.17 = type { ptr, [248 x i8] }
%struct.ma_data_converter = type { i32, i32, i32, i32, i32, i32, i32, i32, %struct.ma_channel_converter, %struct.ma_resampler, i8, i8, i8, i8, i8, i8, ptr }
%struct.ma_channel_converter = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, %union.anon.27, ptr, i32 }
%union.anon.27 = type { ptr }
%struct.ma_resampler = type { ptr, ptr, ptr, i32, i32, i32, i32, %union.anon.28, ptr, i32 }
%union.anon.28 = type { %struct.ma_linear_resampler }
%struct.ma_linear_resampler = type { %struct.ma_linear_resampler_config, i32, i32, i32, i32, %union.anon.29, %union.anon.30, %struct.ma_lpf, ptr, i32 }
%struct.ma_linear_resampler_config = type { i32, i32, i32, i32, i32, double }
%union.anon.29 = type { ptr }
%union.anon.30 = type { ptr }
%struct.ma_lpf = type { i32, i32, i32, i32, i32, ptr, ptr, ptr, i32 }
%struct.anon.31 = type { ptr, %union.ma_device_id, [256 x i8], i32, i32, i32, [254 x i8], i32, i32, i32, [254 x i8], i32, i32, i32, %struct.ma_data_converter, ptr, i32, i32 }
%union.anon.32 = type { %struct.anon.36 }
%struct.anon.36 = type { i64, %struct.ma_event, %struct.ma_event, %struct.ma_semaphore, i32, i32, %union.ma_timer, double, i32, i32, i64, i64, i32 }
%struct.ma_semaphore = type { i32, %union.pthread_mutex_t, %union.pthread_cond_t }
%union.ma_timer = type { i64 }
%struct.ma_context = type { %struct.ma_backend_callbacks, i32, ptr, %struct.ma_log, i32, i64, ptr, %struct.ma_allocation_callbacks, %union.pthread_mutex_t, %union.pthread_mutex_t, i32, i32, i32, ptr, %union.anon.41, %union.anon.46 }
%struct.ma_backend_callbacks = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }
%struct.ma_log = type { [4 x %struct.ma_log_callback], i32, %struct.ma_allocation_callbacks, %union.pthread_mutex_t }
%struct.ma_log_callback = type { ptr, ptr }
%union.anon.41 = type { %struct.anon.42 }
%struct.anon.42 = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %union.pthread_mutex_t, i32 }
%union.anon.46 = type { %struct.anon.47 }
%struct.anon.47 = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr }

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [56 x i8], align 1
@__PRETTY_FUNCTION__.ma_device_stop = external hidden unnamed_addr constant [38 x i8], align 1
@.str.64 = external hidden unnamed_addr constant [56 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL34ma_context_is_backend_asynchronousP10ma_context(ptr noundef) #3

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden void @_ZL20ma_device__set_stateP9ma_device15ma_device_state(ptr noundef, i32 noundef) #4

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_device_stop(ptr noundef %0) #2 {
  %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) #5
  %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 %87

9:                                                ; preds = %1
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = call i32 @ma_device_get_state(ptr noundef %10)
  %12 = icmp eq i32 %11, 0
  br i1 %12, label %13, label %14

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

14:                                               ; preds = %9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = call i32 @ma_device_get_state(ptr noundef %15)
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %18, label %19

18:                                               ; preds = %14
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %87

19:                                               ; preds = %14
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.ma_device, ptr %20, i32 0, i32 8
  call void @ma_mutex_lock(ptr noundef %21)
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = call i32 @ma_device_get_state(ptr noundef %22)
  %24 = icmp eq i32 %23, 2
  br i1 %24, label %25, label %26

25:                                               ; preds = %19
  br label %28

26:                                               ; preds = %19
  call void @__assert_fail(ptr noundef @.str.63, ptr noundef @.str.6, i32 noundef 40460, ptr noundef @__PRETTY_FUNCTION__.ma_device_stop) #6
  unreachable

27:                                               ; No predecessors!
  br label %28

28:                                               ; preds = %27, %25
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZL20ma_device__set_stateP9ma_device15ma_device_state(ptr noundef %29, i32 noundef 4)
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ma_device, ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = call noundef i32 @_ZL34ma_context_is_backend_asynchronousP10ma_context(ptr noundef %32)
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %55

35:                                               ; preds = %28
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ma_device, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.ma_context, ptr %38, i32 0, i32 0
  %40 = getelementptr inbounds %struct.ma_backend_callbacks, ptr %39, i32 0, i32 7
  %41 = load ptr, ptr %40, align 8, !tbaa !37
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %52

43:                                               ; preds = %35
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ma_device, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct.ma_context, ptr %46, i32 0, i32 0
  %48 = getelementptr inbounds %struct.ma_backend_callbacks, ptr %47, i32 0, i32 7
  %49 = load ptr, ptr %48, align 8, !tbaa !37
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = call noundef i32 %49(ptr noundef %50)
  store i32 %51, ptr %4, align 4, !tbaa !43
  br label %53

52:                                               ; preds = %35
  store i32 -3, ptr %4, align 4, !tbaa !43
  br label %53

53:                                               ; preds = %52, %43
  %54 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZL20ma_device__set_stateP9ma_device15ma_device_state(ptr noundef %54, i32 noundef 1)
  br label %83

55:                                               ; preds = %28
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = call i32 @ma_device_get_state(ptr noundef %56)
  %58 = icmp ne i32 %57, 2
  br i1 %58, label %59, label %60

59:                                               ; preds = %55
  br label %62

60:                                               ; preds = %55
  call void @__assert_fail(ptr noundef @.str.64, ptr noundef @.str.6, i32 noundef 40481, ptr noundef @__PRETTY_FUNCTION__.ma_device_stop) #6
  unreachable

61:                                               ; No predecessors!
  br label %62

62:                                               ; preds = %61, %59
  %63 = load ptr, ptr %3, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.ma_device, ptr %63, i32 0, i32 0
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.ma_context, ptr %65, i32 0, i32 0
  %67 = getelementptr inbounds %struct.ma_backend_callbacks, ptr %66, i32 0, i32 11
  %68 = load ptr, ptr %67, align 8, !tbaa !44
  %69 = icmp ne ptr %68, null
  br i1 %69, label %70, label %79

70:                                               ; preds = %62
  %71 = load ptr, ptr %3, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.ma_device, ptr %71, i32 0, i32 0
  %73 = load ptr, ptr %72, align 8, !tbaa !9
  %74 = getelementptr inbounds %struct.ma_context, ptr %73, i32 0, i32 0
  %75 = getelementptr inbounds %struct.ma_backend_callbacks, ptr %74, i32 0, i32 11
  %76 = load ptr, ptr %75, align 8, !tbaa !44
  %77 = load ptr, ptr %3, align 8, !tbaa !5
  %78 = call noundef i32 %76(ptr noundef %77)
  br label %79

79:                                               ; preds = %70, %62
  %80 = load ptr, ptr %3, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.ma_device, ptr %80, i32 0, i32 11
  %82 = call i32 @ma_event_wait(ptr noundef %81)
  store i32 0, ptr %4, align 4, !tbaa !43
  br label %83

83:                                               ; preds = %79, %53
  %84 = load ptr, ptr %3, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.ma_device, ptr %84, i32 0, i32 8
  call void @ma_mutex_unlock(ptr noundef %85)
  %86 = load i32, ptr %4, align 4, !tbaa !43
  store i32 %86, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %87

87:                                               ; preds = %83, %18, %13, %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  %88 = load i32, ptr %2, align 4
  ret i32 %88
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 = { 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 = { alwaysinline 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 }
attributes #6 = { noreturn 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 0}
!10 = !{!"_ZTS9ma_device", !6, i64 0, !11, i64 8, !12, i64 12, !13, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !7, i64 56, !14, i64 96, !14, i64 192, !14, i64 288, !15, i64 384, !16, i64 392, !7, i64 396, !7, i64 397, !7, i64 398, !7, i64 399, !7, i64 400, !17, i64 404, !18, i64 408, !23, i64 480, !26, i64 512, !36, i64 1944, !7, i64 3344}
!11 = !{!"_ZTS14ma_device_type", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"_ZTS15ma_device_state", !7, i64 0}
!14 = !{!"_ZTS8ma_event", !12, i64 0, !7, i64 8, !7, i64 48}
!15 = !{!"long", !7, i64 0}
!16 = !{!"_ZTS9ma_result", !7, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = !{!"_ZTS12ma_duplex_rb", !19, i64 0}
!19 = !{!"_ZTS9ma_pcm_rb", !20, i64 0, !22, i64 64, !12, i64 68}
!20 = !{!"_ZTS5ma_rb", !6, i64 0, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !7, i64 28, !7, i64 29, !21, i64 32}
!21 = !{!"_ZTS23ma_allocation_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!22 = !{!"_ZTS9ma_format", !7, i64 0}
!23 = !{!"_ZTSN9ma_deviceUt_E", !24, i64 0, !6, i64 8, !6, i64 16, !25, i64 24}
!24 = !{!"_ZTS21ma_resample_algorithm", !7, i64 0}
!25 = !{!"_ZTSN9ma_deviceUt_Ut_E", !12, i64 0}
!26 = !{!"_ZTSN9ma_deviceUt0_E", !6, i64 0, !7, i64 8, !7, i64 264, !27, i64 520, !22, i64 524, !12, i64 528, !7, i64 532, !22, i64 788, !12, i64 792, !12, i64 796, !7, i64 800, !12, i64 1056, !12, i64 1060, !28, i64 1064, !29, i64 1072, !6, i64 1384, !12, i64 1392, !12, i64 1396, !6, i64 1400, !35, i64 1408, !35, i64 1416, !35, i64 1424}
!27 = !{!"_ZTS13ma_share_mode", !7, i64 0}
!28 = !{!"_ZTS19ma_channel_mix_mode", !7, i64 0}
!29 = !{!"_ZTS17ma_data_converter", !22, i64 0, !22, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !30, i64 24, !31, i64 28, !32, i64 32, !34, i64 104, !7, i64 296, !7, i64 297, !7, i64 298, !7, i64 299, !7, i64 300, !7, i64 301, !6, i64 304}
!30 = !{!"_ZTS14ma_dither_mode", !7, i64 0}
!31 = !{!"_ZTS32ma_data_converter_execution_path", !7, i64 0}
!32 = !{!"_ZTS20ma_channel_converter", !22, i64 0, !12, i64 4, !12, i64 8, !28, i64 12, !33, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !7, i64 48, !6, i64 56, !12, i64 64}
!33 = !{!"_ZTS26ma_channel_conversion_path", !7, i64 0}
!34 = !{!"_ZTS12ma_resampler", !6, i64 0, !6, i64 8, !6, i64 16, !22, i64 24, !12, i64 28, !12, i64 32, !12, i64 36, !7, i64 40, !6, i64 176, !12, i64 184}
!35 = !{!"long long", !7, i64 0}
!36 = !{!"_ZTSN9ma_deviceUt1_E", !6, i64 0, !7, i64 8, !7, i64 264, !27, i64 520, !22, i64 524, !12, i64 528, !7, i64 532, !22, i64 788, !12, i64 792, !12, i64 796, !7, i64 800, !12, i64 1056, !12, i64 1060, !28, i64 1064, !29, i64 1072, !6, i64 1384, !12, i64 1392, !12, i64 1396}
!37 = !{!38, !6, i64 56}
!38 = !{!"_ZTS10ma_context", !39, i64 0, !40, i64 104, !6, i64 112, !41, i64 120, !42, i64 264, !15, i64 272, !6, i64 280, !21, i64 288, !7, i64 320, !7, i64 360, !12, i64 400, !12, i64 404, !12, i64 408, !6, i64 416, !7, i64 424, !7, i64 1008}
!39 = !{!"_ZTS20ma_backend_callbacks", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!40 = !{!"_ZTS10ma_backend", !7, i64 0}
!41 = !{!"_ZTS6ma_log", !7, i64 0, !12, i64 64, !21, i64 72, !7, i64 104}
!42 = !{!"_ZTS18ma_thread_priority", !7, i64 0}
!43 = !{!16, !16, i64 0}
!44 = !{!38, !6, i64 88}


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

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.63 = external hidden unnamed_addr constant [56 x i8], align 1
@__PRETTY_FUNCTION__.ma_device_stop = external hidden unnamed_addr constant [38 x i8], align 1
@.str.64 = external hidden unnamed_addr constant [56 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL34ma_context_is_backend_asynchronousP10ma_context(ptr noundef) local_unnamed_addr #2

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden void @_ZL20ma_device__set_stateP9ma_device15ma_device_state(ptr noundef, i32 noundef) local_unnamed_addr #3

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

3:                                                ; preds = %1
  %4 = tail call i32 @ma_device_get_state(ptr noundef nonnull %0)
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %37, label %6

6:                                                ; preds = %3
  %7 = tail call i32 @ma_device_get_state(ptr noundef nonnull %0)
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %37, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void @ma_mutex_lock(ptr noundef nonnull %10)
  %11 = tail call i32 @ma_device_get_state(ptr noundef nonnull %0)
  %12 = icmp eq i32 %11, 2
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  tail call void @__assert_fail(ptr noundef nonnull @.str.63, ptr noundef nonnull @.str.6, i32 noundef 40460, ptr noundef nonnull @__PRETTY_FUNCTION__.ma_device_stop) #4
  unreachable

14:                                               ; preds = %9
  tail call void @_ZL20ma_device__set_stateP9ma_device15ma_device_state(ptr noundef nonnull %0, i32 noundef 4)
  %15 = load ptr, ptr %0, align 8, !tbaa !5
  %16 = tail call noundef i32 @_ZL34ma_context_is_backend_asynchronousP10ma_context(ptr noundef %15)
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %24, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 56
  %20 = load ptr, ptr %19, align 8, !tbaa !36
  %.not24 = icmp eq ptr %20, null
  br i1 %.not24, label %23, label %21

21:                                               ; preds = %17
  %22 = tail call noundef i32 %20(ptr noundef nonnull %0)
  br label %23

23:                                               ; preds = %17, %21
  %.0 = phi i32 [ %22, %21 ], [ -3, %17 ]
  tail call void @_ZL20ma_device__set_stateP9ma_device15ma_device_state(ptr noundef nonnull %0, i32 noundef 1)
  br label %36

24:                                               ; preds = %14
  %25 = tail call i32 @ma_device_get_state(ptr noundef nonnull %0)
  %.not22 = icmp eq i32 %25, 2
  br i1 %.not22, label %26, label %27

26:                                               ; preds = %24
  tail call void @__assert_fail(ptr noundef nonnull @.str.64, ptr noundef nonnull @.str.6, i32 noundef 40481, ptr noundef nonnull @__PRETTY_FUNCTION__.ma_device_stop) #4
  unreachable

27:                                               ; preds = %24
  %28 = load ptr, ptr %0, align 8, !tbaa !5
  %29 = getelementptr inbounds i8, ptr %28, i64 88
  %30 = load ptr, ptr %29, align 8, !tbaa !42
  %.not23 = icmp eq ptr %30, null
  br i1 %.not23, label %33, label %31

31:                                               ; preds = %27
  %32 = tail call noundef i32 %30(ptr noundef nonnull %0)
  br label %33

33:                                               ; preds = %31, %27
  %34 = getelementptr inbounds i8, ptr %0, i64 288
  %35 = tail call i32 @ma_event_wait(ptr noundef nonnull %34)
  br label %36

36:                                               ; preds = %33, %23
  %.1 = phi i32 [ %.0, %23 ], [ 0, %33 ]
  tail call void @ma_mutex_unlock(ptr noundef nonnull %10)
  br label %37

37:                                               ; preds = %6, %3, %1, %36
  %.018 = phi i32 [ %.1, %36 ], [ -2, %1 ], [ -3, %3 ], [ 0, %6 ]
  ret i32 %.018
}

attributes #0 = { noreturn nounwind "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" }
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 = { alwaysinline 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 = { noreturn 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, !7, i64 0}
!6 = !{!"_ZTS9ma_device", !7, i64 0, !10, i64 8, !11, i64 12, !12, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !8, i64 56, !13, i64 96, !13, i64 192, !13, i64 288, !14, i64 384, !15, i64 392, !8, i64 396, !8, i64 397, !8, i64 398, !8, i64 399, !8, i64 400, !16, i64 404, !17, i64 408, !22, i64 480, !25, i64 512, !35, i64 1944, !8, i64 3344}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"_ZTS14ma_device_type", !8, i64 0}
!11 = !{!"int", !8, i64 0}
!12 = !{!"_ZTS15ma_device_state", !8, i64 0}
!13 = !{!"_ZTS8ma_event", !11, i64 0, !8, i64 8, !8, i64 48}
!14 = !{!"long", !8, i64 0}
!15 = !{!"_ZTS9ma_result", !8, i64 0}
!16 = !{!"float", !8, i64 0}
!17 = !{!"_ZTS12ma_duplex_rb", !18, i64 0}
!18 = !{!"_ZTS9ma_pcm_rb", !19, i64 0, !21, i64 64, !11, i64 68}
!19 = !{!"_ZTS5ma_rb", !7, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !8, i64 28, !8, i64 29, !20, i64 32}
!20 = !{!"_ZTS23ma_allocation_callbacks", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24}
!21 = !{!"_ZTS9ma_format", !8, i64 0}
!22 = !{!"_ZTSN9ma_deviceUt_E", !23, i64 0, !7, i64 8, !7, i64 16, !24, i64 24}
!23 = !{!"_ZTS21ma_resample_algorithm", !8, i64 0}
!24 = !{!"_ZTSN9ma_deviceUt_Ut_E", !11, i64 0}
!25 = !{!"_ZTSN9ma_deviceUt0_E", !7, i64 0, !8, i64 8, !8, i64 264, !26, i64 520, !21, i64 524, !11, i64 528, !8, i64 532, !21, i64 788, !11, i64 792, !11, i64 796, !8, i64 800, !11, i64 1056, !11, i64 1060, !27, i64 1064, !28, i64 1072, !7, i64 1384, !11, i64 1392, !11, i64 1396, !7, i64 1400, !34, i64 1408, !34, i64 1416, !34, i64 1424}
!26 = !{!"_ZTS13ma_share_mode", !8, i64 0}
!27 = !{!"_ZTS19ma_channel_mix_mode", !8, i64 0}
!28 = !{!"_ZTS17ma_data_converter", !21, i64 0, !21, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !29, i64 24, !30, i64 28, !31, i64 32, !33, i64 104, !8, i64 296, !8, i64 297, !8, i64 298, !8, i64 299, !8, i64 300, !8, i64 301, !7, i64 304}
!29 = !{!"_ZTS14ma_dither_mode", !8, i64 0}
!30 = !{!"_ZTS32ma_data_converter_execution_path", !8, i64 0}
!31 = !{!"_ZTS20ma_channel_converter", !21, i64 0, !11, i64 4, !11, i64 8, !27, i64 12, !32, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !8, i64 48, !7, i64 56, !11, i64 64}
!32 = !{!"_ZTS26ma_channel_conversion_path", !8, i64 0}
!33 = !{!"_ZTS12ma_resampler", !7, i64 0, !7, i64 8, !7, i64 16, !21, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !8, i64 40, !7, i64 176, !11, i64 184}
!34 = !{!"long long", !8, i64 0}
!35 = !{!"_ZTSN9ma_deviceUt1_E", !7, i64 0, !8, i64 8, !8, i64 264, !26, i64 520, !21, i64 524, !11, i64 528, !8, i64 532, !21, i64 788, !11, i64 792, !11, i64 796, !8, i64 800, !11, i64 1056, !11, i64 1060, !27, i64 1064, !28, i64 1072, !7, i64 1384, !11, i64 1392, !11, i64 1396}
!36 = !{!37, !7, i64 56}
!37 = !{!"_ZTS10ma_context", !38, i64 0, !39, i64 104, !7, i64 112, !40, i64 120, !41, i64 264, !14, i64 272, !7, i64 280, !20, i64 288, !8, i64 320, !8, i64 360, !11, i64 400, !11, i64 404, !11, i64 408, !7, i64 416, !8, i64 424, !8, i64 1008}
!38 = !{!"_ZTS20ma_backend_callbacks", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96}
!39 = !{!"_ZTS10ma_backend", !8, i64 0}
!40 = !{!"_ZTS6ma_log", !8, i64 0, !11, i64 64, !20, i64 72, !8, i64 104}
!41 = !{!"_ZTS18ma_thread_priority", !8, i64 0}
!42 = !{!37, !7, i64 88}


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