; 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_encoder = type { %struct.ma_encoder_config, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %union.anon.64 }
%struct.ma_encoder_config = type { i32, i32, i32, i32, %struct.ma_allocation_callbacks }
%struct.ma_allocation_callbacks = type { ptr, ptr, ptr, ptr }
%union.anon.64 = type { %struct.anon.65 }
%struct.anon.65 = type { ptr, ptr }

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.155 = external hidden unnamed_addr constant [19 x i8], align 1
@__PRETTY_FUNCTION__._Z25ma_encoder_init__internalPF9ma_resultP10ma_encoderPKvmPmEPFS_S1_x14ma_seek_originEPvS1_ = external hidden unnamed_addr constant [103 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
define dso_local noundef i32 @_Z25ma_encoder_init__internalPF9ma_resultP10ma_encoderPKvmPmEPFS_S1_x14ma_seek_originEPvS1_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %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 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) #3
  store i32 0, ptr %10, align 4, !tbaa !9
  %12 = load ptr, ptr %9, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %4
  br label %17

15:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.155, ptr noundef @.str.6, i32 noundef 62829, ptr noundef @__PRETTY_FUNCTION__._Z25ma_encoder_init__internalPF9ma_resultP10ma_encoderPKvmPmEPFS_S1_x14ma_seek_originEPvS1_) #4
  unreachable

16:                                               ; No predecessors!
  br label %17

17:                                               ; preds = %16, %14
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = icmp eq ptr %18, null
  br i1 %19, label %23, label %20

20:                                               ; preds = %17
  %21 = load ptr, ptr %7, align 8, !tbaa !5
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %20, %17
  store i32 -2, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %57

24:                                               ; preds = %20
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ma_encoder, ptr %26, i32 0, i32 1
  store ptr %25, ptr %27, align 8, !tbaa !11
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ma_encoder, ptr %29, i32 0, i32 2
  store ptr %28, ptr %30, align 8, !tbaa !18
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %9, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.ma_encoder, ptr %32, i32 0, i32 6
  store ptr %31, ptr %33, align 8, !tbaa !19
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ma_encoder, ptr %34, i32 0, i32 0
  %36 = getelementptr inbounds %struct.ma_encoder_config, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !20
  switch i32 %37, label %45 [
    i32 1, label %38
  ]

38:                                               ; preds = %24
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ma_encoder, ptr %39, i32 0, i32 3
  store ptr @_ZL23ma_encoder__on_init_wavP10ma_encoder, ptr %40, align 8, !tbaa !21
  %41 = load ptr, ptr %9, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ma_encoder, ptr %41, i32 0, i32 4
  store ptr @_ZL25ma_encoder__on_uninit_wavP10ma_encoder, ptr %42, align 8, !tbaa !22
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.ma_encoder, ptr %43, i32 0, i32 5
  store ptr @_ZL35ma_encoder__on_write_pcm_frames_wavP10ma_encoderPKvyPy, ptr %44, align 8, !tbaa !23
  br label %46

45:                                               ; preds = %24
  store i32 -2, ptr %10, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %45, %38
  %47 = load i32, ptr %10, align 4, !tbaa !9
  %48 = icmp eq i32 %47, 0
  br i1 %48, label %49, label %55

49:                                               ; preds = %46
  %50 = load ptr, ptr %9, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ma_encoder, ptr %50, i32 0, i32 3
  %52 = load ptr, ptr %51, align 8, !tbaa !21
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = call noundef i32 %52(ptr noundef %53)
  store i32 %54, ptr %10, align 4, !tbaa !9
  br label %55

55:                                               ; preds = %49, %46
  %56 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %56, ptr %5, align 4
  store i32 1, ptr %11, align 4
  br label %57

57:                                               ; preds = %55, %23
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  %58 = load i32, ptr %5, align 4
  ret i32 %58
}

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

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

; Function Attrs: mustprogress uwtable
declare hidden noundef i32 @_ZL35ma_encoder__on_write_pcm_frames_wavP10ma_encoderPKvyPy(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #2

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 = { nounwind }
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, !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 = !{!12, !6, i64 48}
!12 = !{!"_ZTS10ma_encoder", !13, i64 0, !6, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !7, i64 104}
!13 = !{!"_ZTS17ma_encoder_config", !14, i64 0, !15, i64 4, !16, i64 8, !16, i64 12, !17, i64 16}
!14 = !{!"_ZTS18ma_encoding_format", !7, i64 0}
!15 = !{!"_ZTS9ma_format", !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 = !{!12, !6, i64 56}
!19 = !{!12, !6, i64 88}
!20 = !{!12, !14, i64 0}
!21 = !{!12, !6, i64 64}
!22 = !{!12, !6, i64 72}
!23 = !{!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"

@.str.6 = external hidden unnamed_addr constant [104 x i8], align 1
@.str.155 = external hidden unnamed_addr constant [19 x i8], align 1
@__PRETTY_FUNCTION__._Z25ma_encoder_init__internalPF9ma_resultP10ma_encoderPKvmPmEPFS_S1_x14ma_seek_originEPvS1_ = external hidden unnamed_addr constant [103 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
define dso_local noundef i32 @_Z25ma_encoder_init__internalPF9ma_resultP10ma_encoderPKvmPmEPFS_S1_x14ma_seek_originEPvS1_(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.155, ptr noundef nonnull @.str.6, i32 noundef 62829, ptr noundef nonnull @__PRETTY_FUNCTION__._Z25ma_encoder_init__internalPF9ma_resultP10ma_encoderPKvmPmEPFS_S1_x14ma_seek_originEPvS1_) #2
  unreachable

6:                                                ; preds = %4
  %7 = icmp eq ptr %0, null
  %8 = icmp eq ptr %1, null
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %19, label %9

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %3, i64 48
  store ptr %0, ptr %10, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %3, i64 56
  store ptr %1, ptr %11, align 8, !tbaa !15
  %12 = getelementptr inbounds i8, ptr %3, i64 88
  store ptr %2, ptr %12, align 8, !tbaa !16
  %13 = load i32, ptr %3, align 8, !tbaa !17
  %cond = icmp eq i32 %13, 1
  br i1 %cond, label %14, label %19

14:                                               ; preds = %9
  %15 = getelementptr inbounds i8, ptr %3, i64 64
  store ptr @_ZL23ma_encoder__on_init_wavP10ma_encoder, ptr %15, align 8, !tbaa !18
  %16 = getelementptr inbounds i8, ptr %3, i64 72
  store ptr @_ZL25ma_encoder__on_uninit_wavP10ma_encoder, ptr %16, align 8, !tbaa !19
  %17 = getelementptr inbounds i8, ptr %3, i64 80
  store ptr @_ZL35ma_encoder__on_write_pcm_frames_wavP10ma_encoderPKvyPy, ptr %17, align 8, !tbaa !20
  %18 = tail call noundef i32 @_ZL23ma_encoder__on_init_wavP10ma_encoder(ptr noundef nonnull %3)
  br label %19

19:                                               ; preds = %9, %14, %6
  %.018 = phi i32 [ -2, %6 ], [ %18, %14 ], [ -2, %9 ]
  ret i32 %.018
}

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

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

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

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 = { 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, !14, i64 48}
!6 = !{!"_ZTS10ma_encoder", !7, i64 0, !14, i64 48, !14, i64 56, !14, i64 64, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !9, i64 104}
!7 = !{!"_ZTS17ma_encoder_config", !8, i64 0, !11, i64 4, !12, i64 8, !12, i64 12, !13, i64 16}
!8 = !{!"_ZTS18ma_encoding_format", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS9ma_format", !9, i64 0}
!12 = !{!"int", !9, i64 0}
!13 = !{!"_ZTS23ma_allocation_callbacks", !14, i64 0, !14, i64 8, !14, i64 16, !14, i64 24}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!6, !14, i64 56}
!16 = !{!6, !14, i64 88}
!17 = !{!6, !8, i64 0}
!18 = !{!6, !14, i64 64}
!19 = !{!6, !14, i64 72}
!20 = !{!6, !14, i64 80}


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