; LLVM IR from BoysTownOrg/chapro :: firfb_prepare (cha_firfb_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_firfb_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 %124

25:                                               ; preds = %7
  %26 = load i32, ptr %15, align 4, !tbaa !9
  %27 = srem i32 %26, 2
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %33, label %29

29:                                               ; preds = %25
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = srem i32 %30, 2
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %34

33:                                               ; preds = %29, %25
  store i32 1, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %124

34:                                               ; preds = %29
  %35 = load ptr, ptr %9, align 8, !tbaa !5
  call void @cha_prepare(ptr noundef %35)
  %36 = load i32, ptr %15, align 4, !tbaa !9
  %37 = load ptr, ptr %9, 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 double, ptr %12, align 8, !tbaa !11
  %42 = fdiv double %41, 1.000000e+03
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds ptr, ptr %43, i64 2
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = getelementptr inbounds double, ptr %45, i64 0
  store double %42, ptr %46, align 8, !tbaa !11
  %47 = load i32, ptr %13, align 4, !tbaa !9
  %48 = load ptr, ptr %9, align 8, !tbaa !5
  %49 = getelementptr inbounds ptr, ptr %48, i64 1
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds i32, ptr %50, i64 4
  store i32 %47, ptr %51, align 4, !tbaa !9
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = load ptr, ptr %9, align 8, !tbaa !5
  %54 = getelementptr inbounds ptr, ptr %53, i64 1
  %55 = load ptr, ptr %54, align 8, !tbaa !5
  %56 = getelementptr inbounds i32, ptr %55, i64 1
  store i32 %52, ptr %56, align 4, !tbaa !9
  %57 = load i32, ptr %13, align 4, !tbaa !9
  %58 = mul nsw i32 %57, 2
  store i32 %58, ptr %19, align 4, !tbaa !9
  %59 = load i32, ptr %19, align 4, !tbaa !9
  %60 = add nsw i32 %59, 2
  store i32 %60, ptr %18, align 4, !tbaa !9
  %61 = load i32, ptr %15, align 4, !tbaa !9
  %62 = load i32, ptr %13, align 4, !tbaa !9
  %63 = icmp slt i32 %61, %62
  br i1 %63, label %64, label %72

64:                                               ; preds = %34
  %65 = load i32, ptr %15, align 4, !tbaa !9
  %66 = add nsw i32 %65, 1
  %67 = mul nsw i32 %66, 2
  %68 = load i32, ptr %13, align 4, !tbaa !9
  %69 = load i32, ptr %15, align 4, !tbaa !9
  %70 = sdiv i32 %68, %69
  %71 = mul nsw i32 %67, %70
  br label %74

72:                                               ; preds = %34
  %73 = load i32, ptr %18, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %72, %64
  %75 = phi i32 [ %71, %64 ], [ %73, %72 ]
  store i32 %75, ptr %20, align 4, !tbaa !9
  %76 = load ptr, ptr %9, align 8, !tbaa !5
  %77 = load i32, ptr %18, align 4, !tbaa !9
  %78 = call ptr @cha_allocate(ptr noundef %76, i32 noundef %77, i32 noundef 4, i32 noundef 6)
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = load i32, ptr %18, align 4, !tbaa !9
  %81 = call ptr @cha_allocate(ptr noundef %79, i32 noundef %80, i32 noundef 4, i32 noundef 7)
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = load i32, ptr %11, align 4, !tbaa !9
  %84 = load i32, ptr %13, align 4, !tbaa !9
  %85 = load i32, ptr %15, align 4, !tbaa !9
  %86 = add nsw i32 %84, %85
  %87 = mul nsw i32 %83, %86
  %88 = call ptr @cha_allocate(ptr noundef %82, i32 noundef %87, i32 noundef 4, i32 noundef 8)
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = load i32, ptr %11, align 4, !tbaa !9
  %91 = load i32, ptr %20, align 4, !tbaa !9
  %92 = mul nsw i32 %90, %91
  %93 = call ptr @cha_allocate(ptr noundef %89, i32 noundef %92, i32 noundef 4, i32 noundef 5)
  %94 = load i32, ptr %11, align 4, !tbaa !9
  %95 = load i32, ptr %13, align 4, !tbaa !9
  %96 = mul nsw i32 %94, %95
  %97 = sext i32 %96 to i64
  %98 = call noalias ptr @calloc(i64 noundef %97, i64 noundef 4) #7
  store ptr %98, ptr %16, align 8, !tbaa !5
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  %100 = getelementptr inbounds ptr, ptr %99, i64 5
  %101 = load ptr, ptr %100, align 8, !tbaa !5
  store ptr %101, ptr %17, align 8, !tbaa !5
  %102 = load ptr, ptr %16, align 8, !tbaa !5
  %103 = load ptr, ptr %10, align 8, !tbaa !5
  %104 = load i32, ptr %11, align 4, !tbaa !9
  %105 = load i32, ptr %13, align 4, !tbaa !9
  %106 = load i32, ptr %14, align 4, !tbaa !9
  %107 = load double, ptr %12, align 8, !tbaa !11
  call void @fir_filterbank(ptr noundef %102, ptr noundef %103, i32 noundef %104, i32 noundef %105, i32 noundef %106, double noundef %107)
  %108 = load ptr, ptr %16, align 8, !tbaa !5
  %109 = load ptr, ptr %17, align 8, !tbaa !5
  %110 = load i32, ptr %11, align 4, !tbaa !9
  %111 = load i32, ptr %13, align 4, !tbaa !9
  %112 = load i32, ptr %15, align 4, !tbaa !9
  call void @fir_transform(ptr noundef %108, ptr noundef %109, i32 noundef %110, i32 noundef %111, i32 noundef %112)
  %113 = load ptr, ptr %16, align 8, !tbaa !5
  call void @free(ptr noundef %113) #6
  %114 = load ptr, ptr %9, align 8, !tbaa !5
  %115 = load i32, ptr %11, align 4, !tbaa !9
  %116 = load i32, ptr %15, align 4, !tbaa !9
  %117 = mul nsw i32 %115, %116
  %118 = call ptr @cha_allocate(ptr noundef %114, i32 noundef %117, i32 noundef 4, i32 noundef 9)
  %119 = load ptr, ptr %9, align 8, !tbaa !5
  %120 = load i32, ptr %11, align 4, !tbaa !9
  %121 = load i32, ptr %15, align 4, !tbaa !9
  %122 = mul nsw i32 %120, %121
  %123 = call ptr @cha_allocate(ptr noundef %119, i32 noundef %122, i32 noundef 4, i32 noundef 3)
  store i32 0, ptr %8, align 4
  store i32 1, ptr %21, align 4
  br label %124

124:                                              ; preds = %74, %33, %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
  %125 = load i32, ptr %8, align 4
  ret i32 %125
}

; 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: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #3

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

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

; 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 = { 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 #4 = { 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 #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_firfb_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 %45, label %9

9:                                                ; preds = %7
  %10 = or i32 %6, %4
  %11 = and i32 %10, 1
  %or.cond = icmp eq i32 %11, 0
  br i1 %or.cond, label %12, label %45

12:                                               ; preds = %9
  tail call void @cha_prepare(ptr noundef %0) #5
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  store i32 %6, ptr %14, align 4, !tbaa !9
  %15 = fdiv double %3, 1.000000e+03
  %16 = getelementptr inbounds i8, ptr %0, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  store double %15, ptr %17, align 8, !tbaa !11
  %18 = getelementptr inbounds i8, ptr %14, i64 16
  store i32 %4, ptr %18, align 4, !tbaa !9
  %19 = getelementptr inbounds i8, ptr %14, i64 4
  store i32 %2, ptr %19, align 4, !tbaa !9
  %20 = shl nsw i32 %4, 1
  %21 = add nuw nsw i32 %20, 2
  %22 = icmp slt i32 %6, %4
  br i1 %22, label %23, label %28

23:                                               ; preds = %12
  %24 = shl nuw i32 %6, 1
  %25 = add nuw nsw i32 %24, 2
  %26 = udiv i32 %4, %6
  %27 = mul nsw i32 %26, %25
  br label %28

28:                                               ; preds = %12, %23
  %29 = phi i32 [ %27, %23 ], [ %21, %12 ]
  %30 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %21, i32 noundef 4, i32 noundef 6) #5
  %31 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %21, i32 noundef 4, i32 noundef 7) #5
  %32 = add nsw i32 %6, %4
  %33 = mul nsw i32 %32, %2
  %34 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %33, i32 noundef 4, i32 noundef 8) #5
  %35 = mul nsw i32 %29, %2
  %36 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %35, i32 noundef 4, i32 noundef 5) #5
  %37 = mul nsw i32 %4, %2
  %38 = sext i32 %37 to i64
  %39 = tail call noalias ptr @calloc(i64 noundef %38, i64 noundef 4) #6
  %40 = getelementptr inbounds i8, ptr %0, i64 40
  %41 = load ptr, ptr %40, align 8, !tbaa !5
  tail call void @fir_filterbank(ptr noundef %39, ptr noundef %1, i32 noundef %2, i32 noundef %4, i32 noundef %5, double noundef %3)
  tail call void @fir_transform(ptr noundef %39, ptr noundef %41, i32 noundef %2, i32 noundef %4, i32 noundef %6)
  tail call void @free(ptr noundef %39) #5
  %42 = mul nsw i32 %6, %2
  %43 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %42, i32 noundef 4, i32 noundef 9) #5
  %44 = tail call ptr @cha_allocate(ptr noundef nonnull %0, i32 noundef %42, i32 noundef 4, i32 noundef 3) #5
  br label %45

45:                                               ; preds = %9, %7, %28
  %.0 = phi i32 [ 0, %28 ], [ 1, %7 ], [ 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: 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 #2

; 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 #3

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

; 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 = { 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 #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 = { 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,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass