; LLVM IR from DroneBridge/DroneBridge :: video (video_main_air)

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

@num_interfaces = external dso_local global i32, align 4
@num_data_per_block = external dso_local global i32, align 4
@num_fec_per_block = external dso_local global i32, align 4
@pack_size = external dso_local global i32, align 4
@bitrate_op = external dso_local global i32, align 4
@vid_adhere_80211 = external dso_local global i32, align 4
@comm_id = external dso_local global i8, align 1
@frame_type = external dso_local global i8, align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1
@adapters = external dso_local global [4 x [16 x i8]], align 16
@optarg = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [1163 x i8], align 1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @process_command_line_args(i32 noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  store i32 0, ptr @num_interfaces, align 4, !tbaa !5
  store i8 -56, ptr @comm_id, align 1, !tbaa !11
  store i32 11, ptr @bitrate_op, align 4, !tbaa !5
  store i32 8, ptr @num_data_per_block, align 4, !tbaa !5
  store i32 4, ptr @num_fec_per_block, align 4, !tbaa !5
  store i32 1024, ptr @pack_size, align 4, !tbaa !5
  store i8 1, ptr @frame_type, align 1, !tbaa !11
  store i32 0, ptr @vid_adhere_80211, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  br label %6

6:                                                ; preds = %55, %2
  %7 = load i32, ptr %3, align 4, !tbaa !5
  %8 = load ptr, ptr %4, align 8, !tbaa !9
  %9 = call i32 @getopt(i32 noundef %7, ptr noundef %8, ptr noundef @.str.3) #5
  store i32 %9, ptr %5, align 4, !tbaa !5
  %10 = icmp ne i32 %9, -1
  br i1 %10, label %11, label %56

11:                                               ; preds = %6
  %12 = load i32, ptr %5, align 4, !tbaa !5
  switch i32 %12, label %53 [
    i32 110, label %13
    i32 99, label %22
    i32 100, label %26
    i32 114, label %31
    i32 102, label %36
    i32 98, label %40
    i32 116, label %45
    i32 97, label %49
  ]

13:                                               ; preds = %11
  %14 = load i32, ptr @num_interfaces, align 4, !tbaa !5
  %15 = zext i32 %14 to i64
  %16 = getelementptr inbounds [4 x [16 x i8]], ptr @adapters, i64 0, i64 %15
  %17 = getelementptr inbounds [16 x i8], ptr %16, i64 0, i64 0
  %18 = load ptr, ptr @optarg, align 8, !tbaa !9
  %19 = call ptr @strncpy(ptr noundef %17, ptr noundef %18, i64 noundef 16) #5
  %20 = load i32, ptr @num_interfaces, align 4, !tbaa !5
  %21 = add i32 %20, 1
  store i32 %21, ptr @num_interfaces, align 4, !tbaa !5
  br label %55

22:                                               ; preds = %11
  %23 = load ptr, ptr @optarg, align 8, !tbaa !9
  %24 = call i64 @strtol(ptr noundef %23, ptr noundef null, i32 noundef 10) #5
  %25 = trunc i64 %24 to i8
  store i8 %25, ptr @comm_id, align 1, !tbaa !11
  br label %55

26:                                               ; preds = %11
  %27 = load ptr, ptr @optarg, align 8, !tbaa !9
  %28 = call i64 @strtol(ptr noundef %27, ptr noundef null, i32 noundef 10) #5
  %29 = trunc i64 %28 to i8
  %30 = zext i8 %29 to i32
  store i32 %30, ptr @num_data_per_block, align 4, !tbaa !5
  br label %55

31:                                               ; preds = %11
  %32 = load ptr, ptr @optarg, align 8, !tbaa !9
  %33 = call i64 @strtol(ptr noundef %32, ptr noundef null, i32 noundef 10) #5
  %34 = trunc i64 %33 to i8
  %35 = zext i8 %34 to i32
  store i32 %35, ptr @num_fec_per_block, align 4, !tbaa !5
  br label %55

36:                                               ; preds = %11
  %37 = load ptr, ptr @optarg, align 8, !tbaa !9
  %38 = call i64 @strtol(ptr noundef %37, ptr noundef null, i32 noundef 10) #5
  %39 = trunc i64 %38 to i32
  store i32 %39, ptr @pack_size, align 4, !tbaa !5
  br label %55

40:                                               ; preds = %11
  %41 = load ptr, ptr @optarg, align 8, !tbaa !9
  %42 = call i64 @strtol(ptr noundef %41, ptr noundef null, i32 noundef 10) #5
  %43 = trunc i64 %42 to i8
  %44 = zext i8 %43 to i32
  store i32 %44, ptr @bitrate_op, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %40, %11
  %46 = load ptr, ptr @optarg, align 8, !tbaa !9
  %47 = call i64 @strtol(ptr noundef %46, ptr noundef null, i32 noundef 10) #5
  %48 = trunc i64 %47 to i8
  store i8 %48, ptr @frame_type, align 1, !tbaa !11
  br label %55

49:                                               ; preds = %11
  %50 = load ptr, ptr @optarg, align 8, !tbaa !9
  %51 = call i64 @strtol(ptr noundef %50, ptr noundef null, i32 noundef 10) #5
  %52 = trunc i64 %51 to i32
  store i32 %52, ptr @vid_adhere_80211, align 4, !tbaa !5
  br label %55

53:                                               ; preds = %11
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef 1024, i32 noundef 2048)
  call void @abort() #6
  unreachable

55:                                               ; preds = %49, %45, %36, %31, %26, %22, %13
  br label %6, !llvm.loop !12

56:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret void
}

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

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #3

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

; Function Attrs: noreturn nounwind
declare void @abort() #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #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 = { noreturn 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 = { nounwind }
attributes #6 = { noreturn 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"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"

@num_interfaces = external dso_local local_unnamed_addr global i32, align 4
@num_data_per_block = external dso_local local_unnamed_addr global i32, align 4
@num_fec_per_block = external dso_local local_unnamed_addr global i32, align 4
@pack_size = external dso_local local_unnamed_addr global i32, align 4
@bitrate_op = external dso_local local_unnamed_addr global i32, align 4
@vid_adhere_80211 = external dso_local local_unnamed_addr global i32, align 4
@comm_id = external dso_local local_unnamed_addr global i8, align 1
@frame_type = external dso_local local_unnamed_addr global i8, align 1
@.str.3 = external hidden unnamed_addr constant [17 x i8], align 1
@adapters = external dso_local global [4 x [16 x i8]], align 16
@optarg = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [1163 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @process_command_line_args(i32 noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  store i32 0, ptr @num_interfaces, align 4, !tbaa !5
  store i8 -56, ptr @comm_id, align 1, !tbaa !9
  store i32 11, ptr @bitrate_op, align 4, !tbaa !5
  store i32 8, ptr @num_data_per_block, align 4, !tbaa !5
  store i32 4, ptr @num_fec_per_block, align 4, !tbaa !5
  store i32 1024, ptr @pack_size, align 4, !tbaa !5
  store i8 1, ptr @frame_type, align 1, !tbaa !9
  store i32 0, ptr @vid_adhere_80211, align 4, !tbaa !5
  br label %3

3:                                                ; preds = %.backedge, %2
  %4 = tail call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str.3) #6
  switch i32 %4, label %43 [
    i32 -1, label %45
    i32 110, label %5
    i32 99, label %12
    i32 100, label %16
    i32 114, label %21
    i32 102, label %26
    i32 98, label %30
    i32 116, label %35
    i32 97, label %39
  ]

5:                                                ; preds = %3
  %6 = load i32, ptr @num_interfaces, align 4, !tbaa !5
  %7 = zext i32 %6 to i64
  %8 = getelementptr inbounds [4 x [16 x i8]], ptr @adapters, i64 0, i64 %7
  %9 = load ptr, ptr @optarg, align 8, !tbaa !10
  %10 = tail call ptr @strncpy(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) %9, i64 noundef 16) #6
  %11 = add i32 %6, 1
  store i32 %11, ptr @num_interfaces, align 4, !tbaa !5
  br label %.backedge

12:                                               ; preds = %3
  %13 = load ptr, ptr @optarg, align 8, !tbaa !10
  %14 = tail call i64 @strtol(ptr nocapture noundef %13, ptr noundef null, i32 noundef 10) #6
  %15 = trunc i64 %14 to i8
  store i8 %15, ptr @comm_id, align 1, !tbaa !9
  br label %.backedge

16:                                               ; preds = %3
  %17 = load ptr, ptr @optarg, align 8, !tbaa !10
  %18 = tail call i64 @strtol(ptr nocapture noundef %17, ptr noundef null, i32 noundef 10) #6
  %19 = trunc i64 %18 to i32
  %20 = and i32 %19, 255
  store i32 %20, ptr @num_data_per_block, align 4, !tbaa !5
  br label %.backedge

21:                                               ; preds = %3
  %22 = load ptr, ptr @optarg, align 8, !tbaa !10
  %23 = tail call i64 @strtol(ptr nocapture noundef %22, ptr noundef null, i32 noundef 10) #6
  %24 = trunc i64 %23 to i32
  %25 = and i32 %24, 255
  store i32 %25, ptr @num_fec_per_block, align 4, !tbaa !5
  br label %.backedge

26:                                               ; preds = %3
  %27 = load ptr, ptr @optarg, align 8, !tbaa !10
  %28 = tail call i64 @strtol(ptr nocapture noundef %27, ptr noundef null, i32 noundef 10) #6
  %29 = trunc i64 %28 to i32
  store i32 %29, ptr @pack_size, align 4, !tbaa !5
  br label %.backedge

30:                                               ; preds = %3
  %31 = load ptr, ptr @optarg, align 8, !tbaa !10
  %32 = tail call i64 @strtol(ptr nocapture noundef %31, ptr noundef null, i32 noundef 10) #6
  %33 = trunc i64 %32 to i32
  %34 = and i32 %33, 255
  store i32 %34, ptr @bitrate_op, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %3, %30
  %36 = load ptr, ptr @optarg, align 8, !tbaa !10
  %37 = tail call i64 @strtol(ptr nocapture noundef %36, ptr noundef null, i32 noundef 10) #6
  %38 = trunc i64 %37 to i8
  store i8 %38, ptr @frame_type, align 1, !tbaa !9
  br label %.backedge

39:                                               ; preds = %3
  %40 = load ptr, ptr @optarg, align 8, !tbaa !10
  %41 = tail call i64 @strtol(ptr nocapture noundef %40, ptr noundef null, i32 noundef 10) #6
  %42 = trunc i64 %41 to i32
  store i32 %42, ptr @vid_adhere_80211, align 4, !tbaa !5
  br label %.backedge

.backedge:                                        ; preds = %39, %35, %26, %21, %16, %12, %5
  br label %3, !llvm.loop !12

43:                                               ; preds = %3
  %44 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef 1024, i32 noundef 2048)
  tail call void @abort() #7
  unreachable

45:                                               ; preds = %3
  ret void
}

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

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 noundef) local_unnamed_addr #4

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #5

attributes #0 = { 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 #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 = { 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 #4 = { mustprogress nofree nounwind willreturn "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 = { noreturn 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 = { nounwind }
attributes #7 = { noreturn 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass