; LLVM IR from DroneBridge/DroneBridge :: status (status_main)

; 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_inf_status = external dso_local global i32, align 4
@comm_id = external dso_local global i8, align 1
@db_mode = external dso_local global i8, align 1
@opterr = external global i32, align 4
@.str = external hidden unnamed_addr constant [8 x i8], align 1
@adapters = external dso_local global [4 x [16 x i8]], align 16
@optarg = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [250 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @process_command_line_args(i32 noundef %0, ptr noundef %1) #0 {
  %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 i8 109, ptr @db_mode, align 1, !tbaa !11
  store i32 0, ptr @opterr, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  br label %6

6:                                                ; preds = %36, %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) #5
  store i32 %9, ptr %5, align 4, !tbaa !5
  %10 = icmp ne i32 %9, -1
  br i1 %10, label %11, label %37

11:                                               ; preds = %6
  %12 = load i32, ptr %5, align 4, !tbaa !5
  switch i32 %12, label %35 [
    i32 110, label %13
    i32 109, label %26
    i32 99, label %29
    i32 63, label %33
  ]

13:                                               ; preds = %11
  %14 = load i32, ptr @num_inf_status, align 4, !tbaa !5
  %15 = icmp slt i32 %14, 4
  br i1 %15, label %16, label %25

16:                                               ; preds = %13
  %17 = load i32, ptr @num_inf_status, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [4 x [16 x i8]], ptr @adapters, i64 0, i64 %18
  %20 = getelementptr inbounds [16 x i8], ptr %19, i64 0, i64 0
  %21 = load ptr, ptr @optarg, align 8, !tbaa !9
  %22 = call ptr @strncpy(ptr noundef %20, ptr noundef %21, i64 noundef 16) #5
  %23 = load i32, ptr @num_inf_status, align 4, !tbaa !5
  %24 = add nsw i32 %23, 1
  store i32 %24, ptr @num_inf_status, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %16, %13
  br label %36

26:                                               ; preds = %11
  %27 = load ptr, ptr @optarg, align 8, !tbaa !9
  %28 = load i8, ptr %27, align 1, !tbaa !11
  store i8 %28, ptr @db_mode, align 1, !tbaa !11
  br label %36

29:                                               ; preds = %11
  %30 = load ptr, ptr @optarg, align 8, !tbaa !9
  %31 = call i64 @strtol(ptr noundef %30, ptr noundef null, i32 noundef 10) #5
  %32 = trunc i64 %31 to i8
  store i8 %32, ptr @comm_id, align 1, !tbaa !11
  br label %36

33:                                               ; preds = %11
  %34 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %36

35:                                               ; preds = %11
  call void @abort() #6
  unreachable

36:                                               ; preds = %33, %29, %26, %25
  br label %6, !llvm.loop !12

37:                                               ; preds = %6
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  ret i32 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 i32 @getopt(i32 noundef, ptr noundef, ptr noundef) #2

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

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

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

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

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

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 = { 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_inf_status = external dso_local local_unnamed_addr global i32, align 4
@comm_id = external dso_local local_unnamed_addr global i8, align 1
@db_mode = external dso_local local_unnamed_addr global i8, align 1
@opterr = external local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [8 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.1 = external hidden unnamed_addr constant [250 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @process_command_line_args(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  store i8 109, ptr @db_mode, align 1, !tbaa !5
  store i32 0, ptr @opterr, align 4, !tbaa !8
  br label %3

3:                                                ; preds = %.backedge, %2
  %4 = tail call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str) #6
  switch i32 %4, label %23 [
    i32 -1, label %24
    i32 110, label %5
    i32 109, label %14
    i32 99, label %17
    i32 63, label %21
  ]

5:                                                ; preds = %3
  %6 = load i32, ptr @num_inf_status, align 4, !tbaa !8
  %7 = icmp slt i32 %6, 4
  br i1 %7, label %8, label %.backedge

.backedge:                                        ; preds = %5, %8, %21, %17, %14
  br label %3, !llvm.loop !10

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

14:                                               ; preds = %3
  %15 = load ptr, ptr @optarg, align 8, !tbaa !12
  %16 = load i8, ptr %15, align 1, !tbaa !5
  store i8 %16, ptr @db_mode, align 1, !tbaa !5
  br label %.backedge

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

21:                                               ; preds = %3
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %.backedge

23:                                               ; preds = %3
  tail call void @abort() #7
  unreachable

24:                                               ; preds = %3
  ret i32 0
}

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

; 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 #2

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

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

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

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 = { 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 #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 = { 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 #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 = { 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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !6, i64 0}


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