; LLVM IR from beagleboard/librobotcontrol :: services/rc_battery_monitor/src (rc_battery_monitor)

; 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.rc_filter_t = type { i32, double, double, %struct.rc_vector_t, %struct.rc_vector_t, i32, double, double, i32, i32, double, %struct.rc_ringbuf_t, %struct.rc_ringbuf_t, double, double, i64, i32 }
%struct.rc_vector_t = type { i32, ptr, i32 }
%struct.rc_ringbuf_t = type { ptr, i32, i32, i32 }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [47 x i8], align 1
@opterr = external global i32, align 4
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [116 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [54 x i8], align 1
@stdout = external global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [33 x i8], align 1
@running = external hidden global i32, align 4
@.str.13 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca double, align 8
  %8 = alloca double, align 8
  %9 = alloca double, align 8
  %10 = alloca double, align 8
  %11 = alloca double, align 8
  %12 = alloca i32, 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 double, align 8
  %20 = alloca i32, align 4
  %21 = alloca %struct.rc_filter_t, align 8
  %22 = alloca %struct.rc_filter_t, align 8
  %23 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  store i32 0, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  store i32 0, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  store i32 0, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  store i32 0, ptr %16, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  store i32 0, ptr %17, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.start.p0(i64 192, ptr %21) #5
  call void @rc_filter_empty(ptr dead_on_unwind writable sret(%struct.rc_filter_t) align 8 %21)
  call void @llvm.lifetime.start.p0(i64 192, ptr %22) #5
  call void @rc_filter_empty(ptr dead_on_unwind writable sret(%struct.rc_filter_t) align 8 %22)
  %24 = call i32 @geteuid() #5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %29

26:                                               ; preds = %2
  %27 = load ptr, ptr @stderr, align 8, !tbaa !9
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str) #5
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

29:                                               ; preds = %2
  store i32 0, ptr @opterr, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %29
  %31 = load i32, ptr %4, align 4, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = call i32 @getopt(i32 noundef %31, ptr noundef %32, ptr noundef @.str.1) #5
  store i32 %33, ptr %18, align 4, !tbaa !5
  %34 = icmp ne i32 %33, -1
  br i1 %34, label %35, label %42

35:                                               ; preds = %30
  %36 = load i32, ptr %18, align 4, !tbaa !5
  switch i32 %36, label %39 [
    i32 107, label %37
  ]

37:                                               ; preds = %35
  %38 = call i32 @kill_existing_instance()
  store i32 %38, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

39:                                               ; preds = %35
  %40 = load ptr, ptr @stderr, align 8, !tbaa !9
  %41 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef @.str.2) #5
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

42:                                               ; preds = %30
  %43 = call i32 @rc_model()
  store i32 %43, ptr %20, align 4, !tbaa !5
  %44 = load i32, ptr %20, align 4, !tbaa !5
  %45 = icmp ne i32 %44, 2
  br i1 %45, label %46, label %59

46:                                               ; preds = %42
  %47 = load i32, ptr %20, align 4, !tbaa !5
  %48 = icmp ne i32 %47, 4
  br i1 %48, label %49, label %59

49:                                               ; preds = %46
  %50 = load i32, ptr %20, align 4, !tbaa !5
  %51 = icmp ne i32 %50, 7
  br i1 %51, label %52, label %59

52:                                               ; preds = %49
  %53 = call i32 @system(ptr noundef @.str.3)
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %58

55:                                               ; preds = %52
  %56 = load ptr, ptr @stderr, align 8, !tbaa !9
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.4) #5
  store i32 0, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

58:                                               ; preds = %52
  br label %59

59:                                               ; preds = %58, %49, %46, %42
  %60 = call i32 @access(ptr noundef @.str.5, i32 noundef 0) #5
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %68

62:                                               ; preds = %59
  %63 = load ptr, ptr @stderr, align 8, !tbaa !9
  %64 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %63, ptr noundef @.str.6) #5
  %65 = load ptr, ptr @stderr, align 8, !tbaa !9
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef @.str.7) #5
  %67 = call i32 @kill_existing_instance()
  br label %68

68:                                               ; preds = %62, %59
  %69 = call noalias ptr @fopen(ptr noundef @.str.5, ptr noundef @.str.8)
  store ptr %69, ptr %6, align 8, !tbaa !9
  %70 = load ptr, ptr %6, align 8, !tbaa !9
  %71 = icmp eq ptr %70, null
  br i1 %71, label %72, label %73

72:                                               ; preds = %68
  call void @perror(ptr noundef @.str.9)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

73:                                               ; preds = %68
  %74 = load ptr, ptr %6, align 8, !tbaa !9
  %75 = call i32 @getpid() #5
  %76 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %74, ptr noundef @.str.10, i32 noundef %75) #5
  %77 = load ptr, ptr %6, align 8, !tbaa !9
  %78 = call i32 @fflush(ptr noundef %77)
  %79 = load ptr, ptr %6, align 8, !tbaa !9
  %80 = call i32 @fclose(ptr noundef %79)
  %81 = call ptr @signal(i32 noundef 2, ptr noundef @shutdown_signal_handler) #5
  %82 = call ptr @signal(i32 noundef 15, ptr noundef @shutdown_signal_handler) #5
  %83 = call i32 @rc_led_set(i32 noundef 6, i32 noundef 0)
  %84 = icmp ne i32 %83, 0
  br i1 %84, label %85, label %86

85:                                               ; preds = %73
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

86:                                               ; preds = %73
  %87 = call i32 @rc_led_set(i32 noundef 7, i32 noundef 0)
  %88 = icmp ne i32 %87, 0
  br i1 %88, label %89, label %90

89:                                               ; preds = %86
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

90:                                               ; preds = %86
  %91 = call i32 @rc_led_set(i32 noundef 8, i32 noundef 0)
  %92 = icmp ne i32 %91, 0
  br i1 %92, label %93, label %94

93:                                               ; preds = %90
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

94:                                               ; preds = %90
  %95 = call i32 @rc_led_set(i32 noundef 9, i32 noundef 0)
  %96 = icmp ne i32 %95, 0
  br i1 %96, label %97, label %98

97:                                               ; preds = %94
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

98:                                               ; preds = %94
  %99 = call i32 @rc_adc_init()
  %100 = icmp ne i32 %99, 0
  br i1 %100, label %101, label %102

101:                                              ; preds = %98
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

102:                                              ; preds = %98
  %103 = call double @rc_adc_batt()
  store double %103, ptr %9, align 8, !tbaa !11
  %104 = call i32 @rc_filter_moving_average(ptr noundef %21, i32 noundef 6, double noundef 0x4114585555555555)
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %110

106:                                              ; preds = %102
  %107 = load ptr, ptr @stderr, align 8, !tbaa !9
  %108 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %107, ptr noundef @.str.11) #5
  %109 = call i32 @remove(ptr noundef @.str.5) #5
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

110:                                              ; preds = %102
  %111 = load double, ptr %9, align 8, !tbaa !11
  %112 = call i32 @rc_filter_prefill_outputs(ptr noundef %21, double noundef %111)
  %113 = load double, ptr %9, align 8, !tbaa !11
  %114 = call i32 @rc_filter_prefill_inputs(ptr noundef %21, double noundef %113)
  %115 = call double @rc_adc_dc_jack()
  store double %115, ptr %10, align 8, !tbaa !11
  %116 = call i32 @rc_filter_moving_average(ptr noundef %22, i32 noundef 6, double noundef 0x4114585555555555)
  %117 = icmp ne i32 %116, 0
  br i1 %117, label %118, label %122

118:                                              ; preds = %110
  %119 = load ptr, ptr @stderr, align 8, !tbaa !9
  %120 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %119, ptr noundef @.str.11) #5
  %121 = call i32 @remove(ptr noundef @.str.5) #5
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

122:                                              ; preds = %110
  %123 = load double, ptr %10, align 8, !tbaa !11
  %124 = call i32 @rc_filter_prefill_outputs(ptr noundef %22, double noundef %123)
  %125 = load double, ptr %10, align 8, !tbaa !11
  %126 = call i32 @rc_filter_prefill_inputs(ptr noundef %22, double noundef %125)
  %127 = load ptr, ptr @stdout, align 8, !tbaa !9
  %128 = call i32 @fileno(ptr noundef %127) #5
  %129 = call i32 @isatty(i32 noundef %128) #5
  %130 = icmp ne i32 %129, 0
  br i1 %130, label %131, label %133

131:                                              ; preds = %122
  store i32 1, ptr %13, align 4, !tbaa !5
  %132 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  br label %133

133:                                              ; preds = %131, %122
  %134 = call i32 @startup_blink()
  store i32 1, ptr @running, align 4, !tbaa !5
  br label %135

135:                                              ; preds = %311, %133
  %136 = load i32, ptr @running, align 4, !tbaa !5
  %137 = icmp ne i32 %136, 0
  br i1 %137, label %138, label %312

138:                                              ; preds = %135
  store i32 0, ptr %16, align 4, !tbaa !5
  %139 = call double @rc_adc_batt()
  store double %139, ptr %7, align 8, !tbaa !11
  %140 = call double @rc_adc_dc_jack()
  store double %140, ptr %8, align 8, !tbaa !11
  %141 = load double, ptr %7, align 8, !tbaa !11
  %142 = fcmp olt double %141, 0.000000e+00
  br i1 %142, label %146, label %143

143:                                              ; preds = %138
  %144 = load double, ptr %8, align 8, !tbaa !11
  %145 = fcmp olt double %144, 0.000000e+00
  br i1 %145, label %146, label %150

146:                                              ; preds = %143, %138
  %147 = load ptr, ptr @stderr, align 8, !tbaa !9
  %148 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %147, ptr noundef @.str.13) #5
  %149 = call i32 @remove(ptr noundef @.str.5) #5
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

150:                                              ; preds = %143
  %151 = load double, ptr %7, align 8, !tbaa !11
  %152 = load double, ptr %9, align 8, !tbaa !11
  %153 = fsub double %151, %152
  %154 = fptosi double %153 to i32
  %155 = call i32 @llvm.abs.i32(i32 %154, i1 true)
  %156 = icmp sgt i32 %155, 2
  br i1 %156, label %157, label %163

157:                                              ; preds = %150
  %158 = load double, ptr %7, align 8, !tbaa !11
  %159 = call i32 @rc_filter_prefill_outputs(ptr noundef %21, double noundef %158)
  %160 = load double, ptr %7, align 8, !tbaa !11
  %161 = call i32 @rc_filter_prefill_inputs(ptr noundef %21, double noundef %160)
  %162 = call i32 @startup_blink()
  br label %163

163:                                              ; preds = %157, %150
  %164 = load double, ptr %8, align 8, !tbaa !11
  %165 = load double, ptr %10, align 8, !tbaa !11
  %166 = fsub double %164, %165
  %167 = fptosi double %166 to i32
  %168 = call i32 @llvm.abs.i32(i32 %167, i1 true)
  %169 = icmp sgt i32 %168, 2
  br i1 %169, label %170, label %176

170:                                              ; preds = %163
  %171 = load double, ptr %8, align 8, !tbaa !11
  %172 = call i32 @rc_filter_prefill_outputs(ptr noundef %22, double noundef %171)
  %173 = load double, ptr %8, align 8, !tbaa !11
  %174 = call i32 @rc_filter_prefill_inputs(ptr noundef %22, double noundef %173)
  %175 = call i32 @startup_blink()
  br label %176

176:                                              ; preds = %170, %163
  %177 = load double, ptr %7, align 8, !tbaa !11
  %178 = call double @rc_filter_march(ptr noundef %21, double noundef %177)
  store double %178, ptr %9, align 8, !tbaa !11
  %179 = load double, ptr %8, align 8, !tbaa !11
  %180 = call double @rc_filter_march(ptr noundef %22, double noundef %179)
  store double %180, ptr %10, align 8, !tbaa !11
  %181 = load double, ptr %9, align 8, !tbaa !11
  %182 = fcmp ogt double %181, 5.400000e+00
  br i1 %182, label %183, label %186

183:                                              ; preds = %176
  %184 = getelementptr inbounds %struct.rc_filter_t, ptr %21, i32 0, i32 11
  %185 = call double @rc_ringbuf_std_dev(ptr noundef byval(%struct.rc_ringbuf_t) align 8 %184)
  store double %185, ptr %19, align 8, !tbaa !11
  br label %186

186:                                              ; preds = %183, %176
  %187 = load double, ptr %9, align 8, !tbaa !11
  %188 = fcmp ogt double %187, 5.400000e+00
  br i1 %188, label %189, label %195

189:                                              ; preds = %186
  %190 = load double, ptr %19, align 8, !tbaa !11
  %191 = fcmp olt double %190, 4.000000e-02
  br i1 %191, label %192, label %195

192:                                              ; preds = %189
  store i32 1, ptr %17, align 4, !tbaa !5
  %193 = load double, ptr %9, align 8, !tbaa !11
  %194 = fdiv double %193, 2.000000e+00
  store double %194, ptr %11, align 8, !tbaa !11
  store i32 2, ptr %14, align 4, !tbaa !5
  br label %196

195:                                              ; preds = %189, %186
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %196

196:                                              ; preds = %195, %192
  %197 = load i32, ptr %17, align 4, !tbaa !5
  %198 = icmp ne i32 %197, 0
  br i1 %198, label %199, label %206

199:                                              ; preds = %196
  %200 = load double, ptr %10, align 8, !tbaa !11
  %201 = fcmp ogt double %200, 1.000000e+01
  br i1 %201, label %202, label %206

202:                                              ; preds = %199
  %203 = load double, ptr %11, align 8, !tbaa !11
  %204 = fcmp olt double %203, 4.150000e+00
  br i1 %204, label %205, label %206

205:                                              ; preds = %202
  store i32 1, ptr %16, align 4, !tbaa !5
  br label %207

206:                                              ; preds = %202, %199, %196
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %207

207:                                              ; preds = %206, %205
  %208 = load i32, ptr %17, align 4, !tbaa !5
  %209 = icmp ne i32 %208, 0
  br i1 %209, label %241, label %210

210:                                              ; preds = %207
  %211 = load double, ptr %10, align 8, !tbaa !11
  %212 = fcmp ogt double %211, 1.080000e+01
  br i1 %212, label %213, label %219

213:                                              ; preds = %210
  %214 = load double, ptr %10, align 8, !tbaa !11
  %215 = fcmp olt double %214, 1.700000e+01
  br i1 %215, label %216, label %219

216:                                              ; preds = %213
  store i32 4, ptr %14, align 4, !tbaa !5
  %217 = load double, ptr %10, align 8, !tbaa !11
  %218 = fdiv double %217, 4.000000e+00
  store double %218, ptr %11, align 8, !tbaa !11
  br label %240

219:                                              ; preds = %213, %210
  %220 = load double, ptr %10, align 8, !tbaa !11
  %221 = fcmp ogt double %220, 0x4020333333333334
  br i1 %221, label %222, label %228

222:                                              ; preds = %219
  %223 = load double, ptr %10, align 8, !tbaa !11
  %224 = fcmp olt double %223, 1.275000e+01
  br i1 %224, label %225, label %228

225:                                              ; preds = %222
  store i32 3, ptr %14, align 4, !tbaa !5
  %226 = load double, ptr %10, align 8, !tbaa !11
  %227 = fdiv double %226, 3.000000e+00
  store double %227, ptr %11, align 8, !tbaa !11
  br label %239

228:                                              ; preds = %222, %219
  %229 = load double, ptr %10, align 8, !tbaa !11
  %230 = fcmp ogt double %229, 5.400000e+00
  br i1 %230, label %231, label %237

231:                                              ; preds = %228
  %232 = load double, ptr %10, align 8, !tbaa !11
  %233 = fcmp olt double %232, 8.500000e+00
  br i1 %233, label %234, label %237

234:                                              ; preds = %231
  store i32 2, ptr %14, align 4, !tbaa !5
  %235 = load double, ptr %10, align 8, !tbaa !11
  %236 = fdiv double %235, 2.000000e+00
  store double %236, ptr %11, align 8, !tbaa !11
  br label %238

237:                                              ; preds = %231, %228
  store double 0.000000e+00, ptr %11, align 8, !tbaa !11
  store i32 0, ptr %14, align 4, !tbaa !5
  br label %238

238:                                              ; preds = %237, %234
  br label %239

239:                                              ; preds = %238, %225
  br label %240

240:                                              ; preds = %239, %216
  br label %241

241:                                              ; preds = %240, %207
  %242 = load i32, ptr %13, align 4, !tbaa !5
  %243 = icmp ne i32 %242, 0
  br i1 %243, label %244, label %252

244:                                              ; preds = %241
  %245 = load double, ptr %9, align 8, !tbaa !11
  %246 = load double, ptr %10, align 8, !tbaa !11
  %247 = load i32, ptr %14, align 4, !tbaa !5
  %248 = load double, ptr %11, align 8, !tbaa !11
  %249 = call i32 (ptr, ...) @printf(ptr noundef @.str.14, double noundef %245, double noundef %246, i32 noundef %247, double noundef %248)
  %250 = load ptr, ptr @stdout, align 8, !tbaa !9
  %251 = call i32 @fflush(ptr noundef %250)
  br label %252

252:                                              ; preds = %244, %241
  %253 = load i32, ptr %16, align 4, !tbaa !5
  %254 = icmp ne i32 %253, 0
  br i1 %254, label %255, label %263

255:                                              ; preds = %252
  %256 = load i32, ptr %15, align 4, !tbaa !5
  %257 = add nsw i32 %256, 1
  store i32 %257, ptr %15, align 4, !tbaa !5
  %258 = load i32, ptr %15, align 4, !tbaa !5
  %259 = icmp sgt i32 %258, 4
  br i1 %259, label %260, label %261

260:                                              ; preds = %255
  store i32 0, ptr %15, align 4, !tbaa !5
  br label %261

261:                                              ; preds = %260, %255
  %262 = load i32, ptr %15, align 4, !tbaa !5
  call void @illuminate_leds(i32 noundef %262)
  br label %311

263:                                              ; preds = %252
  %264 = load i32, ptr %14, align 4, !tbaa !5
  %265 = icmp eq i32 %264, 0
  br i1 %265, label %266, label %267

266:                                              ; preds = %263
  call void @illuminate_leds(i32 noundef 0)
  br label %310

267:                                              ; preds = %263
  %268 = load i32, ptr %14, align 4, !tbaa !5
  %269 = icmp ne i32 %268, 2
  br i1 %269, label %270, label %277

270:                                              ; preds = %267
  %271 = load double, ptr %10, align 8, !tbaa !11
  %272 = fcmp ogt double %271, 1.150000e+01
  br i1 %272, label %273, label %277

273:                                              ; preds = %270
  %274 = load double, ptr %10, align 8, !tbaa !11
  %275 = fcmp olt double %274, 1.250000e+01
  br i1 %275, label %276, label %277

276:                                              ; preds = %273
  call void @illuminate_leds(i32 noundef 0)
  br label %309

277:                                              ; preds = %273, %270, %267
  %278 = load double, ptr %11, align 8, !tbaa !11
  %279 = fcmp olt double %278, 2.700000e+00
  br i1 %279, label %280, label %281

280:                                              ; preds = %277
  call void @illuminate_leds(i32 noundef 0)
  br label %308

281:                                              ; preds = %277
  %282 = load double, ptr %11, align 8, !tbaa !11
  %283 = fcmp ogt double %282, 3.900000e+00
  br i1 %283, label %284, label %285

284:                                              ; preds = %281
  call void @illuminate_leds(i32 noundef 4)
  br label %307

285:                                              ; preds = %281
  %286 = load double, ptr %11, align 8, !tbaa !11
  %287 = fcmp ogt double %286, 3.800000e+00
  br i1 %287, label %288, label %289

288:                                              ; preds = %285
  call void @illuminate_leds(i32 noundef 3)
  br label %306

289:                                              ; preds = %285
  %290 = load double, ptr %11, align 8, !tbaa !11
  %291 = fcmp ogt double %290, 3.600000e+00
  br i1 %291, label %292, label %293

292:                                              ; preds = %289
  call void @illuminate_leds(i32 noundef 2)
  br label %305

293:                                              ; preds = %289
  %294 = load double, ptr %11, align 8, !tbaa !11
  %295 = fcmp ogt double %294, 3.250000e+00
  br i1 %295, label %296, label %297

296:                                              ; preds = %293
  call void @illuminate_leds(i32 noundef 1)
  br label %304

297:                                              ; preds = %293
  %298 = load i32, ptr %12, align 4, !tbaa !5
  %299 = icmp ne i32 %298, 0
  br i1 %299, label %300, label %301

300:                                              ; preds = %297
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %302

301:                                              ; preds = %297
  store i32 4, ptr %12, align 4, !tbaa !5
  br label %302

302:                                              ; preds = %301, %300
  %303 = load i32, ptr %12, align 4, !tbaa !5
  call void @illuminate_leds(i32 noundef %303)
  br label %304

304:                                              ; preds = %302, %296
  br label %305

305:                                              ; preds = %304, %292
  br label %306

306:                                              ; preds = %305, %288
  br label %307

307:                                              ; preds = %306, %284
  br label %308

308:                                              ; preds = %307, %280
  br label %309

309:                                              ; preds = %308, %276
  br label %310

310:                                              ; preds = %309, %266
  br label %311

311:                                              ; preds = %310, %261
  call void @rc_usleep(i32 noundef 333333)
  br label %135, !llvm.loop !13

312:                                              ; preds = %135
  call void @illuminate_leds(i32 noundef 0)
  %313 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  %314 = call i32 @remove(ptr noundef @.str.5) #5
  store i32 0, ptr %3, align 4
  store i32 1, ptr %23, align 4
  br label %315

315:                                              ; preds = %312, %146, %118, %106, %101, %97, %93, %89, %85, %72, %55, %39, %37, %26
  call void @llvm.lifetime.end.p0(i64 192, ptr %22) #5
  call void @llvm.lifetime.end.p0(i64 192, ptr %21) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %316 = load i32, ptr %3, align 4
  ret i32 %316
}

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

declare void @rc_filter_empty(ptr dead_on_unwind writable sret(%struct.rc_filter_t) align 8) #2

; Function Attrs: nounwind
declare i32 @geteuid() #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: nounwind
declare i32 @getopt(i32 noundef, ptr noundef, ptr noundef) #3

declare i32 @rc_model() #2

declare i32 @system(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @access(ptr noundef, i32 noundef) #3

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

declare void @perror(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @getpid() #3

declare i32 @fflush(ptr noundef) #2

declare i32 @fclose(ptr noundef) #2

; Function Attrs: nounwind
declare ptr @signal(i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @shutdown_signal_handler(i32 noundef) #0

declare i32 @rc_led_set(i32 noundef, i32 noundef) #2

declare i32 @rc_adc_init() #2

declare double @rc_adc_batt() #2

declare i32 @rc_filter_moving_average(ptr noundef, i32 noundef, double noundef) #2

; Function Attrs: nounwind
declare i32 @remove(ptr noundef) #3

declare i32 @rc_filter_prefill_outputs(ptr noundef, double noundef) #2

declare i32 @rc_filter_prefill_inputs(ptr noundef, double noundef) #2

declare double @rc_adc_dc_jack() #2

; Function Attrs: nounwind
declare i32 @isatty(i32 noundef) #3

; Function Attrs: nounwind
declare i32 @fileno(ptr noundef) #3

declare i32 @printf(ptr noundef, ...) #2

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

declare double @rc_filter_march(ptr noundef, double noundef) #2

declare double @rc_ringbuf_std_dev(ptr noundef byval(%struct.rc_ringbuf_t) align 8) #2

; Function Attrs: nounwind uwtable
declare hidden void @illuminate_leds(i32 noundef) #0

declare void @rc_usleep(i32 noundef) #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @kill_existing_instance() #0

; Function Attrs: nounwind uwtable
declare hidden i32 @startup_blink() #0

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #5 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.rc_filter_t = type { i32, double, double, %struct.rc_vector_t, %struct.rc_vector_t, i32, double, double, i32, i32, double, %struct.rc_ringbuf_t, %struct.rc_ringbuf_t, double, double, i64, i32 }
%struct.rc_vector_t = type { i32, ptr, i32 }
%struct.rc_ringbuf_t = type { ptr, i32, i32, i32 }

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [47 x i8], align 1
@opterr = external local_unnamed_addr global i32, align 4
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [116 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [57 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [40 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [54 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@.str.12 = external hidden unnamed_addr constant [33 x i8], align 1
@running = external hidden local_unnamed_addr global i32, align 4
@.str.13 = external hidden unnamed_addr constant [54 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [33 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.rc_filter_t, align 8
  %4 = alloca %struct.rc_filter_t, align 8
  call void @llvm.lifetime.start.p0(i64 192, ptr nonnull %3) #7
  call void @rc_filter_empty(ptr dead_on_unwind nonnull writable sret(%struct.rc_filter_t) align 8 %3) #7
  call void @llvm.lifetime.start.p0(i64 192, ptr nonnull %4) #7
  call void @rc_filter_empty(ptr dead_on_unwind nonnull writable sret(%struct.rc_filter_t) align 8 %4) #7
  %5 = call i32 @geteuid() #7
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %9, label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  %8 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str) #8
  br label %161

9:                                                ; preds = %2
  store i32 0, ptr @opterr, align 4, !tbaa !9
  %10 = call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str.1) #7
  switch i32 %10, label %13 [
    i32 -1, label %16
    i32 107, label %11
  ]

11:                                               ; preds = %9
  %12 = call i32 @kill_existing_instance()
  br label %161

13:                                               ; preds = %9
  %14 = load ptr, ptr @stderr, align 8, !tbaa !5
  %15 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %14, ptr noundef nonnull @.str.2) #8
  br label %161

16:                                               ; preds = %9
  %17 = call i32 @rc_model() #7
  switch i32 %17, label %18 [
    i32 7, label %23
    i32 4, label %23
    i32 2, label %23
  ]

18:                                               ; preds = %16
  %19 = call i32 @system(ptr noundef nonnull @.str.3) #7
  %.not108 = icmp eq i32 %19, 0
  br i1 %.not108, label %23, label %20

20:                                               ; preds = %18
  %21 = load ptr, ptr @stderr, align 8, !tbaa !5
  %22 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.4) #8
  br label %161

23:                                               ; preds = %16, %16, %16, %18
  %24 = call i32 @access(ptr noundef nonnull @.str.5, i32 noundef 0) #7
  %25 = icmp eq i32 %24, 0
  br i1 %25, label %26, label %32

26:                                               ; preds = %23
  %27 = load ptr, ptr @stderr, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef nonnull @.str.6) #8
  %29 = load ptr, ptr @stderr, align 8, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %29, ptr noundef nonnull @.str.7) #8
  %31 = call i32 @kill_existing_instance()
  br label %32

32:                                               ; preds = %26, %23
  %33 = call noalias ptr @fopen(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.8)
  %34 = icmp eq ptr %33, null
  br i1 %34, label %35, label %36

35:                                               ; preds = %32
  call void @perror(ptr noundef nonnull @.str.9) #9
  br label %161

36:                                               ; preds = %32
  %37 = call i32 @getpid() #7
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef nonnull %33, ptr noundef nonnull @.str.10, i32 noundef %37) #7
  %39 = call i32 @fflush(ptr noundef nonnull %33)
  %40 = call i32 @fclose(ptr noundef nonnull %33)
  %41 = call ptr @signal(i32 noundef 2, ptr noundef nonnull @shutdown_signal_handler) #7
  %42 = call ptr @signal(i32 noundef 15, ptr noundef nonnull @shutdown_signal_handler) #7
  %43 = call i32 @rc_led_set(i32 noundef 6, i32 noundef 0) #7
  %.not109 = icmp eq i32 %43, 0
  br i1 %.not109, label %44, label %161

44:                                               ; preds = %36
  %45 = call i32 @rc_led_set(i32 noundef 7, i32 noundef 0) #7
  %.not110 = icmp eq i32 %45, 0
  br i1 %.not110, label %46, label %161

46:                                               ; preds = %44
  %47 = call i32 @rc_led_set(i32 noundef 8, i32 noundef 0) #7
  %.not111 = icmp eq i32 %47, 0
  br i1 %.not111, label %48, label %161

48:                                               ; preds = %46
  %49 = call i32 @rc_led_set(i32 noundef 9, i32 noundef 0) #7
  %.not112 = icmp eq i32 %49, 0
  br i1 %.not112, label %50, label %161

50:                                               ; preds = %48
  %51 = call i32 @rc_adc_init() #7
  %.not113 = icmp eq i32 %51, 0
  br i1 %.not113, label %52, label %161

52:                                               ; preds = %50
  %53 = call double @rc_adc_batt() #7
  %54 = call i32 @rc_filter_moving_average(ptr noundef nonnull %3, i32 noundef 6, double noundef 0x4114585555555555) #7
  %.not114 = icmp eq i32 %54, 0
  br i1 %.not114, label %59, label %55

55:                                               ; preds = %52
  %56 = load ptr, ptr @stderr, align 8, !tbaa !5
  %57 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef nonnull @.str.11) #8
  %58 = call i32 @remove(ptr noundef nonnull @.str.5) #7
  br label %161

59:                                               ; preds = %52
  %60 = call i32 @rc_filter_prefill_outputs(ptr noundef nonnull %3, double noundef %53) #7
  %61 = call i32 @rc_filter_prefill_inputs(ptr noundef nonnull %3, double noundef %53) #7
  %62 = call double @rc_adc_dc_jack() #7
  %63 = call i32 @rc_filter_moving_average(ptr noundef nonnull %4, i32 noundef 6, double noundef 0x4114585555555555) #7
  %.not115 = icmp eq i32 %63, 0
  br i1 %.not115, label %68, label %64

64:                                               ; preds = %59
  %65 = load ptr, ptr @stderr, align 8, !tbaa !5
  %66 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %65, ptr noundef nonnull @.str.11) #8
  %67 = call i32 @remove(ptr noundef nonnull @.str.5) #7
  br label %161

68:                                               ; preds = %59
  %69 = call i32 @rc_filter_prefill_outputs(ptr noundef nonnull %4, double noundef %62) #7
  %70 = call i32 @rc_filter_prefill_inputs(ptr noundef nonnull %4, double noundef %62) #7
  %71 = load ptr, ptr @stdout, align 8, !tbaa !5
  %72 = call i32 @fileno(ptr noundef %71) #7
  %73 = call i32 @isatty(i32 noundef %72) #7
  %.not116 = icmp eq i32 %73, 0
  br i1 %.not116, label %.lr.ph, label %74

74:                                               ; preds = %68
  %75 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  br label %.lr.ph

.lr.ph:                                           ; preds = %68, %74
  %76 = call i32 @startup_blink()
  store i32 1, ptr @running, align 4, !tbaa !9
  %77 = getelementptr inbounds i8, ptr %3, i64 112
  br label %78

78:                                               ; preds = %.lr.ph, %157
  %.084127 = phi double [ undef, %.lr.ph ], [ %.1, %157 ]
  %.085126 = phi double [ %53, %.lr.ph ], [ %106, %157 ]
  %.088125 = phi i32 [ 0, %.lr.ph ], [ %.189, %157 ]
  %.093124 = phi i32 [ 0, %.lr.ph ], [ %.295, %157 ]
  %.096123 = phi double [ undef, %.lr.ph ], [ %.298, %157 ]
  %.099122 = phi double [ %62, %.lr.ph ], [ %107, %157 ]
  %79 = call double @rc_adc_batt() #7
  %80 = call double @rc_adc_dc_jack() #7
  %81 = fcmp olt double %79, 0.000000e+00
  %82 = fcmp olt double %80, 0.000000e+00
  %or.cond5 = select i1 %81, i1 true, i1 %82
  br i1 %or.cond5, label %83, label %87

83:                                               ; preds = %78
  %84 = load ptr, ptr @stderr, align 8, !tbaa !5
  %85 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %84, ptr noundef nonnull @.str.13) #8
  %86 = call i32 @remove(ptr noundef nonnull @.str.5) #7
  br label %161

87:                                               ; preds = %78
  %88 = fsub double %79, %.085126
  %89 = fptosi double %88 to i32
  %90 = call i32 @llvm.abs.i32(i32 %89, i1 true)
  %91 = icmp ugt i32 %90, 2
  br i1 %91, label %92, label %96

92:                                               ; preds = %87
  %93 = call i32 @rc_filter_prefill_outputs(ptr noundef nonnull %3, double noundef %79) #7
  %94 = call i32 @rc_filter_prefill_inputs(ptr noundef nonnull %3, double noundef %79) #7
  %95 = call i32 @startup_blink()
  br label %96

96:                                               ; preds = %92, %87
  %97 = fsub double %80, %.099122
  %98 = fptosi double %97 to i32
  %99 = call i32 @llvm.abs.i32(i32 %98, i1 true)
  %100 = icmp ugt i32 %99, 2
  br i1 %100, label %101, label %105

101:                                              ; preds = %96
  %102 = call i32 @rc_filter_prefill_outputs(ptr noundef nonnull %4, double noundef %80) #7
  %103 = call i32 @rc_filter_prefill_inputs(ptr noundef nonnull %4, double noundef %80) #7
  %104 = call i32 @startup_blink()
  br label %105

105:                                              ; preds = %101, %96
  %106 = call double @rc_filter_march(ptr noundef nonnull %3, double noundef %79) #7
  %107 = call double @rc_filter_march(ptr noundef nonnull %4, double noundef %80) #7
  %108 = fcmp ogt double %106, 5.400000e+00
  br i1 %108, label %109, label %111

109:                                              ; preds = %105
  %110 = call double @rc_ringbuf_std_dev(ptr noundef nonnull byval(%struct.rc_ringbuf_t) align 8 %77) #7
  br label %111

111:                                              ; preds = %109, %105
  %.1 = phi double [ %110, %109 ], [ %.084127, %105 ]
  %112 = fcmp olt double %.1, 4.000000e-02
  %or.cond7 = select i1 %108, i1 %112, i1 false
  %113 = fmul double %106, 5.000000e-01
  %.197 = select i1 %or.cond7, double %113, double %.096123
  %114 = fcmp ogt double %107, 1.000000e+01
  %or.cond9 = select i1 %or.cond7, i1 %114, i1 false
  %115 = fcmp olt double %.197, 4.150000e+00
  %or.cond11 = select i1 %or.cond9, i1 %115, i1 false
  br i1 %or.cond7, label %131, label %116

116:                                              ; preds = %111
  %117 = fcmp ogt double %107, 1.080000e+01
  %118 = fcmp olt double %107, 1.700000e+01
  %or.cond13 = and i1 %117, %118
  br i1 %or.cond13, label %119, label %121

119:                                              ; preds = %116
  %120 = fmul double %107, 2.500000e-01
  br label %131

121:                                              ; preds = %116
  %122 = fcmp ogt double %107, 0x4020333333333334
  %123 = fcmp olt double %107, 1.275000e+01
  %or.cond15 = and i1 %122, %123
  br i1 %or.cond15, label %124, label %126

124:                                              ; preds = %121
  %125 = fdiv double %107, 3.000000e+00
  br label %131

126:                                              ; preds = %121
  %127 = fcmp ogt double %107, 5.400000e+00
  %128 = fcmp olt double %107, 8.500000e+00
  %or.cond17 = and i1 %127, %128
  br i1 %or.cond17, label %129, label %131

129:                                              ; preds = %126
  %130 = fmul double %107, 5.000000e-01
  br label %131

131:                                              ; preds = %126, %119, %129, %124, %111
  %.298 = phi double [ %113, %111 ], [ %120, %119 ], [ %125, %124 ], [ %130, %129 ], [ 0.000000e+00, %126 ]
  %132 = phi i1 [ false, %111 ], [ false, %119 ], [ false, %124 ], [ false, %129 ], [ true, %126 ]
  %133 = phi i1 [ false, %111 ], [ true, %119 ], [ true, %124 ], [ false, %129 ], [ true, %126 ]
  %.2 = phi i32 [ 2, %111 ], [ 4, %119 ], [ 3, %124 ], [ 2, %129 ], [ 0, %126 ]
  br i1 %.not116, label %138, label %134

134:                                              ; preds = %131
  %135 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14, double noundef %106, double noundef %107, i32 noundef %.2, double noundef %.298)
  %136 = load ptr, ptr @stdout, align 8, !tbaa !5
  %137 = call i32 @fflush(ptr noundef %136)
  br label %138

138:                                              ; preds = %134, %131
  br i1 %or.cond11, label %139, label %142

139:                                              ; preds = %138
  %140 = add nsw i32 %.088125, 1
  %141 = icmp sgt i32 %.088125, 3
  %spec.store.select = select i1 %141, i32 0, i32 %140
  br label %157

142:                                              ; preds = %138
  br i1 %132, label %157, label %143

143:                                              ; preds = %142
  %144 = fcmp ogt double %107, 1.150000e+01
  %145 = fcmp olt double %107, 1.250000e+01
  %146 = and i1 %144, %145
  %or.cond21 = select i1 %133, i1 %146, i1 false
  %147 = fcmp olt double %.298, 2.700000e+00
  %or.cond = select i1 %or.cond21, i1 true, i1 %147
  br i1 %or.cond, label %157, label %148

148:                                              ; preds = %143
  %149 = fcmp ogt double %.298, 3.900000e+00
  br i1 %149, label %157, label %150

150:                                              ; preds = %148
  %151 = fcmp ogt double %.298, 3.800000e+00
  br i1 %151, label %157, label %152

152:                                              ; preds = %150
  %153 = fcmp ogt double %.298, 3.600000e+00
  br i1 %153, label %157, label %154

154:                                              ; preds = %152
  %155 = fcmp ogt double %.298, 3.250000e+00
  br i1 %155, label %157, label %156

156:                                              ; preds = %154
  %.not120 = icmp eq i32 %.093124, 0
  %. = select i1 %.not120, i32 4, i32 0
  br label %157

157:                                              ; preds = %154, %152, %150, %148, %143, %142, %156, %139
  %.sink = phi i32 [ %., %156 ], [ %spec.store.select, %139 ], [ 0, %142 ], [ 0, %143 ], [ 4, %148 ], [ 3, %150 ], [ 2, %152 ], [ 1, %154 ]
  %.295 = phi i32 [ %., %156 ], [ %.093124, %139 ], [ %.093124, %142 ], [ %.093124, %143 ], [ %.093124, %148 ], [ %.093124, %150 ], [ %.093124, %152 ], [ %.093124, %154 ]
  %.189 = phi i32 [ %.088125, %156 ], [ %spec.store.select, %139 ], [ %.088125, %142 ], [ %.088125, %143 ], [ %.088125, %148 ], [ %.088125, %150 ], [ %.088125, %152 ], [ %.088125, %154 ]
  call void @illuminate_leds(i32 noundef %.sink)
  call void @rc_usleep(i32 noundef 333333) #7
  %158 = load i32, ptr @running, align 4, !tbaa !9
  %.not117 = icmp eq i32 %158, 0
  br i1 %.not117, label %._crit_edge, label %78, !llvm.loop !11

._crit_edge:                                      ; preds = %157
  call void @illuminate_leds(i32 noundef 0)
  %159 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  %160 = call i32 @remove(ptr noundef nonnull @.str.5) #7
  br label %161

161:                                              ; preds = %50, %48, %46, %44, %36, %._crit_edge, %83, %64, %55, %35, %20, %13, %11, %6
  %.0 = phi i32 [ -1, %6 ], [ %12, %11 ], [ -1, %13 ], [ 0, %20 ], [ -1, %35 ], [ -1, %55 ], [ -1, %64 ], [ -1, %83 ], [ 0, %._crit_edge ], [ -1, %36 ], [ -1, %44 ], [ -1, %46 ], [ -1, %48 ], [ -1, %50 ]
  call void @llvm.lifetime.end.p0(i64 192, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 192, ptr nonnull %3) #7
  ret i32 %.0
}

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

declare void @rc_filter_empty(ptr dead_on_unwind writable sret(%struct.rc_filter_t) align 8) local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @geteuid() local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: nounwind
declare i32 @getopt(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @rc_model() local_unnamed_addr #2

; Function Attrs: nofree
declare noundef i32 @system(ptr nocapture noundef readonly) local_unnamed_addr #5

; Function Attrs: nofree nounwind
declare noundef i32 @access(ptr nocapture noundef readonly, i32 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare void @perror(ptr nocapture noundef readonly) local_unnamed_addr #4

; Function Attrs: nounwind
declare i32 @getpid() local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind
declare ptr @signal(i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @shutdown_signal_handler(i32 noundef) #0

declare i32 @rc_led_set(i32 noundef, i32 noundef) local_unnamed_addr #2

declare i32 @rc_adc_init() local_unnamed_addr #2

declare double @rc_adc_batt() local_unnamed_addr #2

declare i32 @rc_filter_moving_average(ptr noundef, i32 noundef, double noundef) local_unnamed_addr #2

; Function Attrs: nofree nounwind
declare noundef i32 @remove(ptr nocapture noundef readonly) local_unnamed_addr #4

declare i32 @rc_filter_prefill_outputs(ptr noundef, double noundef) local_unnamed_addr #2

declare i32 @rc_filter_prefill_inputs(ptr noundef, double noundef) local_unnamed_addr #2

declare double @rc_adc_dc_jack() local_unnamed_addr #2

; Function Attrs: nounwind
declare i32 @isatty(i32 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @fileno(ptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

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

declare double @rc_filter_march(ptr noundef, double noundef) local_unnamed_addr #2

declare double @rc_ringbuf_std_dev(ptr noundef byval(%struct.rc_ringbuf_t) align 8) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @illuminate_leds(i32 noundef) local_unnamed_addr #0

declare void @rc_usleep(i32 noundef) local_unnamed_addr #2

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

; Function Attrs: nounwind uwtable
declare hidden i32 @kill_existing_instance() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @startup_blink() local_unnamed_addr #0

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nofree "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 #6 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #7 = { nounwind }
attributes #8 = { cold nounwind }
attributes #9 = { cold }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SCCPPass,SROAPass,SimplifyCFGPass