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

%struct.SignalPoint = type { float, i32 }

@ThresholdCalculate.bandpass_buffer = external hidden global [598 x i32], align 16
@ThresholdCalculate.integral_buffer = external hidden global [598 x i32], align 16
@ThresholdCalculate.peak_buffer = external hidden global [598 x %struct.SignalPoint], align 16
@ThresholdCalculate.square_buffer = external hidden global [36 x i32], align 16
@ThresholdCalculate.last_qrs = external hidden global i64, align 8
@ThresholdCalculate.last_slope = external hidden global i64, align 8
@ThresholdCalculate.current_slope = external hidden global i64, align 8
@ThresholdCalculate.peak_i = external hidden global i32, align 4
@ThresholdCalculate.peak_f = external hidden global i32, align 4
@ThresholdCalculate.threshold_i1 = external hidden global i32, align 4
@ThresholdCalculate.threshold_i2 = external hidden global i32, align 4
@ThresholdCalculate.threshold_f1 = external hidden global i32, align 4
@ThresholdCalculate.threshold_f2 = external hidden global i32, align 4
@ThresholdCalculate.spk_i = external hidden global i32, align 4
@ThresholdCalculate.spk_f = external hidden global i32, align 4
@ThresholdCalculate.npk_i = external hidden global i32, align 4
@ThresholdCalculate.npk_f = external hidden global i32, align 4
@ThresholdCalculate.qrs = external hidden global i8, align 1
@ThresholdCalculate.regular = external hidden global i8, align 1
@ThresholdCalculate.prev_regular = external hidden global i8, align 1
@ThresholdCalculate.rr1 = external hidden global [8 x i32], align 16
@ThresholdCalculate.rr2 = external hidden global [8 x i32], align 16
@ThresholdCalculate.rravg1 = external hidden global i32, align 4
@ThresholdCalculate.rravg2 = external hidden global i32, align 4
@ThresholdCalculate.rrlow = external hidden global i32, align 4
@ThresholdCalculate.rrhigh = external hidden global i32, align 4
@ThresholdCalculate.rrmiss = external hidden global i32, align 4

; 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
define dso_local i64 @ThresholdCalculate(i32 noundef %0, float noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca %struct.SignalPoint, align 4
  %7 = alloca i32, align 4
  %8 = alloca float, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.SignalPoint, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  %24 = alloca i32, align 4
  %25 = alloca i32, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store float %1, ptr %8, align 4, !tbaa !9
  store i32 %2, ptr %9, align 4, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %26 = getelementptr inbounds %struct.SignalPoint, ptr %12, i32 0, i32 1
  store i32 -1, ptr %26, align 4, !tbaa !11
  %27 = load i32, ptr %7, align 4, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = srem i32 %28, 598
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [598 x %struct.SignalPoint], ptr @ThresholdCalculate.peak_buffer, i64 0, i64 %30
  %32 = getelementptr inbounds %struct.SignalPoint, ptr %31, i32 0, i32 1
  store i32 %27, ptr %32, align 4, !tbaa !11
  %33 = load float, ptr %8, align 4, !tbaa !9
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = srem i32 %34, 598
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [598 x %struct.SignalPoint], ptr @ThresholdCalculate.peak_buffer, i64 0, i64 %36
  %38 = getelementptr inbounds %struct.SignalPoint, ptr %37, i32 0, i32 0
  store float %33, ptr %38, align 8, !tbaa !13
  %39 = load i32, ptr %9, align 4, !tbaa !5
  %40 = load i32, ptr %7, align 4, !tbaa !5
  %41 = srem i32 %40, 598
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.bandpass_buffer, i64 0, i64 %42
  store i32 %39, ptr %43, align 4, !tbaa !5
  %44 = load i32, ptr %11, align 4, !tbaa !5
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = srem i32 %45, 598
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.integral_buffer, i64 0, i64 %47
  store i32 %44, ptr %48, align 4, !tbaa !5
  %49 = load i32, ptr %10, align 4, !tbaa !5
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = srem i32 %50, 36
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %52
  store i32 %49, ptr %53, align 4, !tbaa !5
  %54 = load i32, ptr %11, align 4, !tbaa !5
  %55 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %56 = icmp sge i32 %54, %55
  br i1 %56, label %61, label %57

57:                                               ; preds = %5
  %58 = load i32, ptr %9, align 4, !tbaa !5
  %59 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %60 = icmp sge i32 %58, %59
  br i1 %60, label %61, label %64

61:                                               ; preds = %57, %5
  %62 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %62, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !5
  %63 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %63, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %61, %57
  %65 = load i32, ptr %11, align 4, !tbaa !5
  %66 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %67 = icmp sge i32 %65, %66
  br i1 %67, label %68, label %283

68:                                               ; preds = %64
  %69 = load i32, ptr %9, align 4, !tbaa !5
  %70 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %71 = icmp sge i32 %69, %70
  br i1 %71, label %72, label %283

72:                                               ; preds = %68
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = sitofp i32 %73 to float
  %75 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %76 = uitofp i64 %75 to float
  %77 = fadd float %76, 7.200000e+01
  %78 = fcmp ogt float %74, %77
  br i1 %78, label %79, label %241

79:                                               ; preds = %72
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %83 = add i64 %82, 129
  %84 = icmp ule i64 %81, %83
  br i1 %84, label %85, label %167

85:                                               ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %86 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %86, ptr %13, align 4, !tbaa !5
  store i64 0, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %87 = load i32, ptr %13, align 4, !tbaa !5
  %88 = sub nsw i32 %87, 36
  store i32 %88, ptr %14, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %111, %85
  %90 = load i32, ptr %14, align 4, !tbaa !5
  %91 = load i32, ptr %13, align 4, !tbaa !5
  %92 = icmp sle i32 %90, %91
  br i1 %92, label %94, label %93

93:                                               ; preds = %89
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %114

94:                                               ; preds = %89
  %95 = load i32, ptr %14, align 4, !tbaa !5
  %96 = srem i32 %95, 36
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = load i64, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  %102 = icmp ugt i64 %100, %101
  br i1 %102, label %103, label %110

103:                                              ; preds = %94
  %104 = load i32, ptr %14, align 4, !tbaa !5
  %105 = srem i32 %104, 36
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  store i64 %109, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  br label %110

110:                                              ; preds = %103, %94
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %14, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %14, align 4, !tbaa !5
  br label %89, !llvm.loop !16

114:                                              ; preds = %93
  %115 = load i64, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  %116 = load i64, ptr @ThresholdCalculate.last_slope, align 8, !tbaa !14
  %117 = udiv i64 %116, 2
  %118 = trunc i64 %117 to i32
  %119 = sext i32 %118 to i64
  %120 = icmp ule i64 %115, %119
  br i1 %120, label %121, label %122

121:                                              ; preds = %114
  store i8 0, ptr @ThresholdCalculate.qrs, align 1, !tbaa !18
  br label %166

122:                                              ; preds = %114
  %123 = load i32, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !5
  %124 = sitofp i32 %123 to double
  %125 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %126 = sitofp i32 %125 to double
  %127 = fmul double 8.750000e-01, %126
  %128 = call double @llvm.fmuladd.f64(double 1.250000e-01, double %124, double %127)
  %129 = fptosi double %128 to i32
  store i32 %129, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %130 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %131 = sitofp i32 %130 to double
  %132 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %133 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %134 = sub nsw i32 %132, %133
  %135 = sitofp i32 %134 to double
  %136 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %135, double %131)
  %137 = fptosi double %136 to i32
  store i32 %137, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %138 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %139 = sitofp i32 %138 to double
  %140 = fmul double 5.000000e-01, %139
  %141 = fptosi double %140 to i32
  store i32 %141, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !5
  %142 = load i32, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !5
  %143 = sitofp i32 %142 to double
  %144 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %145 = sitofp i32 %144 to double
  %146 = fmul double 8.750000e-01, %145
  %147 = call double @llvm.fmuladd.f64(double 1.250000e-01, double %143, double %146)
  %148 = fptosi double %147 to i32
  store i32 %148, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %149 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %150 = sitofp i32 %149 to double
  %151 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %152 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %153 = sub nsw i32 %151, %152
  %154 = sitofp i32 %153 to double
  %155 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %154, double %150)
  %156 = fptosi double %155 to i32
  store i32 %156, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %157 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %158 = sitofp i32 %157 to double
  %159 = fmul double 5.000000e-01, %158
  %160 = fptosi double %159 to i32
  store i32 %160, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !5
  %161 = load i64, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  store i64 %161, ptr @ThresholdCalculate.last_slope, align 8, !tbaa !14
  store i8 1, ptr @ThresholdCalculate.qrs, align 1, !tbaa !18
  %162 = load float, ptr %8, align 4, !tbaa !9
  %163 = getelementptr inbounds %struct.SignalPoint, ptr %12, i32 0, i32 0
  store float %162, ptr %163, align 4, !tbaa !13
  %164 = load i32, ptr %7, align 4, !tbaa !5
  %165 = getelementptr inbounds %struct.SignalPoint, ptr %12, i32 0, i32 1
  store i32 %164, ptr %165, align 4, !tbaa !11
  br label %166

166:                                              ; preds = %122, %121
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %240

167:                                              ; preds = %79
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %168 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %168, ptr %15, align 4, !tbaa !5
  store i64 0, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %169 = load i32, ptr %15, align 4, !tbaa !5
  %170 = sub nsw i32 %169, 36
  store i32 %170, ptr %16, align 4, !tbaa !5
  br label %171

171:                                              ; preds = %193, %167
  %172 = load i32, ptr %16, align 4, !tbaa !5
  %173 = load i32, ptr %15, align 4, !tbaa !5
  %174 = icmp sle i32 %172, %173
  br i1 %174, label %176, label %175

175:                                              ; preds = %171
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  br label %196

176:                                              ; preds = %171
  %177 = load i32, ptr %16, align 4, !tbaa !5
  %178 = srem i32 %177, 36
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %179
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = sext i32 %181 to i64
  %183 = load i64, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  %184 = icmp ugt i64 %182, %183
  br i1 %184, label %185, label %192

185:                                              ; preds = %176
  %186 = load i32, ptr %16, align 4, !tbaa !5
  %187 = srem i32 %186, 36
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %188
  %190 = load i32, ptr %189, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  store i64 %191, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  br label %192

192:                                              ; preds = %185, %176
  br label %193

193:                                              ; preds = %192
  %194 = load i32, ptr %16, align 4, !tbaa !5
  %195 = add nsw i32 %194, 1
  store i32 %195, ptr %16, align 4, !tbaa !5
  br label %171, !llvm.loop !20

196:                                              ; preds = %175
  %197 = load i32, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !5
  %198 = sitofp i32 %197 to double
  %199 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %200 = sitofp i32 %199 to double
  %201 = fmul double 8.750000e-01, %200
  %202 = call double @llvm.fmuladd.f64(double 1.250000e-01, double %198, double %201)
  %203 = fptosi double %202 to i32
  store i32 %203, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %204 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %205 = sitofp i32 %204 to double
  %206 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %207 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %208 = sub nsw i32 %206, %207
  %209 = sitofp i32 %208 to double
  %210 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %209, double %205)
  %211 = fptosi double %210 to i32
  store i32 %211, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %212 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %213 = sitofp i32 %212 to double
  %214 = fmul double 5.000000e-01, %213
  %215 = fptosi double %214 to i32
  store i32 %215, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !5
  %216 = load i32, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !5
  %217 = sitofp i32 %216 to double
  %218 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %219 = sitofp i32 %218 to double
  %220 = fmul double 8.750000e-01, %219
  %221 = call double @llvm.fmuladd.f64(double 1.250000e-01, double %217, double %220)
  %222 = fptosi double %221 to i32
  store i32 %222, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %223 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %224 = sitofp i32 %223 to double
  %225 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %226 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %227 = sub nsw i32 %225, %226
  %228 = sitofp i32 %227 to double
  %229 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %228, double %224)
  %230 = fptosi double %229 to i32
  store i32 %230, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %231 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %232 = sitofp i32 %231 to double
  %233 = fmul double 5.000000e-01, %232
  %234 = fptosi double %233 to i32
  store i32 %234, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !5
  %235 = load i64, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  store i64 %235, ptr @ThresholdCalculate.last_slope, align 8, !tbaa !14
  store i8 1, ptr @ThresholdCalculate.qrs, align 1, !tbaa !18
  %236 = load float, ptr %8, align 4, !tbaa !9
  %237 = getelementptr inbounds %struct.SignalPoint, ptr %12, i32 0, i32 0
  store float %236, ptr %237, align 4, !tbaa !13
  %238 = load i32, ptr %7, align 4, !tbaa !5
  %239 = getelementptr inbounds %struct.SignalPoint, ptr %12, i32 0, i32 1
  store i32 %238, ptr %239, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %240

240:                                              ; preds = %196, %166
  br label %282

241:                                              ; preds = %72
  %242 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %242, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !5
  %243 = load i32, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !5
  %244 = sitofp i32 %243 to double
  %245 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %246 = sitofp i32 %245 to double
  %247 = fmul double 8.750000e-01, %246
  %248 = call double @llvm.fmuladd.f64(double 1.250000e-01, double %244, double %247)
  %249 = fptosi double %248 to i32
  store i32 %249, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %250 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %251 = sitofp i32 %250 to double
  %252 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %253 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %254 = sub nsw i32 %252, %253
  %255 = sitofp i32 %254 to double
  %256 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %255, double %251)
  %257 = fptosi double %256 to i32
  store i32 %257, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %258 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %259 = sitofp i32 %258 to double
  %260 = fmul double 5.000000e-01, %259
  %261 = fptosi double %260 to i32
  store i32 %261, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !5
  %262 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %262, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !5
  %263 = load i32, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !5
  %264 = sitofp i32 %263 to double
  %265 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %266 = sitofp i32 %265 to double
  %267 = fmul double 8.750000e-01, %266
  %268 = call double @llvm.fmuladd.f64(double 1.250000e-01, double %264, double %267)
  %269 = fptosi double %268 to i32
  store i32 %269, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %270 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %271 = sitofp i32 %270 to double
  %272 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %273 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %274 = sub nsw i32 %272, %273
  %275 = sitofp i32 %274 to double
  %276 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %275, double %271)
  %277 = fptosi double %276 to i32
  store i32 %277, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %278 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %279 = sitofp i32 %278 to double
  %280 = fmul double 5.000000e-01, %279
  %281 = fptosi double %280 to i32
  store i32 %281, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !5
  store i8 0, ptr @ThresholdCalculate.qrs, align 1, !tbaa !18
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !21
  store i32 1, ptr %17, align 4
  br label %747

282:                                              ; preds = %240
  br label %283

283:                                              ; preds = %282, %68, %64
  %284 = load i8, ptr @ThresholdCalculate.qrs, align 1, !tbaa !18, !range !22, !noundef !23
  %285 = trunc i8 %284 to i1
  br i1 %285, label %286, label %393

286:                                              ; preds = %283
  store i32 0, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #4
  store i32 0, ptr %18, align 4, !tbaa !5
  br label %287

287:                                              ; preds = %306, %286
  %288 = load i32, ptr %18, align 4, !tbaa !5
  %289 = icmp slt i32 %288, 7
  br i1 %289, label %291, label %290

290:                                              ; preds = %287
  store i32 8, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #4
  br label %309

291:                                              ; preds = %287
  %292 = load i32, ptr %18, align 4, !tbaa !5
  %293 = add nsw i32 %292, 1
  %294 = sext i32 %293 to i64
  %295 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 %294
  %296 = load i32, ptr %295, align 4, !tbaa !5
  %297 = load i32, ptr %18, align 4, !tbaa !5
  %298 = sext i32 %297 to i64
  %299 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 %298
  store i32 %296, ptr %299, align 4, !tbaa !5
  %300 = load i32, ptr %18, align 4, !tbaa !5
  %301 = sext i32 %300 to i64
  %302 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 %301
  %303 = load i32, ptr %302, align 4, !tbaa !5
  %304 = load i32, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %305 = add nsw i32 %304, %303
  store i32 %305, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  br label %306

306:                                              ; preds = %291
  %307 = load i32, ptr %18, align 4, !tbaa !5
  %308 = add nsw i32 %307, 1
  store i32 %308, ptr %18, align 4, !tbaa !5
  br label %287, !llvm.loop !24

309:                                              ; preds = %290
  %310 = load i32, ptr %7, align 4, !tbaa !5
  %311 = sext i32 %310 to i64
  %312 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %313 = sub i64 %311, %312
  %314 = trunc i64 %313 to i32
  store i32 %314, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  %315 = load i32, ptr %7, align 4, !tbaa !5
  %316 = sext i32 %315 to i64
  store i64 %316, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %317 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  %318 = load i32, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %319 = add nsw i32 %318, %317
  store i32 %319, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %320 = load i32, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %321 = sitofp i32 %320 to double
  %322 = fmul double %321, 1.250000e-01
  %323 = fptosi double %322 to i32
  store i32 %323, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %324 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  %325 = load i32, ptr @ThresholdCalculate.rrlow, align 4, !tbaa !5
  %326 = icmp sge i32 %324, %325
  br i1 %326, label %327, label %375

327:                                              ; preds = %309
  %328 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  %329 = load i32, ptr @ThresholdCalculate.rrhigh, align 4, !tbaa !5
  %330 = icmp sle i32 %328, %329
  br i1 %330, label %331, label %375

331:                                              ; preds = %327
  store i32 0, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  store i32 0, ptr %19, align 4, !tbaa !5
  br label %332

332:                                              ; preds = %351, %331
  %333 = load i32, ptr %19, align 4, !tbaa !5
  %334 = icmp slt i32 %333, 7
  br i1 %334, label %336, label %335

335:                                              ; preds = %332
  store i32 11, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %354

336:                                              ; preds = %332
  %337 = load i32, ptr %19, align 4, !tbaa !5
  %338 = add nsw i32 %337, 1
  %339 = sext i32 %338 to i64
  %340 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 %339
  %341 = load i32, ptr %340, align 4, !tbaa !5
  %342 = load i32, ptr %19, align 4, !tbaa !5
  %343 = sext i32 %342 to i64
  %344 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 %343
  store i32 %341, ptr %344, align 4, !tbaa !5
  %345 = load i32, ptr %19, align 4, !tbaa !5
  %346 = sext i32 %345 to i64
  %347 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 %346
  %348 = load i32, ptr %347, align 4, !tbaa !5
  %349 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %350 = add nsw i32 %349, %348
  store i32 %350, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  br label %351

351:                                              ; preds = %336
  %352 = load i32, ptr %19, align 4, !tbaa !5
  %353 = add nsw i32 %352, 1
  store i32 %353, ptr %19, align 4, !tbaa !5
  br label %332, !llvm.loop !25

354:                                              ; preds = %335
  %355 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  store i32 %355, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 7), align 4, !tbaa !5
  %356 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 7), align 4, !tbaa !5
  %357 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %358 = add nsw i32 %357, %356
  store i32 %358, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %359 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %360 = sitofp i32 %359 to double
  %361 = fmul double %360, 1.250000e-01
  %362 = fptosi double %361 to i32
  store i32 %362, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %363 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %364 = sitofp i32 %363 to double
  %365 = fmul double 9.200000e-01, %364
  %366 = fptosi double %365 to i32
  store i32 %366, ptr @ThresholdCalculate.rrlow, align 4, !tbaa !5
  %367 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %368 = sitofp i32 %367 to double
  %369 = fmul double 1.160000e+00, %368
  %370 = fptosi double %369 to i32
  store i32 %370, ptr @ThresholdCalculate.rrhigh, align 4, !tbaa !5
  %371 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %372 = sitofp i32 %371 to double
  %373 = fmul double 1.660000e+00, %372
  %374 = fptosi double %373 to i32
  store i32 %374, ptr @ThresholdCalculate.rrmiss, align 4, !tbaa !5
  br label %375

375:                                              ; preds = %354, %327, %309
  %376 = load i8, ptr @ThresholdCalculate.regular, align 1, !tbaa !18, !range !22, !noundef !23
  %377 = trunc i8 %376 to i1
  %378 = zext i1 %377 to i8
  store i8 %378, ptr @ThresholdCalculate.prev_regular, align 1, !tbaa !18
  %379 = load i32, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %380 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %381 = icmp eq i32 %379, %380
  br i1 %381, label %382, label %383

382:                                              ; preds = %375
  store i8 1, ptr @ThresholdCalculate.regular, align 1, !tbaa !18
  br label %392

383:                                              ; preds = %375
  store i8 0, ptr @ThresholdCalculate.regular, align 1, !tbaa !18
  %384 = load i8, ptr @ThresholdCalculate.prev_regular, align 1, !tbaa !18, !range !22, !noundef !23
  %385 = trunc i8 %384 to i1
  br i1 %385, label %386, label %391

386:                                              ; preds = %383
  %387 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %388 = sdiv i32 %387, 2
  store i32 %388, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %389 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %390 = sdiv i32 %389, 2
  store i32 %390, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  br label %391

391:                                              ; preds = %386, %383
  br label %392

392:                                              ; preds = %391, %382
  br label %746

393:                                              ; preds = %283
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %394 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %394, ptr %20, align 4, !tbaa !5
  %395 = load i32, ptr %7, align 4, !tbaa !5
  %396 = sext i32 %395 to i64
  %397 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %398 = sub i64 %396, %397
  %399 = load i32, ptr @ThresholdCalculate.rrmiss, align 4, !tbaa !5
  %400 = sext i32 %399 to i64
  %401 = icmp ugt i64 %398, %400
  br i1 %401, label %402, label %689

402:                                              ; preds = %393
  %403 = load i32, ptr %7, align 4, !tbaa !5
  %404 = sitofp i32 %403 to float
  %405 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %406 = uitofp i64 %405 to float
  %407 = fadd float %406, 7.200000e+01
  %408 = fcmp ogt float %404, %407
  br i1 %408, label %409, label %689

409:                                              ; preds = %402
  %410 = load i32, ptr %7, align 4, !tbaa !5
  %411 = sext i32 %410 to i64
  %412 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %413 = sub i64 %411, %412
  %414 = icmp ugt i64 %413, 598
  br i1 %414, label %415, label %418

415:                                              ; preds = %409
  %416 = load i32, ptr %7, align 4, !tbaa !5
  %417 = sext i32 %416 to i64
  store i64 %417, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  br label %418

418:                                              ; preds = %415, %409
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  store i32 0, ptr %21, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %419 = load i32, ptr %20, align 4, !tbaa !5
  %420 = sext i32 %419 to i64
  %421 = load i32, ptr %7, align 4, !tbaa !5
  %422 = sext i32 %421 to i64
  %423 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %424 = sub i64 %422, %423
  %425 = sub i64 %420, %424
  %426 = uitofp i64 %425 to float
  %427 = fadd float %426, 7.200000e+01
  %428 = fptosi float %427 to i32
  store i32 %428, ptr %22, align 4, !tbaa !5
  br label %429

429:                                              ; preds = %673, %418
  %430 = load i32, ptr %22, align 4, !tbaa !5
  %431 = sext i32 %430 to i64
  %432 = load i32, ptr %20, align 4, !tbaa !5
  %433 = sext i32 %432 to i64
  %434 = icmp ult i64 %431, %433
  br i1 %434, label %436, label %435

435:                                              ; preds = %429
  store i32 14, ptr %17, align 4
  br label %676

436:                                              ; preds = %429
  %437 = load i32, ptr %22, align 4, !tbaa !5
  %438 = srem i32 %437, 598
  %439 = sext i32 %438 to i64
  %440 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.integral_buffer, i64 0, i64 %439
  %441 = load i32, ptr %440, align 4, !tbaa !5
  %442 = load i32, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !5
  %443 = icmp sgt i32 %441, %442
  br i1 %443, label %444, label %672

444:                                              ; preds = %436
  %445 = load i32, ptr %22, align 4, !tbaa !5
  %446 = srem i32 %445, 598
  %447 = sext i32 %446 to i64
  %448 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.bandpass_buffer, i64 0, i64 %447
  %449 = load i32, ptr %448, align 4, !tbaa !5
  %450 = load i32, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !5
  %451 = icmp sgt i32 %449, %450
  br i1 %451, label %452, label %672

452:                                              ; preds = %444
  store i64 0, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %453 = load i32, ptr %20, align 4, !tbaa !5
  %454 = sub nsw i32 %453, 36
  store i32 %454, ptr %23, align 4, !tbaa !5
  br label %455

455:                                              ; preds = %477, %452
  %456 = load i32, ptr %23, align 4, !tbaa !5
  %457 = load i32, ptr %20, align 4, !tbaa !5
  %458 = icmp sle i32 %456, %457
  br i1 %458, label %460, label %459

459:                                              ; preds = %455
  store i32 17, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  br label %480

460:                                              ; preds = %455
  %461 = load i32, ptr %23, align 4, !tbaa !5
  %462 = srem i32 %461, 36
  %463 = sext i32 %462 to i64
  %464 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %463
  %465 = load i32, ptr %464, align 4, !tbaa !5
  %466 = sext i32 %465 to i64
  %467 = load i64, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  %468 = icmp ugt i64 %466, %467
  br i1 %468, label %469, label %476

469:                                              ; preds = %460
  %470 = load i32, ptr %23, align 4, !tbaa !5
  %471 = srem i32 %470, 36
  %472 = sext i32 %471 to i64
  %473 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %472
  %474 = load i32, ptr %473, align 4, !tbaa !5
  %475 = sext i32 %474 to i64
  store i64 %475, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  br label %476

476:                                              ; preds = %469, %460
  br label %477

477:                                              ; preds = %476
  %478 = load i32, ptr %23, align 4, !tbaa !5
  %479 = add nsw i32 %478, 1
  store i32 %479, ptr %23, align 4, !tbaa !5
  br label %455, !llvm.loop !26

480:                                              ; preds = %459
  %481 = load i64, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  %482 = load i64, ptr @ThresholdCalculate.last_slope, align 8, !tbaa !14
  %483 = udiv i64 %482, 2
  %484 = trunc i64 %483 to i32
  %485 = sext i32 %484 to i64
  %486 = icmp ult i64 %481, %485
  br i1 %486, label %487, label %499

487:                                              ; preds = %480
  %488 = load i32, ptr %22, align 4, !tbaa !5
  %489 = load i32, ptr %7, align 4, !tbaa !5
  %490 = add nsw i32 %488, %489
  %491 = sitofp i32 %490 to double
  %492 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %493 = uitofp i64 %492 to double
  %494 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %495 = uitofp i64 %494 to double
  %496 = call double @llvm.fmuladd.f64(double 3.600000e-01, double %495, double %493)
  %497 = fcmp olt double %491, %496
  br i1 %497, label %498, label %499

498:                                              ; preds = %487
  store i8 0, ptr @ThresholdCalculate.qrs, align 1, !tbaa !18
  br label %671

499:                                              ; preds = %487, %480
  %500 = load i32, ptr %22, align 4, !tbaa !5
  %501 = sext i32 %500 to i64
  %502 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %503 = sub i64 %501, %502
  %504 = icmp ugt i64 %503, 550
  br i1 %504, label %505, label %670

505:                                              ; preds = %499
  %506 = load i32, ptr %22, align 4, !tbaa !5
  %507 = srem i32 %506, 598
  %508 = sext i32 %507 to i64
  %509 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.integral_buffer, i64 0, i64 %508
  %510 = load i32, ptr %509, align 4, !tbaa !5
  store i32 %510, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !5
  %511 = load i32, ptr %22, align 4, !tbaa !5
  %512 = srem i32 %511, 598
  %513 = sext i32 %512 to i64
  %514 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.bandpass_buffer, i64 0, i64 %513
  %515 = load i32, ptr %514, align 4, !tbaa !5
  store i32 %515, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !5
  %516 = load i32, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !5
  %517 = sitofp i32 %516 to double
  %518 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %519 = sitofp i32 %518 to double
  %520 = fmul double 7.500000e-01, %519
  %521 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %517, double %520)
  %522 = fptosi double %521 to i32
  store i32 %522, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %523 = load i32, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !5
  %524 = sitofp i32 %523 to double
  %525 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %526 = sitofp i32 %525 to double
  %527 = fmul double 7.500000e-01, %526
  %528 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %524, double %527)
  %529 = fptosi double %528 to i32
  store i32 %529, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %530 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %531 = sitofp i32 %530 to double
  %532 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %533 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %534 = sub nsw i32 %532, %533
  %535 = sitofp i32 %534 to double
  %536 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %535, double %531)
  %537 = fptosi double %536 to i32
  store i32 %537, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %538 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %539 = sitofp i32 %538 to double
  %540 = fmul double 5.000000e-01, %539
  %541 = fptosi double %540 to i32
  store i32 %541, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !5
  %542 = load i64, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !14
  store i64 %542, ptr @ThresholdCalculate.last_slope, align 8, !tbaa !14
  %543 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %544 = sitofp i32 %543 to double
  %545 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %546 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %547 = sub nsw i32 %545, %546
  %548 = sitofp i32 %547 to double
  %549 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %548, double %544)
  %550 = fptosi double %549 to i32
  store i32 %550, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %551 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %552 = sitofp i32 %551 to double
  %553 = fmul double 5.000000e-01, %552
  %554 = fptosi double %553 to i32
  store i32 %554, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !5
  store i32 0, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %24) #4
  store i32 0, ptr %24, align 4, !tbaa !5
  br label %555

555:                                              ; preds = %574, %505
  %556 = load i32, ptr %24, align 4, !tbaa !5
  %557 = icmp slt i32 %556, 7
  br i1 %557, label %559, label %558

558:                                              ; preds = %555
  store i32 20, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %24) #4
  br label %577

559:                                              ; preds = %555
  %560 = load i32, ptr %24, align 4, !tbaa !5
  %561 = add nsw i32 %560, 1
  %562 = sext i32 %561 to i64
  %563 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 %562
  %564 = load i32, ptr %563, align 4, !tbaa !5
  %565 = load i32, ptr %24, align 4, !tbaa !5
  %566 = sext i32 %565 to i64
  %567 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 %566
  store i32 %564, ptr %567, align 4, !tbaa !5
  %568 = load i32, ptr %24, align 4, !tbaa !5
  %569 = sext i32 %568 to i64
  %570 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 %569
  %571 = load i32, ptr %570, align 4, !tbaa !5
  %572 = load i32, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %573 = add nsw i32 %572, %571
  store i32 %573, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  br label %574

574:                                              ; preds = %559
  %575 = load i32, ptr %24, align 4, !tbaa !5
  %576 = add nsw i32 %575, 1
  store i32 %576, ptr %24, align 4, !tbaa !5
  br label %555, !llvm.loop !27

577:                                              ; preds = %558
  %578 = load i32, ptr %7, align 4, !tbaa !5
  %579 = load i32, ptr %20, align 4, !tbaa !5
  %580 = load i32, ptr %22, align 4, !tbaa !5
  %581 = sub nsw i32 %579, %580
  %582 = sub nsw i32 %578, %581
  %583 = sext i32 %582 to i64
  %584 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %585 = sub i64 %583, %584
  %586 = trunc i64 %585 to i32
  store i32 %586, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  store i8 1, ptr @ThresholdCalculate.qrs, align 1, !tbaa !18
  %587 = load i32, ptr %22, align 4, !tbaa !5
  store i32 %587, ptr %21, align 4, !tbaa !5
  %588 = load i32, ptr %7, align 4, !tbaa !5
  %589 = load i32, ptr %20, align 4, !tbaa !5
  %590 = load i32, ptr %22, align 4, !tbaa !5
  %591 = sub nsw i32 %589, %590
  %592 = sub nsw i32 %588, %591
  %593 = sext i32 %592 to i64
  store i64 %593, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !14
  %594 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  %595 = load i32, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %596 = add nsw i32 %595, %594
  store i32 %596, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %597 = load i32, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %598 = sitofp i32 %597 to double
  %599 = fmul double %598, 1.250000e-01
  %600 = fptosi double %599 to i32
  store i32 %600, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %601 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  %602 = load i32, ptr @ThresholdCalculate.rrlow, align 4, !tbaa !5
  %603 = icmp sge i32 %601, %602
  br i1 %603, label %604, label %652

604:                                              ; preds = %577
  %605 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  %606 = load i32, ptr @ThresholdCalculate.rrhigh, align 4, !tbaa !5
  %607 = icmp sle i32 %605, %606
  br i1 %607, label %608, label %652

608:                                              ; preds = %604
  store i32 0, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %25) #4
  store i32 0, ptr %25, align 4, !tbaa !5
  br label %609

609:                                              ; preds = %628, %608
  %610 = load i32, ptr %25, align 4, !tbaa !5
  %611 = icmp slt i32 %610, 7
  br i1 %611, label %613, label %612

612:                                              ; preds = %609
  store i32 23, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %25) #4
  br label %631

613:                                              ; preds = %609
  %614 = load i32, ptr %25, align 4, !tbaa !5
  %615 = add nsw i32 %614, 1
  %616 = sext i32 %615 to i64
  %617 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 %616
  %618 = load i32, ptr %617, align 4, !tbaa !5
  %619 = load i32, ptr %25, align 4, !tbaa !5
  %620 = sext i32 %619 to i64
  %621 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 %620
  store i32 %618, ptr %621, align 4, !tbaa !5
  %622 = load i32, ptr %25, align 4, !tbaa !5
  %623 = sext i32 %622 to i64
  %624 = getelementptr inbounds [8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 %623
  %625 = load i32, ptr %624, align 4, !tbaa !5
  %626 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %627 = add nsw i32 %626, %625
  store i32 %627, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  br label %628

628:                                              ; preds = %613
  %629 = load i32, ptr %25, align 4, !tbaa !5
  %630 = add nsw i32 %629, 1
  store i32 %630, ptr %25, align 4, !tbaa !5
  br label %609, !llvm.loop !28

631:                                              ; preds = %612
  %632 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr1, i64 0, i64 7), align 4, !tbaa !5
  store i32 %632, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 7), align 4, !tbaa !5
  %633 = load i32, ptr getelementptr inbounds ([8 x i32], ptr @ThresholdCalculate.rr2, i64 0, i64 7), align 4, !tbaa !5
  %634 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %635 = add nsw i32 %634, %633
  store i32 %635, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %636 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %637 = sitofp i32 %636 to double
  %638 = fmul double %637, 1.250000e-01
  %639 = fptosi double %638 to i32
  store i32 %639, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %640 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %641 = sitofp i32 %640 to double
  %642 = fmul double 9.200000e-01, %641
  %643 = fptosi double %642 to i32
  store i32 %643, ptr @ThresholdCalculate.rrlow, align 4, !tbaa !5
  %644 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %645 = sitofp i32 %644 to double
  %646 = fmul double 1.160000e+00, %645
  %647 = fptosi double %646 to i32
  store i32 %647, ptr @ThresholdCalculate.rrhigh, align 4, !tbaa !5
  %648 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %649 = sitofp i32 %648 to double
  %650 = fmul double 1.660000e+00, %649
  %651 = fptosi double %650 to i32
  store i32 %651, ptr @ThresholdCalculate.rrmiss, align 4, !tbaa !5
  br label %652

652:                                              ; preds = %631, %604, %577
  %653 = load i8, ptr @ThresholdCalculate.regular, align 1, !tbaa !18, !range !22, !noundef !23
  %654 = trunc i8 %653 to i1
  %655 = zext i1 %654 to i8
  store i8 %655, ptr @ThresholdCalculate.prev_regular, align 1, !tbaa !18
  %656 = load i32, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !5
  %657 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !5
  %658 = icmp eq i32 %656, %657
  br i1 %658, label %659, label %660

659:                                              ; preds = %652
  store i8 1, ptr @ThresholdCalculate.regular, align 1, !tbaa !18
  br label %669

660:                                              ; preds = %652
  store i8 0, ptr @ThresholdCalculate.regular, align 1, !tbaa !18
  %661 = load i8, ptr @ThresholdCalculate.prev_regular, align 1, !tbaa !18, !range !22, !noundef !23
  %662 = trunc i8 %661 to i1
  br i1 %662, label %663, label %668

663:                                              ; preds = %660
  %664 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %665 = sdiv i32 %664, 2
  store i32 %665, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %666 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %667 = sdiv i32 %666, 2
  store i32 %667, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  br label %668

668:                                              ; preds = %663, %660
  br label %669

669:                                              ; preds = %668, %659
  store i32 14, ptr %17, align 4
  br label %676

670:                                              ; preds = %499
  br label %671

671:                                              ; preds = %670, %498
  br label %672

672:                                              ; preds = %671, %444, %436
  br label %673

673:                                              ; preds = %672
  %674 = load i32, ptr %22, align 4, !tbaa !5
  %675 = add nsw i32 %674, 1
  store i32 %675, ptr %22, align 4, !tbaa !5
  br label %429, !llvm.loop !29

676:                                              ; preds = %669, %435
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  br label %677

677:                                              ; preds = %676
  %678 = load i8, ptr @ThresholdCalculate.qrs, align 1, !tbaa !18, !range !22, !noundef !23
  %679 = trunc i8 %678 to i1
  br i1 %679, label %680, label %685

680:                                              ; preds = %677
  %681 = load i32, ptr %21, align 4, !tbaa !5
  %682 = srem i32 %681, 598
  %683 = sext i32 %682 to i64
  %684 = getelementptr inbounds [598 x %struct.SignalPoint], ptr @ThresholdCalculate.peak_buffer, i64 0, i64 %683
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 8 %684, i64 8, i1 false), !tbaa.struct !21
  store i32 1, ptr %17, align 4
  br label %686

685:                                              ; preds = %677
  store i32 0, ptr %17, align 4
  br label %686

686:                                              ; preds = %685, %680
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  %687 = load i32, ptr %17, align 4
  switch i32 %687, label %743 [
    i32 0, label %688
  ]

688:                                              ; preds = %686
  br label %689

689:                                              ; preds = %688, %402, %393
  %690 = load i8, ptr @ThresholdCalculate.qrs, align 1, !tbaa !18, !range !22, !noundef !23
  %691 = trunc i8 %690 to i1
  br i1 %691, label %742, label %692

692:                                              ; preds = %689
  %693 = load i32, ptr %11, align 4, !tbaa !5
  %694 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %695 = icmp sge i32 %693, %694
  br i1 %695, label %700, label %696

696:                                              ; preds = %692
  %697 = load i32, ptr %9, align 4, !tbaa !5
  %698 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %699 = icmp sge i32 %697, %698
  br i1 %699, label %700, label %741

700:                                              ; preds = %696, %692
  %701 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %701, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !5
  %702 = load i32, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !5
  %703 = sitofp i32 %702 to double
  %704 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %705 = sitofp i32 %704 to double
  %706 = fmul double 8.750000e-01, %705
  %707 = call double @llvm.fmuladd.f64(double 1.250000e-01, double %703, double %706)
  %708 = fptosi double %707 to i32
  store i32 %708, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %709 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %710 = sitofp i32 %709 to double
  %711 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !5
  %712 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !5
  %713 = sub nsw i32 %711, %712
  %714 = sitofp i32 %713 to double
  %715 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %714, double %710)
  %716 = fptosi double %715 to i32
  store i32 %716, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %717 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !5
  %718 = sitofp i32 %717 to double
  %719 = fmul double 5.000000e-01, %718
  %720 = fptosi double %719 to i32
  store i32 %720, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !5
  %721 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %721, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !5
  %722 = load i32, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !5
  %723 = sitofp i32 %722 to double
  %724 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %725 = sitofp i32 %724 to double
  %726 = fmul double 8.750000e-01, %725
  %727 = call double @llvm.fmuladd.f64(double 1.250000e-01, double %723, double %726)
  %728 = fptosi double %727 to i32
  store i32 %728, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %729 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %730 = sitofp i32 %729 to double
  %731 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !5
  %732 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !5
  %733 = sub nsw i32 %731, %732
  %734 = sitofp i32 %733 to double
  %735 = call double @llvm.fmuladd.f64(double 2.500000e-01, double %734, double %730)
  %736 = fptosi double %735 to i32
  store i32 %736, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %737 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !5
  %738 = sitofp i32 %737 to double
  %739 = fmul double 5.000000e-01, %738
  %740 = fptosi double %739 to i32
  store i32 %740, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !5
  br label %741

741:                                              ; preds = %700, %696
  br label %742

742:                                              ; preds = %741, %689
  store i32 0, ptr %17, align 4
  br label %743

743:                                              ; preds = %742, %686
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  %744 = load i32, ptr %17, align 4
  switch i32 %744, label %747 [
    i32 0, label %745
  ]

745:                                              ; preds = %743
  br label %746

746:                                              ; preds = %745, %392
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 4 %12, i64 8, i1 false), !tbaa.struct !21
  store i32 1, ptr %17, align 4
  br label %747

747:                                              ; preds = %746, %743, %241
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  %748 = load i64, ptr %6, align 4
  ret i64 %748
}

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

; 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) #3

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!12, !6, i64 4}
!12 = !{!"", !10, i64 0, !6, i64 4}
!13 = !{!12, !10, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !19, i64 0}
!19 = !{!"_Bool", !7, i64 0}
!20 = distinct !{!20, !17}
!21 = !{i64 0, i64 4, !9, i64 4, i64 4, !5}
!22 = !{i8 0, i8 2}
!23 = !{}
!24 = distinct !{!24, !17}
!25 = distinct !{!25, !17}
!26 = distinct !{!26, !17}
!27 = distinct !{!27, !17}
!28 = distinct !{!28, !17}
!29 = distinct !{!29, !17}


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

@ThresholdCalculate.bandpass_buffer = external hidden local_unnamed_addr global [598 x i32], align 16
@ThresholdCalculate.integral_buffer = external hidden local_unnamed_addr global [598 x i32], align 16
@ThresholdCalculate.peak_buffer = external hidden local_unnamed_addr global [598 x %struct.SignalPoint], align 16
@ThresholdCalculate.square_buffer = external hidden local_unnamed_addr global [36 x i32], align 16
@ThresholdCalculate.last_qrs = external hidden local_unnamed_addr global i64, align 8
@ThresholdCalculate.last_slope = external hidden local_unnamed_addr global i64, align 8
@ThresholdCalculate.current_slope = external hidden local_unnamed_addr global i64, align 8
@ThresholdCalculate.peak_i = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.peak_f = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.threshold_i1 = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.threshold_i2 = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.threshold_f1 = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.threshold_f2 = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.spk_i = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.spk_f = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.npk_i = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.npk_f = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.qrs = external hidden local_unnamed_addr global i8, align 1
@ThresholdCalculate.regular = external hidden local_unnamed_addr global i8, align 1
@ThresholdCalculate.prev_regular = external hidden local_unnamed_addr global i8, align 1
@ThresholdCalculate.rr1 = external hidden local_unnamed_addr global [8 x i32], align 16
@ThresholdCalculate.rr2 = external hidden local_unnamed_addr global [8 x i32], align 16
@ThresholdCalculate.rravg1 = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.rravg2 = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.rrlow = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.rrhigh = external hidden local_unnamed_addr global i32, align 4
@ThresholdCalculate.rrmiss = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local i64 @ThresholdCalculate(i32 noundef %0, float noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #0 {
  %6 = srem i32 %0, 598
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [598 x %struct.SignalPoint], ptr @ThresholdCalculate.peak_buffer, i64 0, i64 %7
  %9 = getelementptr inbounds i8, ptr %8, i64 4
  store i32 %0, ptr %9, align 4, !tbaa !5
  store float %1, ptr %8, align 8, !tbaa !11
  %10 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.bandpass_buffer, i64 0, i64 %7
  store i32 %2, ptr %10, align 4, !tbaa !12
  %11 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.integral_buffer, i64 0, i64 %7
  store i32 %4, ptr %11, align 4, !tbaa !12
  %12 = srem i32 %0, 36
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %13
  store i32 %3, ptr %14, align 4, !tbaa !12
  %15 = load i32, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !12
  %.not = icmp sgt i32 %15, %4
  %16 = load i32, ptr @ThresholdCalculate.threshold_f1, align 4
  %.not121 = icmp sgt i32 %16, %2
  %or.cond = select i1 %.not, i1 %.not121, i1 false
  br i1 %or.cond, label %18, label %17

17:                                               ; preds = %5
  store i32 %4, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !12
  store i32 %2, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !12
  br label %18

18:                                               ; preds = %5, %17
  %or.cond139 = select i1 %.not, i1 true, i1 %.not121
  br i1 %or.cond139, label %._crit_edge, label %21

._crit_edge:                                      ; preds = %18
  %.pre = load i8, ptr @ThresholdCalculate.qrs, align 1, !tbaa !13, !range !15
  %19 = insertelement <2 x i32> poison, i32 %15, i64 0
  %20 = insertelement <2 x i32> %19, i32 %16, i64 1
  br label %157

21:                                               ; preds = %18
  %22 = sitofp i32 %0 to float
  %23 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !16
  %24 = uitofp i64 %23 to float
  %25 = fadd float %24, 7.200000e+01
  %26 = fcmp olt float %25, %22
  br i1 %26, label %27, label %126

27:                                               ; preds = %21
  %28 = sext i32 %0 to i64
  %29 = add i64 %23, 129
  %.not124 = icmp ult i64 %29, %28
  store i64 0, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !16
  %30 = add nsw i32 %0, -36
  br i1 %.not124, label %.preheader, label %.preheader223

31:                                               ; preds = %45
  %32 = load i64, ptr @ThresholdCalculate.last_slope, align 8, !tbaa !16
  %33 = shl i64 %32, 31
  %34 = ashr i64 %33, 32
  %.not127 = icmp ugt i64 %46, %34
  %35 = insertelement <2 x i32> poison, i32 %15, i64 0
  %36 = insertelement <2 x i32> %35, i32 %16, i64 1
  br i1 %.not127, label %48, label %81

.preheader223:                                    ; preds = %27, %45
  %.0109157 = phi i32 [ %47, %45 ], [ %30, %27 ]
  %37 = phi i64 [ %46, %45 ], [ 0, %27 ]
  %38 = srem i32 %.0109157, 36
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !12
  %42 = sext i32 %41 to i64
  %43 = icmp ult i64 %37, %42
  br i1 %43, label %44, label %45

44:                                               ; preds = %.preheader223
  store i64 %42, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !16
  br label %45

45:                                               ; preds = %.preheader223, %44
  %46 = phi i64 [ %37, %.preheader223 ], [ %42, %44 ]
  %47 = add nsw i32 %.0109157, 1
  %.not126.not = icmp slt i32 %.0109157, %0
  br i1 %.not126.not, label %.preheader223, label %31, !llvm.loop !18

48:                                               ; preds = %31
  %49 = load i32, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !12
  %50 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !12
  %51 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !12
  %52 = load i32, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !12
  %53 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !12
  %54 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !12
  %55 = insertelement <2 x i32> poison, i32 %49, i64 0
  %56 = insertelement <2 x i32> %55, i32 %52, i64 1
  %57 = sitofp <2 x i32> %56 to <2 x double>
  %58 = insertelement <2 x i32> poison, i32 %50, i64 0
  %59 = insertelement <2 x i32> %58, i32 %53, i64 1
  %60 = sitofp <2 x i32> %59 to <2 x double>
  %61 = fmul <2 x double> %60, <double 8.750000e-01, double 8.750000e-01>
  %62 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %57, <2 x double> <double 1.250000e-01, double 1.250000e-01>, <2 x double> %61)
  %63 = fptosi <2 x double> %62 to <2 x i32>
  %64 = extractelement <2 x i32> %63, i64 0
  store i32 %64, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !12
  %65 = insertelement <2 x i32> poison, i32 %51, i64 0
  %66 = insertelement <2 x i32> %65, i32 %54, i64 1
  %67 = sitofp <2 x i32> %66 to <2 x double>
  %68 = sub nsw <2 x i32> %63, %66
  %69 = sitofp <2 x i32> %68 to <2 x double>
  %70 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %69, <2 x double> <double 2.500000e-01, double 2.500000e-01>, <2 x double> %67)
  %71 = fptosi <2 x double> %70 to <2 x i32>
  %72 = extractelement <2 x i32> %71, i64 0
  store i32 %72, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !12
  %73 = sitofp i32 %72 to double
  %74 = fmul double %73, 5.000000e-01
  %75 = fptosi double %74 to i32
  store i32 %75, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !12
  %76 = extractelement <2 x i32> %63, i64 1
  store i32 %76, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !12
  %77 = extractelement <2 x i32> %71, i64 1
  store i32 %77, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !12
  %78 = sitofp i32 %77 to double
  %79 = fmul double %78, 5.000000e-01
  %80 = fptosi double %79 to i32
  store i32 %80, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !12
  store i64 %46, ptr @ThresholdCalculate.last_slope, align 8, !tbaa !16
  br label %81

81:                                               ; preds = %31, %48
  %storemerge = phi i8 [ 1, %48 ], [ 0, %31 ]
  %.sroa.6.0 = phi i32 [ %0, %48 ], [ -1, %31 ]
  %82 = phi <2 x i32> [ %71, %48 ], [ %36, %31 ]
  store i8 %storemerge, ptr @ThresholdCalculate.qrs, align 1, !tbaa !13
  br label %157

.thread:                                          ; preds = %123
  %83 = load i32, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !12
  %84 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !12
  %85 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !12
  %86 = load i32, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !12
  %87 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !12
  %88 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !12
  %89 = insertelement <2 x i32> poison, i32 %83, i64 0
  %90 = insertelement <2 x i32> %89, i32 %86, i64 1
  %91 = sitofp <2 x i32> %90 to <2 x double>
  %92 = insertelement <2 x i32> poison, i32 %84, i64 0
  %93 = insertelement <2 x i32> %92, i32 %87, i64 1
  %94 = sitofp <2 x i32> %93 to <2 x double>
  %95 = fmul <2 x double> %94, <double 8.750000e-01, double 8.750000e-01>
  %96 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %91, <2 x double> <double 1.250000e-01, double 1.250000e-01>, <2 x double> %95)
  %97 = fptosi <2 x double> %96 to <2 x i32>
  %98 = extractelement <2 x i32> %97, i64 0
  store i32 %98, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !12
  %99 = insertelement <2 x i32> poison, i32 %85, i64 0
  %100 = insertelement <2 x i32> %99, i32 %88, i64 1
  %101 = sitofp <2 x i32> %100 to <2 x double>
  %102 = sub nsw <2 x i32> %97, %100
  %103 = sitofp <2 x i32> %102 to <2 x double>
  %104 = tail call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %103, <2 x double> <double 2.500000e-01, double 2.500000e-01>, <2 x double> %101)
  %105 = fptosi <2 x double> %104 to <2 x i32>
  %106 = extractelement <2 x i32> %105, i64 0
  store i32 %106, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !12
  %107 = sitofp i32 %106 to double
  %108 = fmul double %107, 5.000000e-01
  %109 = fptosi double %108 to i32
  store i32 %109, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !12
  %110 = extractelement <2 x i32> %97, i64 1
  store i32 %110, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !12
  %111 = extractelement <2 x i32> %105, i64 1
  store i32 %111, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !12
  %112 = sitofp i32 %111 to double
  %113 = fmul double %112, 5.000000e-01
  %114 = fptosi double %113 to i32
  store i32 %114, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !12
  store i64 %124, ptr @ThresholdCalculate.last_slope, align 8, !tbaa !16
  store i8 1, ptr @ThresholdCalculate.qrs, align 1, !tbaa !13
  br label %.preheader149.preheader

.preheader:                                       ; preds = %27, %123
  %.0108159 = phi i32 [ %125, %123 ], [ %30, %27 ]
  %115 = phi i64 [ %124, %123 ], [ 0, %27 ]
  %116 = srem i32 %.0108159, 36
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !12
  %120 = sext i32 %119 to i64
  %121 = icmp ult i64 %115, %120
  br i1 %121, label %122, label %123

122:                                              ; preds = %.preheader
  store i64 %120, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !16
  br label %123

123:                                              ; preds = %.preheader, %122
  %124 = phi i64 [ %115, %.preheader ], [ %120, %122 ]
  %125 = add nsw i32 %.0108159, 1
  %.not125.not = icmp slt i32 %.0108159, %0
  br i1 %.not125.not, label %.preheader, label %.thread, !llvm.loop !20

126:                                              ; preds = %21
  store i32 %4, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !12
  %127 = sitofp i32 %4 to double
  %128 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !12
  %129 = sitofp i32 %128 to double
  %130 = fmul double %129, 8.750000e-01
  %131 = tail call double @llvm.fmuladd.f64(double %127, double 1.250000e-01, double %130)
  %132 = fptosi double %131 to i32
  store i32 %132, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !12
  %133 = sitofp i32 %132 to double
  %134 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !12
  %135 = sub nsw i32 %134, %132
  %136 = sitofp i32 %135 to double
  %137 = tail call double @llvm.fmuladd.f64(double %136, double 2.500000e-01, double %133)
  %138 = fptosi double %137 to i32
  store i32 %138, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !12
  %139 = sitofp i32 %138 to double
  %140 = fmul double %139, 5.000000e-01
  %141 = fptosi double %140 to i32
  store i32 %141, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !12
  store i32 %2, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !12
  %142 = sitofp i32 %2 to double
  %143 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !12
  %144 = sitofp i32 %143 to double
  %145 = fmul double %144, 8.750000e-01
  %146 = tail call double @llvm.fmuladd.f64(double %142, double 1.250000e-01, double %145)
  %147 = fptosi double %146 to i32
  store i32 %147, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !12
  %148 = sitofp i32 %147 to double
  %149 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !12
  %150 = sub nsw i32 %149, %147
  %151 = sitofp i32 %150 to double
  %152 = tail call double @llvm.fmuladd.f64(double %151, double 2.500000e-01, double %148)
  %153 = fptosi double %152 to i32
  store i32 %153, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !12
  %154 = sitofp i32 %153 to double
  %155 = fmul double %154, 5.000000e-01
  %156 = fptosi double %155 to i32
  store i32 %156, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !12
  store i8 0, ptr @ThresholdCalculate.qrs, align 1, !tbaa !13
  br label %.thread145

157:                                              ; preds = %._crit_edge, %81
  %158 = phi i8 [ %storemerge, %81 ], [ %.pre, %._crit_edge ]
  %.sroa.6.1 = phi i32 [ %.sroa.6.0, %81 ], [ -1, %._crit_edge ]
  %159 = phi <2 x i32> [ %82, %81 ], [ %20, %._crit_edge ]
  %160 = trunc nuw i8 %158 to i1
  br i1 %160, label %.preheader149.preheader, label %221

.preheader149.preheader:                          ; preds = %.thread, %157
  %.sroa.6.1208 = phi i32 [ %0, %.thread ], [ %.sroa.6.1, %157 ]
  %161 = phi <2 x i32> [ %105, %.thread ], [ %159, %157 ]
  %162 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 4), align 4, !tbaa !12
  store i32 %162, ptr @ThresholdCalculate.rr1, align 16, !tbaa !12
  %163 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 8), align 8, !tbaa !12
  store i32 %163, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 4), align 4, !tbaa !12
  %164 = add nsw i32 %163, %162
  %165 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 12), align 4, !tbaa !12
  store i32 %165, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 8), align 8, !tbaa !12
  %166 = add nsw i32 %165, %164
  %167 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 16), align 16, !tbaa !12
  store i32 %167, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 12), align 4, !tbaa !12
  %168 = add nsw i32 %167, %166
  %169 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 20), align 4, !tbaa !12
  store i32 %169, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 16), align 16, !tbaa !12
  %170 = add nsw i32 %169, %168
  %171 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 24), align 8, !tbaa !12
  store i32 %171, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 20), align 4, !tbaa !12
  %172 = add nsw i32 %171, %170
  %173 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 28), align 4, !tbaa !12
  store i32 %173, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 24), align 8, !tbaa !12
  %174 = add nsw i32 %173, %172
  %175 = sext i32 %0 to i64
  %176 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !16
  %177 = trunc i64 %176 to i32
  %178 = sub i32 %0, %177
  store i32 %178, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 28), align 4, !tbaa !12
  store i64 %175, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !16
  %179 = add nsw i32 %178, %174
  %180 = sitofp i32 %179 to double
  %181 = fmul double %180, 1.250000e-01
  %182 = fptosi double %181 to i32
  store i32 %182, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !12
  %183 = load i32, ptr @ThresholdCalculate.rrlow, align 4, !tbaa !12
  %.not136 = icmp slt i32 %178, %183
  %184 = load i32, ptr @ThresholdCalculate.rrhigh, align 4
  %.not137 = icmp sgt i32 %178, %184
  %or.cond140 = select i1 %.not136, i1 true, i1 %.not137
  br i1 %or.cond140, label %.preheader149.preheader._crit_edge, label %.preheader.preheader

.preheader149.preheader._crit_edge:               ; preds = %.preheader149.preheader
  %.pre203 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !12
  br label %209

.preheader.preheader:                             ; preds = %.preheader149.preheader
  %185 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 4), align 4, !tbaa !12
  store i32 %185, ptr @ThresholdCalculate.rr2, align 16, !tbaa !12
  %186 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 8), align 8, !tbaa !12
  store i32 %186, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 4), align 4, !tbaa !12
  %187 = add nsw i32 %186, %185
  %188 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 12), align 4, !tbaa !12
  store i32 %188, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 8), align 8, !tbaa !12
  %189 = add nsw i32 %188, %187
  %190 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 16), align 16, !tbaa !12
  store i32 %190, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 12), align 4, !tbaa !12
  %191 = add nsw i32 %190, %189
  %192 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 20), align 4, !tbaa !12
  store i32 %192, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 16), align 16, !tbaa !12
  %193 = add nsw i32 %192, %191
  %194 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 24), align 8, !tbaa !12
  store i32 %194, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 20), align 4, !tbaa !12
  %195 = add nsw i32 %194, %193
  %196 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 28), align 4, !tbaa !12
  store i32 %196, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 24), align 8, !tbaa !12
  %197 = add nsw i32 %196, %195
  store i32 %178, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 28), align 4, !tbaa !12
  %198 = add nsw i32 %197, %178
  %199 = sitofp i32 %198 to double
  %200 = fmul double %199, 1.250000e-01
  %201 = fptosi double %200 to i32
  store i32 %201, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !12
  %202 = sitofp i32 %201 to double
  %203 = fmul double %202, 9.200000e-01
  %204 = fptosi double %203 to i32
  store i32 %204, ptr @ThresholdCalculate.rrlow, align 4, !tbaa !12
  %205 = fmul double %202, 1.160000e+00
  %206 = fptosi double %205 to i32
  store i32 %206, ptr @ThresholdCalculate.rrhigh, align 4, !tbaa !12
  %207 = fmul double %202, 1.660000e+00
  %208 = fptosi double %207 to i32
  store i32 %208, ptr @ThresholdCalculate.rrmiss, align 4, !tbaa !12
  br label %209

209:                                              ; preds = %.preheader149.preheader._crit_edge, %.preheader.preheader
  %210 = phi i32 [ %.pre203, %.preheader149.preheader._crit_edge ], [ %201, %.preheader.preheader ]
  %211 = load i8, ptr @ThresholdCalculate.regular, align 1, !tbaa !13, !range !15, !noundef !21
  store i8 %211, ptr @ThresholdCalculate.prev_regular, align 1, !tbaa !13
  %212 = icmp eq i32 %210, %182
  br i1 %212, label %213, label %214

213:                                              ; preds = %209
  store i8 1, ptr @ThresholdCalculate.regular, align 1, !tbaa !13
  br label %.thread145

214:                                              ; preds = %209
  store i8 0, ptr @ThresholdCalculate.regular, align 1, !tbaa !13
  %215 = trunc nuw i8 %211 to i1
  br i1 %215, label %216, label %.thread145

216:                                              ; preds = %214
  %217 = extractelement <2 x i32> %161, i64 0
  %218 = sdiv i32 %217, 2
  store i32 %218, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !12
  %219 = extractelement <2 x i32> %161, i64 1
  %220 = sdiv i32 %219, 2
  store i32 %220, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !12
  br label %.thread145

221:                                              ; preds = %157
  %222 = sext i32 %0 to i64
  %223 = load i64, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !16
  %224 = sub i64 %222, %223
  %225 = load i32, ptr @ThresholdCalculate.rrmiss, align 4, !tbaa !12
  %226 = sext i32 %225 to i64
  %227 = icmp ugt i64 %224, %226
  br i1 %227, label %228, label %377

228:                                              ; preds = %221
  %229 = sitofp i32 %0 to float
  %230 = uitofp i64 %223 to float
  %231 = fadd float %230, 7.200000e+01
  %232 = fcmp olt float %231, %229
  br i1 %232, label %233, label %377

233:                                              ; preds = %228
  %234 = icmp ugt i64 %224, 598
  br i1 %234, label %235, label %236

235:                                              ; preds = %233
  store i64 %222, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !16
  %.pre204 = uitofp i64 %222 to float
  %.pre205 = fadd float %.pre204, 7.200000e+01
  br label %236

236:                                              ; preds = %235, %233
  %.pre-phi206 = phi float [ %.pre205, %235 ], [ %231, %233 ]
  %237 = phi i64 [ %222, %235 ], [ %223, %233 ]
  %238 = fptosi float %.pre-phi206 to i32
  %239 = icmp ult i32 %238, %0
  br i1 %239, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %236
  %240 = load i32, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !12
  %241 = load i32, ptr @ThresholdCalculate.threshold_f2, align 4
  %242 = add nsw i32 %0, -36
  %243 = load i64, ptr @ThresholdCalculate.last_slope, align 8
  %244 = shl i64 %243, 31
  %245 = ashr i64 %244, 32
  %246 = uitofp i64 %237 to double
  %247 = tail call double @llvm.fmuladd.f64(double %246, double 3.600000e-01, double %246)
  %248 = sext i32 %238 to i64
  br label %249

249:                                              ; preds = %.lr.ph, %371
  %250 = phi i8 [ %158, %.lr.ph ], [ %372, %371 ]
  %indvars.iv = phi i64 [ %248, %.lr.ph ], [ %indvars.iv.next, %371 ]
  %251 = trunc nsw i64 %indvars.iv to i32
  %252 = srem i32 %251, 598
  %253 = sext i32 %252 to i64
  %254 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.integral_buffer, i64 0, i64 %253
  %255 = load i32, ptr %254, align 4, !tbaa !12
  %256 = icmp sgt i32 %255, %240
  br i1 %256, label %257, label %371

257:                                              ; preds = %249
  %258 = getelementptr inbounds [598 x i32], ptr @ThresholdCalculate.bandpass_buffer, i64 0, i64 %253
  %259 = load i32, ptr %258, align 4, !tbaa !12
  %260 = icmp sgt i32 %259, %241
  br i1 %260, label %261, label %371

261:                                              ; preds = %257
  store i64 0, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !16
  br label %264

262:                                              ; preds = %273
  %263 = icmp ult i64 %274, %245
  br i1 %263, label %276, label %282

264:                                              ; preds = %261, %273
  %.0102161 = phi i32 [ %242, %261 ], [ %275, %273 ]
  %265 = phi i64 [ 0, %261 ], [ %274, %273 ]
  %266 = srem i32 %.0102161, 36
  %267 = sext i32 %266 to i64
  %268 = getelementptr inbounds [36 x i32], ptr @ThresholdCalculate.square_buffer, i64 0, i64 %267
  %269 = load i32, ptr %268, align 4, !tbaa !12
  %270 = sext i32 %269 to i64
  %271 = icmp ult i64 %265, %270
  br i1 %271, label %272, label %273

272:                                              ; preds = %264
  store i64 %270, ptr @ThresholdCalculate.current_slope, align 8, !tbaa !16
  br label %273

273:                                              ; preds = %264, %272
  %274 = phi i64 [ %265, %264 ], [ %270, %272 ]
  %275 = add nsw i32 %.0102161, 1
  %.not128.not = icmp slt i32 %.0102161, %0
  br i1 %.not128.not, label %264, label %262, !llvm.loop !22

276:                                              ; preds = %262
  %277 = trunc i64 %indvars.iv to i32
  %278 = add i32 %277, %0
  %279 = sitofp i32 %278 to double
  %280 = fcmp ogt double %247, %279
  br i1 %280, label %281, label %282

281:                                              ; preds = %276
  store i8 0, ptr @ThresholdCalculate.qrs, align 1, !tbaa !13
  br label %371

282:                                              ; preds = %276, %262
  %283 = sub i64 %indvars.iv, %237
  %284 = icmp ugt i64 %283, 550
  br i1 %284, label %285, label %371

285:                                              ; preds = %282
  store i32 %255, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !12
  store i32 %259, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !12
  %286 = sitofp i32 %255 to double
  %287 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !12
  %288 = sitofp i32 %287 to double
  %289 = fmul double %288, 7.500000e-01
  %290 = tail call double @llvm.fmuladd.f64(double %286, double 2.500000e-01, double %289)
  %291 = fptosi double %290 to i32
  store i32 %291, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !12
  %292 = sitofp i32 %259 to double
  %293 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !12
  %294 = sitofp i32 %293 to double
  %295 = fmul double %294, 7.500000e-01
  %296 = tail call double @llvm.fmuladd.f64(double %292, double 2.500000e-01, double %295)
  %297 = fptosi double %296 to i32
  store i32 %297, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !12
  %298 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !12
  %299 = sitofp i32 %298 to double
  %300 = sub nsw i32 %291, %298
  %301 = sitofp i32 %300 to double
  %302 = tail call double @llvm.fmuladd.f64(double %301, double 2.500000e-01, double %299)
  %303 = fptosi double %302 to i32
  store i32 %303, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !12
  %304 = sitofp i32 %303 to double
  %305 = fmul double %304, 5.000000e-01
  %306 = fptosi double %305 to i32
  store i32 %306, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !12
  store i64 %274, ptr @ThresholdCalculate.last_slope, align 8, !tbaa !16
  %307 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !12
  %308 = sitofp i32 %307 to double
  %309 = sub nsw i32 %297, %307
  %310 = sitofp i32 %309 to double
  %311 = tail call double @llvm.fmuladd.f64(double %310, double 2.500000e-01, double %308)
  %312 = fptosi double %311 to i32
  store i32 %312, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !12
  %313 = sitofp i32 %312 to double
  %314 = fmul double %313, 5.000000e-01
  %315 = fptosi double %314 to i32
  store i32 %315, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !12
  %316 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 4), align 4, !tbaa !12
  store i32 %316, ptr @ThresholdCalculate.rr1, align 16, !tbaa !12
  %317 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 8), align 8, !tbaa !12
  store i32 %317, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 4), align 4, !tbaa !12
  %318 = add nsw i32 %317, %316
  %319 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 12), align 4, !tbaa !12
  store i32 %319, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 8), align 8, !tbaa !12
  %320 = add nsw i32 %319, %318
  %321 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 16), align 16, !tbaa !12
  store i32 %321, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 12), align 4, !tbaa !12
  %322 = add nsw i32 %321, %320
  %323 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 20), align 4, !tbaa !12
  store i32 %323, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 16), align 16, !tbaa !12
  %324 = add nsw i32 %323, %322
  %325 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 24), align 8, !tbaa !12
  store i32 %325, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 20), align 4, !tbaa !12
  %326 = add nsw i32 %325, %324
  %327 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 28), align 4, !tbaa !12
  store i32 %327, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 24), align 8, !tbaa !12
  %328 = add nsw i32 %327, %326
  %329 = trunc i64 %237 to i32
  %330 = sub i32 %251, %329
  store i32 %330, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr1, i64 28), align 4, !tbaa !12
  store i8 1, ptr @ThresholdCalculate.qrs, align 1, !tbaa !13
  store i64 %indvars.iv, ptr @ThresholdCalculate.last_qrs, align 8, !tbaa !16
  %331 = add nsw i32 %328, %330
  %332 = sitofp i32 %331 to double
  %333 = fmul double %332, 1.250000e-01
  %334 = fptosi double %333 to i32
  store i32 %334, ptr @ThresholdCalculate.rravg1, align 4, !tbaa !12
  %335 = load i32, ptr @ThresholdCalculate.rrlow, align 4, !tbaa !12
  %.not130 = icmp slt i32 %330, %335
  %336 = load i32, ptr @ThresholdCalculate.rrhigh, align 4
  %.not131 = icmp sgt i32 %330, %336
  %or.cond141 = select i1 %.not130, i1 true, i1 %.not131
  br i1 %or.cond141, label %._crit_edge201, label %.preheader150.preheader

._crit_edge201:                                   ; preds = %285
  %.pre202 = load i32, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !12
  br label %361

.preheader150.preheader:                          ; preds = %285
  %337 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 4), align 4, !tbaa !12
  store i32 %337, ptr @ThresholdCalculate.rr2, align 16, !tbaa !12
  %338 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 8), align 8, !tbaa !12
  store i32 %338, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 4), align 4, !tbaa !12
  %339 = add nsw i32 %338, %337
  %340 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 12), align 4, !tbaa !12
  store i32 %340, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 8), align 8, !tbaa !12
  %341 = add nsw i32 %340, %339
  %342 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 16), align 16, !tbaa !12
  store i32 %342, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 12), align 4, !tbaa !12
  %343 = add nsw i32 %342, %341
  %344 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 20), align 4, !tbaa !12
  store i32 %344, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 16), align 16, !tbaa !12
  %345 = add nsw i32 %344, %343
  %346 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 24), align 8, !tbaa !12
  store i32 %346, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 20), align 4, !tbaa !12
  %347 = add nsw i32 %346, %345
  %348 = load i32, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 28), align 4, !tbaa !12
  store i32 %348, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 24), align 8, !tbaa !12
  %349 = add nsw i32 %348, %347
  store i32 %330, ptr getelementptr inbounds (i8, ptr @ThresholdCalculate.rr2, i64 28), align 4, !tbaa !12
  %350 = add nsw i32 %349, %330
  %351 = sitofp i32 %350 to double
  %352 = fmul double %351, 1.250000e-01
  %353 = fptosi double %352 to i32
  store i32 %353, ptr @ThresholdCalculate.rravg2, align 4, !tbaa !12
  %354 = sitofp i32 %353 to double
  %355 = fmul double %354, 9.200000e-01
  %356 = fptosi double %355 to i32
  store i32 %356, ptr @ThresholdCalculate.rrlow, align 4, !tbaa !12
  %357 = fmul double %354, 1.160000e+00
  %358 = fptosi double %357 to i32
  store i32 %358, ptr @ThresholdCalculate.rrhigh, align 4, !tbaa !12
  %359 = fmul double %354, 1.660000e+00
  %360 = fptosi double %359 to i32
  store i32 %360, ptr @ThresholdCalculate.rrmiss, align 4, !tbaa !12
  br label %361

361:                                              ; preds = %._crit_edge201, %.preheader150.preheader
  %362 = phi i32 [ %.pre202, %._crit_edge201 ], [ %353, %.preheader150.preheader ]
  %363 = load i8, ptr @ThresholdCalculate.regular, align 1, !tbaa !13, !range !15, !noundef !21
  store i8 %363, ptr @ThresholdCalculate.prev_regular, align 1, !tbaa !13
  %364 = icmp eq i32 %362, %334
  br i1 %364, label %365, label %366

365:                                              ; preds = %361
  store i8 1, ptr @ThresholdCalculate.regular, align 1, !tbaa !13
  br label %.loopexit.thread

366:                                              ; preds = %361
  store i8 0, ptr @ThresholdCalculate.regular, align 1, !tbaa !13
  %367 = trunc nuw i8 %363 to i1
  br i1 %367, label %368, label %.loopexit.thread

368:                                              ; preds = %366
  %369 = sdiv i32 %303, 2
  store i32 %369, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !12
  %370 = sdiv i32 %312, 2
  store i32 %370, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !12
  br label %.loopexit.thread

371:                                              ; preds = %249, %257, %282, %281
  %372 = phi i8 [ %250, %249 ], [ %250, %257 ], [ %250, %282 ], [ 0, %281 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %373 = trunc nsw i64 %indvars.iv.next to i32
  %374 = icmp ult i32 %373, %0
  br i1 %374, label %249, label %.loopexit, !llvm.loop !23

.loopexit:                                        ; preds = %371, %236
  %375 = phi i8 [ %158, %236 ], [ %372, %371 ]
  %376 = trunc nuw i8 %375 to i1
  br i1 %376, label %.loopexit.thread, label %377

377:                                              ; preds = %.loopexit, %228, %221
  %378 = phi i8 [ %375, %.loopexit ], [ %158, %228 ], [ %158, %221 ]
  %379 = trunc nuw i8 %378 to i1
  br i1 %379, label %.thread145, label %380

380:                                              ; preds = %377
  %381 = extractelement <2 x i32> %159, i64 0
  %.not133 = icmp sgt i32 %381, %4
  %382 = extractelement <2 x i32> %159, i64 1
  %.not134 = icmp sgt i32 %382, %2
  %or.cond142 = select i1 %.not133, i1 %.not134, i1 false
  br i1 %or.cond142, label %.thread145, label %383

383:                                              ; preds = %380
  store i32 %4, ptr @ThresholdCalculate.peak_i, align 4, !tbaa !12
  %384 = sitofp i32 %4 to double
  %385 = load i32, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !12
  %386 = sitofp i32 %385 to double
  %387 = fmul double %386, 8.750000e-01
  %388 = tail call double @llvm.fmuladd.f64(double %384, double 1.250000e-01, double %387)
  %389 = fptosi double %388 to i32
  store i32 %389, ptr @ThresholdCalculate.npk_i, align 4, !tbaa !12
  %390 = sitofp i32 %389 to double
  %391 = load i32, ptr @ThresholdCalculate.spk_i, align 4, !tbaa !12
  %392 = sub nsw i32 %391, %389
  %393 = sitofp i32 %392 to double
  %394 = tail call double @llvm.fmuladd.f64(double %393, double 2.500000e-01, double %390)
  %395 = fptosi double %394 to i32
  store i32 %395, ptr @ThresholdCalculate.threshold_i1, align 4, !tbaa !12
  %396 = sitofp i32 %395 to double
  %397 = fmul double %396, 5.000000e-01
  %398 = fptosi double %397 to i32
  store i32 %398, ptr @ThresholdCalculate.threshold_i2, align 4, !tbaa !12
  store i32 %2, ptr @ThresholdCalculate.peak_f, align 4, !tbaa !12
  %399 = sitofp i32 %2 to double
  %400 = load i32, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !12
  %401 = sitofp i32 %400 to double
  %402 = fmul double %401, 8.750000e-01
  %403 = tail call double @llvm.fmuladd.f64(double %399, double 1.250000e-01, double %402)
  %404 = fptosi double %403 to i32
  store i32 %404, ptr @ThresholdCalculate.npk_f, align 4, !tbaa !12
  %405 = sitofp i32 %404 to double
  %406 = load i32, ptr @ThresholdCalculate.spk_f, align 4, !tbaa !12
  %407 = sub nsw i32 %406, %404
  %408 = sitofp i32 %407 to double
  %409 = tail call double @llvm.fmuladd.f64(double %408, double 2.500000e-01, double %405)
  %410 = fptosi double %409 to i32
  store i32 %410, ptr @ThresholdCalculate.threshold_f1, align 4, !tbaa !12
  %411 = sitofp i32 %410 to double
  %412 = fmul double %411, 5.000000e-01
  %413 = fptosi double %412 to i32
  store i32 %413, ptr @ThresholdCalculate.threshold_f2, align 4, !tbaa !12
  br label %.thread145

.loopexit.thread:                                 ; preds = %365, %368, %366, %.loopexit
  %.0104211 = phi i64 [ 0, %.loopexit ], [ %253, %366 ], [ %253, %368 ], [ %253, %365 ]
  %414 = getelementptr inbounds [598 x %struct.SignalPoint], ptr @ThresholdCalculate.peak_buffer, i64 0, i64 %.0104211
  %.sroa.0100.0.copyload = load float, ptr %414, align 8, !tbaa !24
  %.sroa.4.0..sroa_idx = getelementptr inbounds i8, ptr %414, i64 4
  %.sroa.4.0.copyload = load i32, ptr %.sroa.4.0..sroa_idx, align 4, !tbaa !12
  br label %.thread145

.thread145:                                       ; preds = %377, %383, %380, %214, %216, %213, %.loopexit.thread, %126
  %.sroa.0100.3 = phi float [ %.sroa.0100.0.copyload, %.loopexit.thread ], [ undef, %126 ], [ %1, %213 ], [ %1, %216 ], [ %1, %214 ], [ %1, %380 ], [ %1, %383 ], [ %1, %377 ]
  %.sroa.4.3 = phi i32 [ %.sroa.4.0.copyload, %.loopexit.thread ], [ -1, %126 ], [ %.sroa.6.1208, %213 ], [ %.sroa.6.1208, %216 ], [ %.sroa.6.1208, %214 ], [ %.sroa.6.1, %380 ], [ %.sroa.6.1, %383 ], [ %.sroa.6.1, %377 ]
  %415 = bitcast float %.sroa.0100.3 to i32
  %.sroa.4.0.insert.ext = zext i32 %.sroa.4.3 to i64
  %.sroa.4.0.insert.shift = shl nuw i64 %.sroa.4.0.insert.ext, 32
  %.sroa.0100.0.insert.ext = zext i32 %415 to i64
  %.sroa.0100.0.insert.insert = or disjoint i64 %.sroa.4.0.insert.shift, %.sroa.0100.0.insert.ext
  ret i64 %.sroa.0100.0.insert.insert
}

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #2

attributes #0 = { nofree norecurse nosync nounwind 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) }
attributes #2 = { 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, !10, i64 4}
!6 = !{!"", !7, i64 0, !10, i64 4}
!7 = !{!"float", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!6, !7, i64 0}
!12 = !{!10, !10, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"_Bool", !8, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{!17, !17, i64 0}
!17 = !{!"long", !8, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{}
!22 = distinct !{!22, !19}
!23 = distinct !{!23, !19}
!24 = !{!7, !7, i64 0}


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