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

; 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.aecpc_t = type { i32, i32, i32, i32, float, i16, i32, i32, i32, i16, i16, i32, i16, i16, i16, i16, i32, i32, i32, i16, ptr, i32, i32, i32, float, ptr, i32, i32, ptr }

; 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 i32 @WebRtcAec_GetDelayMetrics(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %10, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %16

13:                                               ; preds = %3
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.aecpc_t, ptr %14, i32 0, i32 26
  store i32 12003, ptr %15, align 8, !tbaa !9
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %43

16:                                               ; preds = %3
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %22

19:                                               ; preds = %16
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.aecpc_t, ptr %20, i32 0, i32 26
  store i32 12003, ptr %21, align 8, !tbaa !9
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %43

22:                                               ; preds = %16
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.aecpc_t, ptr %23, i32 0, i32 9
  %25 = load i16, ptr %24, align 4, !tbaa !14
  %26 = sext i16 %25 to i32
  %27 = icmp ne i32 %26, 42
  br i1 %27, label %28, label %31

28:                                               ; preds = %22
  %29 = load ptr, ptr %8, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.aecpc_t, ptr %29, i32 0, i32 26
  store i32 12002, ptr %30, align 8, !tbaa !9
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %43

31:                                               ; preds = %22
  %32 = load ptr, ptr %8, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.aecpc_t, ptr %32, i32 0, i32 28
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = call i32 @WebRtcAec_GetDelayMetricsCore(ptr noundef %34, ptr noundef %35, ptr noundef %36)
  %38 = icmp eq i32 %37, -1
  br i1 %38, label %39, label %42

39:                                               ; preds = %31
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.aecpc_t, ptr %40, i32 0, i32 26
  store i32 12001, ptr %41, align 8, !tbaa !9
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %43

42:                                               ; preds = %31
  store i32 0, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %43

43:                                               ; preds = %42, %39, %28, %19, %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  %44 = load i32, ptr %4, align 4
  ret i32 %44
}

declare i32 @WebRtcAec_GetDelayMetricsCore(ptr noundef, ptr noundef, ptr 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 = { 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, !11, i64 104}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16, !13, i64 20, !11, i64 24, !11, i64 28, !11, i64 32, !13, i64 36, !13, i64 38, !11, i64 40, !13, i64 44, !13, i64 46, !13, i64 48, !13, i64 50, !11, i64 52, !11, i64 56, !11, i64 60, !13, i64 64, !6, i64 72, !11, i64 80, !11, i64 84, !11, i64 88, !12, i64 92, !6, i64 96, !11, i64 104, !11, i64 108, !6, i64 112}
!11 = !{!"int", !7, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!"short", !7, i64 0}
!14 = !{!10, !13, i64 36}
!15 = !{!10, !6, i64 112}


; 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: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @WebRtcAec_GetDelayMetrics(ptr nocapture noundef %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = icmp eq ptr %1, null
  %5 = icmp eq ptr %2, null
  %or.cond = or i1 %4, %5
  br i1 %or.cond, label %.sink.split, label %6

6:                                                ; preds = %3
  %7 = getelementptr inbounds i8, ptr %0, i64 36
  %8 = load i16, ptr %7, align 4, !tbaa !5
  %.not = icmp eq i16 %8, 42
  br i1 %.not, label %9, label %.sink.split

9:                                                ; preds = %6
  %10 = getelementptr inbounds i8, ptr %0, i64 112
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %12 = tail call i32 @WebRtcAec_GetDelayMetricsCore(ptr noundef %11, ptr noundef nonnull %1, ptr noundef nonnull %2) #2
  %13 = icmp eq i32 %12, -1
  br i1 %13, label %.sink.split, label %15

.sink.split:                                      ; preds = %9, %6, %3
  %.sink = phi i32 [ 12003, %3 ], [ 12002, %6 ], [ 12001, %9 ]
  %14 = getelementptr inbounds i8, ptr %0, i64 104
  store i32 %.sink, ptr %14, align 8, !tbaa !14
  br label %15

15:                                               ; preds = %.sink.split, %9
  %.0 = phi i32 [ 0, %9 ], [ -1, %.sink.split ]
  ret i32 %.0
}

declare i32 @WebRtcAec_GetDelayMetricsCore(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 = { 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, !11, i64 36}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12, !10, i64 16, !11, i64 20, !7, i64 24, !7, i64 28, !7, i64 32, !11, i64 36, !11, i64 38, !7, i64 40, !11, i64 44, !11, i64 46, !11, i64 48, !11, i64 50, !7, i64 52, !7, i64 56, !7, i64 60, !11, i64 64, !12, i64 72, !7, i64 80, !7, i64 84, !7, i64 88, !10, i64 92, !12, i64 96, !7, i64 104, !7, i64 108, !12, i64 112}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"float", !8, i64 0}
!11 = !{!"short", !8, i64 0}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !12, i64 112}
!14 = !{!6, !7, i64 104}


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