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

; 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 void @iirfilt_crcf_bench(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3, i32 noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca float, align 4
  %13 = alloca float, align 4
  %14 = alloca float, align 4
  %15 = alloca float, align 4
  %16 = alloca ptr, align 8
  %17 = alloca [4 x { float, float }], align 16
  %18 = alloca [4 x { float, float }], align 16
  %19 = alloca { float, float }, align 4
  %20 = alloca { float, float }, align 4
  %21 = alloca { float, float }, align 4
  %22 = alloca { float, float }, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  store i32 %4, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %23 = load i32, ptr %10, align 4, !tbaa !9
  %24 = icmp eq i32 %23, 1
  br i1 %24, label %25, label %37

25:                                               ; preds = %5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load i64, ptr %26, align 8, !tbaa !11
  %28 = mul i64 %27, 1000
  store i64 %28, ptr %26, align 8, !tbaa !11
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = uitofp i32 %29 to double
  %31 = call double @llvm.fmuladd.f64(double 1.530000e+01, double %30, double 1.280000e+02)
  %32 = fptoui double %31 to i32
  %33 = zext i32 %32 to i64
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = load i64, ptr %34, align 8, !tbaa !11
  %36 = udiv i64 %35, %33
  store i64 %36, ptr %34, align 8, !tbaa !11
  br label %49

37:                                               ; preds = %5
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = load i64, ptr %38, align 8, !tbaa !11
  %40 = mul i64 %39, 800
  store i64 %40, ptr %38, align 8, !tbaa !11
  %41 = load i32, ptr %9, align 4, !tbaa !9
  %42 = uitofp i32 %41 to double
  %43 = call double @llvm.fmuladd.f64(double 5.330000e+01, double %42, double 9.300000e+01)
  %44 = fptoui double %43 to i32
  %45 = zext i32 %44 to i64
  %46 = load ptr, ptr %8, align 8, !tbaa !5
  %47 = load i64, ptr %46, align 8, !tbaa !11
  %48 = udiv i64 %47, %45
  store i64 %48, ptr %46, align 8, !tbaa !11
  br label %49

49:                                               ; preds = %37, %25
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store float 0x3FC99999A0000000, ptr %12, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store float 0.000000e+00, ptr %13, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store float 0x3FB99999A0000000, ptr %14, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store float 6.000000e+01, ptr %15, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #5
  %50 = load i32, ptr %10, align 4, !tbaa !9
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = load float, ptr %12, align 4, !tbaa !13
  %53 = load float, ptr %13, align 4, !tbaa !13
  %54 = load float, ptr %14, align 4, !tbaa !13
  %55 = load float, ptr %15, align 4, !tbaa !13
  %56 = call ptr @iirfilt_crcf_create_prototype(i32 noundef 0, i32 noundef 0, i32 noundef %50, i32 noundef %51, float noundef %52, float noundef %53, float noundef %54, float noundef %55)
  store ptr %56, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 32, ptr %17) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr %18) #5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %57

57:                                               ; preds = %71, %49
  %58 = load i32, ptr %11, align 4, !tbaa !9
  %59 = icmp ult i32 %58, 4
  br i1 %59, label %60, label %74

60:                                               ; preds = %57
  %61 = call float (...) @randnf()
  %62 = call float (...) @randnf()
  %63 = fmul float 0.000000e+00, %62
  %64 = fmul float 1.000000e+00, %62
  %65 = fadd float %61, %63
  %66 = load i32, ptr %11, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds [4 x { float, float }], ptr %17, i64 0, i64 %67
  %69 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 0
  %70 = getelementptr inbounds { float, float }, ptr %68, i32 0, i32 1
  store float %65, ptr %69, align 8
  store float %64, ptr %70, align 4
  br label %71

71:                                               ; preds = %60
  %72 = load i32, ptr %11, align 4, !tbaa !9
  %73 = add i32 %72, 1
  store i32 %73, ptr %11, align 4, !tbaa !9
  br label %57, !llvm.loop !15

74:                                               ; preds = %57
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = call i32 @getrusage(i32 noundef 0, ptr noundef %75) #5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %77

77:                                               ; preds = %128, %74
  %78 = load i32, ptr %11, align 4, !tbaa !9
  %79 = zext i32 %78 to i64
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = load i64, ptr %80, align 8, !tbaa !11
  %82 = icmp ult i64 %79, %81
  br i1 %82, label %83, label %131

83:                                               ; preds = %77
  %84 = load ptr, ptr %16, align 8, !tbaa !5
  %85 = getelementptr inbounds [4 x { float, float }], ptr %17, i64 0, i64 0
  %86 = getelementptr inbounds { float, float }, ptr %85, i32 0, i32 0
  %87 = load float, ptr %86, align 16
  %88 = getelementptr inbounds { float, float }, ptr %85, i32 0, i32 1
  %89 = load float, ptr %88, align 4
  %90 = getelementptr inbounds [4 x { float, float }], ptr %18, i64 0, i64 0
  %91 = getelementptr inbounds { float, float }, ptr %19, i32 0, i32 0
  %92 = getelementptr inbounds { float, float }, ptr %19, i32 0, i32 1
  store float %87, ptr %91, align 4
  store float %89, ptr %92, align 4
  %93 = load <2 x float>, ptr %19, align 4
  %94 = call i32 @iirfilt_crcf_execute(ptr noundef %84, <2 x float> noundef %93, ptr noundef %90)
  %95 = load ptr, ptr %16, align 8, !tbaa !5
  %96 = getelementptr inbounds [4 x { float, float }], ptr %17, i64 0, i64 1
  %97 = getelementptr inbounds { float, float }, ptr %96, i32 0, i32 0
  %98 = load float, ptr %97, align 8
  %99 = getelementptr inbounds { float, float }, ptr %96, i32 0, i32 1
  %100 = load float, ptr %99, align 4
  %101 = getelementptr inbounds [4 x { float, float }], ptr %18, i64 0, i64 1
  %102 = getelementptr inbounds { float, float }, ptr %20, i32 0, i32 0
  %103 = getelementptr inbounds { float, float }, ptr %20, i32 0, i32 1
  store float %98, ptr %102, align 4
  store float %100, ptr %103, align 4
  %104 = load <2 x float>, ptr %20, align 4
  %105 = call i32 @iirfilt_crcf_execute(ptr noundef %95, <2 x float> noundef %104, ptr noundef %101)
  %106 = load ptr, ptr %16, align 8, !tbaa !5
  %107 = getelementptr inbounds [4 x { float, float }], ptr %17, i64 0, i64 2
  %108 = getelementptr inbounds { float, float }, ptr %107, i32 0, i32 0
  %109 = load float, ptr %108, align 16
  %110 = getelementptr inbounds { float, float }, ptr %107, i32 0, i32 1
  %111 = load float, ptr %110, align 4
  %112 = getelementptr inbounds [4 x { float, float }], ptr %18, i64 0, i64 2
  %113 = getelementptr inbounds { float, float }, ptr %21, i32 0, i32 0
  %114 = getelementptr inbounds { float, float }, ptr %21, i32 0, i32 1
  store float %109, ptr %113, align 4
  store float %111, ptr %114, align 4
  %115 = load <2 x float>, ptr %21, align 4
  %116 = call i32 @iirfilt_crcf_execute(ptr noundef %106, <2 x float> noundef %115, ptr noundef %112)
  %117 = load ptr, ptr %16, align 8, !tbaa !5
  %118 = getelementptr inbounds [4 x { float, float }], ptr %17, i64 0, i64 3
  %119 = getelementptr inbounds { float, float }, ptr %118, i32 0, i32 0
  %120 = load float, ptr %119, align 8
  %121 = getelementptr inbounds { float, float }, ptr %118, i32 0, i32 1
  %122 = load float, ptr %121, align 4
  %123 = getelementptr inbounds [4 x { float, float }], ptr %18, i64 0, i64 3
  %124 = getelementptr inbounds { float, float }, ptr %22, i32 0, i32 0
  %125 = getelementptr inbounds { float, float }, ptr %22, i32 0, i32 1
  store float %120, ptr %124, align 4
  store float %122, ptr %125, align 4
  %126 = load <2 x float>, ptr %22, align 4
  %127 = call i32 @iirfilt_crcf_execute(ptr noundef %117, <2 x float> noundef %126, ptr noundef %123)
  br label %128

128:                                              ; preds = %83
  %129 = load i32, ptr %11, align 4, !tbaa !9
  %130 = add i32 %129, 1
  store i32 %130, ptr %11, align 4, !tbaa !9
  br label %77, !llvm.loop !17

131:                                              ; preds = %77
  %132 = load ptr, ptr %7, align 8, !tbaa !5
  %133 = call i32 @getrusage(i32 noundef 0, ptr noundef %132) #5
  %134 = load ptr, ptr %8, align 8, !tbaa !5
  %135 = load i64, ptr %134, align 8, !tbaa !11
  %136 = mul i64 %135, 4
  store i64 %136, ptr %134, align 8, !tbaa !11
  %137 = load ptr, ptr %16, align 8, !tbaa !5
  %138 = call i32 @iirfilt_crcf_destroy(ptr noundef %137)
  call void @llvm.lifetime.end.p0(i64 32, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, 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 void
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

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

declare float @randnf(...) #3

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) #4

declare i32 @iirfilt_crcf_execute(ptr noundef, <2 x float> noundef, ptr noundef) #3

declare i32 @iirfilt_crcf_destroy(ptr 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"="64" "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 "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 }

!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 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !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: nounwind uwtable
define dso_local void @iirfilt_crcf_bench(ptr noundef %0, ptr noundef %1, ptr nocapture noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = alloca [4 x { float, float }], align 16
  %7 = icmp eq i32 %4, 1
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = uitofp i32 %3 to double
  br i1 %7, label %10, label %13

10:                                               ; preds = %5
  %11 = mul i64 %8, 1000
  %12 = tail call double @llvm.fmuladd.f64(double %9, double 1.530000e+01, double 1.280000e+02)
  br label %16

13:                                               ; preds = %5
  %14 = mul i64 %8, 800
  %15 = tail call double @llvm.fmuladd.f64(double %9, double 5.330000e+01, double 9.300000e+01)
  br label %16

16:                                               ; preds = %13, %10
  %.sink38 = phi double [ %15, %13 ], [ %12, %10 ]
  %.sink = phi i64 [ %14, %13 ], [ %11, %10 ]
  %17 = fptoui double %.sink38 to i32
  %18 = zext i32 %17 to i64
  %19 = udiv i64 %.sink, %18
  store i64 %19, ptr %2, align 8, !tbaa !5
  %20 = tail call ptr @iirfilt_crcf_create_prototype(i32 noundef 0, i32 noundef 0, i32 noundef %4, i32 noundef %3, float noundef 0x3FC99999A0000000, float noundef 0.000000e+00, float noundef 0x3FB99999A0000000, float noundef 6.000000e+01) #5
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #5
  %21 = tail call float (...) @randnf() #5
  %22 = tail call float (...) @randnf() #5
  %23 = tail call float (...) @randnf() #5
  %24 = tail call float (...) @randnf() #5
  %25 = tail call float (...) @randnf() #5
  %26 = tail call float (...) @randnf() #5
  %27 = tail call float (...) @randnf() #5
  %28 = tail call float (...) @randnf() #5
  %29 = tail call i32 @getrusage(i32 noundef 0, ptr noundef %0) #5
  %30 = load i64, ptr %2, align 8, !tbaa !5
  %.not = icmp eq i64 %30, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %16
  %31 = fmul float %28, 0.000000e+00
  %32 = fadd float %27, %31
  %33 = fmul float %26, 0.000000e+00
  %34 = fadd float %25, %33
  %35 = fmul float %24, 0.000000e+00
  %36 = fadd float %23, %35
  %37 = fmul float %22, 0.000000e+00
  %38 = fadd float %21, %37
  %.sroa.06.0.vec.insert = insertelement <2 x float> poison, float %38, i64 0
  %.sroa.06.4.vec.insert = insertelement <2 x float> %.sroa.06.0.vec.insert, float %22, i64 1
  %39 = getelementptr inbounds i8, ptr %6, i64 8
  %.sroa.04.0.vec.insert = insertelement <2 x float> poison, float %36, i64 0
  %.sroa.04.4.vec.insert = insertelement <2 x float> %.sroa.04.0.vec.insert, float %24, i64 1
  %40 = getelementptr inbounds i8, ptr %6, i64 16
  %.sroa.02.0.vec.insert = insertelement <2 x float> poison, float %34, i64 0
  %.sroa.02.4.vec.insert = insertelement <2 x float> %.sroa.02.0.vec.insert, float %26, i64 1
  %41 = getelementptr inbounds i8, ptr %6, i64 24
  %.sroa.0.0.vec.insert = insertelement <2 x float> poison, float %32, i64 0
  %.sroa.0.4.vec.insert = insertelement <2 x float> %.sroa.0.0.vec.insert, float %28, i64 1
  br label %42

42:                                               ; preds = %.lr.ph, %42
  %.134 = phi i32 [ 0, %.lr.ph ], [ %47, %42 ]
  %43 = call i32 @iirfilt_crcf_execute(ptr noundef %20, <2 x float> noundef %.sroa.06.4.vec.insert, ptr noundef nonnull %6) #5
  %44 = call i32 @iirfilt_crcf_execute(ptr noundef %20, <2 x float> noundef %.sroa.04.4.vec.insert, ptr noundef nonnull %39) #5
  %45 = call i32 @iirfilt_crcf_execute(ptr noundef %20, <2 x float> noundef %.sroa.02.4.vec.insert, ptr noundef nonnull %40) #5
  %46 = call i32 @iirfilt_crcf_execute(ptr noundef %20, <2 x float> noundef %.sroa.0.4.vec.insert, ptr noundef nonnull %41) #5
  %47 = add i32 %.134, 1
  %48 = zext i32 %47 to i64
  %49 = load i64, ptr %2, align 8, !tbaa !5
  %50 = icmp ugt i64 %49, %48
  br i1 %50, label %42, label %._crit_edge, !llvm.loop !9

._crit_edge:                                      ; preds = %42, %16
  %51 = call i32 @getrusage(i32 noundef 0, ptr noundef %1) #5
  %52 = load i64, ptr %2, align 8, !tbaa !5
  %53 = shl i64 %52, 2
  store i64 %53, ptr %2, align 8, !tbaa !5
  %54 = call i32 @iirfilt_crcf_destroy(ptr noundef %20) #5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #5
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.fmuladd.f64(double, double, double) #2

declare ptr @iirfilt_crcf_create_prototype(i32 noundef, i32 noundef, i32 noundef, i32 noundef, float noundef, float noundef, float noundef, float noundef) local_unnamed_addr #3

declare float @randnf(...) local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @getrusage(i32 noundef, ptr noundef) local_unnamed_addr #4

declare i32 @iirfilt_crcf_execute(ptr noundef, <2 x float> noundef, ptr noundef) local_unnamed_addr #3

declare i32 @iirfilt_crcf_destroy(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress 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"="64" "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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 "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 }

!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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass