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

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

@.str = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__.WebRtc_InitBinaryDelayEstimator = external hidden unnamed_addr constant [61 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

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

6:                                                ; preds = %1
  br label %8

7:                                                ; preds = %1
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 394, ptr noundef @__PRETTY_FUNCTION__.WebRtc_InitBinaryDelayEstimator) #5
  unreachable

8:                                                ; preds = %6
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %9, i32 0, i32 1
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %12, i32 0, i32 13
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %15 = getelementptr inbounds %struct.BinaryDelayEstimatorFarend, ptr %14, i32 0, i32 2
  %16 = load i32, ptr %15, align 8, !tbaa !15
  %17 = sext i32 %16 to i64
  %18 = mul i64 4, %17
  call void @llvm.memset.p0.i64(ptr align 4 %11, i8 0, i64 %18, i1 false)
  %19 = load ptr, ptr %2, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !17
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %22, i32 0, i32 3
  %24 = load i32, ptr %23, align 8, !tbaa !18
  %25 = sext i32 %24 to i64
  %26 = mul i64 4, %25
  call void @llvm.memset.p0.i64(ptr align 4 %21, i8 0, i64 %26, i1 false)
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %27

27:                                               ; preds = %48, %8
  %28 = load i32, ptr %3, align 4, !tbaa !9
  %29 = load ptr, ptr %2, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %29, i32 0, i32 13
  %31 = load ptr, ptr %30, align 8, !tbaa !14
  %32 = getelementptr inbounds %struct.BinaryDelayEstimatorFarend, ptr %31, i32 0, i32 2
  %33 = load i32, ptr %32, align 8, !tbaa !15
  %34 = icmp sle i32 %28, %33
  br i1 %34, label %35, label %51

35:                                               ; preds = %27
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %36, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !19
  %39 = load i32, ptr %3, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr %38, i64 %40
  store i32 10240, ptr %41, align 4, !tbaa !9
  %42 = load ptr, ptr %2, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %42, i32 0, i32 11
  %44 = load ptr, ptr %43, align 8, !tbaa !20
  %45 = load i32, ptr %3, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds float, ptr %44, i64 %46
  store float 0.000000e+00, ptr %47, align 4, !tbaa !21
  br label %48

48:                                               ; preds = %35
  %49 = load i32, ptr %3, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %3, align 4, !tbaa !9
  br label %27, !llvm.loop !22

51:                                               ; preds = %27
  %52 = load ptr, ptr %2, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %52, i32 0, i32 4
  store i32 16384, ptr %53, align 4, !tbaa !24
  %54 = load ptr, ptr %2, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %54, i32 0, i32 5
  store i32 16384, ptr %55, align 8, !tbaa !25
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %56, i32 0, i32 6
  store i32 -2, ptr %57, align 4, !tbaa !26
  %58 = load ptr, ptr %2, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %58, i32 0, i32 7
  store i32 0, ptr %59, align 8, !tbaa !27
  %60 = load ptr, ptr %2, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %60, i32 0, i32 8
  store i32 -2, ptr %61, align 4, !tbaa !28
  %62 = load ptr, ptr %2, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %62, i32 0, i32 13
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = getelementptr inbounds %struct.BinaryDelayEstimatorFarend, ptr %64, i32 0, i32 2
  %66 = load i32, ptr %65, align 8, !tbaa !15
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %67, i32 0, i32 9
  store i32 %66, ptr %68, align 8, !tbaa !29
  %69 = load ptr, ptr %2, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %69, i32 0, i32 10
  store i32 0, ptr %70, align 4, !tbaa !30
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.BinaryDelayEstimator, ptr %71, i32 0, i32 12
  store float 0.000000e+00, ptr %72, align 8, !tbaa !31
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  ret void
}

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 = { nounwind }
attributes #5 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"", !6, i64 0, !6, i64 8, !6, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !6, i64 56, !13, i64 64, !6, i64 72}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !6, i64 72}
!15 = !{!16, !10, i64 16}
!16 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16}
!17 = !{!12, !6, i64 16}
!18 = !{!12, !10, i64 24}
!19 = !{!12, !6, i64 0}
!20 = !{!12, !6, i64 56}
!21 = !{!13, !13, i64 0}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}
!24 = !{!12, !10, i64 28}
!25 = !{!12, !10, i64 32}
!26 = !{!12, !10, i64 36}
!27 = !{!12, !10, i64 40}
!28 = !{!12, !10, i64 44}
!29 = !{!12, !10, i64 48}
!30 = !{!12, !10, i64 52}
!31 = !{!12, !13, i64 64}


