; 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.1 = external hidden unnamed_addr constant [39 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

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

15:                                               ; preds = %29, %0
  %16 = load i32, ptr %6, align 4, !tbaa !5
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = icmp ult i32 %16, %17
  br i1 %18, label %19, label %32

19:                                               ; preds = %15
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = load i32, ptr %1, align 4, !tbaa !5
  %22 = icmp ult i32 %20, %21
  %23 = zext i1 %22 to i64
  %24 = select i1 %22, i32 1, i32 0
  %25 = sitofp i32 %24 to float
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = zext i32 %26 to i64
  %28 = getelementptr inbounds float, ptr %11, i64 %27
  store float %25, ptr %28, align 4, !tbaa !9
  br label %29

29:                                               ; preds = %19
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = add i32 %30, 1
  store i32 %31, ptr %6, align 4, !tbaa !5
  br label %15, !llvm.loop !11

32:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %33 = call ptr @iirfilt_rrrf_create_integrator()
  store ptr %33, ptr %7, align 8, !tbaa !13
  %34 = load ptr, ptr %7, align 8, !tbaa !13
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = call i32 @iirfilt_rrrf_execute_block(ptr noundef %34, ptr noundef %11, i32 noundef %35, ptr noundef %14)
  %37 = load ptr, ptr %7, align 8, !tbaa !13
  %38 = call i32 @iirfilt_rrrf_destroy(ptr noundef %37)
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sub i32 %39, 1
  %41 = zext i32 %40 to i64
  %42 = getelementptr inbounds float, ptr %14, i64 %41
  %43 = load float, ptr %42, align 4, !tbaa !9
  %44 = load i32, ptr %1, align 4, !tbaa !5
  %45 = uitofp i32 %44 to float
  %46 = fsub float %43, %45
  %47 = fpext float %46 to double
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = sub i32 %48, 1
  %50 = zext i32 %49 to i64
  %51 = getelementptr inbounds float, ptr %14, i64 %50
  %52 = load float, ptr %51, align 4, !tbaa !9
  %53 = load i32, ptr %1, align 4, !tbaa !5
  %54 = uitofp i32 %53 to float
  %55 = fsub float %52, %54
  %56 = fpext float %55 to double
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = sub i32 %57, 1
  %59 = zext i32 %58 to i64
  %60 = getelementptr inbounds float, ptr %14, i64 %59
  %61 = load float, ptr %60, align 4, !tbaa !9
  %62 = load i32, ptr %1, align 4, !tbaa !5
  %63 = uitofp i32 %62 to float
  %64 = fsub float %61, %63
  %65 = fpext float %64 to double
  %66 = load i32, ptr %2, align 4, !tbaa !5
  %67 = sub i32 %66, 1
  %68 = zext i32 %67 to i64
  %69 = getelementptr inbounds float, ptr %14, i64 %68
  %70 = load float, ptr %69, align 4, !tbaa !9
  %71 = load i32, ptr %1, align 4, !tbaa !5
  %72 = uitofp i32 %71 to float
  %73 = fsub float %70, %72
  %74 = fpext float %73 to double
  %75 = call double @llvm.fmuladd.f64(double %47, double %56, double 0.000000e+00)
  %76 = call double @sqrt(double noundef %75) #6
  %77 = fcmp ogt double %76, 0x3F847AE140000000
  br i1 %77, label %100, label %78

78:                                               ; preds = %32
  %79 = load i32, ptr %2, align 4, !tbaa !5
  %80 = sub i32 %79, 1
  %81 = zext i32 %80 to i64
  %82 = getelementptr inbounds float, ptr %14, i64 %81
  %83 = load float, ptr %82, align 4, !tbaa !9
  %84 = call i1 @llvm.is.fpclass.f32(float %83, i32 3)
  br i1 %84, label %100, label %85

85:                                               ; preds = %78
  %86 = load i32, ptr %2, align 4, !tbaa !5
  %87 = sub i32 %86, 1
  %88 = zext i32 %87 to i64
  %89 = getelementptr inbounds float, ptr %14, i64 %88
  %90 = load float, ptr %89, align 4, !tbaa !9
  %91 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %91, label %100, label %92

92:                                               ; preds = %85
  %93 = load i32, ptr %1, align 4, !tbaa !5
  %94 = uitofp i32 %93 to float
  %95 = call i1 @llvm.is.fpclass.f32(float %94, i32 3)
  br i1 %95, label %100, label %96

96:                                               ; preds = %92
  %97 = load i32, ptr %1, align 4, !tbaa !5
  %98 = uitofp i32 %97 to float
  %99 = call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 3)
  br i1 %99, label %100, label %139

100:                                              ; preds = %96, %92, %85, %78, %32
  %101 = load i32, ptr %2, align 4, !tbaa !5
  %102 = sub i32 %101, 1
  %103 = zext i32 %102 to i64
  %104 = getelementptr inbounds float, ptr %14, i64 %103
  %105 = load float, ptr %104, align 4, !tbaa !9
  %106 = load i32, ptr %1, align 4, !tbaa !5
  %107 = uitofp i32 %106 to float
  %108 = fsub float %105, %107
  %109 = fpext float %108 to double
  %110 = load i32, ptr %2, align 4, !tbaa !5
  %111 = sub i32 %110, 1
  %112 = zext i32 %111 to i64
  %113 = getelementptr inbounds float, ptr %14, i64 %112
  %114 = load float, ptr %113, align 4, !tbaa !9
  %115 = load i32, ptr %1, align 4, !tbaa !5
  %116 = uitofp i32 %115 to float
  %117 = fsub float %114, %116
  %118 = fpext float %117 to double
  %119 = load i32, ptr %2, align 4, !tbaa !5
  %120 = sub i32 %119, 1
  %121 = zext i32 %120 to i64
  %122 = getelementptr inbounds float, ptr %14, i64 %121
  %123 = load float, ptr %122, align 4, !tbaa !9
  %124 = load i32, ptr %1, align 4, !tbaa !5
  %125 = uitofp i32 %124 to float
  %126 = fsub float %123, %125
  %127 = fpext float %126 to double
  %128 = load i32, ptr %2, align 4, !tbaa !5
  %129 = sub i32 %128, 1
  %130 = zext i32 %129 to i64
  %131 = getelementptr inbounds float, ptr %14, i64 %130
  %132 = load float, ptr %131, align 4, !tbaa !9
  %133 = load i32, ptr %1, align 4, !tbaa !5
  %134 = uitofp i32 %133 to float
  %135 = fsub float %132, %134
  %136 = fpext float %135 to double
  %137 = call double @llvm.fmuladd.f64(double %109, double %118, double 0.000000e+00)
  %138 = call double @sqrt(double noundef %137) #6
  call void @liquid_autotest_failed_expr(ptr noundef @.str, i32 noundef 50, ptr noundef @.str.1, double noundef %138, ptr noundef @.str.2, ptr noundef @.str.3, double noundef 0x3F847AE140000000)
  br label %140

139:                                              ; preds = %96
  call void (...) @liquid_autotest_passed()
  br label %140

140:                                              ; preds = %139, %100
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  %141 = load ptr, ptr %3, align 8
  call void @llvm.stackrestore.p0(ptr %141)
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #6
  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 willreturn
declare ptr @llvm.stacksave.p0() #2

declare ptr @iirfilt_rrrf_create_integrator() #3

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

declare i32 @iirfilt_rrrf_destroy(ptr noundef) #3

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

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

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

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

declare void @liquid_autotest_passed(...) #3

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

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

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 = { nocallback nofree nosync nounwind willreturn }
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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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.1 = external hidden unnamed_addr constant [39 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

; Function Attrs: nounwind uwtable
define dso_local void @autotest_iirfilt_integrator() local_unnamed_addr #0 {
  %1 = alloca [40 x float], align 16
  %2 = alloca [40 x float], align 16
  store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %1, align 16, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %1, i64 16
  store <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, ptr %3, align 16, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 32
  store <2 x float> <float 1.000000e+00, float 1.000000e+00>, ptr %4, align 16, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %1, i64 40
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(120) %5, i8 0, i64 120, i1 false)
  %6 = tail call ptr @iirfilt_rrrf_create_integrator() #5
  %7 = call i32 @iirfilt_rrrf_execute_block(ptr noundef %6, ptr noundef nonnull %1, i32 noundef 40, ptr noundef nonnull %2) #5
  %8 = call i32 @iirfilt_rrrf_destroy(ptr noundef %6) #5
  %9 = getelementptr inbounds i8, ptr %2, i64 156
  %10 = load float, ptr %9, align 4
  %11 = fadd float %10, -1.000000e+01
  %12 = fpext float %11 to double
  %13 = call double @llvm.fmuladd.f64(double %12, double %12, double 0.000000e+00)
  %sqrt = call double @llvm.sqrt.f64(double %13)
  %14 = fcmp ogt double %sqrt, 0x3F847AE140000000
  %15 = fcmp uno float %10, 0.000000e+00
  %or.cond = select i1 %14, i1 true, i1 %15
  br i1 %or.cond, label %16, label %17

16:                                               ; preds = %0
  call void @liquid_autotest_failed_expr(ptr noundef nonnull @.str, i32 noundef 50, ptr noundef nonnull @.str.1, double noundef %sqrt, ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, double noundef 0x3F847AE140000000) #5
  br label %18

17:                                               ; preds = %0
  call void (...) @liquid_autotest_passed() #5
  br label %18

18:                                               ; preds = %17, %16
  ret void
}

declare ptr @iirfilt_rrrf_create_integrator() local_unnamed_addr #1

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

declare i32 @iirfilt_rrrf_destroy(ptr noundef) local_unnamed_addr #1

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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