; LLVM IR from xirc/cp-algorithm :: spoj/giveaway/main.ll (Z5queryiii)

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

@X = external dso_local global [500000 x i32], align 16
@Y = external dso_local global [1000 x [500 x i32]], align 16

; 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 noundef i32 @_Z5queryiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #1 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  store i32 %0, ptr %5, align 4, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = sdiv i32 %18, 500
  store i32 %19, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %20 = load i32, ptr %6, align 4, !tbaa !5
  %21 = sdiv i32 %20, 500
  store i32 %21, ptr %9, align 4, !tbaa !5
  %22 = load i32, ptr %8, align 4, !tbaa !5
  %23 = load i32, ptr %9, align 4, !tbaa !5
  %24 = icmp eq i32 %22, %23
  br i1 %24, label %25, label %48

25:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 0, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %26 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %26, ptr %11, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %43, %25
  %28 = load i32, ptr %11, align 4, !tbaa !5
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %46

32:                                               ; preds = %27
  %33 = load i32, ptr %11, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [500000 x i32], ptr @X, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = icmp sgt i32 %36, %37
  br i1 %38, label %39, label %42

39:                                               ; preds = %32
  %40 = load i32, ptr %10, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr %10, align 4, !tbaa !5
  br label %42

42:                                               ; preds = %39, %32
  br label %43

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

46:                                               ; preds = %31
  %47 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %47, ptr %4, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %131

48:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #3
  store i32 0, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %49 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %49, ptr %14, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %68, %48
  %51 = load i32, ptr %14, align 4, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = mul nsw i32 %52, 500
  %54 = add nsw i32 %53, 500
  %55 = icmp slt i32 %51, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %50
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  br label %71

57:                                               ; preds = %50
  %58 = load i32, ptr %14, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [500000 x i32], ptr @X, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = icmp sgt i32 %61, %62
  br i1 %63, label %64, label %67

64:                                               ; preds = %57
  %65 = load i32, ptr %13, align 4, !tbaa !5
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %13, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %64, %57
  br label %68

68:                                               ; preds = %67
  %69 = load i32, ptr %14, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %14, align 4, !tbaa !5
  br label %50, !llvm.loop !11

71:                                               ; preds = %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %72 = load i32, ptr %9, align 4, !tbaa !5
  %73 = mul nsw i32 %72, 500
  store i32 %73, ptr %15, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %90, %71
  %75 = load i32, ptr %15, align 4, !tbaa !5
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = icmp slt i32 %75, %76
  br i1 %77, label %79, label %78

78:                                               ; preds = %74
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  br label %93

79:                                               ; preds = %74
  %80 = load i32, ptr %15, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [500000 x i32], ptr @X, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = load i32, ptr %7, align 4, !tbaa !5
  %85 = icmp sgt i32 %83, %84
  br i1 %85, label %86, label %89

86:                                               ; preds = %79
  %87 = load i32, ptr %13, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %13, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %86, %79
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %15, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %15, align 4, !tbaa !5
  br label %74, !llvm.loop !12

93:                                               ; preds = %78
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %16, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %126, %93
  %97 = load i32, ptr %16, align 4, !tbaa !5
  %98 = load i32, ptr %9, align 4, !tbaa !5
  %99 = icmp slt i32 %97, %98
  br i1 %99, label %101, label %100

100:                                              ; preds = %96
  store i32 11, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  br label %129

101:                                              ; preds = %96
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %102 = load i32, ptr %16, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [1000 x [500 x i32]], ptr @Y, i64 0, i64 %103
  %105 = getelementptr inbounds [500 x i32], ptr %104, i64 0, i64 0
  %106 = load i32, ptr %16, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [1000 x [500 x i32]], ptr @Y, i64 0, i64 %107
  %109 = getelementptr inbounds [500 x i32], ptr %108, i64 0, i64 0
  %110 = getelementptr inbounds i32, ptr %109, i64 500
  %111 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef %105, ptr noundef %110, ptr noundef nonnull align 4 dereferenceable(4) %7)
  store ptr %111, ptr %17, align 8, !tbaa !13
  %112 = load i32, ptr %16, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [1000 x [500 x i32]], ptr @Y, i64 0, i64 %113
  %115 = getelementptr inbounds [500 x i32], ptr %114, i64 0, i64 0
  %116 = getelementptr inbounds i32, ptr %115, i64 500
  %117 = load ptr, ptr %17, align 8, !tbaa !13
  %118 = ptrtoint ptr %116 to i64
  %119 = ptrtoint ptr %117 to i64
  %120 = sub i64 %118, %119
  %121 = sdiv exact i64 %120, 4
  %122 = load i32, ptr %13, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = add nsw i64 %123, %121
  %125 = trunc i64 %124 to i32
  store i32 %125, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  br label %126

126:                                              ; preds = %101
  %127 = load i32, ptr %16, align 4, !tbaa !5
  %128 = add nsw i32 %127, 1
  store i32 %128, ptr %16, align 4, !tbaa !5
  br label %96, !llvm.loop !15

129:                                              ; preds = %100
  %130 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %130, ptr %4, align 4
  store i32 1, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #3
  br label %131

131:                                              ; preds = %129, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %132 = load i32, ptr %4, align 4
  ret i32 %132
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) #2

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 = { inlinehint 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 #3 = { 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++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !7, i64 0}
!15 = distinct !{!15, !10}


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

@X = external dso_local local_unnamed_addr global [500000 x i32], align 16
@Y = external dso_local global [1000 x [500 x i32]], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5queryiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  %4 = alloca i32, align 4
  store i32 %2, ptr %4, align 4, !tbaa !5
  %5 = sdiv i32 %0, 500
  %6 = sdiv i32 %1, 500
  %7 = icmp eq i32 %5, %6
  br i1 %7, label %.preheader, label %.preheader46

.preheader46:                                     ; preds = %3
  %8 = mul nsw i32 %5, 500
  %9 = add nsw i32 %8, 500
  %10 = icmp sgt i32 %9, %0
  br i1 %10, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %.preheader46
  %11 = sext i32 %0 to i64
  %wide.trip.count = sext i32 %9 to i64
  %12 = sub nsw i64 %wide.trip.count, %11
  %min.iters.check = icmp ult i64 %12, 8
  br i1 %min.iters.check, label %.lr.ph.preheader133, label %vector.ph

.lr.ph.preheader133:                              ; preds = %middle.block, %.lr.ph.preheader
  %indvars.iv.ph = phi i64 [ %11, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.03647.ph = phi i32 [ 0, %.lr.ph.preheader ], [ %22, %middle.block ]
  br label %.lr.ph

vector.ph:                                        ; preds = %.lr.ph.preheader
  %n.vec = and i64 %12, -8
  %ind.end = add nsw i64 %n.vec, %11
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %2, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %19, %vector.body ]
  %vec.phi82 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %20, %vector.body ]
  %offset.idx = add i64 %index, %11
  %13 = getelementptr inbounds [500000 x i32], ptr @X, i64 0, i64 %offset.idx
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  %wide.load = load <4 x i32>, ptr %13, align 4, !tbaa !5
  %wide.load83 = load <4 x i32>, ptr %14, align 4, !tbaa !5
  %15 = icmp sgt <4 x i32> %wide.load, %broadcast.splat
  %16 = icmp sgt <4 x i32> %wide.load83, %broadcast.splat
  %17 = zext <4 x i1> %15 to <4 x i32>
  %18 = zext <4 x i1> %16 to <4 x i32>
  %19 = add <4 x i32> %vec.phi, %17
  %20 = add <4 x i32> %vec.phi82, %18
  %index.next = add nuw i64 %index, 8
  %21 = icmp eq i64 %index.next, %n.vec
  br i1 %21, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %20, %19
  %22 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %12, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader133

.preheader:                                       ; preds = %3
  %23 = icmp slt i32 %0, %1
  br i1 %23, label %.lr.ph61.preheader, label %.loopexit

.lr.ph61.preheader:                               ; preds = %.preheader
  %24 = sext i32 %0 to i64
  %wide.trip.count78 = sext i32 %1 to i64
  %25 = sub nsw i64 %wide.trip.count78, %24
  %min.iters.check107 = icmp ult i64 %25, 8
  br i1 %min.iters.check107, label %.lr.ph61.preheader126, label %vector.ph108

vector.ph108:                                     ; preds = %.lr.ph61.preheader
  %n.vec110 = and i64 %25, -8
  %ind.end111 = add nsw i64 %n.vec110, %24
  %broadcast.splatinsert120 = insertelement <4 x i32> poison, i32 %2, i64 0
  %broadcast.splat121 = shufflevector <4 x i32> %broadcast.splatinsert120, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body113

vector.body113:                                   ; preds = %vector.body113, %vector.ph108
  %index114 = phi i64 [ 0, %vector.ph108 ], [ %index.next122, %vector.body113 ]
  %vec.phi115 = phi <4 x i32> [ zeroinitializer, %vector.ph108 ], [ %32, %vector.body113 ]
  %vec.phi116 = phi <4 x i32> [ zeroinitializer, %vector.ph108 ], [ %33, %vector.body113 ]
  %offset.idx117 = add i64 %index114, %24
  %26 = getelementptr inbounds [500000 x i32], ptr @X, i64 0, i64 %offset.idx117
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  %wide.load118 = load <4 x i32>, ptr %26, align 4, !tbaa !5
  %wide.load119 = load <4 x i32>, ptr %27, align 4, !tbaa !5
  %28 = icmp sgt <4 x i32> %wide.load118, %broadcast.splat121
  %29 = icmp sgt <4 x i32> %wide.load119, %broadcast.splat121
  %30 = zext <4 x i1> %28 to <4 x i32>
  %31 = zext <4 x i1> %29 to <4 x i32>
  %32 = add <4 x i32> %vec.phi115, %30
  %33 = add <4 x i32> %vec.phi116, %31
  %index.next122 = add nuw i64 %index114, 8
  %34 = icmp eq i64 %index.next122, %n.vec110
  br i1 %34, label %middle.block105, label %vector.body113, !llvm.loop !13

middle.block105:                                  ; preds = %vector.body113
  %bin.rdx123 = add <4 x i32> %33, %32
  %35 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx123)
  %cmp.n124 = icmp eq i64 %25, %n.vec110
  br i1 %cmp.n124, label %.loopexit, label %.lr.ph61.preheader126

.lr.ph61.preheader126:                            ; preds = %middle.block105, %.lr.ph61.preheader
  %indvars.iv75.ph = phi i64 [ %24, %.lr.ph61.preheader ], [ %ind.end111, %middle.block105 ]
  %.03859.ph = phi i32 [ 0, %.lr.ph61.preheader ], [ %35, %middle.block105 ]
  br label %.lr.ph61

.lr.ph61:                                         ; preds = %.lr.ph61.preheader126, %.lr.ph61
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %.lr.ph61 ], [ %indvars.iv75.ph, %.lr.ph61.preheader126 ]
  %.03859 = phi i32 [ %spec.select, %.lr.ph61 ], [ %.03859.ph, %.lr.ph61.preheader126 ]
  %36 = getelementptr inbounds [500000 x i32], ptr @X, i64 0, i64 %indvars.iv75
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = icmp sgt i32 %37, %2
  %39 = zext i1 %38 to i32
  %spec.select = add nuw nsw i32 %.03859, %39
  %indvars.iv.next76 = add nsw i64 %indvars.iv75, 1
  %exitcond79.not = icmp eq i64 %indvars.iv.next76, %wide.trip.count78
  br i1 %exitcond79.not, label %.loopexit, label %.lr.ph61, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %middle.block, %.preheader46
  %.036.lcssa = phi i32 [ 0, %.preheader46 ], [ %22, %middle.block ], [ %spec.select42, %.lr.ph ]
  %40 = mul nsw i32 %6, 500
  %41 = icmp slt i32 %40, %1
  br i1 %41, label %.lr.ph52.preheader, label %.preheader44

.lr.ph52.preheader:                               ; preds = %._crit_edge
  %42 = sext i32 %40 to i64
  %wide.trip.count68 = sext i32 %1 to i64
  %43 = sub nsw i64 %wide.trip.count68, %42
  %min.iters.check86 = icmp ult i64 %43, 8
  br i1 %min.iters.check86, label %.lr.ph52.preheader130, label %vector.ph87

.lr.ph52.preheader130:                            ; preds = %middle.block84, %.lr.ph52.preheader
  %indvars.iv65.ph = phi i64 [ %42, %.lr.ph52.preheader ], [ %ind.end90, %middle.block84 ]
  %.249.ph = phi i32 [ %.036.lcssa, %.lr.ph52.preheader ], [ %54, %middle.block84 ]
  br label %.lr.ph52

vector.ph87:                                      ; preds = %.lr.ph52.preheader
  %n.vec89 = and i64 %43, -8
  %ind.end90 = add nsw i64 %n.vec89, %42
  %44 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %.036.lcssa, i64 0
  %broadcast.splatinsert99 = insertelement <4 x i32> poison, i32 %2, i64 0
  %broadcast.splat100 = shufflevector <4 x i32> %broadcast.splatinsert99, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body92

vector.body92:                                    ; preds = %vector.body92, %vector.ph87
  %index93 = phi i64 [ 0, %vector.ph87 ], [ %index.next101, %vector.body92 ]
  %vec.phi94 = phi <4 x i32> [ %44, %vector.ph87 ], [ %51, %vector.body92 ]
  %vec.phi95 = phi <4 x i32> [ zeroinitializer, %vector.ph87 ], [ %52, %vector.body92 ]
  %offset.idx96 = add i64 %index93, %42
  %45 = getelementptr inbounds [500000 x i32], ptr @X, i64 0, i64 %offset.idx96
  %46 = getelementptr inbounds i8, ptr %45, i64 16
  %wide.load97 = load <4 x i32>, ptr %45, align 16, !tbaa !5
  %wide.load98 = load <4 x i32>, ptr %46, align 16, !tbaa !5
  %47 = icmp sgt <4 x i32> %wide.load97, %broadcast.splat100
  %48 = icmp sgt <4 x i32> %wide.load98, %broadcast.splat100
  %49 = zext <4 x i1> %47 to <4 x i32>
  %50 = zext <4 x i1> %48 to <4 x i32>
  %51 = add <4 x i32> %vec.phi94, %49
  %52 = add <4 x i32> %vec.phi95, %50
  %index.next101 = add nuw i64 %index93, 8
  %53 = icmp eq i64 %index.next101, %n.vec89
  br i1 %53, label %middle.block84, label %vector.body92, !llvm.loop !15

middle.block84:                                   ; preds = %vector.body92
  %bin.rdx102 = add <4 x i32> %52, %51
  %54 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx102)
  %cmp.n103 = icmp eq i64 %43, %n.vec89
  br i1 %cmp.n103, label %.preheader44, label %.lr.ph52.preheader130

.lr.ph:                                           ; preds = %.lr.ph.preheader133, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ %indvars.iv.ph, %.lr.ph.preheader133 ]
  %.03647 = phi i32 [ %spec.select42, %.lr.ph ], [ %.03647.ph, %.lr.ph.preheader133 ]
  %55 = getelementptr inbounds [500000 x i32], ptr @X, i64 0, i64 %indvars.iv
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = icmp sgt i32 %56, %2
  %58 = zext i1 %57 to i32
  %spec.select42 = add nuw nsw i32 %.03647, %58
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !16

.preheader44:                                     ; preds = %.lr.ph52, %middle.block84, %._crit_edge
  %.2.lcssa = phi i32 [ %.036.lcssa, %._crit_edge ], [ %54, %middle.block84 ], [ %spec.select43, %.lr.ph52 ]
  %.03354 = add nsw i32 %5, 1
  %59 = icmp slt i32 %.03354, %6
  br i1 %59, label %.lr.ph57.preheader, label %.loopexit

.lr.ph57.preheader:                               ; preds = %.preheader44
  %narrow = add nsw i32 %5, 1
  %60 = sext i32 %narrow to i64
  %wide.trip.count73 = sext i32 %6 to i64
  br label %.lr.ph57

.lr.ph52:                                         ; preds = %.lr.ph52.preheader130, %.lr.ph52
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %.lr.ph52 ], [ %indvars.iv65.ph, %.lr.ph52.preheader130 ]
  %.249 = phi i32 [ %spec.select43, %.lr.ph52 ], [ %.249.ph, %.lr.ph52.preheader130 ]
  %61 = getelementptr inbounds [500000 x i32], ptr @X, i64 0, i64 %indvars.iv65
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = icmp sgt i32 %62, %2
  %64 = zext i1 %63 to i32
  %spec.select43 = add nsw i32 %.249, %64
  %indvars.iv.next66 = add nsw i64 %indvars.iv65, 1
  %exitcond69.not = icmp eq i64 %indvars.iv.next66, %wide.trip.count68
  br i1 %exitcond69.not, label %.preheader44, label %.lr.ph52, !llvm.loop !17

.lr.ph57:                                         ; preds = %.lr.ph57.preheader, %.lr.ph57
  %indvars.iv70 = phi i64 [ %60, %.lr.ph57.preheader ], [ %indvars.iv.next71, %.lr.ph57 ]
  %.455 = phi i32 [ %.2.lcssa, %.lr.ph57.preheader ], [ %73, %.lr.ph57 ]
  %65 = getelementptr inbounds [1000 x [500 x i32]], ptr @Y, i64 0, i64 %indvars.iv70
  %66 = getelementptr inbounds i8, ptr %65, i64 2000
  %67 = call noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull %65, ptr noundef nonnull %66, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %68 = ptrtoint ptr %66 to i64
  %69 = ptrtoint ptr %67 to i64
  %70 = sub i64 %68, %69
  %71 = lshr exact i64 %70, 2
  %72 = trunc i64 %71 to i32
  %73 = add i32 %.455, %72
  %indvars.iv.next71 = add nsw i64 %indvars.iv70, 1
  %exitcond74.not = icmp eq i64 %indvars.iv.next71, %wide.trip.count73
  br i1 %exitcond74.not, label %.loopexit, label %.lr.ph57, !llvm.loop !18

.loopexit:                                        ; preds = %.lr.ph57, %.lr.ph61, %middle.block105, %.preheader44, %.preheader
  %.0 = phi i32 [ 0, %.preheader ], [ %.2.lcssa, %.preheader44 ], [ %35, %middle.block105 ], [ %spec.select, %.lr.ph61 ], [ %73, %.lr.ph57 ]
  ret i32 %.0
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef ptr @_ZSt11upper_boundIPiiET_S1_S1_RKT0_(ptr noundef, ptr noundef, ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #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 = { inlinehint 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 = { nocallback nofree nosync nounwind speculatable 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++ TBAA"}
!9 = distinct !{!9, !10, !11, !12}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.isvectorized", i32 1}
!12 = !{!"llvm.loop.unroll.runtime.disable"}
!13 = distinct !{!13, !10, !11, !12}
!14 = distinct !{!14, !10, !12, !11}
!15 = distinct !{!15, !10, !11, !12}
!16 = distinct !{!16, !10, !12, !11}
!17 = distinct !{!17, !10, !12, !11}
!18 = distinct !{!18, !10}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass