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

; 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 [78 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @butter_azpkf(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca float, align 4
  %15 = alloca { float, float }, align 4
  %16 = alloca { float, float }, align 4
  %17 = alloca { float, float }, align 4
  %18 = alloca { float, float }, align 4
  %19 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !9
  store ptr %2, ptr %8, align 8, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = urem i32 %20, 2
  store i32 %21, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = load i32, ptr %10, align 4, !tbaa !5
  %24 = sub i32 %22, %23
  %25 = udiv i32 %24, 2
  store i32 %25, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !5
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %82, %4
  %27 = load i32, ptr %12, align 4, !tbaa !5
  %28 = load i32, ptr %11, align 4, !tbaa !5
  %29 = icmp ult i32 %27, %28
  br i1 %29, label %30, label %85

30:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %31 = load i32, ptr %12, align 4, !tbaa !5
  %32 = add i32 %31, 1
  %33 = mul i32 2, %32
  %34 = load i32, ptr %6, align 4, !tbaa !5
  %35 = add i32 %33, %34
  %36 = sub i32 %35, 1
  %37 = uitofp i32 %36 to float
  %38 = fpext float %37 to double
  %39 = fmul double %38, 0x400921FB54442D18
  %40 = load i32, ptr %6, align 4, !tbaa !5
  %41 = mul i32 2, %40
  %42 = uitofp i32 %41 to float
  %43 = fpext float %42 to double
  %44 = fdiv double %39, %43
  %45 = fptrunc double %44 to float
  store float %45, ptr %14, align 4, !tbaa !11
  %46 = load float, ptr %14, align 4, !tbaa !11
  %47 = fmul float 0.000000e+00, %46
  %48 = fmul float 1.000000e+00, %46
  %49 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 0
  %50 = getelementptr inbounds { float, float }, ptr %15, i32 0, i32 1
  store float %47, ptr %49, align 4
  store float %48, ptr %50, align 4
  %51 = load <2 x float>, ptr %15, align 4
  %52 = call <2 x float> @cexpf(<2 x float> noundef %51) #4
  store <2 x float> %52, ptr %16, align 4
  %53 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 0
  %54 = load float, ptr %53, align 4
  %55 = getelementptr inbounds { float, float }, ptr %16, i32 0, i32 1
  %56 = load float, ptr %55, align 4
  %57 = load ptr, ptr %8, align 8, !tbaa !9
  %58 = load i32, ptr %13, align 4, !tbaa !5
  %59 = add i32 %58, 1
  store i32 %59, ptr %13, align 4, !tbaa !5
  %60 = zext i32 %58 to i64
  %61 = getelementptr inbounds { float, float }, ptr %57, i64 %60
  %62 = getelementptr inbounds { float, float }, ptr %61, i32 0, i32 0
  %63 = getelementptr inbounds { float, float }, ptr %61, i32 0, i32 1
  store float %54, ptr %62, align 4
  store float %56, ptr %63, align 4
  %64 = load float, ptr %14, align 4, !tbaa !11
  %65 = fmul float -0.000000e+00, %64
  %66 = fmul float -1.000000e+00, %64
  %67 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 0
  %68 = getelementptr inbounds { float, float }, ptr %17, i32 0, i32 1
  store float %65, ptr %67, align 4
  store float %66, ptr %68, align 4
  %69 = load <2 x float>, ptr %17, align 4
  %70 = call <2 x float> @cexpf(<2 x float> noundef %69) #4
  store <2 x float> %70, ptr %18, align 4
  %71 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 0
  %72 = load float, ptr %71, align 4
  %73 = getelementptr inbounds { float, float }, ptr %18, i32 0, i32 1
  %74 = load float, ptr %73, align 4
  %75 = load ptr, ptr %8, align 8, !tbaa !9
  %76 = load i32, ptr %13, align 4, !tbaa !5
  %77 = add i32 %76, 1
  store i32 %77, ptr %13, align 4, !tbaa !5
  %78 = zext i32 %76 to i64
  %79 = getelementptr inbounds { float, float }, ptr %75, i64 %78
  %80 = getelementptr inbounds { float, float }, ptr %79, i32 0, i32 0
  %81 = getelementptr inbounds { float, float }, ptr %79, i32 0, i32 1
  store float %72, ptr %80, align 4
  store float %74, ptr %81, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %82

82:                                               ; preds = %30
  %83 = load i32, ptr %12, align 4, !tbaa !5
  %84 = add i32 %83, 1
  store i32 %84, ptr %12, align 4, !tbaa !5
  br label %26, !llvm.loop !13

85:                                               ; preds = %26
  %86 = load i32, ptr %10, align 4, !tbaa !5
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %88, label %96

88:                                               ; preds = %85
  %89 = load ptr, ptr %8, align 8, !tbaa !9
  %90 = load i32, ptr %13, align 4, !tbaa !5
  %91 = add i32 %90, 1
  store i32 %91, ptr %13, align 4, !tbaa !5
  %92 = zext i32 %90 to i64
  %93 = getelementptr inbounds { float, float }, ptr %89, i64 %92
  %94 = getelementptr inbounds { float, float }, ptr %93, i32 0, i32 0
  %95 = getelementptr inbounds { float, float }, ptr %93, i32 0, i32 1
  store float -1.000000e+00, ptr %94, align 4
  store float 0.000000e+00, ptr %95, align 4
  br label %96

96:                                               ; preds = %88, %85
  %97 = load i32, ptr %13, align 4, !tbaa !5
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = icmp ne i32 %97, %98
  br i1 %99, label %100, label %102

100:                                              ; preds = %96
  %101 = call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef @.str, i32 noundef 63, ptr noundef @.str.1)
  store i32 %101, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %106

102:                                              ; preds = %96
  %103 = load ptr, ptr %9, align 8, !tbaa !9
  %104 = getelementptr inbounds { float, float }, ptr %103, i32 0, i32 0
  %105 = getelementptr inbounds { float, float }, ptr %103, i32 0, i32 1
  store float 1.000000e+00, ptr %104, align 4
  store float 0.000000e+00, ptr %105, align 4
  store i32 0, ptr %5, align 4
  store i32 1, ptr %19, align 4
  br label %106

106:                                              ; preds = %102, %100
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %107 = load i32, ptr %5, align 4
  ret i32 %107
}

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

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) #2

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

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) #3

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 = { 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 }

!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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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 [78 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [38 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @butter_azpkf(i32 noundef %0, ptr nocapture noundef readnone %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = and i32 %0, 1
  %6 = lshr i32 %0, 1
  %.not31 = icmp ult i32 %0, 2
  br i1 %.not31, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %7 = add i32 %0, -1
  %8 = shl i32 %0, 1
  %9 = uitofp i32 %8 to float
  %10 = fpext float %9 to double
  br label %11

11:                                               ; preds = %.lr.ph, %11
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %11 ]
  %.02630 = phi i32 [ 0, %.lr.ph ], [ %12, %11 ]
  %12 = add nuw nsw i32 %.02630, 1
  %13 = shl nuw i32 %12, 1
  %14 = add i32 %7, %13
  %15 = uitofp i32 %14 to float
  %16 = fpext float %15 to double
  %17 = fmul double %16, 0x400921FB54442D18
  %18 = fdiv double %17, %10
  %19 = fptrunc double %18 to float
  %20 = fmul float %19, 0.000000e+00
  %.sroa.04.0.vec.insert = insertelement <2 x float> poison, float %20, i64 0
  %.sroa.04.4.vec.insert = insertelement <2 x float> %.sroa.04.0.vec.insert, float %19, i64 1
  %21 = tail call <2 x float> @cexpf(<2 x float> noundef %.sroa.04.4.vec.insert) #3
  %22 = or disjoint i64 %indvars.iv, 1
  %23 = getelementptr inbounds { float, float }, ptr %2, i64 %indvars.iv
  store <2 x float> %21, ptr %23, align 4
  %24 = fmul float %19, -0.000000e+00
  %25 = fneg float %19
  %.sroa.01.0.vec.insert = insertelement <2 x float> poison, float %24, i64 0
  %.sroa.01.4.vec.insert = insertelement <2 x float> %.sroa.01.0.vec.insert, float %25, i64 1
  %26 = tail call <2 x float> @cexpf(<2 x float> noundef %.sroa.01.4.vec.insert) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 2
  %27 = getelementptr inbounds { float, float }, ptr %2, i64 %22
  store <2 x float> %26, ptr %27, align 4
  %exitcond.not = icmp eq i32 %12, %6
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %11, !llvm.loop !5

._crit_edge.loopexit:                             ; preds = %11
  %28 = trunc nuw i64 %indvars.iv.next to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %4
  %.027.lcssa = phi i32 [ 0, %4 ], [ %28, %._crit_edge.loopexit ]
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %33, label %29

29:                                               ; preds = %._crit_edge
  %30 = or disjoint i32 %.027.lcssa, 1
  %31 = zext i32 %.027.lcssa to i64
  %32 = getelementptr inbounds { float, float }, ptr %2, i64 %31
  store <2 x float> <float -1.000000e+00, float 0.000000e+00>, ptr %32, align 4
  br label %33

33:                                               ; preds = %29, %._crit_edge
  %.1 = phi i32 [ %30, %29 ], [ %.027.lcssa, %._crit_edge ]
  %.not28 = icmp eq i32 %.1, %0
  br i1 %.not28, label %36, label %34

34:                                               ; preds = %33
  %35 = tail call i32 (i32, ptr, i32, ptr, ...) @liquid_error_fl(i32 noundef 1, ptr noundef nonnull @.str, i32 noundef 63, ptr noundef nonnull @.str.1) #3
  br label %37

36:                                               ; preds = %33
  store <2 x float> <float 1.000000e+00, float 0.000000e+00>, ptr %3, align 4
  br label %37

37:                                               ; preds = %36, %34
  %.0 = phi i32 [ %35, %34 ], [ 0, %36 ]
  ret i32 %.0
}

; Function Attrs: nounwind
declare <2 x float> @cexpf(<2 x float> noundef) local_unnamed_addr #1

declare i32 @liquid_error_fl(i32 noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #2

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 = { 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 #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 }

!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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}


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