; LLVM IR from tangjz/acm-icpc :: lydsy/3343.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"

@val = external dso_local global [1000010 x i32], align 16
@cha = external dso_local global [1000010 x i32], align 16
@add = external dso_local global [1010 x i32], align 16
@Size = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z2Noi(i32 noundef) #1

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5queryiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %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 i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = call noundef i32 @_Z2Noi(i32 noundef %18)
  store i32 %19, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = call noundef i32 @_Z2Noi(i32 noundef %20)
  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 %51

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

27:                                               ; preds = %47, %25
  %28 = load i32, ptr %10, align 4, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = icmp sle i32 %28, %29
  br i1 %30, label %32, label %31

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

32:                                               ; preds = %27
  %33 = load i32, ptr %10, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [1000010 x i32], ptr @val, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1010 x i32], ptr @add, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = add nsw i32 %36, %40
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = icmp sge i32 %41, %42
  %44 = zext i1 %43 to i32
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = add nsw i32 %45, %44
  store i32 %46, ptr %7, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %32
  %48 = load i32, ptr %10, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %10, align 4, !tbaa !5
  br label %27, !llvm.loop !9

50:                                               ; preds = %31
  br label %109

51:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %52 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %52, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = load i32, ptr @Size, align 4, !tbaa !5
  %55 = mul nsw i32 %53, %54
  store i32 %55, ptr %12, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %76, %51
  %57 = load i32, ptr %11, align 4, !tbaa !5
  %58 = load i32, ptr %12, align 4, !tbaa !5
  %59 = icmp sle i32 %57, %58
  br i1 %59, label %61, label %60

60:                                               ; preds = %56
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %79

61:                                               ; preds = %56
  %62 = load i32, ptr %11, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [1000010 x i32], ptr @val, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = load i32, ptr %8, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [1010 x i32], ptr @add, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = add nsw i32 %65, %69
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = icmp sge i32 %70, %71
  %73 = zext i1 %72 to i32
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = add nsw i32 %74, %73
  store i32 %75, ptr %7, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %61
  %77 = load i32, ptr %11, align 4, !tbaa !5
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr %11, align 4, !tbaa !5
  br label %56, !llvm.loop !11

79:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %80 = load i32, ptr %9, align 4, !tbaa !5
  %81 = sub nsw i32 %80, 1
  %82 = load i32, ptr @Size, align 4, !tbaa !5
  %83 = mul nsw i32 %81, %82
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %13, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %105, %79
  %86 = load i32, ptr %13, align 4, !tbaa !5
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = icmp sle i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %108

90:                                               ; preds = %85
  %91 = load i32, ptr %13, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [1000010 x i32], ptr @val, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = load i32, ptr %9, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [1010 x i32], ptr @add, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = add nsw i32 %94, %98
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = icmp sge i32 %99, %100
  %102 = zext i1 %101 to i32
  %103 = load i32, ptr %7, align 4, !tbaa !5
  %104 = add nsw i32 %103, %102
  store i32 %104, ptr %7, align 4, !tbaa !5
  br label %105

105:                                              ; preds = %90
  %106 = load i32, ptr %13, align 4, !tbaa !5
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %13, align 4, !tbaa !5
  br label %85, !llvm.loop !12

108:                                              ; preds = %89
  br label %109

109:                                              ; preds = %108, %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = add nsw i32 %110, 1
  store i32 %111, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #5
  br label %112

112:                                              ; preds = %153, %109
  %113 = load i32, ptr %14, align 4, !tbaa !5
  %114 = load i32, ptr %9, align 4, !tbaa !5
  %115 = icmp slt i32 %113, %114
  br i1 %115, label %117, label %116

116:                                              ; preds = %112
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  br label %156

117:                                              ; preds = %112
  %118 = load i32, ptr %14, align 4, !tbaa !5
  %119 = sub nsw i32 %118, 1
  %120 = load i32, ptr @Size, align 4, !tbaa !5
  %121 = mul nsw i32 %119, %120
  %122 = add nsw i32 %121, 1
  store i32 %122, ptr %15, align 4, !tbaa !5
  %123 = load i32, ptr %14, align 4, !tbaa !5
  %124 = load i32, ptr @Size, align 4, !tbaa !5
  %125 = mul nsw i32 %123, %124
  store i32 %125, ptr %16, align 4, !tbaa !5
  %126 = load i32, ptr @Size, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = load i32, ptr %15, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds i32, ptr @cha, i64 %129
  %131 = load i32, ptr %16, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds i32, ptr @cha, i64 %132
  %134 = getelementptr inbounds i32, ptr %133, i64 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #5
  %135 = load i32, ptr %6, align 4, !tbaa !5
  %136 = load i32, ptr %14, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [1010 x i32], ptr @add, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = sub nsw i32 %135, %139
  store i32 %140, ptr %17, align 4, !tbaa !5
  %141 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef %130, ptr noundef %134, ptr noundef nonnull align 4 dereferenceable(4) %17)
  %142 = ptrtoint ptr %141 to i64
  %143 = sub i64 %142, ptrtoint (ptr @cha to i64)
  %144 = sdiv exact i64 %143, 4
  %145 = load i32, ptr %15, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = sub nsw i64 %144, %146
  %148 = sub nsw i64 %127, %147
  %149 = load i32, ptr %7, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = add nsw i64 %150, %148
  %152 = trunc i64 %151 to i32
  store i32 %152, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #5
  br label %153

153:                                              ; preds = %117
  %154 = load i32, ptr %14, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %14, align 4, !tbaa !5
  br label %112, !llvm.loop !13

156:                                              ; preds = %116
  %157 = load i32, ptr %7, align 4, !tbaa !5
  %158 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %157)
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret void
}

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

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

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

!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 = distinct !{!13, !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"

@val = external dso_local local_unnamed_addr global [1000010 x i32], align 16
@cha = external dso_local global [1000010 x i32], align 16
@add = external dso_local local_unnamed_addr global [1010 x i32], align 16
@Size = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [4 x i8], align 1

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z2Noi(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress 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 void @_Z5queryiii(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #2 {
  %4 = alloca i32, align 4
  %5 = tail call noundef i32 @_Z2Noi(i32 noundef %0)
  %6 = tail call noundef i32 @_Z2Noi(i32 noundef %1)
  %7 = icmp eq i32 %5, %6
  br i1 %7, label %.preheader, label %34

.preheader:                                       ; preds = %3
  %.not5061 = icmp sgt i32 %0, %1
  br i1 %.not5061, label %.loopexit, label %.lr.ph64

.lr.ph64:                                         ; preds = %.preheader
  %8 = sext i32 %5 to i64
  %9 = getelementptr inbounds [1010 x i32], ptr @add, i64 0, i64 %8
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = sext i32 %0 to i64
  %12 = add i32 %1, 1
  %13 = sub i32 %1, %0
  %14 = zext i32 %13 to i64
  %15 = add nuw nsw i64 %14, 1
  %min.iters.check130 = icmp ult i32 %13, 7
  br i1 %min.iters.check130, label %scalar.ph129.preheader, label %vector.ph131

vector.ph131:                                     ; preds = %.lr.ph64
  %n.vec133 = and i64 %15, 8589934584
  %ind.end134 = add nsw i64 %n.vec133, %11
  %broadcast.splatinsert143 = insertelement <4 x i32> poison, i32 %10, i64 0
  %broadcast.splat144 = shufflevector <4 x i32> %broadcast.splatinsert143, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert145 = insertelement <4 x i32> poison, i32 %2, i64 0
  %broadcast.splat146 = shufflevector <4 x i32> %broadcast.splatinsert145, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body136

vector.body136:                                   ; preds = %vector.body136, %vector.ph131
  %index137 = phi i64 [ 0, %vector.ph131 ], [ %index.next147, %vector.body136 ]
  %vec.phi138 = phi <4 x i32> [ zeroinitializer, %vector.ph131 ], [ %24, %vector.body136 ]
  %vec.phi139 = phi <4 x i32> [ zeroinitializer, %vector.ph131 ], [ %25, %vector.body136 ]
  %offset.idx140 = add i64 %index137, %11
  %16 = getelementptr inbounds [1000010 x i32], ptr @val, i64 0, i64 %offset.idx140
  %17 = getelementptr inbounds i8, ptr %16, i64 16
  %wide.load141 = load <4 x i32>, ptr %16, align 4, !tbaa !5
  %wide.load142 = load <4 x i32>, ptr %17, align 4, !tbaa !5
  %18 = add nsw <4 x i32> %broadcast.splat144, %wide.load141
  %19 = add nsw <4 x i32> %broadcast.splat144, %wide.load142
  %20 = icmp sge <4 x i32> %18, %broadcast.splat146
  %21 = icmp sge <4 x i32> %19, %broadcast.splat146
  %22 = zext <4 x i1> %20 to <4 x i32>
  %23 = zext <4 x i1> %21 to <4 x i32>
  %24 = add <4 x i32> %vec.phi138, %22
  %25 = add <4 x i32> %vec.phi139, %23
  %index.next147 = add nuw i64 %index137, 8
  %26 = icmp eq i64 %index.next147, %n.vec133
  br i1 %26, label %middle.block128, label %vector.body136, !llvm.loop !9

middle.block128:                                  ; preds = %vector.body136
  %bin.rdx148 = add <4 x i32> %25, %24
  %27 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx148)
  %cmp.n149 = icmp eq i64 %15, %n.vec133
  br i1 %cmp.n149, label %.loopexit, label %scalar.ph129.preheader

scalar.ph129.preheader:                           ; preds = %middle.block128, %.lr.ph64
  %indvars.iv83.ph = phi i64 [ %11, %.lr.ph64 ], [ %ind.end134, %middle.block128 ]
  %.063.ph = phi i32 [ 0, %.lr.ph64 ], [ %27, %middle.block128 ]
  br label %scalar.ph129

scalar.ph129:                                     ; preds = %scalar.ph129.preheader, %scalar.ph129
  %indvars.iv83 = phi i64 [ %indvars.iv.next84, %scalar.ph129 ], [ %indvars.iv83.ph, %scalar.ph129.preheader ]
  %.063 = phi i32 [ %33, %scalar.ph129 ], [ %.063.ph, %scalar.ph129.preheader ]
  %28 = getelementptr inbounds [1000010 x i32], ptr @val, i64 0, i64 %indvars.iv83
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = add nsw i32 %10, %29
  %31 = icmp sge i32 %30, %2
  %32 = zext i1 %31 to i32
  %33 = add nuw nsw i32 %.063, %32
  %indvars.iv.next84 = add nsw i64 %indvars.iv83, 1
  %lftr.wideiv86 = trunc i64 %indvars.iv.next84 to i32
  %exitcond87.not = icmp eq i32 %12, %lftr.wideiv86
  br i1 %exitcond87.not, label %.loopexit, label %scalar.ph129, !llvm.loop !13

34:                                               ; preds = %3
  %35 = load i32, ptr @Size, align 4, !tbaa !5
  %36 = mul nsw i32 %35, %5
  %.not52 = icmp slt i32 %36, %0
  br i1 %.not52, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %34
  %37 = sext i32 %5 to i64
  %38 = getelementptr inbounds [1010 x i32], ptr @add, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %0 to i64
  %41 = add i32 %36, 1
  %42 = sub i32 %36, %0
  %43 = zext i32 %42 to i64
  %44 = add nuw nsw i64 %43, 1
  %min.iters.check = icmp ult i32 %42, 7
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph
  %indvars.iv.ph = phi i64 [ %40, %.lr.ph ], [ %ind.end, %middle.block ]
  %.154.ph = phi i32 [ 0, %.lr.ph ], [ %56, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %44, 8589934584
  %ind.end = add nsw i64 %n.vec, %40
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %39, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert103 = insertelement <4 x i32> poison, i32 %2, i64 0
  %broadcast.splat104 = shufflevector <4 x i32> %broadcast.splatinsert103, <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 ], [ %53, %vector.body ]
  %vec.phi101 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %54, %vector.body ]
  %offset.idx = add i64 %index, %40
  %45 = getelementptr inbounds [1000010 x i32], ptr @val, i64 0, i64 %offset.idx
  %46 = getelementptr inbounds i8, ptr %45, i64 16
  %wide.load = load <4 x i32>, ptr %45, align 4, !tbaa !5
  %wide.load102 = load <4 x i32>, ptr %46, align 4, !tbaa !5
  %47 = add nsw <4 x i32> %broadcast.splat, %wide.load
  %48 = add nsw <4 x i32> %broadcast.splat, %wide.load102
  %49 = icmp sge <4 x i32> %47, %broadcast.splat104
  %50 = icmp sge <4 x i32> %48, %broadcast.splat104
  %51 = zext <4 x i1> %49 to <4 x i32>
  %52 = zext <4 x i1> %50 to <4 x i32>
  %53 = add <4 x i32> %vec.phi, %51
  %54 = add <4 x i32> %vec.phi101, %52
  %index.next = add nuw i64 %index, 8
  %55 = icmp eq i64 %index.next, %n.vec
  br i1 %55, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <4 x i32> %54, %53
  %56 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  %cmp.n = icmp eq i64 %44, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge:                                      ; preds = %scalar.ph, %middle.block, %34
  %.1.lcssa = phi i32 [ 0, %34 ], [ %56, %middle.block ], [ %83, %scalar.ph ]
  %57 = add nsw i32 %6, -1
  %58 = mul nsw i32 %35, %57
  %.not49.not55 = icmp slt i32 %58, %1
  br i1 %.not49.not55, label %.lr.ph59, label %.loopexit

.lr.ph59:                                         ; preds = %._crit_edge
  %59 = sext i32 %6 to i64
  %60 = getelementptr inbounds [1010 x i32], ptr @add, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sext i32 %58 to i64
  %wide.trip.count = sext i32 %1 to i64
  %63 = sub nsw i64 %wide.trip.count, %62
  %min.iters.check107 = icmp ult i64 %63, 8
  br i1 %min.iters.check107, label %scalar.ph106.preheader, label %vector.ph108

scalar.ph106.preheader:                           ; preds = %middle.block105, %.lr.ph59
  %indvars.iv79.ph = phi i64 [ %62, %.lr.ph59 ], [ %ind.end111, %middle.block105 ]
  %.257.ph = phi i32 [ %.1.lcssa, %.lr.ph59 ], [ %77, %middle.block105 ]
  br label %scalar.ph106

vector.ph108:                                     ; preds = %.lr.ph59
  %n.vec110 = and i64 %63, -8
  %ind.end111 = add nsw i64 %n.vec110, %62
  %64 = insertelement <4 x i32> <i32 poison, i32 0, i32 0, i32 0>, i32 %.1.lcssa, i64 0
  %broadcast.splatinsert120 = insertelement <4 x i32> poison, i32 %61, i64 0
  %broadcast.splat121 = shufflevector <4 x i32> %broadcast.splatinsert120, <4 x i32> poison, <4 x i32> zeroinitializer
  %broadcast.splatinsert122 = insertelement <4 x i32> poison, i32 %2, i64 0
  %broadcast.splat123 = shufflevector <4 x i32> %broadcast.splatinsert122, <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.next124, %vector.body113 ]
  %vec.phi115 = phi <4 x i32> [ %64, %vector.ph108 ], [ %74, %vector.body113 ]
  %vec.phi116 = phi <4 x i32> [ zeroinitializer, %vector.ph108 ], [ %75, %vector.body113 ]
  %offset.idx117 = add i64 %index114, %62
  %65 = add nsw i64 %offset.idx117, 1
  %66 = getelementptr inbounds [1000010 x i32], ptr @val, i64 0, i64 %65
  %67 = getelementptr inbounds i8, ptr %66, i64 16
  %wide.load118 = load <4 x i32>, ptr %66, align 4, !tbaa !5
  %wide.load119 = load <4 x i32>, ptr %67, align 4, !tbaa !5
  %68 = add nsw <4 x i32> %broadcast.splat121, %wide.load118
  %69 = add nsw <4 x i32> %broadcast.splat121, %wide.load119
  %70 = icmp sge <4 x i32> %68, %broadcast.splat123
  %71 = icmp sge <4 x i32> %69, %broadcast.splat123
  %72 = zext <4 x i1> %70 to <4 x i32>
  %73 = zext <4 x i1> %71 to <4 x i32>
  %74 = add <4 x i32> %vec.phi115, %72
  %75 = add <4 x i32> %vec.phi116, %73
  %index.next124 = add nuw i64 %index114, 8
  %76 = icmp eq i64 %index.next124, %n.vec110
  br i1 %76, label %middle.block105, label %vector.body113, !llvm.loop !15

middle.block105:                                  ; preds = %vector.body113
  %bin.rdx125 = add <4 x i32> %75, %74
  %77 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx125)
  %cmp.n126 = icmp eq i64 %63, %n.vec110
  br i1 %cmp.n126, label %.loopexit, label %scalar.ph106.preheader

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %.154 = phi i32 [ %83, %scalar.ph ], [ %.154.ph, %scalar.ph.preheader ]
  %78 = getelementptr inbounds [1000010 x i32], ptr @val, i64 0, i64 %indvars.iv
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = add nsw i32 %39, %79
  %81 = icmp sge i32 %80, %2
  %82 = zext i1 %81 to i32
  %83 = add nuw nsw i32 %.154, %82
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next to i32
  %exitcond.not = icmp eq i32 %41, %lftr.wideiv
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !16

scalar.ph106:                                     ; preds = %scalar.ph106.preheader, %scalar.ph106
  %indvars.iv79 = phi i64 [ %indvars.iv.next80, %scalar.ph106 ], [ %indvars.iv79.ph, %scalar.ph106.preheader ]
  %.257 = phi i32 [ %89, %scalar.ph106 ], [ %.257.ph, %scalar.ph106.preheader ]
  %indvars.iv.next80 = add nsw i64 %indvars.iv79, 1
  %84 = getelementptr inbounds [1000010 x i32], ptr @val, i64 0, i64 %indvars.iv.next80
  %85 = load i32, ptr %84, align 4, !tbaa !5
  %86 = add nsw i32 %61, %85
  %87 = icmp sge i32 %86, %2
  %88 = zext i1 %87 to i32
  %89 = add nuw nsw i32 %.257, %88
  %exitcond82.not = icmp eq i64 %indvars.iv.next80, %wide.trip.count
  br i1 %exitcond82.not, label %.loopexit, label %scalar.ph106, !llvm.loop !17

.loopexit:                                        ; preds = %scalar.ph106, %scalar.ph129, %middle.block105, %middle.block128, %._crit_edge, %.preheader
  %.3 = phi i32 [ 0, %.preheader ], [ %.1.lcssa, %._crit_edge ], [ %27, %middle.block128 ], [ %77, %middle.block105 ], [ %33, %scalar.ph129 ], [ %89, %scalar.ph106 ]
  %.04366 = add nsw i32 %5, 1
  %90 = icmp slt i32 %.04366, %6
  br i1 %90, label %.lr.ph71.preheader, label %._crit_edge72

.lr.ph71.preheader:                               ; preds = %.loopexit
  %91 = sext i32 %.04366 to i64
  br label %.lr.ph71

._crit_edge72:                                    ; preds = %.lr.ph71, %.loopexit
  %.4.lcssa = phi i32 [ %.3, %.loopexit ], [ %110, %.lr.ph71 ]
  %92 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.4.lcssa)
  ret void

.lr.ph71:                                         ; preds = %.lr.ph71.preheader, %.lr.ph71
  %indvars.iv88 = phi i64 [ %91, %.lr.ph71.preheader ], [ %indvars.iv.next89, %.lr.ph71 ]
  %.468 = phi i32 [ %.3, %.lr.ph71.preheader ], [ %110, %.lr.ph71 ]
  %.043.in67 = phi i32 [ %5, %.lr.ph71.preheader ], [ %111, %.lr.ph71 ]
  %93 = load i32, ptr @Size, align 4, !tbaa !5
  %94 = mul nsw i32 %93, %.043.in67
  %95 = add nsw i32 %94, 1
  %96 = sext i32 %93 to i64
  %97 = mul nsw i64 %indvars.iv88, %96
  %98 = sext i32 %95 to i64
  %99 = getelementptr inbounds i32, ptr @cha, i64 %98
  %gep = getelementptr i32, ptr getelementptr inbounds (i8, ptr @cha, i64 4), i64 %97
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #6
  %100 = getelementptr inbounds [1010 x i32], ptr @add, i64 0, i64 %indvars.iv88
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = sub nsw i32 %2, %101
  store i32 %102, ptr %4, align 4, !tbaa !5
  %103 = call noundef ptr @_ZSt11lower_boundIPiiET_S1_S1_RKT0_(ptr noundef nonnull %99, ptr noundef nonnull %gep, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %104 = ptrtoint ptr %103 to i64
  %105 = sub i64 %104, ptrtoint (ptr @cha to i64)
  %106 = lshr exact i64 %105, 2
  %107 = trunc i64 %106 to i32
  %108 = add i32 %93, %.468
  %109 = add i32 %108, %95
  %110 = sub i32 %109, %107
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #6
  %indvars.iv.next89 = add nsw i64 %indvars.iv88, 1
  %111 = trunc nsw i64 %indvars.iv88 to i32
  %lftr.wideiv91 = trunc i64 %indvars.iv.next89 to i32
  %exitcond92.not = icmp eq i32 %6, %lftr.wideiv91
  br i1 %exitcond92.not, label %._crit_edge72, label %.lr.ph71, !llvm.loop !18
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { inlinehint 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 #2 = { 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 = { 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 #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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !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, !12, !11}
!14 = distinct !{!14, !10, !11, !12}
!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,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass