; LLVM IR from DroneBridge/DroneBridge :: recorder (recorder)

; 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.video_file_t = type { ptr, [512 x i8] }
%struct.sockaddr_un = type { i16, [108 x i8] }
%struct.fd_set = type { [16 x i64] }
%struct.timeval = type { i64, i64 }

@recorder_running = external dso_local global i32, align 4
@stderr = external global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [26 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local void @open_new_file(ptr noundef, ptr noundef) #0

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

; Function Attrs: nounwind
declare ptr @strcpy(ptr 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

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

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @delete_file(ptr noundef) #0

declare i32 @fclose(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @write_to_file(ptr noundef, ptr noundef, i64 noundef) #0

; 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 [448 x i8], align 16
  %7 = alloca %struct.video_file_t, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca %struct.sockaddr_un, align 2
  %11 = alloca i32, align 4
  %12 = alloca i8, align 1
  %13 = alloca %struct.fd_set, align 8
  %14 = alloca %struct.timeval, align 8
  %15 = alloca [819200 x i8], align 16
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  %18 = alloca ptr, align 8
  %19 = 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
  %20 = call ptr @signal(i32 noundef 2, ptr noundef @int_handler) #6
  %21 = call ptr @signal(i32 noundef 15, ptr noundef @int_handler) #6
  %22 = call ptr @signal(i32 noundef 9, ptr noundef @int_handler) #6
  call void @llvm.lifetime.start.p0(i64 448, ptr %6) #6
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds ptr, ptr %23, i64 1
  %25 = load ptr, ptr %24, align 8, !tbaa !9
  %26 = call i64 @strlen(ptr noundef %25) #7
  %27 = icmp eq i64 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %2
  %29 = getelementptr inbounds [448 x i8], ptr %6, i64 0, i64 0
  %30 = call ptr @strcpy(ptr noundef %29, ptr noundef @.str.8) #6
  br label %37

31:                                               ; preds = %2
  %32 = getelementptr inbounds [448 x i8], ptr %6, i64 0, i64 0
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds ptr, ptr %33, i64 1
  %35 = load ptr, ptr %34, align 8, !tbaa !9
  %36 = call ptr @strcpy(ptr noundef %32, ptr noundef %35) #6
  br label %37

37:                                               ; preds = %31, %28
  call void @llvm.lifetime.start.p0(i64 520, ptr %7) #6
  %38 = getelementptr inbounds [448 x i8], ptr %6, i64 0, i64 0
  call void @open_new_file(ptr noundef %38, ptr noundef %7)
  %39 = getelementptr inbounds %struct.video_file_t, ptr %7, i32 0, i32 0
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = icmp eq ptr %40, null
  br i1 %41, label %42, label %43

42:                                               ; preds = %37
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %210

43:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.start.p0(i64 110, ptr %10) #6
  %44 = call i32 @socket(i32 noundef 1, i32 noundef 1, i32 noundef 0) #6
  store i32 %44, ptr %9, align 4, !tbaa !5
  %45 = icmp slt i32 %44, 0
  br i1 %45, label %46, label %58

46:                                               ; preds = %43
  br label %47

47:                                               ; preds = %46
  %48 = load ptr, ptr @stderr, align 8, !tbaa !9
  %49 = call ptr @__errno_location() #8
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = call ptr @strerror(i32 noundef %50) #6
  %52 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %48, ptr noundef @.str.9, ptr noundef %51) #6
  %53 = call ptr @__errno_location() #8
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = call ptr @strerror(i32 noundef %54) #6
  call void (i32, ptr, ...) @syslog(i32 noundef 3, ptr noundef @.str.9, ptr noundef %55)
  br label %56

56:                                               ; preds = %47
  br label %57

57:                                               ; preds = %56
  call void @delete_file(ptr noundef %7)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %209

58:                                               ; preds = %43
  %59 = getelementptr inbounds %struct.sockaddr_un, ptr %10, i32 0, i32 0
  store i16 1, ptr %59, align 2, !tbaa !13
  %60 = getelementptr inbounds %struct.sockaddr_un, ptr %10, i32 0, i32 1
  %61 = getelementptr inbounds [108 x i8], ptr %60, i64 0, i64 0
  %62 = call ptr @strcpy(ptr noundef %61, ptr noundef @.str.10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #6
  store i8 0, ptr %12, align 1, !tbaa !16
  br label %63

63:                                               ; preds = %84, %58
  %64 = load i32, ptr %9, align 4, !tbaa !5
  %65 = call i32 @connect(i32 noundef %64, ptr noundef %10, i32 noundef 110)
  %66 = icmp eq i32 %65, 0
  br i1 %66, label %67, label %72

67:                                               ; preds = %63
  br label %68

68:                                               ; preds = %67
  %69 = call i32 (ptr, ...) @printf(ptr noundef @.str.11, ptr noundef @.str.10)
  call void (i32, ptr, ...) @syslog(i32 noundef 6, ptr noundef @.str.11, ptr noundef @.str.10)
  br label %70

70:                                               ; preds = %68
  br label %71

71:                                               ; preds = %70
  store i8 1, ptr %12, align 1, !tbaa !16
  br label %76

72:                                               ; preds = %63
  %73 = call i32 @usleep(i32 noundef 50000)
  %74 = load i32, ptr %11, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %11, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %72, %71
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %11, align 4, !tbaa !5
  %79 = icmp ne i32 %78, 100
  br i1 %79, label %80, label %84

80:                                               ; preds = %77
  %81 = load i8, ptr %12, align 1, !tbaa !16, !range !18, !noundef !19
  %82 = trunc i8 %81 to i1
  %83 = xor i1 %82, true
  br label %84

84:                                               ; preds = %80, %77
  %85 = phi i1 [ false, %77 ], [ %83, %80 ]
  br i1 %85, label %63, label %86, !llvm.loop !20

86:                                               ; preds = %84
  %87 = load i8, ptr %12, align 1, !tbaa !16, !range !18, !noundef !19
  %88 = trunc i8 %87 to i1
  br i1 %88, label %102, label %89

89:                                               ; preds = %86
  br label %90

90:                                               ; preds = %89
  %91 = call ptr @__errno_location() #8
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = call ptr @strerror(i32 noundef %92) #6
  %94 = call i32 (ptr, ...) @printf(ptr noundef @.str.12, ptr noundef @.str.10, ptr noundef %93)
  %95 = call ptr @__errno_location() #8
  %96 = load i32, ptr %95, align 4, !tbaa !5
  %97 = call ptr @strerror(i32 noundef %96) #6
  call void (i32, ptr, ...) @syslog(i32 noundef 6, ptr noundef @.str.12, ptr noundef @.str.10, ptr noundef %97)
  br label %98

98:                                               ; preds = %90
  br label %99

99:                                               ; preds = %98
  call void @delete_file(ptr noundef %7)
  %100 = load i32, ptr %9, align 4, !tbaa !5
  %101 = call i32 @close(i32 noundef %100)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %208

102:                                              ; preds = %86
  call void @llvm.lifetime.start.p0(i64 128, ptr %13) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #6
  call void @llvm.lifetime.start.p0(i64 819200, ptr %15) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  store i64 0, ptr %16, align 8, !tbaa !22
  br label %103

103:                                              ; preds = %194, %102
  %104 = load volatile i32, ptr @recorder_running, align 4, !tbaa !5
  %105 = icmp ne i32 %104, 0
  br i1 %105, label %106, label %195

106:                                              ; preds = %103
  %107 = getelementptr inbounds %struct.timeval, ptr %14, i32 0, i32 0
  store i64 1, ptr %107, align 8, !tbaa !24
  %108 = getelementptr inbounds %struct.timeval, ptr %14, i32 0, i32 1
  store i64 0, ptr %108, align 8, !tbaa !26
  br label %109

109:                                              ; preds = %106
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  store ptr %13, ptr %18, align 8, !tbaa !9
  store i32 0, ptr %17, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %120, %109
  %111 = load i32, ptr %17, align 4, !tbaa !5
  %112 = zext i32 %111 to i64
  %113 = icmp ult i64 %112, 16
  br i1 %113, label %114, label %123

114:                                              ; preds = %110
  %115 = load ptr, ptr %18, align 8, !tbaa !9
  %116 = getelementptr inbounds %struct.fd_set, ptr %115, i32 0, i32 0
  %117 = load i32, ptr %17, align 4, !tbaa !5
  %118 = zext i32 %117 to i64
  %119 = getelementptr inbounds [16 x i64], ptr %116, i64 0, i64 %118
  store i64 0, ptr %119, align 8, !tbaa !22
  br label %120

120:                                              ; preds = %114
  %121 = load i32, ptr %17, align 4, !tbaa !5
  %122 = add i32 %121, 1
  store i32 %122, ptr %17, align 4, !tbaa !5
  br label %110, !llvm.loop !27

123:                                              ; preds = %110
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #6
  br label %124

124:                                              ; preds = %123
  br label %125

125:                                              ; preds = %124
  %126 = load i32, ptr %9, align 4, !tbaa !5
  %127 = srem i32 %126, 64
  %128 = zext i32 %127 to i64
  %129 = shl i64 1, %128
  %130 = getelementptr inbounds %struct.fd_set, ptr %13, i32 0, i32 0
  %131 = load i32, ptr %9, align 4, !tbaa !5
  %132 = sdiv i32 %131, 64
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [16 x i64], ptr %130, i64 0, i64 %133
  %135 = load i64, ptr %134, align 8, !tbaa !22
  %136 = or i64 %135, %129
  store i64 %136, ptr %134, align 8, !tbaa !22
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  %137 = load i32, ptr %9, align 4, !tbaa !5
  %138 = add nsw i32 %137, 1
  %139 = call i32 @select(i32 noundef %138, ptr noundef %13, ptr noundef null, ptr noundef null, ptr noundef %14)
  store i32 %139, ptr %19, align 4, !tbaa !5
  %140 = load i32, ptr %19, align 4, !tbaa !5
  %141 = icmp sgt i32 %140, 0
  br i1 %141, label %142, label %174

142:                                              ; preds = %125
  %143 = getelementptr inbounds %struct.fd_set, ptr %13, i32 0, i32 0
  %144 = load i32, ptr %9, align 4, !tbaa !5
  %145 = sdiv i32 %144, 64
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [16 x i64], ptr %143, i64 0, i64 %146
  %148 = load i64, ptr %147, align 8, !tbaa !22
  %149 = load i32, ptr %9, align 4, !tbaa !5
  %150 = srem i32 %149, 64
  %151 = zext i32 %150 to i64
  %152 = shl i64 1, %151
  %153 = and i64 %148, %152
  %154 = icmp ne i64 %153, 0
  br i1 %154, label %155, label %173

155:                                              ; preds = %142
  %156 = load i32, ptr %9, align 4, !tbaa !5
  %157 = load i64, ptr %16, align 8, !tbaa !22
  %158 = getelementptr inbounds [819200 x i8], ptr %15, i64 0, i64 %157
  %159 = load i64, ptr %16, align 8, !tbaa !22
  %160 = sub nsw i64 819200, %159
  %161 = call i64 @recv(i32 noundef %156, ptr noundef %158, i64 noundef %160, i32 noundef 0)
  %162 = load i64, ptr %16, align 8, !tbaa !22
  %163 = add nsw i64 %162, %161
  store i64 %163, ptr %16, align 8, !tbaa !22
  %164 = load i64, ptr %16, align 8, !tbaa !22
  %165 = icmp sge i64 %164, 10240
  br i1 %165, label %166, label %172

166:                                              ; preds = %155
  %167 = getelementptr inbounds [819200 x i8], ptr %15, i64 0, i64 0
  %168 = load i64, ptr %16, align 8, !tbaa !22
  %169 = call zeroext i1 @write_to_file(ptr noundef %7, ptr noundef %167, i64 noundef %168)
  br i1 %169, label %170, label %171

170:                                              ; preds = %166
  store i64 0, ptr %16, align 8, !tbaa !22
  br label %171

171:                                              ; preds = %170, %166
  br label %172

172:                                              ; preds = %171, %155
  br label %173

173:                                              ; preds = %172, %142
  br label %194

174:                                              ; preds = %125
  %175 = load i32, ptr %19, align 4, !tbaa !5
  %176 = icmp eq i32 %175, -1
  br i1 %176, label %177, label %193

177:                                              ; preds = %174
  %178 = call ptr @__errno_location() #8
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = icmp ne i32 %179, 4
  br i1 %180, label %181, label %192

181:                                              ; preds = %177
  br label %182

182:                                              ; preds = %181
  %183 = call ptr @__errno_location() #8
  %184 = load i32, ptr %183, align 4, !tbaa !5
  %185 = call ptr @strerror(i32 noundef %184) #6
  %186 = call i32 (ptr, ...) @printf(ptr noundef @.str.13, ptr noundef %185)
  %187 = call ptr @__errno_location() #8
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = call ptr @strerror(i32 noundef %188) #6
  call void (i32, ptr, ...) @syslog(i32 noundef 4, ptr noundef @.str.13, ptr noundef %189)
  br label %190

190:                                              ; preds = %182
  br label %191

191:                                              ; preds = %190
  br label %192

192:                                              ; preds = %191, %177
  br label %193

193:                                              ; preds = %192, %174
  br label %194

194:                                              ; preds = %193, %173
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  br label %103, !llvm.loop !28

195:                                              ; preds = %103
  %196 = getelementptr inbounds [819200 x i8], ptr %15, i64 0, i64 0
  %197 = load i64, ptr %16, align 8, !tbaa !22
  %198 = call zeroext i1 @write_to_file(ptr noundef %7, ptr noundef %196, i64 noundef %197)
  %199 = load i32, ptr %9, align 4, !tbaa !5
  %200 = call i32 @close(i32 noundef %199)
  %201 = getelementptr inbounds %struct.video_file_t, ptr %7, i32 0, i32 0
  %202 = load ptr, ptr %201, align 8, !tbaa !11
  %203 = call i32 @fclose(ptr noundef %202)
  br label %204

204:                                              ; preds = %195
  %205 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  call void (i32, ptr, ...) @syslog(i32 noundef 6, ptr noundef @.str.14)
  br label %206

206:                                              ; preds = %204
  br label %207

207:                                              ; preds = %206
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 819200, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 128, ptr %13) #6
  br label %208

208:                                              ; preds = %207, %99
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %209

209:                                              ; preds = %208, %57
  call void @llvm.lifetime.end.p0(i64 110, ptr %10) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %210

210:                                              ; preds = %209, %42
  call void @llvm.lifetime.end.p0(i64 520, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 448, ptr %6) #6
  %211 = load i32, ptr %3, align 4
  ret i32 %211
}

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

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #5

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 noundef, i32 noundef) #2

declare i32 @connect(i32 noundef, ptr noundef, i32 noundef) #3

declare i32 @usleep(i32 noundef) #3

declare i32 @close(i32 noundef) #3

declare i32 @select(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #3

declare i64 @recv(i32 noundef, ptr noundef, i64 noundef, i32 noundef) #3

attributes #0 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 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 #5 = { nounwind willreturn memory(read) "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(read) }
attributes #8 = { 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, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !10, i64 0}
!12 = !{!"", !10, i64 0, !7, i64 8}
!13 = !{!14, !15, i64 0}
!14 = !{!"sockaddr_un", !15, i64 0, !7, i64 2}
!15 = !{!"short", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"_Bool", !7, i64 0}
!18 = !{i8 0, i8 2}
!19 = !{}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = !{!23, !23, i64 0}
!23 = !{!"long", !7, i64 0}
!24 = !{!25, !23, i64 0}
!25 = !{!"timeval", !23, i64 0, !23, i64 8}
!26 = !{!25, !23, i64 8}
!27 = distinct !{!27, !21}
!28 = distinct !{!28, !21}


; 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.video_file_t = type { ptr, [512 x i8] }
%struct.sockaddr_un = type { i16, [108 x i8] }
%struct.fd_set = type { [16 x i64] }
%struct.timeval = type { i64, i64 }

@recorder_running = external dso_local global i32, align 4
@stderr = external local_unnamed_addr global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [48 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [43 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [44 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [26 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local void @open_new_file(ptr noundef, ptr 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: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strcpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly) 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: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @delete_file(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @write_to_file(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca [448 x i8], align 16
  %4 = alloca %struct.video_file_t, align 8
  %5 = alloca %struct.sockaddr_un, align 2
  %6 = alloca %struct.fd_set, align 8
  %7 = alloca %struct.timeval, align 8
  %8 = alloca [819200 x i8], align 16
  %9 = tail call ptr @signal(i32 noundef 2, ptr noundef nonnull @int_handler) #8
  %10 = tail call ptr @signal(i32 noundef 15, ptr noundef nonnull @int_handler) #8
  %11 = tail call ptr @signal(i32 noundef 9, ptr noundef nonnull @int_handler) #8
  call void @llvm.lifetime.start.p0(i64 448, ptr nonnull %3) #8
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !5
  %char0 = load i8, ptr %13, align 1
  %14 = icmp eq i8 %char0, 0
  %.str.8. = select i1 %14, ptr @.str.8, ptr %13
  %15 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) %.str.8.) #8
  call void @llvm.lifetime.start.p0(i64 520, ptr nonnull %4) #8
  call void @open_new_file(ptr noundef nonnull %3, ptr noundef nonnull %4)
  %16 = load ptr, ptr %4, align 8, !tbaa !9
  %17 = icmp eq ptr %16, null
  br i1 %17, label %91, label %18

18:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 110, ptr nonnull %5) #8
  %19 = call i32 @socket(i32 noundef 1, i32 noundef 1, i32 noundef 0) #8
  %20 = icmp slt i32 %19, 0
  br i1 %20, label %21, label %29

21:                                               ; preds = %18
  %22 = load ptr, ptr @stderr, align 8, !tbaa !5
  %23 = tail call ptr @__errno_location() #9
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = call ptr @strerror(i32 noundef %24) #8
  %26 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.9, ptr noundef %25) #10
  %27 = load i32, ptr %23, align 4, !tbaa !11
  %28 = call ptr @strerror(i32 noundef %27) #8
  call void (i32, ptr, ...) @syslog(i32 noundef 3, ptr noundef nonnull @.str.9, ptr noundef %28) #8
  call void @delete_file(ptr noundef nonnull %4)
  br label %90

29:                                               ; preds = %18
  store i16 1, ptr %5, align 2, !tbaa !13
  %30 = getelementptr inbounds i8, ptr %5, i64 2
  %31 = call ptr @strcpy(ptr noundef nonnull dereferenceable(1) %30, ptr noundef nonnull dereferenceable(1) @.str.10) #8
  br label %32

32:                                               ; preds = %45, %29
  %.032 = phi i32 [ 0, %29 ], [ %47, %45 ]
  %33 = call i32 @connect(i32 noundef %19, ptr noundef nonnull %5, i32 noundef 110) #8
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %.thread46, label %45

.thread46:                                        ; preds = %32
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11, ptr noundef nonnull @.str.10)
  call void (i32, ptr, ...) @syslog(i32 noundef 6, ptr noundef nonnull @.str.11, ptr noundef nonnull @.str.10) #8
  call void @llvm.lifetime.start.p0(i64 128, ptr nonnull %6) #8
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %7) #8
  call void @llvm.lifetime.start.p0(i64 819200, ptr nonnull %8) #8
  %36 = load volatile i32, ptr @recorder_running, align 4, !tbaa !11
  %.not48 = icmp eq i32 %36, 0
  br i1 %.not48, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.thread46
  %37 = getelementptr inbounds i8, ptr %7, i64 8
  %38 = and i32 %19, 63
  %39 = zext nneg i32 %38 to i64
  %40 = shl nuw i64 1, %39
  %41 = lshr i32 %19, 6
  %42 = zext nneg i32 %41 to i64
  %43 = getelementptr inbounds [16 x i64], ptr %6, i64 0, i64 %42
  %44 = add nuw nsw i32 %19, 1
  br label %57

45:                                               ; preds = %32
  %46 = call i32 @usleep(i32 noundef 50000) #8
  %47 = add nuw nsw i32 %.032, 1
  %48 = icmp eq i32 %47, 100
  br i1 %48, label %49, label %32, !llvm.loop !16

49:                                               ; preds = %45
  %50 = tail call ptr @__errno_location() #9
  %51 = load i32, ptr %50, align 4, !tbaa !11
  %52 = call ptr @strerror(i32 noundef %51) #8
  %53 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12, ptr noundef nonnull @.str.10, ptr noundef %52)
  %54 = load i32, ptr %50, align 4, !tbaa !11
  %55 = call ptr @strerror(i32 noundef %54) #8
  call void (i32, ptr, ...) @syslog(i32 noundef 6, ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.10, ptr noundef %55) #8
  call void @delete_file(ptr noundef nonnull %4)
  %56 = call i32 @close(i32 noundef %19) #8
  br label %90

57:                                               ; preds = %.lr.ph, %83
  %.02849 = phi i64 [ 0, %.lr.ph ], [ %.129, %83 ]
  store i64 1, ptr %7, align 8, !tbaa !18
  store i64 0, ptr %37, align 8, !tbaa !21
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(128) %6, i8 0, i64 128, i1 false), !tbaa !22
  %58 = load i64, ptr %43, align 8, !tbaa !22
  %59 = or i64 %58, %40
  store i64 %59, ptr %43, align 8, !tbaa !22
  %60 = call i32 @select(i32 noundef %44, ptr noundef nonnull %6, ptr noundef null, ptr noundef null, ptr noundef nonnull %7) #8
  %61 = icmp sgt i32 %60, 0
  br i1 %61, label %62, label %73

62:                                               ; preds = %57
  %63 = load i64, ptr %43, align 8, !tbaa !22
  %64 = and i64 %63, %40
  %.not42 = icmp eq i64 %64, 0
  br i1 %.not42, label %83, label %65

65:                                               ; preds = %62
  %66 = getelementptr inbounds [819200 x i8], ptr %8, i64 0, i64 %.02849
  %67 = sub nsw i64 819200, %.02849
  %68 = call i64 @recv(i32 noundef %19, ptr noundef nonnull %66, i64 noundef %67, i32 noundef 0) #8
  %69 = add nsw i64 %68, %.02849
  %70 = icmp sgt i64 %69, 10239
  br i1 %70, label %71, label %83

71:                                               ; preds = %65
  %72 = call zeroext i1 @write_to_file(ptr noundef nonnull %4, ptr noundef nonnull %8, i64 noundef %69)
  %spec.select = select i1 %72, i64 0, i64 %69
  br label %83

73:                                               ; preds = %57
  %74 = icmp eq i32 %60, -1
  br i1 %74, label %75, label %83

75:                                               ; preds = %73
  %76 = tail call ptr @__errno_location() #9
  %77 = load i32, ptr %76, align 4, !tbaa !11
  %.not41 = icmp eq i32 %77, 4
  br i1 %.not41, label %83, label %78

78:                                               ; preds = %75
  %79 = call ptr @strerror(i32 noundef %77) #8
  %80 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13, ptr noundef %79)
  %81 = load i32, ptr %76, align 4, !tbaa !11
  %82 = call ptr @strerror(i32 noundef %81) #8
  call void (i32, ptr, ...) @syslog(i32 noundef 4, ptr noundef nonnull @.str.13, ptr noundef %82) #8
  br label %83

83:                                               ; preds = %71, %73, %78, %75, %62, %65
  %.129 = phi i64 [ %69, %65 ], [ %.02849, %62 ], [ %.02849, %78 ], [ %.02849, %75 ], [ %.02849, %73 ], [ %spec.select, %71 ]
  %84 = load volatile i32, ptr @recorder_running, align 4, !tbaa !11
  %.not = icmp eq i32 %84, 0
  br i1 %.not, label %._crit_edge, label %57, !llvm.loop !23

._crit_edge:                                      ; preds = %83, %.thread46
  %.028.lcssa = phi i64 [ 0, %.thread46 ], [ %.129, %83 ]
  %85 = call zeroext i1 @write_to_file(ptr noundef nonnull %4, ptr noundef nonnull %8, i64 noundef %.028.lcssa)
  %86 = call i32 @close(i32 noundef %19) #8
  %87 = load ptr, ptr %4, align 8, !tbaa !9
  %88 = call i32 @fclose(ptr noundef %87)
  %89 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  call void (i32, ptr, ...) @syslog(i32 noundef 6, ptr noundef nonnull @.str.14) #8
  call void @llvm.lifetime.end.p0(i64 819200, ptr nonnull %8) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %7) #8
  call void @llvm.lifetime.end.p0(i64 128, ptr nonnull %6) #8
  br label %90

90:                                               ; preds = %49, %._crit_edge, %21
  %.1 = phi i32 [ -1, %21 ], [ 0, %._crit_edge ], [ -1, %49 ]
  call void @llvm.lifetime.end.p0(i64 110, ptr nonnull %5) #8
  br label %91

91:                                               ; preds = %2, %90
  %.2 = phi i32 [ %.1, %90 ], [ -1, %2 ]
  call void @llvm.lifetime.end.p0(i64 520, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 448, ptr nonnull %3) #8
  ret i32 %.2
}

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

; Function Attrs: nounwind
declare i32 @socket(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #5

declare i32 @connect(i32 noundef, ptr noundef, i32 noundef) local_unnamed_addr #4

declare i32 @usleep(i32 noundef) local_unnamed_addr #4

declare i32 @close(i32 noundef) local_unnamed_addr #4

declare i32 @select(i32 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare i64 @recv(i32 noundef, ptr noundef, i64 noundef, i32 noundef) local_unnamed_addr #4

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

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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = { 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 #4 = { "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 = { 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 #6 = { 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 #7 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"", !6, i64 0, !7, i64 8}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !15, i64 0}
!14 = !{!"sockaddr_un", !15, i64 0, !7, i64 2}
!15 = !{!"short", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!19, !20, i64 0}
!19 = !{!"timeval", !20, i64 0, !20, i64 8}
!20 = !{!"long", !7, i64 0}
!21 = !{!19, !20, i64 8}
!22 = !{!20, !20, i64 0}
!23 = distinct !{!23, !17}


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