; LLVM IR from BoysTownOrg/chapro :: iirfb_prepare (cha_iirfb_prepare)

; 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"

; Function Attrs: nounwind uwtable
define dso_local i32 @cha_iirfb_prepare(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, double noundef %7, i32 noundef %8) #0 {
  %10 = alloca i32, align 4
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca double, align 8
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  store ptr %0, ptr %11, align 8, !tbaa !5
  store ptr %1, ptr %12, align 8, !tbaa !5
  store ptr %2, ptr %13, align 8, !tbaa !5
  store ptr %3, ptr %14, align 8, !tbaa !5
  store ptr %4, ptr %15, align 8, !tbaa !5
  store i32 %5, ptr %16, align 4, !tbaa !9
  store i32 %6, ptr %17, align 4, !tbaa !9
  store double %7, ptr %18, align 8, !tbaa !11
  store i32 %8, ptr %19, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %25 = load i32, ptr %19, align 4, !tbaa !9
  %26 = icmp sle i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %9
  store i32 1, ptr %10, align 4
  store i32 1, ptr %24, align 4
  br label %100

28:                                               ; preds = %9
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  call void @cha_prepare(ptr noundef %29)
  %30 = load double, ptr %18, align 8, !tbaa !11
  %31 = fdiv double %30, 1.000000e+03
  %32 = load ptr, ptr %11, align 8, !tbaa !5
  %33 = getelementptr inbounds ptr, ptr %32, i64 2
  %34 = load ptr, ptr %33, align 8, !tbaa !5
  %35 = getelementptr inbounds double, ptr %34, i64 0
  store double %31, ptr %35, align 8, !tbaa !11
  %36 = load i32, ptr %19, align 4, !tbaa !9
  %37 = load ptr, ptr %11, align 8, !tbaa !5
  %38 = getelementptr inbounds ptr, ptr %37, i64 1
  %39 = load ptr, ptr %38, align 8, !tbaa !5
  %40 = getelementptr inbounds i32, ptr %39, i64 0
  store i32 %36, ptr %40, align 4, !tbaa !9
  %41 = load i32, ptr %17, align 4, !tbaa !9
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %21, align 4, !tbaa !9
  %43 = load i32, ptr %16, align 4, !tbaa !9
  %44 = load ptr, ptr %11, align 8, !tbaa !5
  %45 = getelementptr inbounds ptr, ptr %44, i64 1
  %46 = load ptr, ptr %45, align 8, !tbaa !5
  %47 = getelementptr inbounds i32, ptr %46, i64 1
  store i32 %43, ptr %47, align 4, !tbaa !9
  %48 = load i32, ptr %21, align 4, !tbaa !9
  %49 = load ptr, ptr %11, align 8, !tbaa !5
  %50 = getelementptr inbounds ptr, ptr %49, i64 1
  %51 = load ptr, ptr %50, align 8, !tbaa !5
  %52 = getelementptr inbounds i32, ptr %51, i64 2
  store i32 %48, ptr %52, align 4, !tbaa !9
  %53 = load i32, ptr %17, align 4, !tbaa !9
  %54 = mul nsw i32 2, %53
  store i32 %54, ptr %23, align 4, !tbaa !9
  %55 = load i32, ptr %17, align 4, !tbaa !9
  %56 = sdiv i32 %55, 2
  %57 = mul nsw i32 5, %56
  store i32 %57, ptr %22, align 4, !tbaa !9
  %58 = load ptr, ptr %11, align 8, !tbaa !5
  %59 = load i32, ptr %16, align 4, !tbaa !9
  %60 = load i32, ptr %22, align 4, !tbaa !9
  %61 = mul nsw i32 %59, %60
  %62 = call ptr @cha_allocate(ptr noundef %58, i32 noundef %61, i32 noundef 4, i32 noundef 5)
  %63 = load ptr, ptr %11, align 8, !tbaa !5
  %64 = load i32, ptr %16, align 4, !tbaa !9
  %65 = load i32, ptr %23, align 4, !tbaa !9
  %66 = mul nsw i32 %64, %65
  %67 = call ptr @cha_allocate(ptr noundef %63, i32 noundef %66, i32 noundef 4, i32 noundef 7)
  %68 = load ptr, ptr %11, align 8, !tbaa !5
  %69 = load i32, ptr %16, align 4, !tbaa !9
  %70 = call ptr @cha_allocate(ptr noundef %68, i32 noundef %69, i32 noundef 4, i32 noundef 10)
  %71 = load ptr, ptr %11, align 8, !tbaa !5
  %72 = load ptr, ptr %12, align 8, !tbaa !5
  %73 = load ptr, ptr %13, align 8, !tbaa !5
  %74 = load ptr, ptr %14, align 8, !tbaa !5
  %75 = load ptr, ptr %15, align 8, !tbaa !5
  %76 = load i32, ptr %16, align 4, !tbaa !9
  %77 = load i32, ptr %17, align 4, !tbaa !9
  %78 = load double, ptr %18, align 8, !tbaa !11
  %79 = call i32 @iir_filterbank(ptr noundef %71, ptr noundef %72, ptr noundef %73, ptr noundef %74, ptr noundef %75, i32 noundef %76, i32 noundef %77, double noundef %78)
  store i32 %79, ptr %20, align 4, !tbaa !9
  %80 = load i32, ptr %20, align 4, !tbaa !9
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  %82 = getelementptr inbounds ptr, ptr %81, i64 1
  %83 = load ptr, ptr %82, align 8, !tbaa !5
  %84 = getelementptr inbounds i32, ptr %83, i64 3
  store i32 %80, ptr %84, align 4, !tbaa !9
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = load i32, ptr %16, align 4, !tbaa !9
  %87 = load i32, ptr %20, align 4, !tbaa !9
  %88 = mul nsw i32 %86, %87
  %89 = call ptr @cha_allocate(ptr noundef %85, i32 noundef %88, i32 noundef 4, i32 noundef 8)
  %90 = load ptr, ptr %11, align 8, !tbaa !5
  %91 = load i32, ptr %16, align 4, !tbaa !9
  %92 = load i32, ptr %19, align 4, !tbaa !9
  %93 = mul nsw i32 %91, %92
  %94 = call ptr @cha_allocate(ptr noundef %90, i32 noundef %93, i32 noundef 4, i32 noundef 9)
  %95 = load ptr, ptr %11, align 8, !tbaa !5
  %96 = load i32, ptr %16, align 4, !tbaa !9
  %97 = load i32, ptr %19, align 4, !tbaa !9
  %98 = mul nsw i32 %96, %97
  %99 = call ptr @cha_allocate(ptr noundef %95, i32 noundef %98, i32 noundef 4, i32 noundef 3)
  store i32 0, ptr %10, align 4
  store i32 1, ptr %24, align 4
  br label %100

100:                                              ; preds = %28, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  %101 = load i32, ptr %10, align 4
  ret i32 %101
}

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

declare void @cha_prepare(ptr noundef) #2

declare ptr @cha_allocate(ptr noundef, i32 noundef, i32 noundef, i32 noundef) #2

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @iir_filterbank(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, double noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { inlinehint 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 }

!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, !12, i64 0}
!12 = !{!"double", !7, i64 0}


; 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 0, 2) i32 @cha_iirfb_prepare(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, double noundef %7, i32 noundef %8) local_unnamed_addr #0 {
  %10 = icmp slt i32 %8, 1
  br i1 %10, label %36, label %11

11:                                               ; preds = %9
  tail call void @cha_prepare(ptr noundef %0) #3
  %12 = fdiv double %7, 1.000000e+03
  %13 = getelementptr inbounds i8, ptr %0, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  store double %12, ptr %14, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  store i32 %8, ptr %16, align 4, !tbaa !11
  %17 = add nsw i32 %6, 1
  %18 = getelementptr inbounds i8, ptr %16, i64 4
  store i32 %5, ptr %18, align 4, !tbaa !11
  %19 = getelementptr inbounds i8, ptr %16, i64 8
  store i32 %17, ptr %19, align 4, !tbaa !11
  %20 = sdiv i32 %6, 2
  %21 = mul i32 %5, 5
  %22 = mul i32 %21, %20
  %23 = tail call ptr @cha_allocate(ptr noundef %0, i32 noundef %22, i32 noundef 4, i32 noundef 5) #3
  %24 = shl i32 %5, 1
  %25 = mul i32 %24, %6
  %26 = tail call ptr @cha_allocate(ptr noundef %0, i32 noundef %25, i32 noundef 4, i32 noundef 7) #3
  %27 = tail call ptr @cha_allocate(ptr noundef %0, i32 noundef %5, i32 noundef 4, i32 noundef 10) #3
  %28 = tail call i32 @iir_filterbank(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, i32 noundef %5, i32 noundef %6, double noundef %7)
  %29 = load ptr, ptr %15, align 8, !tbaa !5
  %30 = getelementptr inbounds i8, ptr %29, i64 12
  store i32 %28, ptr %30, align 4, !tbaa !11
  %31 = mul nsw i32 %28, %5
  %32 = tail call ptr @cha_allocate(ptr noundef %0, i32 noundef %31, i32 noundef 4, i32 noundef 8) #3
  %33 = mul nsw i32 %8, %5
  %34 = tail call ptr @cha_allocate(ptr noundef %0, i32 noundef %33, i32 noundef 4, i32 noundef 9) #3
  %35 = tail call ptr @cha_allocate(ptr noundef %0, i32 noundef %33, i32 noundef 4, i32 noundef 3) #3
  br label %36

36:                                               ; preds = %9, %11
  %.0 = phi i32 [ 0, %11 ], [ 1, %9 ]
  ret i32 %.0
}

declare void @cha_prepare(ptr noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint nounwind uwtable
declare hidden i32 @iir_filterbank(ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef, double noundef) local_unnamed_addr #2

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 = { inlinehint 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 = { 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 = !{!"double", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}


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