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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.130 = external hidden unnamed_addr constant [74 x i8], align 1

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) #0

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

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

declare i32 @liquid_firdes_kaiser(i32 noundef, float noundef, float noundef, float noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @rresamp_crcf_create_kaiser(i32 noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3, float noundef %4) #4 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca float, 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
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store float %3, ptr %10, align 4, !tbaa !9
  store float %4, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = call i32 @liquid_gcd(i32 noundef %19, i32 noundef %20)
  store i32 %21, ptr %12, align 4, !tbaa !5
  %22 = load i32, ptr %12, align 4, !tbaa !5
  %23 = load i32, ptr %7, align 4, !tbaa !5
  %24 = udiv i32 %23, %22
  store i32 %24, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr %12, align 4, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !5
  %27 = udiv i32 %26, %25
  store i32 %27, ptr %8, align 4, !tbaa !5
  %28 = load float, ptr %10, align 4, !tbaa !9
  %29 = fcmp olt float %28, 0.000000e+00
  br i1 %29, label %30, label %44

30:                                               ; preds = %5
  %31 = load i32, ptr %7, align 4, !tbaa !5
  %32 = load i32, ptr %8, align 4, !tbaa !5
  %33 = icmp ugt i32 %31, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  br label %42

35:                                               ; preds = %30
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = uitofp i32 %36 to float
  %38 = fmul float 5.000000e-01, %37
  %39 = load i32, ptr %8, align 4, !tbaa !5
  %40 = uitofp i32 %39 to float
  %41 = fdiv float %38, %40
  br label %42

42:                                               ; preds = %35, %34
  %43 = phi float [ 5.000000e-01, %34 ], [ %41, %35 ]
  store float %43, ptr %10, align 4, !tbaa !9
  br label %52

44:                                               ; preds = %5
  %45 = load float, ptr %10, align 4, !tbaa !9
  %46 = fcmp ogt float %45, 5.000000e-01
  br i1 %46, label %47, label %51

47:                                               ; preds = %44
  %48 = load float, ptr %10, align 4, !tbaa !9
  %49 = fpext float %48 to double
  %50 = call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef @.str.126, i32 noundef 103, ptr noundef @.str.130, ptr noundef @.str.2, double noundef %49)
  store ptr %50, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %118

51:                                               ; preds = %44
  br label %52

52:                                               ; preds = %51, %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %53 = load i32, ptr %7, align 4, !tbaa !5
  %54 = mul i32 2, %53
  %55 = load i32, ptr %9, align 4, !tbaa !5
  %56 = mul i32 %54, %55
  %57 = add i32 %56, 1
  store i32 %57, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #5
  %58 = load i32, ptr %14, align 4, !tbaa !5
  %59 = zext i32 %58 to i64
  %60 = mul i64 %59, 4
  %61 = call noalias ptr @malloc(i64 noundef %60) #6
  store ptr %61, ptr %15, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %62 = load i32, ptr %14, align 4, !tbaa !5
  %63 = zext i32 %62 to i64
  %64 = mul i64 %63, 4
  %65 = call noalias ptr @malloc(i64 noundef %64) #6
  store ptr %65, ptr %16, align 8, !tbaa !11
  %66 = load i32, ptr %14, align 4, !tbaa !5
  %67 = load float, ptr %10, align 4, !tbaa !9
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = uitofp i32 %68 to float
  %70 = fdiv float %67, %69
  %71 = load float, ptr %11, align 4, !tbaa !9
  %72 = load ptr, ptr %15, align 8, !tbaa !11
  %73 = call i32 @liquid_firdes_kaiser(i32 noundef %66, float noundef %70, float noundef %71, float noundef 0.000000e+00, ptr noundef %72)
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %88, %52
  %75 = load i32, ptr %17, align 4, !tbaa !5
  %76 = load i32, ptr %14, align 4, !tbaa !5
  %77 = icmp ult i32 %75, %76
  br i1 %77, label %78, label %91

78:                                               ; preds = %74
  %79 = load ptr, ptr %15, align 8, !tbaa !11
  %80 = load i32, ptr %17, align 4, !tbaa !5
  %81 = zext i32 %80 to i64
  %82 = getelementptr inbounds float, ptr %79, i64 %81
  %83 = load float, ptr %82, align 4, !tbaa !9
  %84 = load ptr, ptr %16, align 8, !tbaa !11
  %85 = load i32, ptr %17, align 4, !tbaa !5
  %86 = zext i32 %85 to i64
  %87 = getelementptr inbounds float, ptr %84, i64 %86
  store float %83, ptr %87, align 4, !tbaa !9
  br label %88

88:                                               ; preds = %78
  %89 = load i32, ptr %17, align 4, !tbaa !5
  %90 = add i32 %89, 1
  store i32 %90, ptr %17, align 4, !tbaa !5
  br label %74, !llvm.loop !13

91:                                               ; preds = %74
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #5
  %92 = load i32, ptr %7, align 4, !tbaa !5
  %93 = load i32, ptr %8, align 4, !tbaa !5
  %94 = load i32, ptr %9, align 4, !tbaa !5
  %95 = load ptr, ptr %16, align 8, !tbaa !11
  %96 = call ptr @rresamp_crcf_create(i32 noundef %92, i32 noundef %93, i32 noundef %94, ptr noundef %95)
  store ptr %96, ptr %18, align 8, !tbaa !11
  %97 = load ptr, ptr %18, align 8, !tbaa !11
  %98 = load float, ptr %10, align 4, !tbaa !9
  %99 = fmul float 2.000000e+00, %98
  %100 = load ptr, ptr %18, align 8, !tbaa !11
  %101 = getelementptr inbounds %struct.rresamp_crcf_s, ptr %100, i32 0, i32 1
  %102 = load i32, ptr %101, align 4, !tbaa !15
  %103 = uitofp i32 %102 to float
  %104 = load ptr, ptr %18, align 8, !tbaa !11
  %105 = getelementptr inbounds %struct.rresamp_crcf_s, ptr %104, i32 0, i32 0
  %106 = load i32, ptr %105, align 8, !tbaa !17
  %107 = uitofp i32 %106 to float
  %108 = fdiv float %103, %107
  %109 = call float @sqrtf(float noundef %108) #5
  %110 = fmul float %99, %109
  %111 = call i32 @rresamp_crcf_set_scale(ptr noundef %97, float noundef %110)
  %112 = load i32, ptr %12, align 4, !tbaa !5
  %113 = load ptr, ptr %18, align 8, !tbaa !11
  %114 = getelementptr inbounds %struct.rresamp_crcf_s, ptr %113, i32 0, i32 3
  store i32 %112, ptr %114, align 4, !tbaa !18
  %115 = load ptr, ptr %15, align 8, !tbaa !11
  call void @free(ptr noundef %115) #5
  %116 = load ptr, ptr %16, align 8, !tbaa !11
  call void @free(ptr noundef %116) #5
  %117 = load ptr, ptr %18, align 8, !tbaa !11
  store ptr %117, ptr %6, align 8
  store i32 1, ptr %13, align 4
  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
  br label %118

118:                                              ; preds = %91, %47
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %119 = load ptr, ptr %6, align 8
  ret ptr %119
}

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

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

attributes #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 = { 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 #3 = { 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 #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 4}
!16 = !{!"rresamp_crcf_s", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !12, i64 16}
!17 = !{!16, !6, i64 0}
!18 = !{!16, !6, i64 12}


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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [85 x i8], align 1
@.str.130 = external hidden unnamed_addr constant [74 x i8], align 1

declare ptr @liquid_error_config_fl(ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

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

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

declare i32 @liquid_firdes_kaiser(i32 noundef, float noundef, float noundef, float noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local ptr @rresamp_crcf_create_kaiser(i32 noundef %0, i32 noundef %1, i32 noundef %2, float noundef %3, float noundef %4) local_unnamed_addr #3 {
  %6 = tail call i32 @liquid_gcd(i32 noundef %0, i32 noundef %1) #6
  %7 = udiv i32 %0, %6
  %8 = udiv i32 %1, %6
  %9 = fcmp olt float %3, 0.000000e+00
  br i1 %9, label %10, label %17

10:                                               ; preds = %5
  %11 = icmp ugt i32 %7, %8
  %12 = uitofp i32 %7 to float
  %13 = fmul float %12, 5.000000e-01
  %14 = uitofp i32 %8 to float
  %15 = fdiv float %13, %14
  %16 = select i1 %11, float 5.000000e-01, float %15
  br label %22

17:                                               ; preds = %5
  %18 = fcmp ogt float %3, 5.000000e-01
  br i1 %18, label %19, label %._crit_edge

._crit_edge:                                      ; preds = %17
  %.pre = uitofp i32 %7 to float
  br label %22

19:                                               ; preds = %17
  %20 = fpext float %3 to double
  %21 = tail call ptr (ptr, i32, ptr, ...) @liquid_error_config_fl(ptr noundef nonnull @.str.126, i32 noundef 103, ptr noundef nonnull @.str.130, ptr noundef nonnull @.str.2, double noundef %20) #6
  br label %46

22:                                               ; preds = %._crit_edge, %10
  %.pre-phi = phi float [ %.pre, %._crit_edge ], [ %12, %10 ]
  %.043 = phi float [ %3, %._crit_edge ], [ %16, %10 ]
  %23 = shl i32 %7, 1
  %24 = mul i32 %23, %2
  %25 = or disjoint i32 %24, 1
  %26 = zext i32 %25 to i64
  %27 = shl nuw nsw i64 %26, 2
  %28 = tail call noalias ptr @malloc(i64 noundef %27) #7
  %29 = tail call noalias ptr @malloc(i64 noundef %27) #7
  %30 = fdiv float %.043, %.pre-phi
  %31 = tail call i32 @liquid_firdes_kaiser(i32 noundef %25, float noundef %30, float noundef %4, float noundef 0.000000e+00, ptr noundef %28) #6
  %32 = zext i32 %24 to i64
  %33 = shl nuw nsw i64 %32, 2
  %34 = or disjoint i64 %33, 4
  tail call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %29, ptr noundef nonnull align 4 dereferenceable(1) %28, i64 %34, i1 false), !tbaa !5
  %35 = tail call ptr @rresamp_crcf_create(i32 noundef %7, i32 noundef %8, i32 noundef %2, ptr noundef %29)
  %36 = fmul float %.043, 2.000000e+00
  %37 = getelementptr inbounds i8, ptr %35, i64 4
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = uitofp i32 %38 to float
  %40 = load i32, ptr %35, align 8, !tbaa !13
  %41 = uitofp i32 %40 to float
  %42 = fdiv float %39, %41
  %sqrt = tail call float @llvm.sqrt.f32(float %42)
  %43 = fmul float %36, %sqrt
  %44 = tail call i32 @rresamp_crcf_set_scale(ptr noundef nonnull %35, float noundef %43)
  %45 = getelementptr inbounds i8, ptr %35, i64 12
  store i32 %6, ptr %45, align 4, !tbaa !14
  tail call void @free(ptr noundef %28) #6
  tail call void @free(ptr noundef %29) #6
  br label %46

46:                                               ; preds = %22, %19
  %.0 = phi ptr [ %35, %22 ], [ %21, %19 ]
  ret ptr %.0
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.sqrt.f32(float) #4

; 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) #5

attributes #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 = { 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 #2 = { 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { nounwind }
attributes #7 = { 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 4}
!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}
!13 = !{!10, !11, i64 0}
!14 = !{!10, !11, i64 12}


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