; LLVM IR from jgaeddert/liquid-dsp :: src/filter/src (filter_crcf)

; 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.rresamp_crcf_s = type { i32, i32, 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: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

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

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

declare i32 @liquid_firdes_prototype(i32 noundef, i32 noundef, i32 noundef, float noundef, float noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @rresamp_crcf_create(i32 noundef, i32 noundef, i32 noundef, ptr noundef) #4

declare i32 @liquid_gcd(i32 noundef, i32 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @rresamp_crcf_set_scale(ptr noundef, float noundef) #4

; Function Attrs: nounwind
declare float @sqrtf(float noundef) #2

; Function Attrs: nounwind uwtable
define dso_local ptr @rresamp_crcf_create_prototype(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4) #4 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = alloca float, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store float %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %20 = load i32, ptr %7, align 4, !tbaa !5
  %21 = load i32, ptr %8, align 4, !tbaa !5
  %22 = call i32 @liquid_gcd(i32 noundef %20, i32 noundef %21)
  store i32 %22, ptr %11, align 4, !tbaa !5
  %23 = load i32, ptr %11, align 4, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = udiv i32 %24, %23
  store i32 %25, ptr %7, align 4, !tbaa !5
  %26 = load i32, ptr %11, align 4, !tbaa !5
  %27 = load i32, ptr %8, align 4, !tbaa !5
  %28 = udiv i32 %27, %26
  store i32 %28, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %29 = load i32, ptr %7, align 4, !tbaa !5
  %30 = load i32, ptr %8, align 4, !tbaa !5
  %31 = icmp ult i32 %29, %30
  %32 = zext i1 %31 to i32
  store i32 %32, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %33 = load i32, ptr %12, align 4, !tbaa !5
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %37

35:                                               ; preds = %5
  %36 = load i32, ptr %8, align 4, !tbaa !5
  br label %39

37:                                               ; preds = %5
  %38 = load i32, ptr %7, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %37, %35
  %40 = phi i32 [ %36, %35 ], [ %38, %37 ]
  store i32 %40, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %41 = load i32, ptr %13, align 4, !tbaa !5
  %42 = mul i32 2, %41
  %43 = load i32, ptr %9, align 4, !tbaa !5
  %44 = mul i32 %42, %43
  %45 = add i32 %44, 1
  store i32 %45, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %46 = load i32, ptr %14, align 4, !tbaa !5
  %47 = zext i32 %46 to i64
  %48 = mul i64 %47, 4
  %49 = call noalias ptr @malloc(i64 noundef %48) #6
  store ptr %49, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %50 = load i32, ptr %14, align 4, !tbaa !5
  %51 = zext i32 %50 to i64
  %52 = mul i64 %51, 4
  %53 = call noalias ptr @malloc(i64 noundef %52) #6
  store ptr %53, ptr %16, align 8, !tbaa !11
  %54 = load i32, ptr %6, align 4, !tbaa !5
  %55 = load i32, ptr %13, align 4, !tbaa !5
  %56 = load i32, ptr %9, align 4, !tbaa !5
  %57 = load float, ptr %10, align 4, !tbaa !9
  %58 = load ptr, ptr %15, align 8, !tbaa !11
  %59 = call i32 @liquid_firdes_prototype(i32 noundef %54, i32 noundef %55, i32 noundef %56, float noundef %57, float noundef 0.000000e+00, ptr noundef %58)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %74, %39
  %61 = load i32, ptr %17, align 4, !tbaa !5
  %62 = load i32, ptr %14, align 4, !tbaa !5
  %63 = icmp ult i32 %61, %62
  br i1 %63, label %64, label %77

64:                                               ; preds = %60
  %65 = load ptr, ptr %15, align 8, !tbaa !11
  %66 = load i32, ptr %17, align 4, !tbaa !5
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds float, ptr %65, i64 %67
  %69 = load float, ptr %68, align 4, !tbaa !9
  %70 = load ptr, ptr %16, align 8, !tbaa !11
  %71 = load i32, ptr %17, align 4, !tbaa !5
  %72 = zext i32 %71 to i64
  %73 = getelementptr inbounds float, ptr %70, i64 %72
  store float %69, ptr %73, align 4, !tbaa !9
  br label %74

74:                                               ; preds = %64
  %75 = load i32, ptr %17, align 4, !tbaa !5
  %76 = add i32 %75, 1
  store i32 %76, ptr %17, align 4, !tbaa !5
  br label %60, !llvm.loop !13

77:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %78 = load i32, ptr %7, align 4, !tbaa !5
  %79 = load i32, ptr %8, align 4, !tbaa !5
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = load ptr, ptr %16, align 8, !tbaa !11
  %82 = call ptr @rresamp_crcf_create(i32 noundef %78, i32 noundef %79, i32 noundef %80, ptr noundef %81)
  store ptr %82, ptr %18, align 8, !tbaa !11
  %83 = load i32, ptr %11, align 4, !tbaa !5
  %84 = load ptr, ptr %18, align 8, !tbaa !11
  %85 = getelementptr inbounds %struct.rresamp_crcf_s, ptr %84, i32 0, i32 3
  store i32 %83, ptr %85, align 4, !tbaa !15
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #5
  %86 = load ptr, ptr %18, align 8, !tbaa !11
  %87 = call float @rresamp_crcf_get_rate(ptr noundef %86)
  store float %87, ptr %19, align 4, !tbaa !9
  %88 = load ptr, ptr %18, align 8, !tbaa !11
  %89 = load i32, ptr %12, align 4, !tbaa !5
  %90 = icmp ne i32 %89, 0
  br i1 %90, label %91, label %94

91:                                               ; preds = %77
  %92 = load float, ptr %19, align 4, !tbaa !9
  %93 = call float @sqrtf(float noundef %92) #5
  br label %98

94:                                               ; preds = %77
  %95 = load float, ptr %19, align 4, !tbaa !9
  %96 = call float @sqrtf(float noundef %95) #5
  %97 = fdiv float 1.000000e+00, %96
  br label %98

98:                                               ; preds = %94, %91
  %99 = phi float [ %93, %91 ], [ %97, %94 ]
  %100 = call i32 @rresamp_crcf_set_scale(ptr noundef %88, float noundef %99)
  %101 = load ptr, ptr %15, align 8, !tbaa !11
  call void @free(ptr noundef %101) #5
  %102 = load ptr, ptr %16, align 8, !tbaa !11
  call void @free(ptr noundef %102) #5
  %103 = load ptr, ptr %18, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  ret ptr %103
}

; Function Attrs: nounwind uwtable
declare dso_local float @rresamp_crcf_get_rate(ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { 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 #3 = { "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 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 }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!16, !6, i64 12}
!16 = !{!"rresamp_crcf_s", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !12, i64 16}


; 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: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

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

declare i32 @liquid_firdes_prototype(i32 noundef, i32 noundef, i32 noundef, float noundef, float noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @rresamp_crcf_create(i32 noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare i32 @liquid_gcd(i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @rresamp_crcf_set_scale(ptr noundef, float noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(write)
declare float @sqrtf(float noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @rresamp_crcf_create_prototype(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4) local_unnamed_addr #3 {
  %6 = tail call i32 @liquid_gcd(i32 noundef %1, i32 noundef %2) #7
  %7 = udiv i32 %1, %6
  %8 = udiv i32 %2, %6
  %9 = tail call i32 @llvm.umax.i32(i32 %7, i32 %8)
  %10 = shl i32 %9, 1
  %11 = mul i32 %10, %3
  %12 = or disjoint i32 %11, 1
  %13 = zext i32 %12 to i64
  %14 = shl nuw nsw i64 %13, 2
  %15 = tail call noalias ptr @malloc(i64 noundef %14) #8
  %16 = tail call noalias ptr @malloc(i64 noundef %14) #8
  %17 = tail call i32 @liquid_firdes_prototype(i32 noundef %0, i32 noundef %9, i32 noundef %3, float noundef %4, float noundef 0.000000e+00, ptr noundef %15) #7
  %18 = zext i32 %11 to i64
  %19 = shl nuw nsw i64 %18, 2
  %20 = or disjoint i64 %19, 4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %16, ptr noundef nonnull align 4 dereferenceable(1) %15, i64 %20, i1 false), !tbaa !5
  %21 = icmp ult i32 %7, %8
  %22 = tail call ptr @rresamp_crcf_create(i32 noundef %7, i32 noundef %8, i32 noundef %3, ptr noundef %16)
  %23 = getelementptr inbounds i8, ptr %22, i64 12
  store i32 %6, ptr %23, align 4, !tbaa !9
  %24 = tail call float @rresamp_crcf_get_rate(ptr noundef %22)
  %25 = tail call float @sqrtf(float noundef %24) #7
  %26 = fdiv float 1.000000e+00, %25
  %27 = select i1 %21, float %25, float %26
  %28 = tail call i32 @rresamp_crcf_set_scale(ptr noundef nonnull %22, float noundef %27)
  tail call void @free(ptr noundef %15) #7
  tail call void @free(ptr noundef %16) #7
  ret ptr %22
}

; Function Attrs: nounwind uwtable
declare dso_local float @rresamp_crcf_get_rate(ptr noundef) local_unnamed_addr #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.umax.i32(i32, i32) #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #6

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) 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 #1 = { 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 #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 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 nofree nounwind willreturn memory(write) "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { nounwind }
attributes #8 = { nounwind allocsize(0) }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 12}
!10 = !{!"rresamp_crcf_s", !11, i64 0, !11, i64 4, !11, i64 8, !11, i64 12, !12, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopIdiomRecognizePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass