; LLVM IR from ashishzero/karma :: src/modules/core (stb)

; 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.stbrp__findresult = type { i32, i32, ptr }
%struct.stbrp_rect = type { i32, i16, i16, i16, i16, i32 }

; 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: mustprogress uwtable
define dso_local i32 @stbrp_pack_rects(ptr noundef %0, ptr noundef %1, i32 noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca %struct.stbrp__findresult, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %21, %3
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = load i32, ptr %6, align 4, !tbaa !9
  %13 = icmp slt i32 %11, %12
  br i1 %13, label %14, label %24

14:                                               ; preds = %10
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds %struct.stbrp_rect, ptr %16, i64 %18
  %20 = getelementptr inbounds %struct.stbrp_rect, ptr %19, i32 0, i32 5
  store i32 %15, ptr %20, align 4, !tbaa !11
  br label %21

21:                                               ; preds = %14
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %7, align 4, !tbaa !9
  br label %10, !llvm.loop !14

24:                                               ; preds = %10
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = sext i32 %26 to i64
  call void @qsort(ptr noundef %25, i64 noundef %27, i64 noundef 16, ptr noundef @_ZL19rect_height_comparePKvS0_)
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %28

28:                                               ; preds = %115, %24
  %29 = load i32, ptr %7, align 4, !tbaa !9
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %32, label %118

32:                                               ; preds = %28
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = load i32, ptr %7, align 4, !tbaa !9
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds %struct.stbrp_rect, ptr %33, i64 %35
  %37 = getelementptr inbounds %struct.stbrp_rect, ptr %36, i32 0, i32 1
  %38 = load i16, ptr %37, align 4, !tbaa !16
  %39 = zext i16 %38 to i32
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %50, label %41

41:                                               ; preds = %32
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds %struct.stbrp_rect, ptr %42, i64 %44
  %46 = getelementptr inbounds %struct.stbrp_rect, ptr %45, i32 0, i32 2
  %47 = load i16, ptr %46, align 2, !tbaa !17
  %48 = zext i16 %47 to i32
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %61

50:                                               ; preds = %41, %32
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = load i32, ptr %7, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds %struct.stbrp_rect, ptr %51, i64 %53
  %55 = getelementptr inbounds %struct.stbrp_rect, ptr %54, i32 0, i32 4
  store i16 0, ptr %55, align 2, !tbaa !18
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct.stbrp_rect, ptr %56, i64 %58
  %60 = getelementptr inbounds %struct.stbrp_rect, ptr %59, i32 0, i32 3
  store i16 0, ptr %60, align 4, !tbaa !19
  br label %114

61:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i32, ptr %7, align 4, !tbaa !9
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds %struct.stbrp_rect, ptr %63, i64 %65
  %67 = getelementptr inbounds %struct.stbrp_rect, ptr %66, i32 0, i32 1
  %68 = load i16, ptr %67, align 4, !tbaa !16
  %69 = zext i16 %68 to i32
  %70 = load ptr, ptr %5, align 8, !tbaa !5
  %71 = load i32, ptr %7, align 4, !tbaa !9
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds %struct.stbrp_rect, ptr %70, i64 %72
  %74 = getelementptr inbounds %struct.stbrp_rect, ptr %73, i32 0, i32 2
  %75 = load i16, ptr %74, align 2, !tbaa !17
  %76 = zext i16 %75 to i32
  %77 = call { i64, ptr } @_ZL29stbrp__skyline_pack_rectangleP13stbrp_contextii(ptr noundef %62, i32 noundef %69, i32 noundef %76)
  %78 = getelementptr inbounds { i64, ptr }, ptr %9, i32 0, i32 0
  %79 = extractvalue { i64, ptr } %77, 0
  store i64 %79, ptr %78, align 8
  %80 = getelementptr inbounds { i64, ptr }, ptr %9, i32 0, i32 1
  %81 = extractvalue { i64, ptr } %77, 1
  store ptr %81, ptr %80, align 8
  %82 = getelementptr inbounds %struct.stbrp__findresult, ptr %9, i32 0, i32 2
  %83 = load ptr, ptr %82, align 8, !tbaa !20
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %102

85:                                               ; preds = %61
  %86 = getelementptr inbounds %struct.stbrp__findresult, ptr %9, i32 0, i32 0
  %87 = load i32, ptr %86, align 8, !tbaa !22
  %88 = trunc i32 %87 to i16
  %89 = load ptr, ptr %5, align 8, !tbaa !5
  %90 = load i32, ptr %7, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds %struct.stbrp_rect, ptr %89, i64 %91
  %93 = getelementptr inbounds %struct.stbrp_rect, ptr %92, i32 0, i32 3
  store i16 %88, ptr %93, align 4, !tbaa !19
  %94 = getelementptr inbounds %struct.stbrp__findresult, ptr %9, i32 0, i32 1
  %95 = load i32, ptr %94, align 4, !tbaa !23
  %96 = trunc i32 %95 to i16
  %97 = load ptr, ptr %5, align 8, !tbaa !5
  %98 = load i32, ptr %7, align 4, !tbaa !9
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds %struct.stbrp_rect, ptr %97, i64 %99
  %101 = getelementptr inbounds %struct.stbrp_rect, ptr %100, i32 0, i32 4
  store i16 %96, ptr %101, align 2, !tbaa !18
  br label %113

102:                                              ; preds = %61
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = load i32, ptr %7, align 4, !tbaa !9
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds %struct.stbrp_rect, ptr %103, i64 %105
  %107 = getelementptr inbounds %struct.stbrp_rect, ptr %106, i32 0, i32 4
  store i16 -1, ptr %107, align 2, !tbaa !18
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = load i32, ptr %7, align 4, !tbaa !9
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds %struct.stbrp_rect, ptr %108, i64 %110
  %112 = getelementptr inbounds %struct.stbrp_rect, ptr %111, i32 0, i32 3
  store i16 -1, ptr %112, align 4, !tbaa !19
  br label %113

113:                                              ; preds = %102, %85
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  br label %114

114:                                              ; preds = %113, %50
  br label %115

115:                                              ; preds = %114
  %116 = load i32, ptr %7, align 4, !tbaa !9
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %7, align 4, !tbaa !9
  br label %28, !llvm.loop !24

118:                                              ; preds = %28
  %119 = load ptr, ptr %5, align 8, !tbaa !5
  %120 = load i32, ptr %6, align 4, !tbaa !9
  %121 = sext i32 %120 to i64
  call void @qsort(ptr noundef %119, i64 noundef %121, i64 noundef 16, ptr noundef @_ZL19rect_original_orderPKvS0_)
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %122

122:                                              ; preds = %162, %118
  %123 = load i32, ptr %7, align 4, !tbaa !9
  %124 = load i32, ptr %6, align 4, !tbaa !9
  %125 = icmp slt i32 %123, %124
  br i1 %125, label %126, label %165

126:                                              ; preds = %122
  %127 = load ptr, ptr %5, align 8, !tbaa !5
  %128 = load i32, ptr %7, align 4, !tbaa !9
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds %struct.stbrp_rect, ptr %127, i64 %129
  %131 = getelementptr inbounds %struct.stbrp_rect, ptr %130, i32 0, i32 3
  %132 = load i16, ptr %131, align 4, !tbaa !19
  %133 = zext i16 %132 to i32
  %134 = icmp eq i32 %133, 65535
  br i1 %134, label %135, label %144

135:                                              ; preds = %126
  %136 = load ptr, ptr %5, align 8, !tbaa !5
  %137 = load i32, ptr %7, align 4, !tbaa !9
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds %struct.stbrp_rect, ptr %136, i64 %138
  %140 = getelementptr inbounds %struct.stbrp_rect, ptr %139, i32 0, i32 4
  %141 = load i16, ptr %140, align 2, !tbaa !18
  %142 = zext i16 %141 to i32
  %143 = icmp eq i32 %142, 65535
  br label %144

144:                                              ; preds = %135, %126
  %145 = phi i1 [ false, %126 ], [ %143, %135 ]
  %146 = xor i1 %145, true
  %147 = zext i1 %146 to i32
  %148 = load ptr, ptr %5, align 8, !tbaa !5
  %149 = load i32, ptr %7, align 4, !tbaa !9
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds %struct.stbrp_rect, ptr %148, i64 %150
  %152 = getelementptr inbounds %struct.stbrp_rect, ptr %151, i32 0, i32 5
  store i32 %147, ptr %152, align 4, !tbaa !11
  %153 = load ptr, ptr %5, align 8, !tbaa !5
  %154 = load i32, ptr %7, align 4, !tbaa !9
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds %struct.stbrp_rect, ptr %153, i64 %155
  %157 = getelementptr inbounds %struct.stbrp_rect, ptr %156, i32 0, i32 5
  %158 = load i32, ptr %157, align 4, !tbaa !11
  %159 = icmp ne i32 %158, 0
  br i1 %159, label %161, label %160

160:                                              ; preds = %144
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %161

161:                                              ; preds = %160, %144
  br label %162

162:                                              ; preds = %161
  %163 = load i32, ptr %7, align 4, !tbaa !9
  %164 = add nsw i32 %163, 1
  store i32 %164, ptr %7, align 4, !tbaa !9
  br label %122, !llvm.loop !25

165:                                              ; preds = %122
  %166 = load i32, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  ret i32 %166
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL19rect_height_comparePKvS0_(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare hidden { i64, ptr } @_ZL29stbrp__skyline_pack_rectangleP13stbrp_contextii(ptr noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL19rect_original_orderPKvS0_(ptr noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { "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 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 }

!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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !10, i64 12}
!12 = !{!"_ZTS10stbrp_rect", !10, i64 0, !13, i64 4, !13, i64 6, !13, i64 8, !13, i64 10, !10, i64 12}
!13 = !{!"short", !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!12, !13, i64 4}
!17 = !{!12, !13, i64 6}
!18 = !{!12, !13, i64 10}
!19 = !{!12, !13, i64 8}
!20 = !{!21, !6, i64 8}
!21 = !{!"_ZTS17stbrp__findresult", !10, i64 0, !10, i64 4, !6, i64 8}
!22 = !{!21, !10, i64 0}
!23 = !{!21, !10, i64 4}
!24 = distinct !{!24, !15}
!25 = distinct !{!25, !15}


; 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.stbrp_rect = type { i32, i16, i16, i16, i16, i32 }

; Function Attrs: mustprogress uwtable
define dso_local range(i32 0, 2) i32 @stbrp_pack_rects(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = icmp sgt i32 %2, 0
  br i1 %4, label %.lr.ph.preheader, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %3
  %5 = sext i32 %2 to i64
  tail call void @qsort(ptr noundef %1, i64 noundef %5, i64 noundef 16, ptr noundef nonnull @_ZL19rect_height_comparePKvS0_)
  br label %._crit_edge55.thread

.lr.ph.preheader:                                 ; preds = %3
  %wide.trip.count = zext nneg i32 %2 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %6 = icmp ult i32 %2, 4
  br i1 %6, label %._crit_edge.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

.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 ]
  %7 = getelementptr inbounds %struct.stbrp_rect, ptr %1, i64 %indvars.iv, i32 5
  %8 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %8, ptr %7, align 4, !tbaa !5
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %9 = getelementptr inbounds %struct.stbrp_rect, ptr %1, i64 %indvars.iv.next, i32 5
  %10 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %10, ptr %9, align 4, !tbaa !5
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %11 = getelementptr inbounds %struct.stbrp_rect, ptr %1, i64 %indvars.iv.next.1, i32 5
  %12 = trunc nuw nsw i64 %indvars.iv.next.1 to i32
  store i32 %12, ptr %11, align 4, !tbaa !5
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %13 = getelementptr inbounds %struct.stbrp_rect, ptr %1, i64 %indvars.iv.next.2, i32 5
  %14 = trunc nuw nsw i64 %indvars.iv.next.2 to i32
  store i32 %14, ptr %13, align 4, !tbaa !5
  %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 %._crit_edge.unr-lcssa, label %.lr.ph, !llvm.loop !11

._crit_edge.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 %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.unr-lcssa ]
  %15 = getelementptr inbounds %struct.stbrp_rect, ptr %1, i64 %indvars.iv.epil, i32 5
  %16 = trunc nuw nsw i64 %indvars.iv.epil to i32
  store i32 %16, ptr %15, align 4, !tbaa !5
  %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 %._crit_edge, label %.lr.ph.epil, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.unr-lcssa
  %17 = zext nneg i32 %2 to i64
  tail call void @qsort(ptr noundef nonnull %1, i64 noundef %17, i64 noundef 16, ptr noundef nonnull @_ZL19rect_height_comparePKvS0_)
  br i1 %4, label %.lr.ph54.preheader, label %._crit_edge55.thread

.lr.ph54.preheader:                               ; preds = %._crit_edge
  %wide.trip.count65 = zext nneg i32 %2 to i64
  br label %.lr.ph54

.lr.ph54:                                         ; preds = %.lr.ph54.preheader, %42
  %indvars.iv62 = phi i64 [ 0, %.lr.ph54.preheader ], [ %indvars.iv.next63, %42 ]
  %18 = getelementptr inbounds %struct.stbrp_rect, ptr %1, i64 %indvars.iv62
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = load i16, ptr %19, align 4, !tbaa !15
  %21 = zext i16 %20 to i32
  %22 = icmp eq i16 %20, 0
  br i1 %22, label %27, label %23

23:                                               ; preds = %.lr.ph54
  %24 = getelementptr inbounds i8, ptr %18, i64 6
  %25 = load i16, ptr %24, align 2, !tbaa !16
  %26 = icmp eq i16 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %23, %.lr.ph54
  %28 = getelementptr inbounds i8, ptr %18, i64 10
  store i16 0, ptr %28, align 2, !tbaa !17
  %29 = getelementptr inbounds i8, ptr %18, i64 8
  store i16 0, ptr %29, align 4, !tbaa !18
  br label %42

30:                                               ; preds = %23
  %31 = zext i16 %25 to i32
  %32 = tail call { i64, ptr } @_ZL29stbrp__skyline_pack_rectangleP13stbrp_contextii(ptr noundef %0, i32 noundef %21, i32 noundef %31)
  %33 = extractvalue { i64, ptr } %32, 1
  %.not = icmp eq ptr %33, null
  %34 = getelementptr inbounds i8, ptr %18, i64 8
  br i1 %.not, label %40, label %35

35:                                               ; preds = %30
  %36 = extractvalue { i64, ptr } %32, 0
  %37 = trunc i64 %36 to i16
  store i16 %37, ptr %34, align 4, !tbaa !18
  %.sroa.0.4.extract.shift = lshr i64 %36, 32
  %38 = trunc i64 %.sroa.0.4.extract.shift to i16
  %39 = getelementptr inbounds i8, ptr %18, i64 10
  store i16 %38, ptr %39, align 2, !tbaa !17
  br label %42

40:                                               ; preds = %30
  %41 = getelementptr inbounds i8, ptr %18, i64 10
  store i16 -1, ptr %41, align 2, !tbaa !17
  store i16 -1, ptr %34, align 4, !tbaa !18
  br label %42

42:                                               ; preds = %35, %40, %27
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %exitcond66.not = icmp eq i64 %indvars.iv.next63, %wide.trip.count65
  br i1 %exitcond66.not, label %._crit_edge55, label %.lr.ph54, !llvm.loop !19

._crit_edge55.thread:                             ; preds = %._crit_edge.thread, %._crit_edge
  %.ph = phi i64 [ %17, %._crit_edge ], [ %5, %._crit_edge.thread ]
  tail call void @qsort(ptr noundef %1, i64 noundef %.ph, i64 noundef 16, ptr noundef nonnull @_ZL19rect_original_orderPKvS0_)
  br label %._crit_edge60

._crit_edge55:                                    ; preds = %42
  tail call void @qsort(ptr noundef nonnull %1, i64 noundef %17, i64 noundef 16, ptr noundef nonnull @_ZL19rect_original_orderPKvS0_)
  br i1 %4, label %.lr.ph59.preheader, label %._crit_edge60

.lr.ph59.preheader:                               ; preds = %._crit_edge55
  %xtraiter72 = and i64 %wide.trip.count, 1
  %43 = icmp eq i32 %2, 1
  br i1 %43, label %._crit_edge60.loopexit.unr-lcssa, label %.lr.ph59.preheader.new

.lr.ph59.preheader.new:                           ; preds = %.lr.ph59.preheader
  %unroll_iter76 = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph59

.lr.ph59:                                         ; preds = %.thread.1, %.lr.ph59.preheader.new
  %indvars.iv67 = phi i64 [ 0, %.lr.ph59.preheader.new ], [ %indvars.iv.next68.1, %.thread.1 ]
  %.04556 = phi i32 [ 1, %.lr.ph59.preheader.new ], [ %64, %.thread.1 ]
  %niter77 = phi i64 [ 0, %.lr.ph59.preheader.new ], [ %niter77.next.1, %.thread.1 ]
  %44 = getelementptr inbounds %struct.stbrp_rect, ptr %1, i64 %indvars.iv67
  %45 = getelementptr inbounds i8, ptr %44, i64 8
  %46 = load i16, ptr %45, align 4, !tbaa !18
  %47 = icmp eq i16 %46, -1
  br i1 %47, label %48, label %.thread

48:                                               ; preds = %.lr.ph59
  %49 = getelementptr inbounds i8, ptr %44, i64 10
  %50 = load i16, ptr %49, align 2, !tbaa !17
  %.fr = freeze i16 %50
  %51 = icmp ne i16 %.fr, -1
  %52 = zext i1 %51 to i32
  %spec.select = select i1 %51, i32 %.04556, i32 0
  br label %.thread

.thread:                                          ; preds = %.lr.ph59, %48
  %.sink = phi i32 [ %52, %48 ], [ 1, %.lr.ph59 ]
  %53 = phi i32 [ %spec.select, %48 ], [ %.04556, %.lr.ph59 ]
  %54 = getelementptr inbounds i8, ptr %44, i64 12
  store i32 %.sink, ptr %54, align 4
  %indvars.iv.next68 = or disjoint i64 %indvars.iv67, 1
  %55 = getelementptr inbounds %struct.stbrp_rect, ptr %1, i64 %indvars.iv.next68
  %56 = getelementptr inbounds i8, ptr %55, i64 8
  %57 = load i16, ptr %56, align 4, !tbaa !18
  %58 = icmp eq i16 %57, -1
  br i1 %58, label %59, label %.thread.1

59:                                               ; preds = %.thread
  %60 = getelementptr inbounds i8, ptr %55, i64 10
  %61 = load i16, ptr %60, align 2, !tbaa !17
  %.fr.1 = freeze i16 %61
  %62 = icmp ne i16 %.fr.1, -1
  %63 = zext i1 %62 to i32
  %spec.select.1 = select i1 %62, i32 %53, i32 0
  br label %.thread.1

.thread.1:                                        ; preds = %59, %.thread
  %.sink.1 = phi i32 [ %63, %59 ], [ 1, %.thread ]
  %64 = phi i32 [ %spec.select.1, %59 ], [ %53, %.thread ]
  %65 = getelementptr inbounds i8, ptr %55, i64 12
  store i32 %.sink.1, ptr %65, align 4
  %indvars.iv.next68.1 = add nuw nsw i64 %indvars.iv67, 2
  %niter77.next.1 = add i64 %niter77, 2
  %niter77.ncmp.1 = icmp eq i64 %niter77.next.1, %unroll_iter76
  br i1 %niter77.ncmp.1, label %._crit_edge60.loopexit.unr-lcssa, label %.lr.ph59, !llvm.loop !20

._crit_edge60.loopexit.unr-lcssa:                 ; preds = %.thread.1, %.lr.ph59.preheader
  %.lcssa.ph = phi i32 [ poison, %.lr.ph59.preheader ], [ %64, %.thread.1 ]
  %indvars.iv67.unr = phi i64 [ 0, %.lr.ph59.preheader ], [ %indvars.iv.next68.1, %.thread.1 ]
  %.04556.unr = phi i32 [ 1, %.lr.ph59.preheader ], [ %64, %.thread.1 ]
  %lcmp.mod74.not = icmp eq i64 %xtraiter72, 0
  br i1 %lcmp.mod74.not, label %._crit_edge60, label %.lr.ph59.epil

.lr.ph59.epil:                                    ; preds = %._crit_edge60.loopexit.unr-lcssa
  %66 = getelementptr inbounds %struct.stbrp_rect, ptr %1, i64 %indvars.iv67.unr
  %67 = getelementptr inbounds i8, ptr %66, i64 8
  %68 = load i16, ptr %67, align 4, !tbaa !18
  %69 = icmp eq i16 %68, -1
  br i1 %69, label %70, label %.thread.epil

70:                                               ; preds = %.lr.ph59.epil
  %71 = getelementptr inbounds i8, ptr %66, i64 10
  %72 = load i16, ptr %71, align 2, !tbaa !17
  %.fr.epil = freeze i16 %72
  %73 = icmp ne i16 %.fr.epil, -1
  %74 = zext i1 %73 to i32
  %spec.select.epil = select i1 %73, i32 %.04556.unr, i32 0
  br label %.thread.epil

.thread.epil:                                     ; preds = %70, %.lr.ph59.epil
  %.sink.epil = phi i32 [ %74, %70 ], [ 1, %.lr.ph59.epil ]
  %75 = phi i32 [ %spec.select.epil, %70 ], [ %.04556.unr, %.lr.ph59.epil ]
  %76 = getelementptr inbounds i8, ptr %66, i64 12
  store i32 %.sink.epil, ptr %76, align 4
  br label %._crit_edge60

._crit_edge60:                                    ; preds = %.thread.epil, %._crit_edge60.loopexit.unr-lcssa, %._crit_edge55.thread, %._crit_edge55
  %.045.lcssa = phi i32 [ 1, %._crit_edge55 ], [ 1, %._crit_edge55.thread ], [ %.lcssa.ph, %._crit_edge60.loopexit.unr-lcssa ], [ %75, %.thread.epil ]
  ret i32 %.045.lcssa
}

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL19rect_height_comparePKvS0_(ptr noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden { i64, ptr } @_ZL29stbrp__skyline_pack_rectangleP13stbrp_contextii(ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL19rect_original_orderPKvS0_(ptr noundef, ptr noundef) #2

attributes #0 = { mustprogress 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 = { 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 #2 = { mustprogress 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" }

!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 12}
!6 = !{!"_ZTS10stbrp_rect", !7, i64 0, !10, i64 4, !10, i64 6, !10, i64 8, !10, i64 10, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"short", !8, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = !{!6, !10, i64 4}
!16 = !{!6, !10, i64 6}
!17 = !{!6, !10, i64 10}
!18 = !{!6, !10, i64 8}
!19 = distinct !{!19, !12}
!20 = distinct !{!20, !12}


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