; 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 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [90 x i8], align 1
@__PRETTY_FUNCTION__.WebRtc_InitBinaryDelayEstimator = external hidden unnamed_addr constant [61 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 nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: nounwind uwtable
define dso_local void @WebRtc_InitBinaryDelayEstimator(ptr noundef %0) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %3

2:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 394, ptr noundef nonnull @__PRETTY_FUNCTION__.WebRtc_InitBinaryDelayEstimator) #3
  unreachable

3:                                                ; preds = %1
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 72
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  %9 = load i32, ptr %8, align 8, !tbaa !13
  %10 = sext i32 %9 to i64
  %11 = shl nsw i64 %10, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %5, i8 0, i64 %11, i1 false)
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load i32, ptr %14, align 8, !tbaa !16
  %16 = sext i32 %15 to i64
  %17 = shl nsw i64 %16, 2
  tail call void @llvm.memset.p0.i64(ptr align 4 %13, i8 0, i64 %17, i1 false)
  %18 = load ptr, ptr %6, align 8, !tbaa !12
  %19 = getelementptr inbounds i8, ptr %18, i64 16
  %20 = load i32, ptr %19, align 8, !tbaa !13
  %.not2122 = icmp slt i32 %20, 0
  br i1 %.not2122, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %21 = load ptr, ptr %0, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %0, i64 56
  %23 = load ptr, ptr %22, align 8, !tbaa !18
  br label %24

24:                                               ; preds = %.lr.ph, %24
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %24 ]
  %25 = getelementptr inbounds i32, ptr %21, i64 %indvars.iv
  store i32 10240, ptr %25, align 4, !tbaa !19
  %26 = getelementptr inbounds float, ptr %23, i64 %indvars.iv
  store float 0.000000e+00, ptr %26, align 4, !tbaa !20
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %27 = load i32, ptr %19, align 8, !tbaa !13
  %28 = sext i32 %27 to i64
  %.not21.not = icmp slt i64 %indvars.iv, %28
  br i1 %.not21.not, label %24, label %._crit_edge, !llvm.loop !21

._crit_edge:                                      ; preds = %24, %3
  %.lcssa = phi i32 [ %20, %3 ], [ %27, %24 ]
  %29 = getelementptr inbounds i8, ptr %0, i64 28
  store <4 x i32> <i32 16384, i32 16384, i32 -2, i32 0>, ptr %29, align 4, !tbaa !19
  %30 = getelementptr inbounds i8, ptr %0, i64 44
  store i32 -2, ptr %30, align 4, !tbaa !23
  %31 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %.lcssa, ptr %31, align 8, !tbaa !24
  %32 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 0, ptr %32, align 4, !tbaa !25
  %33 = getelementptr inbounds i8, ptr %0, i64 64
  store float 0.000000e+00, ptr %33, align 8, !tbaa !26
  ret void
}

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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 = { 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 8}
!6 = !{!"", !7, i64 0, !7, i64 8, !7, i64 16, !10, i64 24, !10, i64 28, !10, i64 32, !10, i64 36, !10, i64 40, !10, i64 44, !10, i64 48, !10, i64 52, !7, i64 56, !11, i64 64, !7, i64 72}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"float", !8, i64 0}
!12 = !{!6, !7, i64 72}
!13 = !{!14, !10, i64 16}
!14 = !{!"", !7, i64 0, !7, i64 8, !10, i64 16}
!15 = !{!6, !7, i64 16}
!16 = !{!6, !10, i64 24}
!17 = !{!6, !7, i64 0}
!18 = !{!6, !7, i64 56}
!19 = !{!10, !10, i64 0}
!20 = !{!11, !11, i64 0}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}
!23 = !{!6, !10, i64 44}
!24 = !{!6, !10, i64 48}
!25 = !{!6, !10, i64 52}
!26 = !{!6, !11, i64 64}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass