; LLVM IR from hans-ob1/neural_cam_ros :: src/detector (box)

; 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.box = type { float, float, float, float }
%struct.sortable_bbox = type { i32, i32, ptr }

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

; 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
declare dso_local float @box_iou(<2 x float>, <2 x float>, <2 x float>, <2 x float>) #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind uwtable
declare dso_local i32 @nms_comparator(ptr noundef, ptr noundef) #3

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #4

declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #5

; Function Attrs: nounwind
declare void @free(ptr noundef) #6

; Function Attrs: nounwind uwtable
define dso_local void @do_nms_sort(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca float, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca ptr, align 8
  %15 = alloca %struct.box, align 4
  %16 = alloca %struct.box, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  store float %4, ptr %10, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #7
  %17 = load i32, ptr %8, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = call noalias ptr @calloc(i64 noundef %18, i64 noundef 16) #8
  store ptr %19, ptr %14, align 8, !tbaa !5
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %42, %5
  %21 = load i32, ptr %11, align 4, !tbaa !9
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = icmp slt i32 %21, %22
  br i1 %23, label %24, label %45

24:                                               ; preds = %20
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = load ptr, ptr %14, align 8, !tbaa !5
  %27 = load i32, ptr %11, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds %struct.sortable_bbox, ptr %26, i64 %28
  %30 = getelementptr inbounds %struct.sortable_bbox, ptr %29, i32 0, i32 0
  store i32 %25, ptr %30, align 8, !tbaa !13
  %31 = load ptr, ptr %14, align 8, !tbaa !5
  %32 = load i32, ptr %11, align 4, !tbaa !9
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds %struct.sortable_bbox, ptr %31, i64 %33
  %35 = getelementptr inbounds %struct.sortable_bbox, ptr %34, i32 0, i32 1
  store i32 0, ptr %35, align 4, !tbaa !15
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = load ptr, ptr %14, align 8, !tbaa !5
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds %struct.sortable_bbox, ptr %37, i64 %39
  %41 = getelementptr inbounds %struct.sortable_bbox, ptr %40, i32 0, i32 2
  store ptr %36, ptr %41, align 8, !tbaa !16
  br label %42

42:                                               ; preds = %24
  %43 = load i32, ptr %11, align 4, !tbaa !9
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %11, align 4, !tbaa !9
  br label %20, !llvm.loop !17

45:                                               ; preds = %20
  store i32 0, ptr %13, align 4, !tbaa !9
  br label %46

46:                                               ; preds = %150, %45
  %47 = load i32, ptr %13, align 4, !tbaa !9
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %50, label %153

50:                                               ; preds = %46
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %51

51:                                               ; preds = %62, %50
  %52 = load i32, ptr %11, align 4, !tbaa !9
  %53 = load i32, ptr %8, align 4, !tbaa !9
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %55, label %65

55:                                               ; preds = %51
  %56 = load i32, ptr %13, align 4, !tbaa !9
  %57 = load ptr, ptr %14, align 8, !tbaa !5
  %58 = load i32, ptr %11, align 4, !tbaa !9
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds %struct.sortable_bbox, ptr %57, i64 %59
  %61 = getelementptr inbounds %struct.sortable_bbox, ptr %60, i32 0, i32 1
  store i32 %56, ptr %61, align 4, !tbaa !15
  br label %62

62:                                               ; preds = %55
  %63 = load i32, ptr %11, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %11, align 4, !tbaa !9
  br label %51, !llvm.loop !19

65:                                               ; preds = %51
  %66 = load ptr, ptr %14, align 8, !tbaa !5
  %67 = load i32, ptr %8, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  call void @qsort(ptr noundef %66, i64 noundef %68, i64 noundef 16, ptr noundef @nms_comparator)
  store i32 0, ptr %11, align 4, !tbaa !9
  br label %69

69:                                               ; preds = %146, %65
  %70 = load i32, ptr %11, align 4, !tbaa !9
  %71 = load i32, ptr %8, align 4, !tbaa !9
  %72 = icmp slt i32 %70, %71
  br i1 %72, label %73, label %149

73:                                               ; preds = %69
  %74 = load ptr, ptr %7, align 8, !tbaa !5
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = load i32, ptr %11, align 4, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds %struct.sortable_bbox, ptr %75, i64 %77
  %79 = getelementptr inbounds %struct.sortable_bbox, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !13
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds ptr, ptr %74, i64 %81
  %83 = load ptr, ptr %82, align 8, !tbaa !5
  %84 = load i32, ptr %13, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds float, ptr %83, i64 %85
  %87 = load float, ptr %86, align 4, !tbaa !11
  %88 = fcmp oeq float %87, 0.000000e+00
  br i1 %88, label %89, label %90

89:                                               ; preds = %73
  br label %146

90:                                               ; preds = %73
  call void @llvm.lifetime.start.p0(i64 16, ptr %15) #7
  %91 = load ptr, ptr %6, align 8, !tbaa !5
  %92 = load ptr, ptr %14, align 8, !tbaa !5
  %93 = load i32, ptr %11, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds %struct.sortable_bbox, ptr %92, i64 %94
  %96 = getelementptr inbounds %struct.sortable_bbox, ptr %95, i32 0, i32 0
  %97 = load i32, ptr %96, align 8, !tbaa !13
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds %struct.box, ptr %91, i64 %98
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %15, ptr align 4 %99, i64 16, i1 false), !tbaa.struct !20
  %100 = load i32, ptr %11, align 4, !tbaa !9
  %101 = add nsw i32 %100, 1
  store i32 %101, ptr %12, align 4, !tbaa !9
  br label %102

102:                                              ; preds = %142, %90
  %103 = load i32, ptr %12, align 4, !tbaa !9
  %104 = load i32, ptr %8, align 4, !tbaa !9
  %105 = icmp slt i32 %103, %104
  br i1 %105, label %106, label %145

106:                                              ; preds = %102
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #7
  %107 = load ptr, ptr %6, align 8, !tbaa !5
  %108 = load ptr, ptr %14, align 8, !tbaa !5
  %109 = load i32, ptr %12, align 4, !tbaa !9
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds %struct.sortable_bbox, ptr %108, i64 %110
  %112 = getelementptr inbounds %struct.sortable_bbox, ptr %111, i32 0, i32 0
  %113 = load i32, ptr %112, align 8, !tbaa !13
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds %struct.box, ptr %107, i64 %114
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %16, ptr align 4 %115, i64 16, i1 false), !tbaa.struct !20
  %116 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %15, i32 0, i32 0
  %117 = load <2 x float>, ptr %116, align 4
  %118 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %15, i32 0, i32 1
  %119 = load <2 x float>, ptr %118, align 4
  %120 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %16, i32 0, i32 0
  %121 = load <2 x float>, ptr %120, align 4
  %122 = getelementptr inbounds { <2 x float>, <2 x float> }, ptr %16, i32 0, i32 1
  %123 = load <2 x float>, ptr %122, align 4
  %124 = call float @box_iou(<2 x float> %117, <2 x float> %119, <2 x float> %121, <2 x float> %123)
  %125 = load float, ptr %10, align 4, !tbaa !11
  %126 = fcmp ogt float %124, %125
  br i1 %126, label %127, label %141

127:                                              ; preds = %106
  %128 = load ptr, ptr %7, align 8, !tbaa !5
  %129 = load ptr, ptr %14, align 8, !tbaa !5
  %130 = load i32, ptr %12, align 4, !tbaa !9
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds %struct.sortable_bbox, ptr %129, i64 %131
  %133 = getelementptr inbounds %struct.sortable_bbox, ptr %132, i32 0, i32 0
  %134 = load i32, ptr %133, align 8, !tbaa !13
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds ptr, ptr %128, i64 %135
  %137 = load ptr, ptr %136, align 8, !tbaa !5
  %138 = load i32, ptr %13, align 4, !tbaa !9
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds float, ptr %137, i64 %139
  store float 0.000000e+00, ptr %140, align 4, !tbaa !11
  br label %141

141:                                              ; preds = %127, %106
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #7
  br label %142

142:                                              ; preds = %141
  %143 = load i32, ptr %12, align 4, !tbaa !9
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %12, align 4, !tbaa !9
  br label %102, !llvm.loop !21

145:                                              ; preds = %102
  call void @llvm.lifetime.end.p0(i64 16, ptr %15) #7
  br label %146

146:                                              ; preds = %145, %89
  %147 = load i32, ptr %11, align 4, !tbaa !9
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %11, align 4, !tbaa !9
  br label %69, !llvm.loop !22

149:                                              ; preds = %69
  br label %150

150:                                              ; preds = %149
  %151 = load i32, ptr %13, align 4, !tbaa !9
  %152 = add nsw i32 %151, 1
  store i32 %152, ptr %13, align 4, !tbaa !9
  br label %46, !llvm.loop !23

153:                                              ; preds = %46
  %154 = load ptr, ptr %14, align 8, !tbaa !5
  call void @free(ptr noundef %154) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nounwind allocsize(0,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 #5 = { "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 "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 = { nounwind }
attributes #8 = { nounwind allocsize(0,1) }

!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 = !{!12, !12, i64 0}
!12 = !{!"float", !7, i64 0}
!13 = !{!14, !10, i64 0}
!14 = !{!"", !10, i64 0, !10, i64 4, !6, i64 8}
!15 = !{!14, !10, i64 4}
!16 = !{!14, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{i64 0, i64 4, !11, i64 4, i64 4, !11, i64 8, i64 4, !11, i64 12, i64 4, !11}
!21 = distinct !{!21, !18}
!22 = distinct !{!22, !18}
!23 = distinct !{!23, !18}


; 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.sortable_bbox = type { i32, i32, ptr }
%struct.box = type { float, float, float, float }

; Function Attrs: nounwind uwtable
declare dso_local float @box_iou(<2 x float>, <2 x float>, <2 x float>, <2 x float>) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local i32 @nms_comparator(ptr noundef, ptr noundef) #1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nofree
declare void @qsort(ptr noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
define dso_local void @do_nms_sort(ptr nocapture noundef readonly %0, ptr noundef %1, i32 noundef %2, i32 noundef %3, float noundef %4) local_unnamed_addr #0 {
  %6 = sext i32 %2 to i64
  %7 = tail call noalias ptr @calloc(i64 noundef %6, i64 noundef 16) #5
  %8 = icmp sgt i32 %2, 0
  br i1 %8, label %.lr.ph.preheader, label %.preheader50.thread

.lr.ph.preheader:                                 ; preds = %5
  %wide.trip.count = zext nneg i32 %2 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %9 = icmp ult i32 %2, 4
  br i1 %9, label %.preheader50.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483644
  br label %.lr.ph

.preheader50.unr-lcssa:                           ; preds = %.lr.ph, %.lr.ph.preheader
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader50, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader50.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.preheader50.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader50.unr-lcssa ]
  %10 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv.epil
  %11 = trunc nuw nsw i64 %indvars.iv.epil to i32
  store i32 %11, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %10, i64 4
  store i32 0, ptr %12, align 4, !tbaa !11
  %13 = getelementptr inbounds i8, ptr %10, i64 8
  store ptr %1, ptr %13, align 8, !tbaa !12
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader50, label %.lr.ph.epil, !llvm.loop !13

.preheader50:                                     ; preds = %.lr.ph.epil, %.preheader50.unr-lcssa
  %14 = icmp sgt i32 %3, 0
  br i1 %14, label %.preheader.lr.ph, label %._crit_edge63

.preheader50.thread:                              ; preds = %5
  %15 = icmp sgt i32 %3, 0
  br i1 %15, label %.preheader.preheader, label %._crit_edge63

.preheader.lr.ph:                                 ; preds = %.preheader50
  br i1 %8, label %.preheader.us.preheader, label %.preheader.preheader

.preheader.preheader:                             ; preds = %.preheader50.thread, %.preheader.lr.ph
  br label %.preheader

.preheader.us.preheader:                          ; preds = %.preheader.lr.ph
  %wide.trip.count93 = zext nneg i32 %3 to i64
  %wide.trip.count75 = zext nneg i32 %2 to i64
  %xtraiter99 = and i64 %wide.trip.count, 3
  %16 = icmp ult i32 %2, 4
  %unroll_iter102 = and i64 %wide.trip.count, 2147483644
  %lcmp.mod101.not = icmp eq i64 %xtraiter99, 0
  br label %.lr.ph53.us.preheader

.lr.ph53.us.preheader:                            ; preds = %._crit_edge61.us, %.preheader.us.preheader
  %indvars.iv90 = phi i64 [ 0, %.preheader.us.preheader ], [ %indvars.iv.next91, %._crit_edge61.us ]
  %17 = trunc nuw nsw i64 %indvars.iv90 to i32
  br i1 %16, label %.lr.ph60.us.unr-lcssa, label %.lr.ph53.us

.lr.ph60.us.unr-lcssa:                            ; preds = %.lr.ph53.us, %.lr.ph53.us.preheader
  %indvars.iv72.unr = phi i64 [ 0, %.lr.ph53.us.preheader ], [ %indvars.iv.next73.3, %.lr.ph53.us ]
  br i1 %lcmp.mod101.not, label %.lr.ph60.us, label %.lr.ph53.us.epil

.lr.ph53.us.epil:                                 ; preds = %.lr.ph60.us.unr-lcssa, %.lr.ph53.us.epil
  %indvars.iv72.epil = phi i64 [ %indvars.iv.next73.epil, %.lr.ph53.us.epil ], [ %indvars.iv72.unr, %.lr.ph60.us.unr-lcssa ]
  %epil.iter100 = phi i64 [ %epil.iter100.next, %.lr.ph53.us.epil ], [ 0, %.lr.ph60.us.unr-lcssa ]
  %18 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv72.epil, i32 1
  store i32 %17, ptr %18, align 4, !tbaa !11
  %indvars.iv.next73.epil = add nuw nsw i64 %indvars.iv72.epil, 1
  %epil.iter100.next = add i64 %epil.iter100, 1
  %epil.iter100.cmp.not = icmp eq i64 %epil.iter100.next, %xtraiter99
  br i1 %epil.iter100.cmp.not, label %.lr.ph60.us, label %.lr.ph53.us.epil, !llvm.loop !15

.lr.ph60.us:                                      ; preds = %.lr.ph53.us.epil, %.lr.ph60.us.unr-lcssa
  tail call void @qsort(ptr noundef nonnull %7, i64 noundef %6, i64 noundef 16, ptr noundef nonnull @nms_comparator) #6
  br label %19

19:                                               ; preds = %.lr.ph60.us, %.loopexit.us
  %indvars.iv84 = phi i64 [ 0, %.lr.ph60.us ], [ %indvars.iv.next85.pre-phi, %.loopexit.us ]
  %indvars.iv77 = phi i64 [ 1, %.lr.ph60.us ], [ %indvars.iv.next78, %.loopexit.us ]
  %20 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv84
  %21 = load i32, ptr %20, align 8, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds ptr, ptr %1, i64 %22
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = getelementptr inbounds float, ptr %24, i64 %indvars.iv90
  %26 = load float, ptr %25, align 4, !tbaa !17
  %27 = fcmp oeq float %26, 0.000000e+00
  br i1 %27, label %..loopexit.us_crit_edge, label %28

..loopexit.us_crit_edge:                          ; preds = %19
  %.pre95 = add nuw nsw i64 %indvars.iv84, 1
  br label %.loopexit.us

28:                                               ; preds = %19
  %29 = getelementptr inbounds %struct.box, ptr %0, i64 %22
  %.sroa.01.0.copyload.us = load <2 x float>, ptr %29, align 4
  %.sroa.42.0..sroa_idx.us = getelementptr inbounds i8, ptr %29, i64 8
  %.sroa.42.0.copyload.us = load <2 x float>, ptr %.sroa.42.0..sroa_idx.us, align 4
  %30 = add nuw nsw i64 %indvars.iv84, 1
  %31 = icmp slt i64 %30, %6
  br i1 %31, label %.lr.ph57.us, label %.loopexit.us

.lr.ph57.us:                                      ; preds = %28, %44
  %indvars.iv79 = phi i64 [ %indvars.iv.next80, %44 ], [ %indvars.iv77, %28 ]
  %32 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv79
  %33 = load i32, ptr %32, align 8, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds %struct.box, ptr %0, i64 %34
  %.sroa.0.0.copyload.us = load <2 x float>, ptr %35, align 4
  %.sroa.4.0..sroa_idx.us = getelementptr inbounds i8, ptr %35, i64 8
  %.sroa.4.0.copyload.us = load <2 x float>, ptr %.sroa.4.0..sroa_idx.us, align 4
  %36 = tail call float @box_iou(<2 x float> %.sroa.01.0.copyload.us, <2 x float> %.sroa.42.0.copyload.us, <2 x float> %.sroa.0.0.copyload.us, <2 x float> %.sroa.4.0.copyload.us)
  %37 = fcmp ogt float %36, %4
  br i1 %37, label %38, label %44

38:                                               ; preds = %.lr.ph57.us
  %39 = load i32, ptr %32, align 8, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds ptr, ptr %1, i64 %40
  %42 = load ptr, ptr %41, align 8, !tbaa !16
  %43 = getelementptr inbounds float, ptr %42, i64 %indvars.iv90
  store float 0.000000e+00, ptr %43, align 4, !tbaa !17
  br label %44

44:                                               ; preds = %38, %.lr.ph57.us
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %exitcond83.not = icmp eq i64 %indvars.iv.next80, %wide.trip.count75
  br i1 %exitcond83.not, label %.loopexit.us, label %.lr.ph57.us, !llvm.loop !19

.loopexit.us:                                     ; preds = %44, %..loopexit.us_crit_edge, %28
  %indvars.iv.next85.pre-phi = phi i64 [ %.pre95, %..loopexit.us_crit_edge ], [ %30, %28 ], [ %30, %44 ]
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond89.not = icmp eq i64 %indvars.iv.next85.pre-phi, %wide.trip.count75
  br i1 %exitcond89.not, label %._crit_edge61.us, label %19, !llvm.loop !21

.lr.ph53.us:                                      ; preds = %.lr.ph53.us.preheader, %.lr.ph53.us
  %indvars.iv72 = phi i64 [ %indvars.iv.next73.3, %.lr.ph53.us ], [ 0, %.lr.ph53.us.preheader ]
  %niter103 = phi i64 [ %niter103.next.3, %.lr.ph53.us ], [ 0, %.lr.ph53.us.preheader ]
  %45 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv72, i32 1
  store i32 %17, ptr %45, align 4, !tbaa !11
  %indvars.iv.next73 = or disjoint i64 %indvars.iv72, 1
  %46 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv.next73, i32 1
  store i32 %17, ptr %46, align 4, !tbaa !11
  %indvars.iv.next73.1 = or disjoint i64 %indvars.iv72, 2
  %47 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv.next73.1, i32 1
  store i32 %17, ptr %47, align 4, !tbaa !11
  %indvars.iv.next73.2 = or disjoint i64 %indvars.iv72, 3
  %48 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv.next73.2, i32 1
  store i32 %17, ptr %48, align 4, !tbaa !11
  %indvars.iv.next73.3 = add nuw nsw i64 %indvars.iv72, 4
  %niter103.next.3 = add i64 %niter103, 4
  %niter103.ncmp.3 = icmp eq i64 %niter103.next.3, %unroll_iter102
  br i1 %niter103.ncmp.3, label %.lr.ph60.us.unr-lcssa, label %.lr.ph53.us, !llvm.loop !22

._crit_edge61.us:                                 ; preds = %.loopexit.us
  %indvars.iv.next91 = add nuw nsw i64 %indvars.iv90, 1
  %exitcond94.not = icmp eq i64 %indvars.iv.next91, %wide.trip.count93
  br i1 %exitcond94.not, label %._crit_edge63, label %.lr.ph53.us.preheader, !llvm.loop !23

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %49 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv
  %50 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %50, ptr %49, align 8, !tbaa !5
  %51 = getelementptr inbounds i8, ptr %49, i64 4
  store i32 0, ptr %51, align 4, !tbaa !11
  %52 = getelementptr inbounds i8, ptr %49, i64 8
  store ptr %1, ptr %52, align 8, !tbaa !12
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %53 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv.next
  %54 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %54, ptr %53, align 8, !tbaa !5
  %55 = getelementptr inbounds i8, ptr %53, i64 4
  store i32 0, ptr %55, align 4, !tbaa !11
  %56 = getelementptr inbounds i8, ptr %53, i64 8
  store ptr %1, ptr %56, align 8, !tbaa !12
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %57 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv.next.1
  %58 = trunc nuw nsw i64 %indvars.iv.next.1 to i32
  store i32 %58, ptr %57, align 8, !tbaa !5
  %59 = getelementptr inbounds i8, ptr %57, i64 4
  store i32 0, ptr %59, align 4, !tbaa !11
  %60 = getelementptr inbounds i8, ptr %57, i64 8
  store ptr %1, ptr %60, align 8, !tbaa !12
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %61 = getelementptr inbounds %struct.sortable_bbox, ptr %7, i64 %indvars.iv.next.2
  %62 = trunc nuw nsw i64 %indvars.iv.next.2 to i32
  store i32 %62, ptr %61, align 8, !tbaa !5
  %63 = getelementptr inbounds i8, ptr %61, i64 4
  store i32 0, ptr %63, align 4, !tbaa !11
  %64 = getelementptr inbounds i8, ptr %61, i64 8
  store ptr %1, ptr %64, align 8, !tbaa !12
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader50.unr-lcssa, label %.lr.ph, !llvm.loop !24

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %.04862 = phi i32 [ %65, %.preheader ], [ 0, %.preheader.preheader ]
  tail call void @qsort(ptr noundef %7, i64 noundef %6, i64 noundef 16, ptr noundef nonnull @nms_comparator) #6
  %65 = add nuw nsw i32 %.04862, 1
  %exitcond71.not = icmp eq i32 %65, %3
  br i1 %exitcond71.not, label %._crit_edge63, label %.preheader, !llvm.loop !23

._crit_edge63:                                    ; preds = %.preheader, %._crit_edge61.us, %.preheader50.thread, %.preheader50
  tail call void @free(ptr noundef %7) #6
  ret void
}

attributes #0 = { nounwind uwtable "min-legal-vector-width"="64" "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 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 "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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 allocsize(0,1) }
attributes #6 = { 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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !10, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !14}
!16 = !{!10, !10, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !8, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}
!23 = distinct !{!23, !20}
!24 = distinct !{!24, !20}


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