; LLVM IR from GCY/wxECGAnalyzer :: embedded/stm32f407 - 360Hz/src/stm32f4/algorithm (So_Chen_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"

%struct.SignalPoint = type { float, i32 }

@signal_window_count = external hidden global i32, align 4
@signal_window = external hidden global [5 x %struct.SignalPoint], align 16
@slop = external hidden global %struct.SignalPoint, align 4
@so_chen_init_flag = external hidden global i8, align 1
@maxi_init = external hidden global i8, align 1
@max = external hidden global %struct.SignalPoint, align 4
@maxi = external hidden global float, align 4
@init_count = external hidden global i32, align 4
@slop_threshold = external hidden global float, align 4
@qrs_on_set_flag = external hidden global i8, align 1
@last_point = external hidden global i32, align 4
@max_init = external hidden global i8, align 1
@max_slop = external hidden global %struct.SignalPoint, align 4
@qrs_onset_point = external hidden global %struct.SignalPoint, align 4
@last_maxi = external hidden global float, align 4
@qrs_on_set_count = external hidden global i32, align 4
@qrs_onset_idx = external hidden global i32, align 4

; Function Attrs: nounwind uwtable
define dso_local i64 @So_Chen_detect(i64 %0, i32 noundef %1, float noundef %2, float noundef %3) #0 {
  %5 = alloca %struct.SignalPoint, align 4
  %6 = alloca %struct.SignalPoint, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca float, align 4
  %10 = alloca %struct.SignalPoint, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i64 %0, ptr %6, align 4
  store i32 %1, ptr %7, align 4, !tbaa !5
  store float %2, ptr %8, align 4, !tbaa !9
  store float %3, ptr %9, align 4, !tbaa !9
  %13 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %14 = icmp ult i32 %13, 5
  br i1 %14, label %15, label %23

15:                                               ; preds = %4
  %16 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %17 = urem i32 %16, 5
  %18 = zext i32 %17 to i64
  %19 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %18
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %19, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !11
  %20 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %21 = add i32 %20, 1
  store i32 %21, ptr @signal_window_count, align 4, !tbaa !5
  %22 = getelementptr inbounds %struct.SignalPoint, ptr %5, i32 0, i32 1
  store i32 -1, ptr %22, align 4, !tbaa !12
  br label %206

23:                                               ; preds = %4
  %24 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %25 = urem i32 %24, 5
  %26 = zext i32 %25 to i64
  %27 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %26
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %27, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !11
  %28 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %29 = add i32 %28, 1
  store i32 %29, ptr @signal_window_count, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %30

30:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %31 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %32 = sub i32 %31, 2
  store i32 %32, ptr %11, align 4, !tbaa !5
  %33 = load i32, ptr %11, align 4, !tbaa !5
  %34 = sub i32 %33, 2
  %35 = urem i32 %34, 5
  %36 = zext i32 %35 to i64
  %37 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.SignalPoint, ptr %37, i32 0, i32 0
  %39 = load float, ptr %38, align 8, !tbaa !14
  %40 = load i32, ptr %11, align 4, !tbaa !5
  %41 = sub i32 %40, 1
  %42 = urem i32 %41, 5
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.SignalPoint, ptr %44, i32 0, i32 0
  %46 = load float, ptr %45, align 8, !tbaa !14
  %47 = fneg float %46
  %48 = call float @llvm.fmuladd.f32(float -2.000000e+00, float %39, float %47)
  %49 = load i32, ptr %11, align 4, !tbaa !5
  %50 = add i32 %49, 1
  %51 = urem i32 %50, 5
  %52 = zext i32 %51 to i64
  %53 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %52
  %54 = getelementptr inbounds %struct.SignalPoint, ptr %53, i32 0, i32 0
  %55 = load float, ptr %54, align 8, !tbaa !14
  %56 = fadd float %48, %55
  %57 = load i32, ptr %11, align 4, !tbaa !5
  %58 = add i32 %57, 2
  %59 = urem i32 %58, 5
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.SignalPoint, ptr %61, i32 0, i32 0
  %63 = load float, ptr %62, align 8, !tbaa !14
  %64 = call float @llvm.fmuladd.f32(float 2.000000e+00, float %63, float %56)
  store float %64, ptr @slop, align 4, !tbaa !14
  %65 = load i32, ptr %11, align 4, !tbaa !5
  %66 = urem i32 %65, 5
  %67 = zext i32 %66 to i64
  %68 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %67
  %69 = getelementptr inbounds %struct.SignalPoint, ptr %68, i32 0, i32 1
  %70 = load i32, ptr %69, align 4, !tbaa !12
  store i32 %70, ptr getelementptr inbounds (%struct.SignalPoint, ptr @slop, i32 0, i32 1), align 4, !tbaa !12
  %71 = load i8, ptr @so_chen_init_flag, align 1, !tbaa !15, !range !17, !noundef !18
  %72 = trunc i8 %71 to i1
  br i1 %72, label %97, label %73

73:                                               ; preds = %30
  %74 = load i8, ptr @maxi_init, align 1, !tbaa !15, !range !17, !noundef !18
  %75 = trunc i8 %74 to i1
  br i1 %75, label %78, label %76

76:                                               ; preds = %73
  store float 0.000000e+00, ptr @max, align 4, !tbaa !14
  store i32 -1, ptr getelementptr inbounds (%struct.SignalPoint, ptr @max, i32 0, i32 1), align 4, !tbaa !12
  %77 = load float, ptr @slop, align 4, !tbaa !14
  store float %77, ptr @maxi, align 4, !tbaa !9
  store i8 1, ptr @maxi_init, align 1, !tbaa !15
  br label %78

78:                                               ; preds = %76, %73
  %79 = load i32, ptr @init_count, align 4, !tbaa !5
  %80 = add i32 %79, 1
  store i32 %80, ptr @init_count, align 4, !tbaa !5
  %81 = load i32, ptr @init_count, align 4, !tbaa !5
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = icmp ugt i32 %81, %82
  br i1 %83, label %84, label %89

84:                                               ; preds = %78
  store i8 1, ptr @so_chen_init_flag, align 1, !tbaa !15
  %85 = load float, ptr %8, align 4, !tbaa !9
  %86 = fdiv float %85, 1.600000e+01
  %87 = load float, ptr @maxi, align 4, !tbaa !9
  %88 = fmul float %86, %87
  store float %88, ptr @slop_threshold, align 4, !tbaa !9
  br label %89

89:                                               ; preds = %84, %78
  %90 = load float, ptr @slop, align 4, !tbaa !14
  %91 = load float, ptr @maxi, align 4, !tbaa !9
  %92 = fcmp ogt float %90, %91
  br i1 %92, label %93, label %95

93:                                               ; preds = %89
  %94 = load float, ptr @slop, align 4, !tbaa !14
  store float %94, ptr @maxi, align 4, !tbaa !9
  br label %95

95:                                               ; preds = %93, %89
  %96 = getelementptr inbounds %struct.SignalPoint, ptr %5, i32 0, i32 1
  store i32 -1, ptr %96, align 4, !tbaa !12
  store i32 1, ptr %12, align 4
  br label %205

97:                                               ; preds = %30
  %98 = load i8, ptr @qrs_on_set_flag, align 1, !tbaa !15, !range !17, !noundef !18
  %99 = trunc i8 %98 to i1
  br i1 %99, label %100, label %157

100:                                              ; preds = %97
  %101 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %102 = load i32, ptr @last_point, align 4, !tbaa !5
  %103 = sub i32 %101, %102
  %104 = icmp ugt i32 %103, 126
  br i1 %104, label %105, label %157

105:                                              ; preds = %100
  %106 = load i8, ptr @max_init, align 1, !tbaa !15, !range !17, !noundef !18
  %107 = trunc i8 %106 to i1
  br i1 %107, label %113, label %108

108:                                              ; preds = %105
  %109 = load i32, ptr %11, align 4, !tbaa !5
  %110 = urem i32 %109, 5
  %111 = zext i32 %110 to i64
  %112 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %111
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @max, ptr align 8 %112, i64 8, i1 false), !tbaa.struct !11
  store i8 1, ptr @max_init, align 1, !tbaa !15
  br label %113

113:                                              ; preds = %108, %105
  %114 = load i32, ptr %11, align 4, !tbaa !5
  %115 = urem i32 %114, 5
  %116 = zext i32 %115 to i64
  %117 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %116
  %118 = getelementptr inbounds %struct.SignalPoint, ptr %117, i32 0, i32 0
  %119 = load float, ptr %118, align 8, !tbaa !14
  %120 = load float, ptr @max, align 4, !tbaa !14
  %121 = fcmp ogt float %119, %120
  br i1 %121, label %122, label %127

122:                                              ; preds = %113
  %123 = load i32, ptr %11, align 4, !tbaa !5
  %124 = urem i32 %123, 5
  %125 = zext i32 %124 to i64
  %126 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %125
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @max, ptr align 8 %126, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @max_slop, ptr align 4 @slop, i64 8, i1 false), !tbaa.struct !11
  br label %156

127:                                              ; preds = %113
  %128 = load i32, ptr %11, align 4, !tbaa !5
  %129 = urem i32 %128, 5
  %130 = zext i32 %129 to i64
  %131 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %130
  %132 = getelementptr inbounds %struct.SignalPoint, ptr %131, i32 0, i32 0
  %133 = load float, ptr %132, align 8, !tbaa !14
  %134 = load float, ptr @max, align 4, !tbaa !14
  %135 = fcmp olt float %133, %134
  br i1 %135, label %136, label %155

