; LLVM IR from DroneBridge/DroneBridge :: control (opentx)

; 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.timespec = type { i64, i64 }
%struct.js_event = type { i32, i16, i8, i8 }

@keep_running = external hidden global i32, align 4
@.str.3 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [53 x i8], align 1
@stderr = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @custom_signal_handler(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @initialize_opentx(i32 noundef) #0

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

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

declare void @syslog(i32 noundef, ptr 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 dso_local zeroext i16 @normalize_opentx(i16 noundef signext) #0

; Function Attrs: nounwind uwtable
define dso_local void @opentx(i32 noundef %0, i64 %1, i64 %2) #0 {
  %4 = alloca %struct.timespec, align 8
  %5 = alloca i32, align 4
  %6 = alloca %struct.js_event, align 4
  %7 = alloca [14 x i16], align 16
  %8 = alloca %struct.timespec, align 8
  %9 = alloca [32 x i16], align 16
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = getelementptr inbounds { i64, i64 }, ptr %4, i32 0, i32 0
  store i64 %1, ptr %12, align 8
  %13 = getelementptr inbounds { i64, i64 }, ptr %4, i32 0, i32 1
  store i64 %2, ptr %13, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  %14 = call ptr @signal(i32 noundef 2, ptr noundef @custom_signal_handler) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 28, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.start.p0(i64 64, ptr %9) #6
  call void @llvm.memset.p0.i64(ptr align 16 %9, i8 0, i64 64, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %15 = load i32, ptr %5, align 4, !tbaa !5
  %16 = call i32 @initialize_opentx(i32 noundef %15)
  store i32 %16, ptr %10, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %3
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  call void (i32, ptr, ...) @syslog(i32 noundef 6, ptr noundef @.str.3)
  br label %19

19:                                               ; preds = %17
  br label %20

20:                                               ; preds = %19
  br label %21

21:                                               ; preds = %175, %20
  %22 = load volatile i32, ptr @keep_running, align 4, !tbaa !5
  %23 = icmp ne i32 %22, 0
  br i1 %23, label %24, label %178

24:                                               ; preds = %21
  %25 = call i32 @nanosleep(ptr noundef %4, ptr noundef %8)
  br label %26

26:                                               ; preds = %62, %24
  %27 = load i32, ptr %10, align 4, !tbaa !5
  %28 = call i64 @read(i32 noundef %27, ptr noundef %6, i64 noundef 8)
  %29 = icmp sgt i64 %28, 0
  br i1 %29, label %30, label %63

30:                                               ; preds = %26
  %31 = getelementptr inbounds %struct.js_event, ptr %6, i32 0, i32 2
  %32 = load i8, ptr %31, align 2, !tbaa !9
  %33 = zext i8 %32 to i32
  %34 = and i32 %33, -129
  %35 = trunc i32 %34 to i8
  store i8 %35, ptr %31, align 2, !tbaa !9
  %36 = getelementptr inbounds %struct.js_event, ptr %6, i32 0, i32 2
  %37 = load i8, ptr %36, align 2, !tbaa !9
  %38 = zext i8 %37 to i32
  %39 = icmp eq i32 %38, 2
  br i1 %39, label %40, label %47

40:                                               ; preds = %30
  %41 = getelementptr inbounds %struct.js_event, ptr %6, i32 0, i32 1
  %42 = load i16, ptr %41, align 4, !tbaa !12
  %43 = getelementptr inbounds %struct.js_event, ptr %6, i32 0, i32 3
  %44 = load i8, ptr %43, align 1, !tbaa !13
  %45 = zext i8 %44 to i64
  %46 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 %45
  store i16 %42, ptr %46, align 2, !tbaa !14
  br label %62

47:                                               ; preds = %30
  %48 = getelementptr inbounds %struct.js_event, ptr %6, i32 0, i32 2
  %49 = load i8, ptr %48, align 2, !tbaa !9
  %50 = zext i8 %49 to i32
  %51 = icmp eq i32 %50, 1
  br i1 %51, label %52, label %61

52:                                               ; preds = %47
  %53 = getelementptr inbounds %struct.js_event, ptr %6, i32 0, i32 1
  %54 = load i16, ptr %53, align 4, !tbaa !12
  %55 = getelementptr inbounds %struct.js_event, ptr %6, i32 0, i32 3
  %56 = load i8, ptr %55, align 1, !tbaa !13
  %57 = zext i8 %56 to i32
  %58 = add nsw i32 8, %57
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 %59
  store i16 %54, ptr %60, align 2, !tbaa !14
  br label %61

61:                                               ; preds = %52, %47
  br label %62

62:                                               ; preds = %61, %40
  br label %26, !llvm.loop !15

63:                                               ; preds = %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %64 = call ptr @__errno_location() #7
  %65 = load i32, ptr %64, align 4, !tbaa !5
  store i32 %65, ptr %11, align 4, !tbaa !5
  %66 = load i32, ptr %11, align 4, !tbaa !5
  %67 = icmp ne i32 %66, 11
  br i1 %67, label %68, label %89

68:                                               ; preds = %63
  %69 = load i32, ptr %11, align 4, !tbaa !5
  %70 = icmp eq i32 %69, 19
  br i1 %70, label %71, label %78

71:                                               ; preds = %68
  br label %72

72:                                               ; preds = %71
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  call void (i32, ptr, ...) @syslog(i32 noundef 4, ptr noundef @.str.4)
  br label %74

74:                                               ; preds = %72
  br label %75

75:                                               ; preds = %74
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = call i32 @initialize_opentx(i32 noundef %76)
  store i32 %77, ptr %10, align 4, !tbaa !5
  br label %88

78:                                               ; preds = %68
  br label %79

79:                                               ; preds = %78
  %80 = load ptr, ptr @stderr, align 8, !tbaa !17
  %81 = load i32, ptr %11, align 4, !tbaa !5
  %82 = call ptr @strerror(i32 noundef %81) #6
  %83 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %80, ptr noundef @.str.5, ptr noundef %82) #6
  %84 = load i32, ptr %11, align 4, !tbaa !5
  %85 = call ptr @strerror(i32 noundef %84) #6
  call void (i32, ptr, ...) @syslog(i32 noundef 3, ptr noundef @.str.5, ptr noundef %85)
  br label %86

86:                                               ; preds = %79
  br label %87

87:                                               ; preds = %86
  br label %88

88:                                               ; preds = %87, %75
  br label %89

89:                                               ; preds = %88, %63
  %90 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 0
  %91 = load i16, ptr %90, align 16, !tbaa !14
  %92 = call zeroext i16 @normalize_opentx(i16 noundef signext %91)
  %93 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 0
  store i16 %92, ptr %93, align 16, !tbaa !14
  %94 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 1
  %95 = load i16, ptr %94, align 2, !tbaa !14
  %96 = call zeroext i16 @normalize_opentx(i16 noundef signext %95)
  %97 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 1
  store i16 %96, ptr %97, align 2, !tbaa !14
  %98 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 2
  %99 = load i16, ptr %98, align 4, !tbaa !14
  %100 = call zeroext i16 @normalize_opentx(i16 noundef signext %99)
  %101 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 2
  store i16 %100, ptr %101, align 4, !tbaa !14
  %102 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 3
  %103 = load i16, ptr %102, align 2, !tbaa !14
  %104 = call zeroext i16 @normalize_opentx(i16 noundef signext %103)
  %105 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 3
  store i16 %104, ptr %105, align 2, !tbaa !14
  %106 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 4
  %107 = load i16, ptr %106, align 8, !tbaa !14
  %108 = call zeroext i16 @normalize_opentx(i16 noundef signext %107)
  %109 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 4
  store i16 %108, ptr %109, align 8, !tbaa !14
  %110 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 5
  %111 = load i16, ptr %110, align 2, !tbaa !14
  %112 = call zeroext i16 @normalize_opentx(i16 noundef signext %111)
  %113 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 5
  store i16 %112, ptr %113, align 2, !tbaa !14
  %114 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 6
  %115 = load i16, ptr %114, align 4, !tbaa !14
  %116 = call zeroext i16 @normalize_opentx(i16 noundef signext %115)
  %117 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 6
  store i16 %116, ptr %117, align 4, !tbaa !14
  %118 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 7
  %119 = load i16, ptr %118, align 2, !tbaa !14
  %120 = call zeroext i16 @normalize_opentx(i16 noundef signext %119)
  %121 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 7
  store i16 %120, ptr %121, align 2, !tbaa !14
  %122 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 8
  %123 = load i16, ptr %122, align 16, !tbaa !14
  %124 = sext i16 %123 to i32
  %125 = icmp eq i32 %124, 1
  br i1 %125, label %126, label %128

126:                                              ; preds = %89
  %127 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 8
  store i16 1000, ptr %127, align 16, !tbaa !14
  br label %130

128:                                              ; preds = %89
  %129 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 8
  store i16 2000, ptr %129, align 16, !tbaa !14
  br label %130

130:                                              ; preds = %128, %126
  %131 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 9
  %132 = load i16, ptr %131, align 2, !tbaa !14
  %133 = sext i16 %132 to i32
  %134 = icmp eq i32 %133, 1
  br i1 %134, label %135, label %137

135:                                              ; preds = %130
  %136 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 9
  store i16 1000, ptr %136, align 2, !tbaa !14
  br label %139

137:                                              ; preds = %130
  %138 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 9
  store i16 2000, ptr %138, align 2, !tbaa !14
  br label %139

139:                                              ; preds = %137, %135
  %140 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 10
  %141 = load i16, ptr %140, align 4, !tbaa !14
  %142 = sext i16 %141 to i32
  %143 = icmp eq i32 %142, 1
  br i1 %143, label %144, label %146

144:                                              ; preds = %139
  %145 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 10
  store i16 1000, ptr %145, align 4, !tbaa !14
  br label %148

146:                                              ; preds = %139
  %147 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 10
  store i16 2000, ptr %147, align 4, !tbaa !14
  br label %148

148:                                              ; preds = %146, %144
  %149 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 11
  %150 = load i16, ptr %149, align 2, !tbaa !14
  %151 = sext i16 %150 to i32
  %152 = icmp eq i32 %151, 1
  br i1 %152, label %153, label %155

153:                                              ; preds = %148
  %154 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 11
  store i16 1000, ptr %154, align 2, !tbaa !14
  br label %157

155:                                              ; preds = %148
  %156 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 11
  store i16 2000, ptr %156, align 2, !tbaa !14
  br label %157

157:                                              ; preds = %155, %153
  %158 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 12
  %159 = load i16, ptr %158, align 8, !tbaa !14
  %160 = sext i16 %159 to i32
  %161 = icmp eq i32 %160, 1
  br i1 %161, label %162, label %164

162:                                              ; preds = %157
  %163 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 12
  store i16 1000, ptr %163, align 8, !tbaa !14
  br label %166

164:                                              ; preds = %157
  %165 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 12
  store i16 2000, ptr %165, align 8, !tbaa !14
  br label %166

166:                                              ; preds = %164, %162
  %167 = getelementptr inbounds [32 x i16], ptr %9, i64 0, i64 13
  %168 = load i16, ptr %167, align 2, !tbaa !14
  %169 = sext i16 %168 to i32
  %170 = icmp eq i32 %169, 1
  br i1 %170, label %171, label %173

171:                                              ; preds = %166
  %172 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 13
  store i16 1000, ptr %172, align 2, !tbaa !14
  br label %175

173:                                              ; preds = %166
  %174 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 13
  store i16 2000, ptr %174, align 2, !tbaa !14
  br label %175

175:                                              ; preds = %173, %171
  %176 = getelementptr inbounds [14 x i16], ptr %7, i64 0, i64 0
  %177 = call i32 @send_rc_packet(ptr noundef %176)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %21, !llvm.loop !19

178:                                              ; preds = %21
  %179 = load i32, ptr %10, align 4, !tbaa !5
  %180 = call i32 @close(i32 noundef %179)
  call void (...) @close_raw_interfaces()
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 64, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 28, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  ret void
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare i32 @nanosleep(ptr noundef, ptr noundef) #2

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #5

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

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

declare i32 @send_rc_packet(ptr noundef) #2

declare i32 @close(i32 noundef) #2

declare void @close_raw_interfaces(...) #2

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 nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind willreturn memory(none) "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 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }

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

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


; 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.timespec = type { i64, i64 }
%struct.js_event = type { i32, i16, i8, i8 }

@keep_running = external hidden global i32, align 4
@.str.3 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [53 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [27 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @custom_signal_handler(i32 noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @initialize_opentx(i32 noundef) local_unnamed_addr #0

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

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

declare void @syslog(i32 noundef, ptr noundef, ...) local_unnamed_addr #3

; 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 dso_local zeroext i16 @normalize_opentx(i16 noundef signext) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @opentx(i32 noundef %0, i64 %1, i64 %2) local_unnamed_addr #0 {
  %4 = alloca %struct.timespec, align 8
  %5 = alloca %struct.js_event, align 4
  %6 = alloca [14 x i16], align 16
  %7 = alloca %struct.timespec, align 8
  %8 = alloca [32 x i16], align 16
  store i64 %1, ptr %4, align 8
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  store i64 %2, ptr %9, align 8
  %10 = tail call ptr @signal(i32 noundef 2, ptr noundef nonnull @custom_signal_handler) #8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %5) #8
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %6) #8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #8
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %8) #8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(64) %8, i8 0, i64 64, i1 false)
  %11 = tail call i32 @initialize_opentx(i32 noundef %0)
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  tail call void (i32, ptr, ...) @syslog(i32 noundef 6, ptr noundef nonnull @.str.3) #8
  %13 = load volatile i32, ptr @keep_running, align 4, !tbaa !5
  %.not11 = icmp eq i32 %13, 0
  br i1 %.not11, label %._crit_edge15, label %.lr.ph14

.lr.ph14:                                         ; preds = %3
  %14 = getelementptr inbounds i8, ptr %5, i64 6
  %15 = getelementptr inbounds i8, ptr %5, i64 4
  %16 = getelementptr inbounds i8, ptr %5, i64 7
  %17 = getelementptr inbounds i8, ptr %8, i64 2
  %18 = getelementptr inbounds i8, ptr %6, i64 2
  %19 = getelementptr inbounds i8, ptr %8, i64 4
  %20 = getelementptr inbounds i8, ptr %6, i64 4
  %21 = getelementptr inbounds i8, ptr %8, i64 6
  %22 = getelementptr inbounds i8, ptr %6, i64 6
  %23 = getelementptr inbounds i8, ptr %8, i64 8
  %24 = getelementptr inbounds i8, ptr %6, i64 8
  %25 = getelementptr inbounds i8, ptr %8, i64 10
  %26 = getelementptr inbounds i8, ptr %6, i64 10
  %27 = getelementptr inbounds i8, ptr %8, i64 12
  %28 = getelementptr inbounds i8, ptr %6, i64 12
  %29 = getelementptr inbounds i8, ptr %8, i64 14
  %30 = getelementptr inbounds i8, ptr %6, i64 14
  %31 = getelementptr inbounds i8, ptr %8, i64 16
  %32 = getelementptr inbounds i8, ptr %6, i64 16
  %33 = getelementptr inbounds i8, ptr %8, i64 24
  %34 = getelementptr inbounds i8, ptr %6, i64 24
  br label %35

35:                                               ; preds = %.lr.ph14, %64
  %.012 = phi i32 [ %11, %.lr.ph14 ], [ %.1, %64 ]
  %36 = call i32 @nanosleep(ptr noundef nonnull %4, ptr noundef nonnull %7) #8
  %37 = call i64 @read(i32 noundef %.012, ptr noundef nonnull %5, i64 noundef 8) #8
  %38 = icmp sgt i64 %37, 0
  br i1 %38, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %35, %51
  %39 = load i8, ptr %14, align 2, !tbaa !9
  %40 = and i8 %39, 127
  store i8 %40, ptr %14, align 2, !tbaa !9
  switch i8 %40, label %51 [
    i8 2, label %41
    i8 1, label %45
  ]

41:                                               ; preds = %.lr.ph
  %42 = load i16, ptr %15, align 4, !tbaa !12
  %43 = load i8, ptr %16, align 1, !tbaa !13
  %44 = zext i8 %43 to i64
  br label %.sink.split

45:                                               ; preds = %.lr.ph
  %46 = load i16, ptr %15, align 4, !tbaa !12
  %47 = load i8, ptr %16, align 1, !tbaa !13
  %48 = zext i8 %47 to i64
  %49 = add nuw nsw i64 %48, 8
  br label %.sink.split

.sink.split:                                      ; preds = %41, %45
  %.sink22 = phi i64 [ %49, %45 ], [ %44, %41 ]
  %.sink = phi i16 [ %46, %45 ], [ %42, %41 ]
  %50 = getelementptr inbounds [32 x i16], ptr %8, i64 0, i64 %.sink22
  store i16 %.sink, ptr %50, align 2, !tbaa !14
  br label %51

51:                                               ; preds = %.sink.split, %.lr.ph
  %52 = call i64 @read(i32 noundef %.012, ptr noundef nonnull %5, i64 noundef 8) #8
  %53 = icmp sgt i64 %52, 0
  br i1 %53, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %51, %35
  %54 = tail call ptr @__errno_location() #9
  %55 = load i32, ptr %54, align 4, !tbaa !5
  switch i32 %55, label %59 [
    i32 11, label %64
    i32 19, label %56
  ]

56:                                               ; preds = %._crit_edge
  %57 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  call void (i32, ptr, ...) @syslog(i32 noundef 4, ptr noundef nonnull @.str.4) #8
  %58 = call i32 @initialize_opentx(i32 noundef %0)
  br label %64

59:                                               ; preds = %._crit_edge
  %60 = load ptr, ptr @stderr, align 8, !tbaa !17
  %61 = call ptr @strerror(i32 noundef %55) #8
  %62 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %60, ptr noundef nonnull @.str.5, ptr noundef %61) #10
  %63 = call ptr @strerror(i32 noundef %55) #8
  call void (i32, ptr, ...) @syslog(i32 noundef 3, ptr noundef nonnull @.str.5, ptr noundef %63) #8
  br label %64

64:                                               ; preds = %._crit_edge, %56, %59
  %.1 = phi i32 [ %58, %56 ], [ %.012, %59 ], [ %.012, %._crit_edge ]
  %65 = load i16, ptr %8, align 16, !tbaa !14
  %66 = call zeroext i16 @normalize_opentx(i16 noundef signext %65)
  store i16 %66, ptr %6, align 16, !tbaa !14
  %67 = load i16, ptr %17, align 2, !tbaa !14
  %68 = call zeroext i16 @normalize_opentx(i16 noundef signext %67)
  store i16 %68, ptr %18, align 2, !tbaa !14
  %69 = load i16, ptr %19, align 4, !tbaa !14
  %70 = call zeroext i16 @normalize_opentx(i16 noundef signext %69)
  store i16 %70, ptr %20, align 4, !tbaa !14
  %71 = load i16, ptr %21, align 2, !tbaa !14
  %72 = call zeroext i16 @normalize_opentx(i16 noundef signext %71)
  store i16 %72, ptr %22, align 2, !tbaa !14
  %73 = load i16, ptr %23, align 8, !tbaa !14
  %74 = call zeroext i16 @normalize_opentx(i16 noundef signext %73)
  store i16 %74, ptr %24, align 8, !tbaa !14
  %75 = load i16, ptr %25, align 2, !tbaa !14
  %76 = call zeroext i16 @normalize_opentx(i16 noundef signext %75)
  store i16 %76, ptr %26, align 2, !tbaa !14
  %77 = load i16, ptr %27, align 4, !tbaa !14
  %78 = call zeroext i16 @normalize_opentx(i16 noundef signext %77)
  store i16 %78, ptr %28, align 4, !tbaa !14
  %79 = load i16, ptr %29, align 2, !tbaa !14
  %80 = call zeroext i16 @normalize_opentx(i16 noundef signext %79)
  store i16 %80, ptr %30, align 2, !tbaa !14
  %81 = load <4 x i16>, ptr %31, align 16, !tbaa !14
  %82 = icmp eq <4 x i16> %81, <i16 1, i16 1, i16 1, i16 1>
  %83 = select <4 x i1> %82, <4 x i16> <i16 1000, i16 1000, i16 1000, i16 1000>, <4 x i16> <i16 2000, i16 2000, i16 2000, i16 2000>
  store <4 x i16> %83, ptr %32, align 16, !tbaa !14
  %84 = load <2 x i16>, ptr %33, align 8, !tbaa !14
  %85 = icmp eq <2 x i16> %84, <i16 1, i16 1>
  %86 = select <2 x i1> %85, <2 x i16> <i16 1000, i16 1000>, <2 x i16> <i16 2000, i16 2000>
  store <2 x i16> %86, ptr %34, align 8, !tbaa !14
  %87 = call i32 @send_rc_packet(ptr noundef nonnull %6) #8
  %88 = load volatile i32, ptr @keep_running, align 4, !tbaa !5
  %.not = icmp eq i32 %88, 0
  br i1 %.not, label %._crit_edge15, label %35, !llvm.loop !19

._crit_edge15:                                    ; preds = %64, %3
  %.0.lcssa = phi i32 [ %11, %3 ], [ %.1, %64 ]
  %89 = call i32 @close(i32 noundef %.0.lcssa) #8
  call void (...) @close_raw_interfaces() #8
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %8) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %6) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %5) #8
  ret void
}

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

declare i32 @nanosleep(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #6

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #7

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #4

declare i32 @send_rc_packet(ptr noundef) local_unnamed_addr #3

declare i32 @close(i32 noundef) local_unnamed_addr #3

declare void @close_raw_interfaces(...) local_unnamed_addr #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { "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 = { 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { 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 #7 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(none) }
attributes #10 = { cold 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, !7, i64 6}
!10 = !{!"js_event", !6, i64 0, !11, i64 4, !7, i64 6, !7, i64 7}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !7, i64 7}
!14 = !{!11, !11, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !18, i64 0}
!18 = !{!"any pointer", !7, i64 0}
!19 = distinct !{!19, !16}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass