; LLVM IR from Tunghohin/Competitive_Coding :: Daimayuan/328_KM2020_C.ll (Z5solvev)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@dp = external dso_local global [5010 x [5010 x i32]], align 16
@arr = external dso_local global [5010 x i32], align 16
@nxt = external dso_local global [5010 x i32], align 16
@pos = external dso_local global [5010 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %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
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %25, %0
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = icmp sle i32 %15, %16
  br i1 %17, label %19, label %18

18:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %28

19:                                               ; preds = %14
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [5010 x i32], ptr @pos, i64 0, i64 %23
  store i32 %21, ptr %24, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %19
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

28:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %58, %28
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = icmp sle i32 %30, %31
  br i1 %32, label %34, label %33

33:                                               ; preds = %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %61

34:                                               ; preds = %29
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [5010 x i32], ptr @arr, i64 0, i64 %36
  %38 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %37)
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = icmp ne i32 %39, 1
  br i1 %40, label %41, label %57

41:                                               ; preds = %34
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [5010 x i32], ptr @arr, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sub nsw i32 %46, 1
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [5010 x i32], ptr @arr, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = icmp eq i32 %45, %50
  br i1 %51, label %52, label %57

52:                                               ; preds = %41
  %53 = load i32, ptr %1, align 4, !tbaa !5
  %54 = add nsw i32 %53, -1
  store i32 %54, ptr %1, align 4, !tbaa !5
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = add nsw i32 %55, -1
  store i32 %56, ptr %3, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %52, %41, %34
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %3, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %3, align 4, !tbaa !5
  br label %29, !llvm.loop !11

61:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %85, %61
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = load i32, ptr %1, align 4, !tbaa !5
  %65 = icmp sle i32 %63, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %62
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %88

67:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %68 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %68, ptr %6, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %81, %67
  %70 = load i32, ptr %6, align 4, !tbaa !5
  %71 = load i32, ptr %1, align 4, !tbaa !5
  %72 = icmp sle i32 %70, %71
  br i1 %72, label %74, label %73

73:                                               ; preds = %69
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %84

74:                                               ; preds = %69
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %76
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [5010 x i32], ptr %77, i64 0, i64 %79
  store i32 0, ptr %80, align 4, !tbaa !5
  br label %81

81:                                               ; preds = %74
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = add nsw i32 %82, 1
  store i32 %83, ptr %6, align 4, !tbaa !5
  br label %69, !llvm.loop !12

84:                                               ; preds = %73
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %4, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %4, align 4, !tbaa !5
  br label %62, !llvm.loop !13

88:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %89 = load i32, ptr %1, align 4, !tbaa !5
  store i32 %89, ptr %7, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %112, %88
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = icmp sge i32 %91, 1
  br i1 %92, label %94, label %93

93:                                               ; preds = %90
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %115

94:                                               ; preds = %90
  %95 = load i32, ptr %7, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [5010 x i32], ptr @arr, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [5010 x i32], ptr @pos, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [5010 x i32], ptr @nxt, i64 0, i64 %103
  store i32 %101, ptr %104, align 4, !tbaa !5
  %105 = load i32, ptr %7, align 4, !tbaa !5
  %106 = load i32, ptr %7, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [5010 x i32], ptr @arr, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [5010 x i32], ptr @pos, i64 0, i64 %110
  store i32 %105, ptr %111, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %94
  %113 = load i32, ptr %7, align 4, !tbaa !5
  %114 = add nsw i32 %113, -1
  store i32 %114, ptr %7, align 4, !tbaa !5
  br label %90, !llvm.loop !14

115:                                              ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %197, %115
  %117 = load i32, ptr %8, align 4, !tbaa !5
  %118 = load i32, ptr %1, align 4, !tbaa !5
  %119 = icmp slt i32 %117, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %116
  store i32 17, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %200

121:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %193, %121
  %123 = load i32, ptr %9, align 4, !tbaa !5
  %124 = load i32, ptr %8, align 4, !tbaa !5
  %125 = add nsw i32 %123, %124
  %126 = load i32, ptr %1, align 4, !tbaa !5
  %127 = icmp sle i32 %125, %126
  br i1 %127, label %129, label %128

128:                                              ; preds = %122
  store i32 20, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %196

129:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %130 = load i32, ptr %9, align 4, !tbaa !5
  %131 = load i32, ptr %8, align 4, !tbaa !5
  %132 = add nsw i32 %130, %131
  store i32 %132, ptr %10, align 4, !tbaa !5
  %133 = load i32, ptr %9, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %135
  %137 = load i32, ptr %10, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [5010 x i32], ptr %136, i64 0, i64 %138
  %140 = load i32, ptr %139, align 4, !tbaa !5
  %141 = load i32, ptr %9, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %142
  %144 = load i32, ptr %10, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [5010 x i32], ptr %143, i64 0, i64 %145
  store i32 %140, ptr %146, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %147 = load i32, ptr %9, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [5010 x i32], ptr @nxt, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  store i32 %150, ptr %11, align 4, !tbaa !5
  br label %151

151:                                              ; preds = %155, %129
  %152 = load i32, ptr %11, align 4, !tbaa !5
  %153 = load i32, ptr %10, align 4, !tbaa !5
  %154 = icmp sle i32 %152, %153
  br i1 %154, label %155, label %192

155:                                              ; preds = %151
  %156 = load i32, ptr %9, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %157
  %159 = load i32, ptr %10, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [5010 x i32], ptr %158, i64 0, i64 %160
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %162 = load i32, ptr %9, align 4, !tbaa !5
  %163 = add nsw i32 %162, 1
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %164
  %166 = load i32, ptr %11, align 4, !tbaa !5
  %167 = sub nsw i32 %166, 1
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [5010 x i32], ptr %165, i64 0, i64 %168
  %170 = load i32, ptr %169, align 4, !tbaa !5
  %171 = add nsw i32 %170, 1
  %172 = load i32, ptr %11, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %173
  %175 = load i32, ptr %10, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [5010 x i32], ptr %174, i64 0, i64 %176
  %178 = load i32, ptr %177, align 4, !tbaa !5
  %179 = add nsw i32 %171, %178
  store i32 %179, ptr %12, align 4, !tbaa !5
  %180 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %161, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %181 = load i32, ptr %180, align 4, !tbaa !5
  %182 = load i32, ptr %9, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %183
  %185 = load i32, ptr %10, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [5010 x i32], ptr %184, i64 0, i64 %186
  store i32 %181, ptr %187, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  %188 = load i32, ptr %11, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [5010 x i32], ptr @nxt, i64 0, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !5
  store i32 %191, ptr %11, align 4, !tbaa !5
  br label %151, !llvm.loop !15

192:                                              ; preds = %151
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %193

193:                                              ; preds = %192
  %194 = load i32, ptr %9, align 4, !tbaa !5
  %195 = add nsw i32 %194, 1
  store i32 %195, ptr %9, align 4, !tbaa !5
  br label %122, !llvm.loop !16

196:                                              ; preds = %128
  br label %197

197:                                              ; preds = %196
  %198 = load i32, ptr %8, align 4, !tbaa !5
  %199 = add nsw i32 %198, 1
  store i32 %199, ptr %8, align 4, !tbaa !5
  br label %116, !llvm.loop !17

200:                                              ; preds = %120
  %201 = load i32, ptr %1, align 4, !tbaa !5
  %202 = sub nsw i32 %201, 1
  %203 = load i32, ptr %1, align 4, !tbaa !5
  %204 = sext i32 %203 to i64
  %205 = getelementptr inbounds [5010 x i32], ptr getelementptr inbounds ([5010 x [5010 x i32]], ptr @dp, i64 0, i64 1), i64 0, i64 %204
  %206 = load i32, ptr %205, align 4, !tbaa !5
  %207 = sub nsw i32 %202, %206
  %208 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %207)
  %209 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %208, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret void
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #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}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@dp = external dso_local global [5010 x [5010 x i32]], align 16
@arr = external dso_local global [5010 x i32], align 16
@nxt = external dso_local local_unnamed_addr global [5010 x i32], align 16
@pos = external dso_local local_unnamed_addr global [5010 x i32], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  %3 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %.not69 = icmp slt i32 %4, 1
  br i1 %.not69, label %.preheader63.._crit_edge88_crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %0
  %5 = add nuw i32 %4, 1
  %wide.trip.count = zext i32 %5 to i64
  %6 = zext nneg i32 %4 to i64
  %min.iters.check = icmp ult i32 %4, 8
  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 [ 1, %.lr.ph ], [ %ind.end, %middle.block ]
  br label %scalar.ph

vector.ph:                                        ; preds = %.lr.ph
  %n.vec = and i64 %6, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %5, 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 ]
  %offset.idx = or disjoint i64 %index, 1
  %7 = getelementptr inbounds [5010 x i32], ptr @pos, i64 0, i64 %offset.idx
  %8 = getelementptr inbounds i8, ptr %7, i64 16
  store <4 x i32> %broadcast.splat, ptr %7, align 4, !tbaa !5
  store <4 x i32> %broadcast.splat, ptr %8, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %9 = icmp eq i64 %index.next, %n.vec
  br i1 %9, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %6
  br i1 %cmp.n, label %.preheader67, label %scalar.ph.preheader

.preheader67:                                     ; preds = %scalar.ph, %middle.block
  br i1 %.not69, label %.preheader63.._crit_edge88_crit_edge, label %.lr.ph73

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %10 = getelementptr inbounds [5010 x i32], ptr @pos, i64 0, i64 %indvars.iv
  store i32 %5, ptr %10, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.preheader67, label %scalar.ph, !llvm.loop !13

.preheader66:                                     ; preds = %24
  %.not5875 = icmp slt i32 %25, 1
  br i1 %.not5875, label %.preheader63.._crit_edge88_crit_edge, label %.preheader65.preheader

.preheader65.preheader:                           ; preds = %.preheader66
  %wide.trip.count99 = zext nneg i32 %25 to i64
  %xtraiter = and i64 %wide.trip.count99, 1
  %11 = icmp eq i32 %25, 1
  br i1 %11, label %.lr.ph78.preheader.unr-lcssa, label %.preheader65.preheader.new

.preheader65.preheader.new:                       ; preds = %.preheader65.preheader
  %unroll_iter = and i64 %wide.trip.count99, 2147483646
  br label %.preheader65

.lr.ph73:                                         ; preds = %.preheader67, %24
  %.05272 = phi i32 [ %26, %24 ], [ 1, %.preheader67 ]
  %12 = sext i32 %.05272 to i64
  %13 = getelementptr inbounds [5010 x i32], ptr @arr, i64 0, i64 %12
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %13)
  %.not62 = icmp eq i32 %.05272, 1
  br i1 %.not62, label %.lr.ph73._crit_edge, label %15

.lr.ph73._crit_edge:                              ; preds = %.lr.ph73
  %.pre = load i32, ptr %1, align 4, !tbaa !5
  br label %24

15:                                               ; preds = %.lr.ph73
  %16 = load i32, ptr %13, align 4, !tbaa !5
  %17 = add nsw i32 %.05272, -1
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [5010 x i32], ptr @arr, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = icmp eq i32 %16, %20
  %.pre110 = load i32, ptr %1, align 4, !tbaa !5
  br i1 %21, label %22, label %24

22:                                               ; preds = %15
  %23 = add nsw i32 %.pre110, -1
  store i32 %23, ptr %1, align 4, !tbaa !5
  br label %24

24:                                               ; preds = %.lr.ph73._crit_edge, %15, %22
  %25 = phi i32 [ %23, %22 ], [ %.pre110, %15 ], [ %.pre, %.lr.ph73._crit_edge ]
  %.1 = phi i32 [ %17, %22 ], [ %.05272, %15 ], [ 1, %.lr.ph73._crit_edge ]
  %26 = add nsw i32 %.1, 1
  %.not57.not = icmp slt i32 %.1, %25
  br i1 %.not57.not, label %.lr.ph73, label %.preheader66, !llvm.loop !14

.preheader65:                                     ; preds = %.preheader65, %.preheader65.preheader.new
  %indvar = phi i64 [ 0, %.preheader65.preheader.new ], [ %indvar.next.1, %.preheader65 ]
  %niter = phi i64 [ 0, %.preheader65.preheader.new ], [ %niter.next.1, %.preheader65 ]
  %27 = mul nuw nsw i64 %indvar, 20044
  %gep = getelementptr i8, ptr getelementptr inbounds (i8, ptr @dp, i64 20044), i64 %27
  %28 = trunc i64 %indvar to i32
  %29 = xor i32 %28, -1
  %30 = add i32 %25, %29
  %31 = zext i32 %30 to i64
  %32 = shl nuw nsw i64 %31, 2
  %33 = add nuw nsw i64 %32, 4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %gep, i8 0, i64 %33, i1 false), !tbaa !5
  %indvar.next = or disjoint i64 %indvar, 1
  %34 = mul nuw nsw i64 %indvar.next, 20044
  %gep.1 = getelementptr i8, ptr getelementptr inbounds (i8, ptr @dp, i64 20044), i64 %34
  %35 = trunc i64 %indvar.next to i32
  %36 = xor i32 %35, -1
  %37 = add i32 %25, %36
  %38 = zext i32 %37 to i64
  %39 = shl nuw nsw i64 %38, 2
  %40 = add nuw nsw i64 %39, 4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(1) %gep.1, i8 0, i64 %40, i1 false), !tbaa !5
  %indvar.next.1 = add nuw nsw i64 %indvar, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.lr.ph78.preheader.unr-lcssa, label %.preheader65, !llvm.loop !15

.lr.ph78.preheader.unr-lcssa:                     ; preds = %.preheader65, %.preheader65.preheader
  %indvar.unr = phi i64 [ 0, %.preheader65.preheader ], [ %indvar.next.1, %.preheader65 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph78.preheader, label %.preheader65.epil

.preheader65.epil:                                ; preds = %.lr.ph78.preheader.unr-lcssa
  %41 = mul nuw nsw i64 %indvar.unr, 20044
  %gep.epil = getelementptr i8, ptr getelementptr inbounds (i8, ptr @dp, i64 20044), i64 %41
  %42 = trunc i64 %indvar.unr to i32
  %43 = xor i32 %42, -1
  %44 = add i32 %25, %43
  %45 = zext i32 %44 to i64
  %46 = shl nuw nsw i64 %45, 2
  %47 = add nuw nsw i64 %46, 4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(1) %gep.epil, i8 0, i64 %47, i1 false), !tbaa !5
  br label %.lr.ph78.preheader

.lr.ph78.preheader:                               ; preds = %.lr.ph78.preheader.unr-lcssa, %.preheader65.epil
  %48 = zext nneg i32 %25 to i64
  br label %.lr.ph78

.preheader63.._crit_edge88_crit_edge:             ; preds = %0, %.preheader67, %.preheader66
  %49 = phi i32 [ %25, %.preheader66 ], [ %4, %.preheader67 ], [ %4, %0 ]
  %.pre113 = sext i32 %49 to i64
  br label %._crit_edge88

.lr.ph78:                                         ; preds = %.lr.ph78.preheader, %.lr.ph78
  %indvars.iv101 = phi i64 [ %48, %.lr.ph78.preheader ], [ %indvars.iv.next102, %.lr.ph78 ]
  %50 = getelementptr inbounds [5010 x i32], ptr @arr, i64 0, i64 %indvars.iv101
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [5010 x i32], ptr @pos, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = getelementptr inbounds [5010 x i32], ptr @nxt, i64 0, i64 %indvars.iv101
  store i32 %54, ptr %55, align 4, !tbaa !5
  %56 = trunc nuw nsw i64 %indvars.iv101 to i32
  store i32 %56, ptr %53, align 4, !tbaa !5
  %indvars.iv.next102 = add nsw i64 %indvars.iv101, -1
  %57 = icmp ugt i64 %indvars.iv101, 1
  br i1 %57, label %.lr.ph78, label %.preheader, !llvm.loop !16

.preheader:                                       ; preds = %.lr.ph78, %._crit_edge
  %58 = phi i32 [ %71, %._crit_edge ], [ %25, %.lr.ph78 ]
  %indvars.iv107 = phi i64 [ %indvars.iv.next108, %._crit_edge ], [ 0, %.lr.ph78 ]
  %indvars.iv.next108 = add nuw nsw i64 %indvars.iv107, 1
  %59 = sext i32 %58 to i64
  %.not5984.not = icmp slt i64 %indvars.iv107, %59
  br i1 %.not5984.not, label %.lr.ph86.preheader, label %._crit_edge

.lr.ph86.preheader:                               ; preds = %.preheader
  %60 = trunc nuw nsw i64 %indvars.iv.next108 to i32
  br label %.lr.ph86

._crit_edge88:                                    ; preds = %._crit_edge, %.preheader63.._crit_edge88_crit_edge
  %.pre-phi114 = phi i64 [ %.pre113, %.preheader63.._crit_edge88_crit_edge ], [ %.pre-phi, %._crit_edge ]
  %.lcssa = phi i32 [ %49, %.preheader63.._crit_edge88_crit_edge ], [ %71, %._crit_edge ]
  %61 = getelementptr inbounds [5010 x i32], ptr getelementptr inbounds (i8, ptr @dp, i64 20040), i64 0, i64 %.pre-phi114
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = xor i32 %62, -1
  %64 = add i32 %.lcssa, %63
  %65 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %64)
  %66 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %65, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  ret void

.loopexit.loopexit:                               ; preds = %.lr.ph83
  %.pre111 = load i32, ptr %1, align 4, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.lr.ph86
  %67 = phi i32 [ %.pre111, %.loopexit.loopexit ], [ %73, %.lr.ph86 ]
  %68 = phi i32 [ %.pre111, %.loopexit.loopexit ], [ %74, %.lr.ph86 ]
  %69 = add nuw nsw i64 %indvars.iv.next105, %indvars.iv107
  %70 = trunc nuw i64 %69 to i32
  %.not59 = icmp slt i32 %68, %70
  br i1 %.not59, label %._crit_edge.loopexit, label %.lr.ph86, !llvm.loop !17

._crit_edge.loopexit:                             ; preds = %.loopexit
  %.pre112 = sext i32 %67 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %.pre-phi = phi i64 [ %.pre112, %._crit_edge.loopexit ], [ %59, %.preheader ]
  %71 = phi i32 [ %67, %._crit_edge.loopexit ], [ %58, %.preheader ]
  %72 = icmp slt i64 %indvars.iv.next108, %.pre-phi
  br i1 %72, label %.preheader, label %._crit_edge88, !llvm.loop !18

.lr.ph86:                                         ; preds = %.lr.ph86.preheader, %.loopexit
  %73 = phi i32 [ %58, %.lr.ph86.preheader ], [ %67, %.loopexit ]
  %74 = phi i32 [ %58, %.lr.ph86.preheader ], [ %68, %.loopexit ]
  %indvars.iv104 = phi i64 [ 1, %.lr.ph86.preheader ], [ %indvars.iv.next105, %.loopexit ]
  %75 = phi i32 [ %60, %.lr.ph86.preheader ], [ %70, %.loopexit ]
  %indvars.iv.next105 = add nuw nsw i64 %indvars.iv104, 1
  %76 = zext nneg i32 %75 to i64
  %77 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next105, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %indvars.iv104, i64 %76
  store i32 %78, ptr %79, align 4, !tbaa !5
  %.0.in79 = getelementptr inbounds [5010 x i32], ptr @nxt, i64 0, i64 %indvars.iv104
  %.080 = load i32, ptr %.0.in79, align 4, !tbaa !5
  %.not6081 = icmp sgt i32 %.080, %75
  br i1 %.not6081, label %.loopexit, label %.lr.ph83

.lr.ph83:                                         ; preds = %.lr.ph86, %.lr.ph83
  %.082 = phi i32 [ %.0, %.lr.ph83 ], [ %.080, %.lr.ph86 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %80 = add nsw i32 %.082, -1
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next105, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  %85 = sext i32 %.082 to i64
  %86 = getelementptr inbounds [5010 x [5010 x i32]], ptr @dp, i64 0, i64 %85, i64 %76
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = add nsw i32 %84, %87
  store i32 %88, ptr %2, align 4, !tbaa !5
  %89 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %79, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %90 = load i32, ptr %89, align 4, !tbaa !5
  store i32 %90, ptr %79, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  %.0.in = getelementptr inbounds [5010 x i32], ptr @nxt, i64 0, i64 %85
  %.0 = load i32, ptr %.0.in, align 4, !tbaa !5
  %.not60 = icmp sgt i32 %.0, %75
  br i1 %.not60, label %.loopexit.loopexit, label %.lr.ph83, !llvm.loop !19
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


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