; LLVM IR from GCY/wxECGAnalyzer :: embedded/stm32f407 - 360Hz/src/stm32f4/algorithm (Pan_Tompkins_detect)

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

@TwoPoleRecursive.xnt = external hidden global i32, align 4
@TwoPoleRecursive.xm1 = external hidden global i32, align 4
@TwoPoleRecursive.xm2 = external hidden global i32, align 4
@TwoPoleRecursive.ynt = external hidden global i32, align 4
@TwoPoleRecursive.ym1 = external hidden global i32, align 4
@TwoPoleRecursive.ym2 = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i32 @TwoPoleRecursive(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  %3 = load i32, ptr %2, align 4, !tbaa !5
  store i32 %3, ptr @TwoPoleRecursive.xnt, align 4, !tbaa !5
  %4 = load i32, ptr @TwoPoleRecursive.ym1, align 4, !tbaa !5
  %5 = load i32, ptr @TwoPoleRecursive.ym1, align 4, !tbaa !5
  %6 = ashr i32 %5, 1
  %7 = add nsw i32 %4, %6
  %8 = load i32, ptr @TwoPoleRecursive.ym1, align 4, !tbaa !5
  %9 = ashr i32 %8, 2
  %10 = add nsw i32 %7, %9
  %11 = load i32, ptr @TwoPoleRecursive.ym1, align 4, !tbaa !5
  %12 = ashr i32 %11, 3
  %13 = add nsw i32 %10, %12
  %14 = load i32, ptr @TwoPoleRecursive.ym2, align 4, !tbaa !5
  %15 = ashr i32 %14, 1
  %16 = load i32, ptr @TwoPoleRecursive.ym2, align 4, !tbaa !5
  %17 = ashr i32 %16, 2
  %18 = add nsw i32 %15, %17
  %19 = load i32, ptr @TwoPoleRecursive.ym2, align 4, !tbaa !5
  %20 = ashr i32 %19, 3
  %21 = add nsw i32 %18, %20
  %22 = load i32, ptr @TwoPoleRecursive.ym2, align 4, !tbaa !5
  %23 = ashr i32 %22, 5
  %24 = add nsw i32 %21, %23
  %25 = load i32, ptr @TwoPoleRecursive.ym2, align 4, !tbaa !5
  %26 = ashr i32 %25, 6
  %27 = add nsw i32 %24, %26
  %28 = load i32, ptr @TwoPoleRecursive.xnt, align 4, !tbaa !5
  %29 = add nsw i32 %27, %28
  %30 = load i32, ptr @TwoPoleRecursive.xm2, align 4, !tbaa !5
  %31 = sub nsw i32 %29, %30
  %32 = add nsw i32 %13, %31
  store i32 %32, ptr @TwoPoleRecursive.ynt, align 4, !tbaa !5
  %33 = load i32, ptr @TwoPoleRecursive.xm1, align 4, !tbaa !5
  store i32 %33, ptr @TwoPoleRecursive.xm2, align 4, !tbaa !5
  %34 = load i32, ptr @TwoPoleRecursive.xnt, align 4, !tbaa !5
  store i32 %34, ptr @TwoPoleRecursive.xm1, align 4, !tbaa !5
  %35 = load i32, ptr @TwoPoleRecursive.ym1, align 4, !tbaa !5
  store i32 %35, ptr @TwoPoleRecursive.xm2, align 4, !tbaa !5
  %36 = load i32, ptr @TwoPoleRecursive.ym1, align 4, !tbaa !5
  store i32 %36, ptr @TwoPoleRecursive.ym2, align 4, !tbaa !5
  %37 = load i32, ptr @TwoPoleRecursive.ynt, align 4, !tbaa !5
  store i32 %37, ptr @TwoPoleRecursive.ym1, align 4, !tbaa !5
  %38 = load i32, ptr @TwoPoleRecursive.ynt, align 4, !tbaa !5
  ret i32 %38
}

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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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

@TwoPoleRecursive.xnt = external hidden local_unnamed_addr global i32, align 4
@TwoPoleRecursive.xm1 = external hidden local_unnamed_addr global i32, align 4
@TwoPoleRecursive.xm2 = external hidden local_unnamed_addr global i32, align 4
@TwoPoleRecursive.ynt = external hidden local_unnamed_addr global i32, align 4
@TwoPoleRecursive.ym1 = external hidden local_unnamed_addr global i32, align 4
@TwoPoleRecursive.ym2 = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local i32 @TwoPoleRecursive(i32 noundef %0) local_unnamed_addr #0 {
  store i32 %0, ptr @TwoPoleRecursive.xnt, align 4, !tbaa !5
  %2 = load i32, ptr @TwoPoleRecursive.ym1, align 4, !tbaa !5
  %3 = ashr i32 %2, 1
  %4 = ashr i32 %2, 2
  %5 = ashr i32 %2, 3
  %6 = load i32, ptr @TwoPoleRecursive.ym2, align 4, !tbaa !5
  %7 = ashr i32 %6, 1
  %8 = ashr i32 %6, 2
  %9 = ashr i32 %6, 3
  %10 = ashr i32 %6, 5
  %11 = ashr i32 %6, 6
  %12 = load i32, ptr @TwoPoleRecursive.xm2, align 4, !tbaa !5
  %13 = add i32 %2, %0
  %14 = add i32 %13, %3
  %15 = add i32 %14, %4
  %16 = add i32 %15, %5
  %17 = add i32 %16, %8
  %18 = add i32 %17, %7
  %19 = add i32 %18, %9
  %20 = add i32 %19, %10
  %21 = add i32 %20, %11
  %22 = sub i32 %21, %12
  store i32 %22, ptr @TwoPoleRecursive.ynt, align 4, !tbaa !5
  store i32 %0, ptr @TwoPoleRecursive.xm1, align 4, !tbaa !5
  store i32 %2, ptr @TwoPoleRecursive.xm2, align 4, !tbaa !5
  store i32 %2, ptr @TwoPoleRecursive.ym2, align 4, !tbaa !5
  store i32 %22, ptr @TwoPoleRecursive.ym1, align 4, !tbaa !5
  ret i32 %22
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) 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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass