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

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

@.str = external hidden unnamed_addr constant [90 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #1

declare i32 @iirfilt_rrrf_execute_block(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

declare i32 @iirfilt_rrrf_destroy(ptr noundef) #2

; Function Attrs: nounwind
declare double @sqrt(double noundef) #3

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i1 @llvm.is.fpclass.f32(float, i32 immarg) #4

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) #2

declare void @liquid_autotest_passed(...) #2

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #1

; Function Attrs: nounwind uwtable
define dso_local void @autotest_iirfilt_differentiator() #5 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #6
  store i32 400, ptr %1, align 4, !tbaa !5
  %7 = load i32, ptr %1, align 4, !tbaa !5
  %8 = zext i32 %7 to i64
  %9 = call ptr @llvm.stacksave.p0()
  store ptr %9, ptr %2, align 8
  %10 = alloca float, i64 %8, align 16
  store i64 %8, ptr %3, align 8
  %11 = load i32, ptr %1, align 4, !tbaa !5
  %12 = zext i32 %11 to i64
  %13 = alloca float, i64 %12, align 16
  store i64 %12, ptr %4, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #6
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %24, %0
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = icmp ult i32 %15, %16
  br i1 %17, label %18, label %27

18:                                               ; preds = %14
  %19 = load i32, ptr %5, align 4, !tbaa !5
  %20 = uitofp i32 %19 to float
  %21 = load i32, ptr %5, align 4, !tbaa !5
  %22 = zext i32 %21 to i64
  %23 = getelementptr inbounds float, ptr %10, i64 %22
  store float %20, ptr %23, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %18
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = add i32 %25, 1
  store i32 %26, ptr %5, align 4, !tbaa !5
  br label %14, !llvm.loop !11

27:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  %28 = call ptr @iirfilt_rrrf_create_differentiator()
  store ptr %28, ptr %6, align 8, !tbaa !13
  %29 = load ptr, ptr %6, align 8, !tbaa !13
  %30 = load i32, ptr %1, align 4, !tbaa !5
  %31 = call i32 @iirfilt_rrrf_execute_block(ptr noundef %29, ptr noundef %10, i32 noundef %30, ptr noundef %13)
  %32 = load ptr, ptr %6, align 8, !tbaa !13
  %33 = call i32 @iirfilt_rrrf_destroy(ptr noundef %32)
  %34 = load i32, ptr %1, align 4, !tbaa !5
  %35 = sub i32 %34, 1
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds float, ptr %13, i64 %36
  %38 = load float, ptr %37, align 4, !tbaa !9
  %39 = fsub float %38, 1.000000e+00
  %40 = fpext float %39 to double
  %41 = load i32, ptr %1, align 4, !tbaa !5
  %42 = sub i32 %41, 1
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds float, ptr %13, i64 %43
  %45 = load float, ptr %44, align 4, !tbaa !9
  %46 = fsub float %45, 1.000000e+00
  %47 = fpext float %46 to double
  %48 = load i32, ptr %1, align 4, !tbaa !5
  %49 = sub i32 %48, 1
  %50 = zext i32 %49 to i64
  %51 = getelementptr inbounds float, ptr %13, i64 %50
  %52 = load float, ptr %51, align 4, !tbaa !9
  %53 = fsub float %52, 1.000000e+00
  %54 = fpext float %53 to double
  %55 = load i32, ptr %1, align 4, !tbaa !5
  %56 = sub i32 %55, 1
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds float, ptr %13, i64 %57
  %59 = load float, ptr %58, align 4, !tbaa !9
  %60 = fsub float %59, 1.000000e+00
  %61 = fpext float %60 to double
  %62 = call double @llvm.fmuladd.f64(double %40, double %47, double 0.000000e+00)
  %63 = call double @sqrt(double noundef %62) #6
  %64 = fcmp ogt double %63, 0x3F847AE140000000
  br i1 %64, label %83, label %65

65:                                               ; preds = %27
  %66 = load i32, ptr %1, align 4, !tbaa !5
  %67 = sub i32 %66, 1
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %13, i64 %68
  %70 = load float, ptr %69, align 4, !tbaa !9
  %71 = call i1 @llvm.is.fpclass.f32(float %70, i32 3)
  br i1 %71, label %83, label %72

72:                                               ; preds = %65
  %73 = load i32, ptr %1, align 4, !tbaa !5
  %74 = sub i32 %73, 1
  %75 = zext i32 %74 to i64
  %76 = getelementptr inbounds float, ptr %13, i64 %75
  %77 = load float, ptr %76, align 4, !tbaa !9
  %78 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %78, label %83, label %79

79:                                               ; preds = %72
  %80 = call i1 @llvm.is.fpclass.f32(float 1.000000e+00, i32 3)
  br i1 %80, label %83, label %81

81:                                               ; preds = %79
  %82 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %82, label %83, label %114

83:                                               ; preds = %81, %79, %72, %65, %27
  %84 = load i32, ptr %1, align 4, !tbaa !5
  %85 = sub i32 %84, 1
  %86 = zext i32 %85 to i64
  %87 = getelementptr inbounds float, ptr %13, i64 %86
  %88 = load float, ptr %87, align 4, !tbaa !9
  %89 = fsub float %88, 1.000000e+00
  %90 = fpext float %89 to double
  %91 = load i32, ptr %1, align 4, !tbaa !5
  %92 = sub i32 %91, 1
  %93 = zext i32 %92 to i64
  %94 = getelementptr inbounds float, ptr %13, i64 %93
  %95 = load float, ptr %94, align 4, !tbaa !9
  %96 = fsub float %95, 1.000000e+00
  %97 = fpext float %96 to double
  %98 = load i32, ptr %1, align 4, !tbaa !5
  %99 = sub i32 %98, 1
  %100 = zext i32 %99 to i64
  %101 = getelementptr inbounds float, ptr %13, i64 %100
  %102 = load float, ptr %101, align 4, !tbaa !9
  %103 = fsub float %102, 1.000000e+00
  %104 = fpext float %103 to double
  %105 = load i32, ptr %1, align 4, !tbaa !5
  %106 = sub i32 %105, 1
  %107 = zext i32 %106 to i64
  %108 = getelementptr inbounds float, ptr %13, i64 %107
  %109 = load float, ptr %108, align 4, !tbaa !9
  %110 = fsub float %109, 1.000000e+00
  %111 = fpext float %110 to double
  %112 = call double @llvm.fmuladd.f64(double %90, double %97, double 0.000000e+00)
  %113 = call double @sqrt(double noundef %112) #6
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 76, ptr noundef @.str.4, double noundef %113, ptr noundef @.str.2, ptr noundef @.str.3, double noundef 0x3F847AE140000000)
  br label %115

114:                                              ; preds = %81
  call void (...) @liquid_autotest_passed()
  br label %115

115:                                              ; preds = %114, %83
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #6
  %116 = load ptr, ptr %2, align 8
  call void @llvm.stackrestore.p0(ptr %116)
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  ret void
}

declare ptr @iirfilt_rrrf_create_differentiator() #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind willreturn }
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 "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 = { 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 #6 = { 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 = !{!"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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !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"

@.str = external hidden unnamed_addr constant [90 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [35 x i8], align 1

declare i32 @iirfilt_rrrf_execute_block(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare i32 @iirfilt_rrrf_destroy(ptr noundef) local_unnamed_addr #0

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

declare void @liquid_autotest_failed_expr(ptr noundef, i32 noundef, ptr noundef, double noundef, ptr noundef, ptr noundef, double noundef) local_unnamed_addr #0

declare void @liquid_autotest_passed(...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @autotest_iirfilt_differentiator() local_unnamed_addr #2 {
vector.ph:
  %0 = alloca [400 x float], align 16
  %1 = alloca [400 x float], align 16
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next.1, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next.1, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %2 = uitofp <4 x i32> %vec.ind to <4 x float>
  %3 = uitofp <4 x i32> %step.add to <4 x float>
  %4 = getelementptr inbounds float, ptr %0, i64 %index
  %5 = getelementptr inbounds i8, ptr %4, i64 16
  store <4 x float> %2, ptr %4, align 16, !tbaa !5
  store <4 x float> %3, ptr %5, align 16, !tbaa !5
  %index.next = or disjoint i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %step.add.1 = add <4 x i32> %vec.ind, <i32 12, i32 12, i32 12, i32 12>
  %6 = uitofp <4 x i32> %vec.ind.next to <4 x float>
  %7 = uitofp <4 x i32> %step.add.1 to <4 x float>
  %8 = getelementptr inbounds float, ptr %0, i64 %index.next
  %9 = getelementptr inbounds i8, ptr %8, i64 16
  store <4 x float> %6, ptr %8, align 16, !tbaa !5
  store <4 x float> %7, ptr %9, align 16, !tbaa !5
  %index.next.1 = add nuw nsw i64 %index, 16
  %vec.ind.next.1 = add <4 x i32> %vec.ind, <i32 16, i32 16, i32 16, i32 16>
  %10 = icmp eq i64 %index.next.1, 400
  br i1 %10, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %11 = tail call ptr @iirfilt_rrrf_create_differentiator() #4
  %12 = call i32 @iirfilt_rrrf_execute_block(ptr noundef %11, ptr noundef nonnull %0, i32 noundef 400, ptr noundef nonnull %1) #4
  %13 = call i32 @iirfilt_rrrf_destroy(ptr noundef %11) #4
  %14 = getelementptr inbounds i8, ptr %1, i64 1596
  %15 = load float, ptr %14, align 4
  %16 = fadd float %15, -1.000000e+00
  %17 = fpext float %16 to double
  %18 = call double @llvm.fmuladd.f64(double %17, double %17, double 0.000000e+00)
  %sqrt = call double @llvm.sqrt.f64(double %18)
  %19 = fcmp ogt double %sqrt, 0x3F847AE140000000
  %20 = fcmp uno float %15, 0.000000e+00
  %or.cond = select i1 %19, i1 true, i1 %20
  br i1 %or.cond, label %21, label %22

21:                                               ; preds = %middle.block
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 76, ptr noundef nonnull @.str.4, double noundef %sqrt, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0x3F847AE140000000) #4
  br label %23

22:                                               ; preds = %middle.block
  call void (...) @liquid_autotest_passed() #4
  br label %23

23:                                               ; preds = %22, %21
  ret void
}

declare ptr @iirfilt_rrrf_create_differentiator() local_unnamed_addr #0

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.sqrt.f64(double) #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 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}


; Effective O3 passes: AggressiveInstCombinePass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,SROAPass,SimplifyCFGPass,TailCallElimPass