; LLVM IR from BoysTownOrg/chapro :: cfirfb_prepare (cha_cfirfb_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_cfirfb_prepare(ptr noundef %0, ptr noundef %1, i32 noundef %2, double noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca double, align 8
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca ptr, align 8
  %17 = alloca ptr, align 8
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store ptr %0, ptr %9, align 8, !tbaa !5
  store ptr %1, ptr %10, align 8, !tbaa !5
  store i32 %2, ptr %11, align 4, !tbaa !9
  store double %3, ptr %12, align 8, !tbaa !11
  store i32 %4, ptr %13, align 4, !tbaa !9
  store i32 %5, ptr %14, align 4, !tbaa !9
  store i32 %6, ptr %15, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #6
  %22 = load i32, ptr %15, align 4, !tbaa !9
  %23 = icmp sle i32 %22, 0
  br i1 %23, label %24, label %25

24:                                               ; preds = %7
  store i32 1, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %128

25:                                               ; preds = %7
  %26 = load ptr, ptr %9, align 8, !tbaa !5
  call void @cha_prepare(ptr noundef %26)
  %27 = load i32, ptr %15, align 4, !tbaa !9
  %28 = load ptr, ptr %9, align 8, !tbaa !5
  %29 = getelementptr inbounds ptr, ptr %28, i64 1
  %30 = load ptr, ptr %29, align 8, !tbaa !5
  %31 = getelementptr inbounds i32, ptr %30, i64 0
  store i32 %27, ptr %31, align 4, !tbaa !9
  %32 = load double, ptr %12, align 8, !tbaa !11
  %33 = fdiv double %32, 1.000000e+03
  %34 = load ptr, ptr %9, align 8, !tbaa !5
  %35 = getelementptr inbounds ptr, ptr %34, i64 2
  %36 = load ptr, ptr %35, align 8, !tbaa !5
  %37 = getelementptr inbounds double, ptr %36, i64 0
  store double %33, ptr %37, align 8, !tbaa !11
  %38 = load i32, ptr %13, align 4, !tbaa !9
  %39 = load ptr, ptr %9, align 8, !tbaa !5
  %40 = getelementptr inbounds ptr, ptr %39, i64 1
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  %42 = getelementptr inbounds i32, ptr %41, i64 4
  store i32 %38, ptr %42, align 4, !tbaa !9
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = load ptr, ptr %9, 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 %13, align 4, !tbaa !9
  %49 = mul nsw i32 %48, 2
  store i32 %49, ptr %19, align 4, !tbaa !9
  %50 = load i32, ptr %19, align 4, !tbaa !9
  %51 = add nsw i32 %50, 2
  store i32 %51, ptr %18, align 4, !tbaa !9
  %52 = load i32, ptr %15, align 4, !tbaa !9
  %53 = load i32, ptr %13, align 4, !tbaa !9
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %55, label %62

55:                                               ; preds = %25
  %56 = load i32, ptr %15, align 4, !tbaa !9
  %57 = mul nsw i32 %56, 4
  %58 = load i32, ptr %13, align 4, !tbaa !9
  %59 = load i32, ptr %15, align 4, !tbaa !9
  %60 = sdiv i32 %58, %59
  %61 = mul nsw i32 %57, %60
  br label %65

62:                                               ; preds = %25
  %63 = load i32, ptr %13, align 4, !tbaa !9
  %64 = mul nsw i32 %63, 4
  br label %65

65:                                               ; preds = %62, %55
  %66 = phi i32 [ %61, %55 ], [ %64, %62 ]
  store i32 %66, ptr %20, align 4, !tbaa !9
  %67 = load ptr, ptr %9, align 8, !tbaa !5
  %68 = load i32, ptr %18, align 4, !tbaa !9
  %69 = mul nsw i32 %68, 2
  %70 = call ptr @cha_allocate(ptr noundef %67, i32 noundef %69, i32 noundef 4, i32 noundef 6)
  %71 = load ptr, ptr %9, align 8, !tbaa !5
  %72 = load i32, ptr %18, align 4, !tbaa !9
  %73 = mul nsw i32 %72, 2
  %74 = call ptr @cha_allocate(ptr noundef %71, i32 noundef %73, i32 noundef 4, i32 noundef 7)
  %75 = load ptr, ptr %9, align 8, !tbaa !5
  %76 = load i32, ptr %11, align 4, !tbaa !9
  %77 = load i32, ptr %13, align 4, !tbaa !9
  %78 = load i32, ptr %15, align 4, !tbaa !9
  %79 = add nsw i32 %77, %78
  %80 = mul nsw i32 %76, %79
  %81 = mul nsw i32 %80, 2
  %82 = call ptr @cha_allocate(ptr noundef %75, i32 noundef %81, i32 noundef 4, i32 noundef 8)
  %83 = load ptr, ptr %9, align 8, !tbaa !5
  %84 = load i32, ptr %11, align 4, !tbaa !9
  %85 = load i32, ptr %20, align 4, !tbaa !9
  %86 = mul nsw i32 %84, %85
  %87 = call ptr @cha_allocate(ptr noundef %83, i32 noundef %86, i32 noundef 4, i32 noundef 5)
  %88 = load ptr, ptr %9, align 8, !tbaa !5
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = load i32, ptr %11, align 4, !tbaa !9
  call void @save_bw(ptr noundef %88, ptr noundef %89, i32 noundef %90)
  %91 = load i32, ptr %11, align 4, !tbaa !9
  %92 = load i32, ptr %13, align 4, !tbaa !9
  %93 = mul nsw i32 %91, %92
  %94 = sext i32 %93 to i64
  %95 = call noalias ptr @calloc(i64 noundef %94, i64 noundef 4) #7
  store ptr %95, ptr %16, align 8, !tbaa !5
  %96 = load ptr, ptr %16, align 8, !tbaa !5
  %97 = load ptr, ptr %10, align 8, !tbaa !5
  %98 = load i32, ptr %11, align 4, !tbaa !9
  %99 = load i32, ptr %13, align 4, !tbaa !9
  %100 = load i32, ptr %14, align 4, !tbaa !9
  %101 = load double, ptr %12, align 8, !tbaa !11
  call void @fir_filterbank(ptr noundef %96, ptr noundef %97, i32 noundef %98, i32 noundef %99, i32 noundef %100, double noundef %101)
  %102 = load ptr, ptr %9, align 8, !tbaa !5
  %103 = getelementptr inbounds ptr, ptr %102, i64 5
  %104 = load ptr, ptr %103, align 8, !tbaa !5
  store ptr %104, ptr %17, align 8, !tbaa !5
  %105 = load i32, ptr %15, align 4, !tbaa !9
  %106 = load i32, ptr %13, align 4, !tbaa !9
  %107 = icmp slt i32 %105, %106
  br i1 %107, label %108, label %114

108:                                              ; preds = %65
  %109 = load ptr, ptr %16, align 8, !tbaa !5
  %110 = load ptr, ptr %17, align 8, !tbaa !5
  %111 = load i32, ptr %11, align 4, !tbaa !9
  %112 = load i32, ptr %13, align 4, !tbaa !9
  %113 = load i32, ptr %15, align 4, !tbaa !9
  call void @fir_transform_sc(ptr noundef %109, ptr noundef %110, i32 noundef %111, i32 noundef %112, i32 noundef %113)
  br label %120

114:                                              ; preds = %65
  %115 = load ptr, ptr %16, align 8, !tbaa !5
  %116 = load ptr, ptr %17, align 8, !tbaa !5
  %117 = load i32, ptr %11, align 4, !tbaa !9
  %118 = load i32, ptr %13, align 4, !tbaa !9
  %119 = load i32, ptr %15, align 4, !tbaa !9
  call void @fir_transform_lc(ptr noundef %115, ptr noundef %116, i32 noundef %117, i32 noundef %118, i32 noundef %119)
  br label %120

120:                                              ; preds = %114, %108
  %121 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %121) #6
  %122 = load ptr, ptr %9, align 8, !tbaa !5
  %123 = load i32, ptr %11, align 4, !tbaa !9
  %124 = load i32, ptr %15, align 4, !tbaa !9
  %125 = mul nsw i32 %123, %124
  %126 = mul nsw i32 %125, 2
  %127 = call ptr @cha_allocate(ptr noundef %122, i32 noundef %126, i32 noundef 4, i32 noundef 3)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %128

128:                                              ; preds = %120, %24
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  %129 = load i32, ptr %8, align 4
  ret i32 %129
}

; 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 void @save_bw(ptr noundef, ptr noundef, i32 noundef) #3

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #4

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

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

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #5

; 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 allocsize(0,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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind allocsize(0,1) }

!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_cfirfb_prepare(ptr noundef %0, ptr noundef %1, i32 noundef %2, double noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  %8 = icmp slt i32 %6, 1
  br i1 %8, label %44, label %9

9:                                                ; preds = %7
  tail call void @cha_prepare(ptr noundef %0) #5
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  store i32 %6, ptr %11, align 4, !tbaa !9
  %12 = fdiv double %3, 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 !11
  %15 = getelementptr inbounds i8, ptr %11, i64 16
  store i32 %4, ptr %15, align 4, !tbaa !9
  %16 = getelementptr inbounds i8, ptr %11, i64 4
  store i32 %2, ptr %16, align 4, !tbaa !9
  %17 = shl i32 %4, 2
  %18 = icmp slt i32 %6, %4
  br i1 %18, label %19, label %23

19:                                               ; preds = %9
  %20 = shl nsw i32 %6, 2
  %21 = udiv i32 %4, %6
  %22 = mul nsw i32 %20, %21
  br label %23

23:                                               ; preds = %9, %19
  %24 = phi i32 [ %22, %19 ], [ %17, %9 ]
  %25 = add i32 %17, 4
  %26 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %25, i32 noundef 4, i32 noundef 6) #5
  %27 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %25, i32 noundef 4, i32 noundef 7) #5
  %28 = add nsw i32 %6, %4
  %29 = shl i32 %2, 1
  %30 = mul i32 %29, %28
  %31 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %30, i32 noundef 4, i32 noundef 8) #5
  %32 = mul nsw i32 %24, %2
  %33 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %32, i32 noundef 4, i32 noundef 5) #5
  tail call void @save_bw(ptr noundef nonnull %0, ptr noundef %1, i32 noundef %2)
  %34 = mul nsw i32 %4, %2
  %35 = sext i32 %34 to i64
  %36 = tail call noalias ptr @calloc(i64 noundef %35, i64 noundef 4) #6
  tail call void @fir_filterbank(ptr noundef %36, ptr noundef %1, i32 noundef %2, i32 noundef %4, i32 noundef %5, double noundef %3)
  %37 = getelementptr inbounds i8, ptr %0, i64 40
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  br i1 %18, label %39, label %40

39:                                               ; preds = %23
  tail call void @fir_transform_sc(ptr noundef %36, ptr noundef %38, i32 noundef %2, i32 noundef %4, i32 noundef %6)
  br label %41

40:                                               ; preds = %23
  tail call void @fir_transform_lc(ptr noundef %36, ptr noundef %38, i32 noundef %2, i32 noundef %4, i32 noundef %6)
  br label %41

41:                                               ; preds = %40, %39
  tail call void @free(ptr noundef %36) #5
  %42 = mul i32 %29, %6
  %43 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %42, i32 noundef 4, i32 noundef 3) #5
  br label %44

44:                                               ; preds = %7, %41
  %.0 = phi i32 [ 0, %41 ], [ 1, %7 ]
  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 void @save_bw(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #3

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

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

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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0,1) }

!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}


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