136:                                              ; preds = %127
  %137 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  store i32 %137, ptr @last_point, align 4, !tbaa !5
  store i8 0, ptr @qrs_on_set_flag, align 1, !tbaa !15
  store i8 0, ptr @max_init, align 1, !tbaa !15
  %138 = load float, ptr @max, align 4, !tbaa !14
  %139 = load float, ptr @qrs_onset_point, align 4, !tbaa !14
  %140 = fsub float %138, %139
  %141 = fptosi float %140 to i32
  %142 = call i32 @llvm.abs.i32(i32 %141, i1 true)
  %143 = sitofp i32 %142 to float
  %144 = load float, ptr @maxi, align 4, !tbaa !9
  %145 = fsub float %143, %144
  %146 = load float, ptr %9, align 4, !tbaa !9
  %147 = fdiv float %145, %146
  %148 = load float, ptr @maxi, align 4, !tbaa !9
  %149 = fadd float %147, %148
  store float %149, ptr @maxi, align 4, !tbaa !9
  %150 = load float, ptr %8, align 4, !tbaa !9
  %151 = fdiv float %150, 1.600000e+01
  %152 = load float, ptr @maxi, align 4, !tbaa !9
  %153 = fmul float %151, %152
  store float %153, ptr @slop_threshold, align 4, !tbaa !9
  %154 = load float, ptr @maxi, align 4, !tbaa !9
  store float %154, ptr @last_maxi, align 4, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 @max, i64 8, i1 false), !tbaa.struct !11
  store i32 1, ptr %12, align 4
  br label %205

155:                                              ; preds = %127
  br label %156

156:                                              ; preds = %155, %122
  br label %203

157:                                              ; preds = %100, %97
  %158 = load float, ptr @slop, align 4, !tbaa !14
  %159 = load float, ptr @slop_threshold, align 4, !tbaa !9
  %160 = fcmp ogt float %158, %159
  br i1 %160, label %161, label %164

