; 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_delay_config = type { i32, i32, i32, i32, float, float, float }
%struct.ma_delay = type { %struct.ma_delay_config, i32, i32, ptr }

; Function Attrs: mustprogress uwtable
declare dso_local ptr @ma_malloc(i64 noundef, ptr noundef) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL22ma_get_bytes_per_frame9ma_formatj(i32 noundef, i32 noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @ma_silence_pcm_frames(ptr noundef, i64 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local i32 @ma_delay_init(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %3
  store i32 -2, ptr %4, align 4
  br label %67

11:                                               ; preds = %3
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %12, i8 0, i64 48, i1 false)
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = icmp eq ptr %13, null
  br i1 %14, label %15, label %16

15:                                               ; preds = %11
  store i32 -2, ptr %4, align 4
  br label %67

16:                                               ; preds = %11
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ma_delay_config, ptr %17, i32 0, i32 6
  %19 = load float, ptr %18, align 4, !tbaa !9
  %20 = fcmp olt float %19, 0.000000e+00
  br i1 %20, label %26, label %21

21:                                               ; preds = %16
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.ma_delay_config, ptr %22, i32 0, i32 6
  %24 = load float, ptr %23, align 4, !tbaa !9
  %25 = fcmp ogt float %24, 1.000000e+00
  br i1 %25, label %26, label %27

26:                                               ; preds = %21, %16
  store i32 -2, ptr %4, align 4
  br label %67

27:                                               ; preds = %21
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  %29 = load ptr, ptr %7, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.ma_delay, ptr %29, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %30, ptr align 4 %28, i64 28, i1 false), !tbaa.struct !13
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ma_delay_config, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !16
  %34 = load ptr, ptr %7, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.ma_delay, ptr %34, i32 0, i32 2
  store i32 %33, ptr %35, align 8, !tbaa !17
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ma_delay, ptr %36, i32 0, i32 1
  store i32 0, ptr %37, align 4, !tbaa !19
  %38 = load ptr, ptr %7, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.ma_delay, ptr %38, i32 0, i32 2
  %40 = load i32, ptr %39, align 8, !tbaa !17
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.ma_delay_config, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 4, !tbaa !20
  %44 = call noundef i32 @_ZL22ma_get_bytes_per_frame9ma_formatj(i32 noundef 5, i32 noundef %43)
  %45 = mul i32 %40, %44
  %46 = zext i32 %45 to i64
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = call ptr @ma_malloc(i64 noundef %46, ptr noundef %47)
  %49 = load ptr, ptr %7, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.ma_delay, ptr %49, i32 0, i32 3
  store ptr %48, ptr %50, align 8, !tbaa !21
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.ma_delay, ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !21
  %54 = icmp eq ptr %53, null
  br i1 %54, label %55, label %56

55:                                               ; preds = %27
  store i32 -4, ptr %4, align 4
  br label %67

56:                                               ; preds = %27
  %57 = load ptr, ptr %7, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.ma_delay, ptr %57, i32 0, i32 3
  %59 = load ptr, ptr %58, align 8, !tbaa !21
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ma_delay, ptr %60, i32 0, i32 2
  %62 = load i32, ptr %61, align 8, !tbaa !17
  %63 = zext i32 %62 to i64
  %64 = load ptr, ptr %5, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.ma_delay_config, ptr %64, i32 0, i32 0
  %66 = load i32, ptr %65, align 4, !tbaa !20
  call void @ma_silence_pcm_frames(ptr noundef %59, i64 noundef %63, i32 noundef 5, i32 noundef %66)
  store i32 0, ptr %4, align 4
  br label %67

67:                                               ; preds = %56, %55, %26, %15, %10
  %68 = load i32, ptr %4, align 4
  ret i32 %68
}

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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" }

!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, !12, i64 24}
!10 = !{!"_ZTS15ma_delay_config", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !12, i64 20, !12, i64 24}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{i64 0, i64 4, !14, i64 4, i64 4, !14, i64 8, i64 4, !14, i64 12, i64 4, !14, i64 16, i64 4, !15, i64 20, i64 4, !15, i64 24, i64 4, !15}
!14 = !{!11, !11, i64 0}
!15 = !{!12, !12, i64 0}
!16 = !{!10, !11, i64 8}
!17 = !{!18, !11, i64 32}
!18 = !{!"_ZTS8ma_delay", !10, i64 0, !11, i64 28, !11, i64 32, !6, i64 40}
!19 = !{!18, !11, i64 28}
!20 = !{!10, !11, i64 0}
!21 = !{!18, !6, i64 40}


; 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 ptr @ma_malloc(i64 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

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

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

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

5:                                                ; preds = %3
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(48) %2, i8 0, i64 48, i1 false)
  %6 = icmp eq ptr %0, null
  br i1 %6, label %28, label %7

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load float, ptr %8, align 4, !tbaa !5
  %10 = fcmp olt float %9, 0.000000e+00
  %11 = fcmp ogt float %9, 1.000000e+00
  %or.cond = or i1 %10, %11
  br i1 %or.cond, label %28, label %12

12:                                               ; preds = %7
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(28) %2, ptr noundef nonnull align 4 dereferenceable(28) %0, i64 28, i1 false), !tbaa.struct !11
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load i32, ptr %13, align 4, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %2, i64 32
  store i32 %14, ptr %15, align 8, !tbaa !15
  %16 = getelementptr inbounds i8, ptr %2, i64 28
  store i32 0, ptr %16, align 4, !tbaa !18
  %17 = load i32, ptr %0, align 4, !tbaa !19
  %18 = tail call noundef i32 @_ZL22ma_get_bytes_per_frame9ma_formatj(i32 noundef 5, i32 noundef %17)
  %19 = mul i32 %18, %14
  %20 = zext i32 %19 to i64
  %21 = tail call ptr @ma_malloc(i64 noundef %20, ptr noundef %1)
  %22 = getelementptr inbounds i8, ptr %2, i64 40
  store ptr %21, ptr %22, align 8, !tbaa !20
  %23 = icmp eq ptr %21, null
  br i1 %23, label %28, label %24

24:                                               ; preds = %12
  %25 = load i32, ptr %15, align 8, !tbaa !15
  %26 = zext i32 %25 to i64
  %27 = load i32, ptr %0, align 4, !tbaa !19
  tail call void @ma_silence_pcm_frames(ptr noundef nonnull %21, i64 noundef %26, i32 noundef 5, i32 noundef %27)
  br label %28

28:                                               ; preds = %12, %7, %5, %3, %24
  %.0 = phi i32 [ 0, %24 ], [ -2, %3 ], [ -2, %5 ], [ -2, %7 ], [ -4, %12 ]
  ret i32 %.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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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" }

!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, !10, i64 24}
!6 = !{!"_ZTS15ma_delay_config", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !10, i64 20, !10, i64 24}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{i64 0, i64 4, !12, i64 4, i64 4, !12, i64 8, i64 4, !12, i64 12, i64 4, !12, i64 16, i64 4, !13, i64 20, i64 4, !13, i64 24, i64 4, !13}
!12 = !{!7, !7, i64 0}
!13 = !{!10, !10, i64 0}
!14 = !{!6, !7, i64 8}
!15 = !{!16, !7, i64 32}
!16 = !{!"_ZTS8ma_delay", !6, i64 0, !7, i64 28, !7, i64 32, !17, i64 40}
!17 = !{!"any pointer", !8, i64 0}
!18 = !{!16, !7, i64 28}
!19 = !{!6, !7, i64 0}
!20 = !{!16, !17, i64 40}


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