; LLVM IR from Ryuk17/SpeechAlgorithms :: WebRTC_AEC/src (aec_core)

; 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.AecCore = type { i32, i32, i32, i32, i32, i32, ptr, ptr, ptr, ptr, [128 x float], [128 x float], [128 x float], [65 x float], [65 x float], [65 x float], [65 x float], ptr, [2 x [2080 x float]], [2 x [2080 x float]], [65 x [2 x float]], [65 x [2 x float]], [2080 x [2 x float]], [65 x float], [65 x float], [65 x float], [65 x float], float, float, float, i32, i32, float, float, i32, [64 x float], i32, i16, i16, i16, i32, ptr, ptr, i32, i32, i32, i32, float, float, i32, %struct.PowerLevel, %struct.PowerLevel, %struct.PowerLevel, %struct.PowerLevel, i32, i32, %struct.Stats, %struct.Stats, %struct.Stats, %struct.Stats, i32, i32, float, [75 x i32], i32, ptr, ptr, i32, i32 }
%struct.PowerLevel = type { float, i32, float, float, i32, float, float }
%struct.Stats = type { float, float, float, float, float, float, float, i32, i32 }

; 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: nounwind uwtable
define dso_local void @WebRtcAec_BufferFarendPartition(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [128 x float], align 16
  %6 = alloca [2 x [65 x float]], align 16
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 512, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 520, ptr %6) #4
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.AecCore, ptr %7, i32 0, i32 41
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = call i64 @WebRtc_available_write(ptr noundef %9)
  %11 = icmp ult i64 %10, 1
  br i1 %11, label %12, label %15

12:                                               ; preds = %2
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call i32 @WebRtcAec_MoveFarReadPtr(ptr noundef %13, i32 noundef 1)
  br label %15

15:                                               ; preds = %12, %2
  %16 = getelementptr inbounds [128 x float], ptr %5, i64 0, i64 0
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %16, ptr align 4 %17, i64 512, i1 false)
  %18 = getelementptr inbounds [128 x float], ptr %5, i64 0, i64 0
  %19 = getelementptr inbounds [2 x [65 x float]], ptr %6, i64 0, i64 0
  call void @TimeToFrequency(ptr noundef %18, ptr noundef %19, i32 noundef 0)
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.AecCore, ptr %20, i32 0, i32 41
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = getelementptr inbounds [2 x [65 x float]], ptr %6, i64 0, i64 0
  %24 = getelementptr inbounds [65 x float], ptr %23, i64 0, i64 0
  %25 = call i64 @WebRtc_WriteBuffer(ptr noundef %22, ptr noundef %24, i64 noundef 1)
  %26 = getelementptr inbounds [128 x float], ptr %5, i64 0, i64 0
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %26, ptr align 4 %27, i64 512, i1 false)
  %28 = getelementptr inbounds [128 x float], ptr %5, i64 0, i64 0
  %29 = getelementptr inbounds [2 x [65 x float]], ptr %6, i64 0, i64 0
  call void @TimeToFrequency(ptr noundef %28, ptr noundef %29, i32 noundef 1)
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.AecCore, ptr %30, i32 0, i32 42
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  %33 = getelementptr inbounds [2 x [65 x float]], ptr %6, i64 0, i64 0
  %34 = getelementptr inbounds [65 x float], ptr %33, i64 0, i64 0
  %35 = call i64 @WebRtc_WriteBuffer(ptr noundef %32, ptr noundef %34, i64 noundef 1)
  call void @llvm.lifetime.end.p0(i64 520, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr %5) #4
  ret void
}

declare i64 @WebRtc_available_write(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @WebRtcAec_MoveFarReadPtr(ptr noundef, i32 noundef) #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) #3

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

declare i64 @WebRtc_WriteBuffer(ptr noundef, ptr noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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/C++ TBAA"}
!9 = !{!10, !6, i64 54944}
!10 = !{!"AecCore", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !7, i64 56, !7, i64 568, !7, i64 1080, !7, i64 1592, !7, i64 1852, !7, i64 2112, !7, i64 2372, !6, i64 2632, !7, i64 2640, !7, i64 19280, !7, i64 35920, !7, i64 36440, !7, i64 36960, !7, i64 53600, !7, i64 53860, !7, i64 54120, !7, i64 54380, !12, i64 54640, !12, i64 54644, !12, i64 54648, !11, i64 54652, !11, i64 54656, !12, i64 54660, !12, i64 54664, !11, i64 54668, !7, i64 54672, !11, i64 54928, !13, i64 54932, !13, i64 54934, !13, i64 54936, !11, i64 54940, !6, i64 54944, !6, i64 54952, !11, i64 54960, !11, i64 54964, !11, i64 54968, !11, i64 54972, !12, i64 54976, !12, i64 54980, !11, i64 54984, !14, i64 54988, !14, i64 55016, !14, i64 55044, !14, i64 55072, !11, i64 55100, !11, i64 55104, !15, i64 55108, !15, i64 55144, !15, i64 55180, !15, i64 55216, !11, i64 55252, !11, i64 55256, !12, i64 55260, !7, i64 55264, !11, i64 55564, !6, i64 55568, !6, i64 55576, !11, i64 55584, !11, i64 55588}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!"PowerLevel", !12, i64 0, !11, i64 4, !12, i64 8, !12, i64 12, !11, i64 16, !12, i64 20, !12, i64 24}
!15 = !{!"Stats", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !11, i64 28, !11, i64 32}
!16 = !{!10, !6, i64 54952}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @WebRtcAec_BufferFarendPartition(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = alloca [128 x float], align 16
  %4 = alloca [2 x [65 x float]], align 16
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 520, ptr nonnull %4) #4
  %5 = getelementptr inbounds i8, ptr %0, i64 54944
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = tail call i64 @WebRtc_available_write(ptr noundef %6) #4
  %8 = icmp eq i64 %7, 0
  br i1 %8, label %9, label %11

9:                                                ; preds = %2
  %10 = tail call i32 @WebRtcAec_MoveFarReadPtr(ptr noundef nonnull %0, i32 noundef 1)
  br label %11

11:                                               ; preds = %9, %2
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %3, ptr noundef nonnull align 4 dereferenceable(512) %1, i64 512, i1 false)
  call void @TimeToFrequency(ptr noundef nonnull %3, ptr noundef nonnull %4, i32 noundef 0)
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = call i64 @WebRtc_WriteBuffer(ptr noundef %12, ptr noundef nonnull %4, i64 noundef 1) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(512) %3, ptr noundef nonnull align 4 dereferenceable(512) %1, i64 512, i1 false)
  call void @TimeToFrequency(ptr noundef nonnull %3, ptr noundef nonnull %4, i32 noundef 1)
  %14 = getelementptr inbounds i8, ptr %0, i64 54952
  %15 = load ptr, ptr %14, align 8, !tbaa !15
  %16 = call i64 @WebRtc_WriteBuffer(ptr noundef %15, ptr noundef nonnull %4, i64 noundef 1) #4
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %3) #4
  ret void
}

declare i64 @WebRtc_available_write(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @WebRtcAec_MoveFarReadPtr(ptr noundef, i32 noundef) local_unnamed_addr #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) #3

; Function Attrs: nounwind uwtable
declare hidden void @TimeToFrequency(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare i64 @WebRtc_WriteBuffer(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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, !10, i64 54944}
!6 = !{!"AecCore", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !7, i64 16, !7, i64 20, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !8, i64 56, !8, i64 568, !8, i64 1080, !8, i64 1592, !8, i64 1852, !8, i64 2112, !8, i64 2372, !10, i64 2632, !8, i64 2640, !8, i64 19280, !8, i64 35920, !8, i64 36440, !8, i64 36960, !8, i64 53600, !8, i64 53860, !8, i64 54120, !8, i64 54380, !11, i64 54640, !11, i64 54644, !11, i64 54648, !7, i64 54652, !7, i64 54656, !11, i64 54660, !11, i64 54664, !7, i64 54668, !8, i64 54672, !7, i64 54928, !12, i64 54932, !12, i64 54934, !12, i64 54936, !7, i64 54940, !10, i64 54944, !10, i64 54952, !7, i64 54960, !7, i64 54964, !7, i64 54968, !7, i64 54972, !11, i64 54976, !11, i64 54980, !7, i64 54984, !13, i64 54988, !13, i64 55016, !13, i64 55044, !13, i64 55072, !7, i64 55100, !7, i64 55104, !14, i64 55108, !14, i64 55144, !14, i64 55180, !14, i64 55216, !7, i64 55252, !7, i64 55256, !11, i64 55260, !8, i64 55264, !7, i64 55564, !10, i64 55568, !10, i64 55576, !7, i64 55584, !7, i64 55588}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!"short", !8, i64 0}
!13 = !{!"PowerLevel", !11, i64 0, !7, i64 4, !11, i64 8, !11, i64 12, !7, i64 16, !11, i64 20, !11, i64 24}
!14 = !{!"Stats", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !7, i64 28, !7, i64 32}
!15 = !{!6, !10, i64 54952}


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