161:                                              ; preds = %157
  %162 = load i32, ptr @qrs_on_set_count, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  store i32 %163, ptr @qrs_on_set_count, align 4, !tbaa !5
  br label %169

164:                                              ; preds = %157
  %165 = load i32, ptr @qrs_on_set_count, align 4, !tbaa !5
  %166 = icmp ne i32 %165, 0
  br i1 %166, label %167, label %168

167:                                              ; preds = %164
  store i32 0, ptr @qrs_on_set_count, align 4, !tbaa !5
  br label %168

168:                                              ; preds = %167, %164
  br label %169

169:                                              ; preds = %168, %161
  %170 = load i32, ptr @qrs_on_set_count, align 4, !tbaa !5
  %171 = icmp sge i32 %170, 2
  br i1 %171, label %172, label %174

172:                                              ; preds = %169
  store i8 1, ptr @qrs_on_set_flag, align 1, !tbaa !15
  store i32 0, ptr @qrs_on_set_count, align 4, !tbaa !5
  %173 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %173, ptr @qrs_onset_idx, align 4, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 @qrs_onset_point, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !11
  br label %202

174:                                              ; preds = %169
  %175 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %176 = load i32, ptr @last_point, align 4, !tbaa !5
  %177 = sub i32 %175, %176
  %178 = icmp ugt i32 %177, 252
  br i1 %178, label %179, label %201

179:                                              ; preds = %174
  %180 = load float, ptr @slop_threshold, align 4, !tbaa !9
  %181 = fcmp ogt float %180, 0.000000e+00
  br i1 %181, label %182, label %201

182:                                              ; preds = %179
  %183 = load float, ptr @slop, align 4, !tbaa !14
  %184 = load float, ptr @slop_threshold, align 4, !tbaa !9
  %185 = fsub float %184, %183
  store float %185, ptr @slop_threshold, align 4, !tbaa !9
  %186 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %187 = load i32, ptr @last_point, align 4, !tbaa !5
  %188 = sub i32 %186, %187
  %189 = icmp ugt i32 %188, 1080
  br i1 %189, label %190, label %200

190:                                              ; preds = %182
  %191 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %192 = load i32, ptr @last_point, align 4, !tbaa !5
  %193 = sub i32 %191, %192
  %194 = load float, ptr %8, align 4, !tbaa !9
  %195 = fptosi float %194 to i32
  %196 = lshr i32 %193, %195
  %197 = uitofp i32 %196 to float
  %198 = load float, ptr @slop_threshold, align 4, !tbaa !9
  %199 = fsub float %198, %197
  store float %199, ptr @slop_threshold, align 4, !tbaa !9
  br label %200

200:                                              ; preds = %190, %182
  br label %201

201:                                              ; preds = %200, %179, %174
  br label %202

202:                                              ; preds = %201, %172
  br label %203

203:                                              ; preds = %202, %156
  %204 = getelementptr inbounds %struct.SignalPoint, ptr %5, i32 0, i32 1
  store i32 -1, ptr %204, align 4, !tbaa !12
  store i32 1, ptr %12, align 4
  br label %205

205:                                              ; preds = %203, %136, %95
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %206

206:                                              ; preds = %205, %15
  %207 = load i64, ptr %5, align 4
  ret i64 %207
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

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 nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"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 = !{i64 0, i64 4, !9, i64 4, i64 4, !5}
!12 = !{!13, !6, i64 4}
!13 = !{!"", !10, i64 0, !6, i64 4}
!14 = !{!13, !10, i64 0}
!15 = !{!16, !16, i64 0}
!16 = !{!"_Bool", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}


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

%struct.SignalPoint = type { float, i32 }

@signal_window_count = external hidden local_unnamed_addr global i32, align 4
@signal_window = external hidden local_unnamed_addr global [5 x %struct.SignalPoint], align 16
@slop = external hidden local_unnamed_addr global %struct.SignalPoint, align 4
@so_chen_init_flag = external hidden local_unnamed_addr global i8, align 1
@maxi_init = external hidden local_unnamed_addr global i8, align 1
@max = external hidden local_unnamed_addr global %struct.SignalPoint, align 4
@maxi = external hidden local_unnamed_addr global float, align 4
@init_count = external hidden local_unnamed_addr global i32, align 4
@slop_threshold = external hidden local_unnamed_addr global float, align 4
@qrs_on_set_flag = external hidden local_unnamed_addr global i8, align 1
@last_point = external hidden local_unnamed_addr global i32, align 4
@max_init = external hidden local_unnamed_addr global i8, align 1
@max_slop = external hidden local_unnamed_addr global %struct.SignalPoint, align 4
@qrs_onset_point = external hidden local_unnamed_addr global %struct.SignalPoint, align 4
@last_maxi = external hidden local_unnamed_addr global float, align 4
@qrs_on_set_count = external hidden local_unnamed_addr global i32, align 4
@qrs_onset_idx = 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 i64 @So_Chen_detect(i64 %0, i32 noundef %1, float noundef %2, float noundef %3) local_unnamed_addr #0 {
  %5 = load i32, ptr @signal_window_count, align 4, !tbaa !5
  %6 = icmp ult i32 %5, 5
  br i1 %6, label %7, label %11

7:                                                ; preds = %4
  %8 = zext nneg i32 %5 to i64
  %9 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %8
  store i64 %0, ptr %9, align 8
  %10 = add nuw nsw i32 %5, 1
  store i32 %10, ptr @signal_window_count, align 4, !tbaa !5
  br label %117

11:                                               ; preds = %4
  %12 = urem i32 %5, 5
  %13 = zext nneg i32 %12 to i64
  %14 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %13
  store i64 %0, ptr %14, align 8
  %15 = add i32 %5, 1
  store i32 %15, ptr @signal_window_count, align 4, !tbaa !5
  %16 = add i32 %5, -1
  %17 = add i32 %5, -3
  %18 = urem i32 %17, 5
  %19 = zext nneg i32 %18 to i64
  %20 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %19
  %21 = load float, ptr %20, align 8, !tbaa !9
  %22 = add i32 %5, -2
  %23 = urem i32 %22, 5
  %24 = zext nneg i32 %23 to i64
  %25 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %24
  %26 = load float, ptr %25, align 8, !tbaa !9
  %27 = fneg float %26
  %28 = tail call float @llvm.fmuladd.f32(float %21, float -2.000000e+00, float %27)
  %29 = trunc i64 %0 to i32
  %30 = bitcast i32 %29 to float
  %31 = fadd float %28, %30
  %32 = urem i32 %15, 5
  %33 = zext nneg i32 %32 to i64
  %34 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %33
  %35 = load float, ptr %34, align 8, !tbaa !9
  %36 = tail call float @llvm.fmuladd.f32(float %35, float 2.000000e+00, float %31)
  store float %36, ptr @slop, align 4, !tbaa !9
  %37 = urem i32 %16, 5
  %38 = zext nneg i32 %37 to i64
  %39 = getelementptr inbounds [5 x %struct.SignalPoint], ptr @signal_window, i64 0, i64 %38
  %40 = getelementptr inbounds i8, ptr %39, i64 4
  %41 = load i32, ptr %40, align 4, !tbaa !12
  store i32 %41, ptr getelementptr inbounds (i8, ptr @slop, i64 4), align 4, !tbaa !12
  %42 = load i8, ptr @so_chen_init_flag, align 1, !tbaa !13, !range !15, !noundef !16
  %43 = trunc nuw i8 %42 to i1
  br i1 %43, label %58, label %44

44:                                               ; preds = %11
  %45 = load i8, ptr @maxi_init, align 1, !tbaa !13, !range !15, !noundef !16
  %46 = trunc nuw i8 %45 to i1
  br i1 %46, label %._crit_edge27, label %47

._crit_edge27:                                    ; preds = %44
  %.pre.pre = load float, ptr @maxi, align 4, !tbaa !17
  br label %48

47:                                               ; preds = %44
  store float 0.000000e+00, ptr @max, align 4, !tbaa !9
  store i32 -1, ptr getelementptr inbounds (i8, ptr @max, i64 4), align 4, !tbaa !12
  store float %36, ptr @maxi, align 4, !tbaa !17
  store i8 1, ptr @maxi_init, align 1, !tbaa !13
  br label %48

48:                                               ; preds = %._crit_edge27, %47
  %.pre = phi float [ %.pre.pre, %._crit_edge27 ], [ %36, %47 ]
  %49 = load i32, ptr @init_count, align 4, !tbaa !5
  %50 = add i32 %49, 1
  store i32 %50, ptr @init_count, align 4, !tbaa !5
  %51 = icmp ugt i32 %50, %1
  br i1 %51, label %52, label %55

52:                                               ; preds = %48
  store i8 1, ptr @so_chen_init_flag, align 1, !tbaa !13
  %53 = fmul float %2, 6.250000e-02
  %54 = fmul float %53, %.pre
  store float %54, ptr @slop_threshold, align 4, !tbaa !17
  br label %55

55:                                               ; preds = %52, %48
  %56 = fcmp ogt float %36, %.pre
  br i1 %56, label %57, label %114

57:                                               ; preds = %55
  store float %36, ptr @maxi, align 4, !tbaa !17
  br label %114

58:                                               ; preds = %11
  %59 = load i8, ptr @qrs_on_set_flag, align 1, !tbaa !13, !range !15, !noundef !16
  %60 = trunc nuw i8 %59 to i1
  br i1 %60, label %61, label %92

61:                                               ; preds = %58
  %62 = load i32, ptr @last_point, align 4, !tbaa !5
  %63 = sub i32 %15, %62
  %64 = icmp ugt i32 %63, 126
  br i1 %64, label %65, label %92

65:                                               ; preds = %61
  %66 = load i8, ptr @max_init, align 1, !tbaa !13, !range !15, !noundef !16
  %67 = trunc nuw i8 %66 to i1
  br i1 %67, label %69, label %.thread32

.thread32:                                        ; preds = %65
  %68 = load i64, ptr %39, align 8
  store i64 %68, ptr @max, align 4
  store i8 1, ptr @max_init, align 1, !tbaa !13
  br label %114

69:                                               ; preds = %65
  %.pre24 = load float, ptr %39, align 8, !tbaa !9
  %.pre25 = load float, ptr @max, align 4
  %70 = bitcast float %.pre25 to i32
  %71 = fcmp ogt float %.pre24, %.pre25
  br i1 %71, label %72, label %75

72:                                               ; preds = %69
  %73 = load i64, ptr %39, align 8
  store i64 %73, ptr @max, align 4
  %74 = load i64, ptr @slop, align 4
  store i64 %74, ptr @max_slop, align 4
  br label %114

75:                                               ; preds = %69
  %76 = fcmp olt float %.pre24, %.pre25
  br i1 %76, label %77, label %114

77:                                               ; preds = %75
  store i32 %15, ptr @last_point, align 4, !tbaa !5
  store i8 0, ptr @qrs_on_set_flag, align 1, !tbaa !13
  store i8 0, ptr @max_init, align 1, !tbaa !13
  %78 = load float, ptr @qrs_onset_point, align 4, !tbaa !9
  %79 = fsub float %.pre25, %78
  %80 = fptosi float %79 to i32
  %81 = tail call i32 @llvm.abs.i32(i32 %80, i1 true)
  %82 = uitofp nneg i32 %81 to float
  %83 = load float, ptr @maxi, align 4, !tbaa !17
  %84 = fsub float %82, %83
  %85 = fdiv float %84, %3
  %86 = fadd float %83, %85
  store float %86, ptr @maxi, align 4, !tbaa !17
  %87 = fmul float %2, 6.250000e-02
  %88 = fmul float %87, %86
  store float %88, ptr @slop_threshold, align 4, !tbaa !17
  store float %86, ptr @last_maxi, align 4, !tbaa !17
  %.sroa.2.0.copyload = load i32, ptr getelementptr inbounds (i8, ptr @max, i64 4), align 4, !tbaa !5
  %89 = zext i32 %.sroa.2.0.copyload to i64
  %90 = shl nuw i64 %89, 32
  %91 = zext i32 %70 to i64
  br label %114

92:                                               ; preds = %61, %58
  %93 = load float, ptr @slop_threshold, align 4
  %94 = fcmp ogt float %36, %93
  %95 = load i32, ptr @qrs_on_set_count, align 4, !tbaa !5
  br i1 %94, label %98, label %96

96:                                               ; preds = %92
  %.not = icmp eq i32 %95, 0
  br i1 %.not, label %.thread, label %97

97:                                               ; preds = %96
  store i32 0, ptr @qrs_on_set_count, align 4, !tbaa !5
  br label %.thread

98:                                               ; preds = %92
  %99 = add nsw i32 %95, 1
  store i32 %99, ptr @qrs_on_set_count, align 4, !tbaa !5
  %100 = icmp sgt i32 %95, 0
  br i1 %100, label %101, label %.thread

101:                                              ; preds = %98
  store i8 1, ptr @qrs_on_set_flag, align 1, !tbaa !13
  store i32 0, ptr @qrs_on_set_count, align 4, !tbaa !5
  store i32 %16, ptr @qrs_onset_idx, align 4, !tbaa !5
  store i64 %0, ptr @qrs_onset_point, align 4
  br label %114

.thread:                                          ; preds = %97, %96, %98
  %102 = load i32, ptr @last_point, align 4, !tbaa !5
  %103 = sub i32 %15, %102
  %104 = icmp ugt i32 %103, 252
  %105 = fcmp ogt float %93, 0.000000e+00
  %or.cond = and i1 %105, %104
  br i1 %or.cond, label %106, label %114

106:                                              ; preds = %.thread
  %107 = fsub float %93, %36
  store float %107, ptr @slop_threshold, align 4, !tbaa !17
  %108 = icmp ugt i32 %103, 1080
  br i1 %108, label %109, label %114

109:                                              ; preds = %106
  %110 = fptosi float %2 to i32
  %111 = lshr i32 %103, %110
  %112 = uitofp i32 %111 to float
  %113 = fsub float %107, %112
  store float %113, ptr @slop_threshold, align 4, !tbaa !17
  br label %114

114:                                              ; preds = %.thread32, %75, %72, %.thread, %109, %106, %101, %55, %57, %77
  %115 = phi i64 [ %91, %77 ], [ 0, %57 ], [ 0, %55 ], [ 0, %101 ], [ 0, %106 ], [ 0, %109 ], [ 0, %.thread ], [ 0, %72 ], [ 0, %75 ], [ 0, %.thread32 ]
  %.sroa.2.0 = phi i64 [ %90, %77 ], [ -4294967296, %57 ], [ -4294967296, %55 ], [ -4294967296, %101 ], [ -4294967296, %106 ], [ -4294967296, %109 ], [ -4294967296, %.thread ], [ -4294967296, %72 ], [ -4294967296, %75 ], [ -4294967296, %.thread32 ]
  %116 = or disjoint i64 %.sroa.2.0, %115
  br label %117

117:                                              ; preds = %114, %7
  %.sroa.017.0.insert.insert = phi i64 [ -4294967296, %7 ], [ %116, %114 ]
  ret i64 %.sroa.017.0.insert.insert
}

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #1

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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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, !11, i64 0}
!10 = !{!"", !11, i64 0, !6, i64 4}
!11 = !{!"float", !7, i64 0}
!12 = !{!10, !6, i64 4}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!11, !11, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass