; LLVM IR from BigdogManLuo/DSPLibrary :: DSPTools/ButterWorth_Filter (filter)

; 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.Queue = type { [40 x float], i32, i32, i32, float, float }

; 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 memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
declare dso_local void @InQueue(ptr noundef, float noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local float @OutQueue(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local float @AverFilter(ptr noundef %0, float noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store float %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store float 0.000000e+00, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.Queue, ptr %6, i32 0, i32 3
  %8 = load i32, ptr %7, align 4, !tbaa !11
  %9 = icmp eq i32 %8, 0
  br i1 %9, label %10, label %27

10:                                               ; preds = %2
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = load float, ptr %4, align 4, !tbaa !9
  call void @InQueue(ptr noundef %11, float noundef %12)
  %13 = load float, ptr %4, align 4, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.Queue, ptr %14, i32 0, i32 4
  %16 = load float, ptr %15, align 4, !tbaa !14
  %17 = fadd float %16, %13
  store float %17, ptr %15, align 4, !tbaa !14
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.Queue, ptr %18, i32 0, i32 4
  %20 = load float, ptr %19, align 4, !tbaa !14
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.Queue, ptr %21, i32 0, i32 2
  %23 = load i32, ptr %22, align 4, !tbaa !15
  %24 = add nsw i32 %23, 1
  %25 = sitofp i32 %24 to float
  %26 = fdiv float %20, %25
  store float %26, ptr %5, align 4, !tbaa !9
  br label %49

27:                                               ; preds = %2
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = call float @OutQueue(ptr noundef %28)
  %30 = load ptr, ptr %3, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.Queue, ptr %30, i32 0, i32 5
  store float %29, ptr %31, align 4, !tbaa !16
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = load float, ptr %4, align 4, !tbaa !9
  call void @InQueue(ptr noundef %32, float noundef %33)
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.Queue, ptr %34, i32 0, i32 4
  %36 = load float, ptr %35, align 4, !tbaa !14
  %37 = load float, ptr %4, align 4, !tbaa !9
  %38 = fadd float %36, %37
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.Queue, ptr %39, i32 0, i32 5
  %41 = load float, ptr %40, align 4, !tbaa !16
  %42 = fsub float %38, %41
  %43 = load ptr, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.Queue, ptr %43, i32 0, i32 4
  store float %42, ptr %44, align 4, !tbaa !14
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.Queue, ptr %45, i32 0, i32 4
  %47 = load float, ptr %46, align 4, !tbaa !14
  %48 = fdiv float %47, 4.000000e+01
  store float %48, ptr %5, align 4, !tbaa !9
  br label %49

49:                                               ; preds = %27, %10
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.Queue, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !15
  %53 = icmp eq i32 %52, 39
  br i1 %53, label %54, label %57

54:                                               ; preds = %49
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.Queue, ptr %55, i32 0, i32 3
  store i32 1, ptr %56, align 4, !tbaa !11
  br label %57

57:                                               ; preds = %54, %49
  %58 = load float, ptr %5, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret float %58
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"float", !7, i64 0}
!11 = !{!12, !13, i64 168}
!12 = !{!"", !7, i64 0, !13, i64 160, !13, i64 164, !13, i64 168, !10, i64 172, !10, i64 176}
!13 = !{!"int", !7, i64 0}
!14 = !{!12, !10, i64 172}
!15 = !{!12, !13, i64 164}
!16 = !{!12, !10, i64 176}


; 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
declare dso_local void @InQueue(ptr noundef, float noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local float @OutQueue(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local float @AverFilter(ptr noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = getelementptr inbounds i8, ptr %0, i64 168
  %4 = load i32, ptr %3, align 4, !tbaa !5
  %5 = icmp eq i32 %4, 0
  br i1 %5, label %6, label %15

6:                                                ; preds = %2
  tail call void @InQueue(ptr noundef nonnull %0, float noundef %1)
  %7 = getelementptr inbounds i8, ptr %0, i64 172
  %8 = load float, ptr %7, align 4, !tbaa !11
  %9 = fadd float %8, %1
  store float %9, ptr %7, align 4, !tbaa !11
  %10 = getelementptr inbounds i8, ptr %0, i64 164
  %11 = load i32, ptr %10, align 4, !tbaa !12
  %12 = add nsw i32 %11, 1
  %13 = sitofp i32 %12 to float
  %14 = fdiv float %9, %13
  br label %24

15:                                               ; preds = %2
  %16 = tail call float @OutQueue(ptr noundef nonnull %0)
  %17 = getelementptr inbounds i8, ptr %0, i64 176
  store float %16, ptr %17, align 4, !tbaa !13
  tail call void @InQueue(ptr noundef nonnull %0, float noundef %1)
  %18 = getelementptr inbounds i8, ptr %0, i64 172
  %19 = load float, ptr %18, align 4, !tbaa !11
  %20 = fadd float %19, %1
  %21 = load float, ptr %17, align 4, !tbaa !13
  %22 = fsub float %20, %21
  store float %22, ptr %18, align 4, !tbaa !11
  %23 = fdiv float %22, 4.000000e+01
  %.phi.trans.insert = getelementptr inbounds i8, ptr %0, i64 164
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !12
  br label %24

24:                                               ; preds = %15, %6
  %25 = phi i32 [ %11, %6 ], [ %.pre, %15 ]
  %.0 = phi float [ %14, %6 ], [ %23, %15 ]
  %26 = icmp eq i32 %25, 39
  br i1 %26, label %27, label %28

27:                                               ; preds = %24
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %27, %24
  ret float %.0
}

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

!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, !9, i64 168}
!6 = !{!"", !7, i64 0, !9, i64 160, !9, i64 164, !9, i64 168, !10, i64 172, !10, i64 176}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!"float", !7, i64 0}
!11 = !{!6, !10, i64 172}
!12 = !{!6, !9, i64 164}
!13 = !{!6, !10, i64 176}


; Effective O3 passes: BDCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,TailCallElimPass