; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/225 Division 1/Problem D (D)

; 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_ostream" = type { ptr, %"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 }

@n = external dso_local global i32, align 4
@a = external dso_local global [1001 x i32], align 16
@off = external dso_local global i32, align 4
@MOD = external dso_local global i64, align 8
@dp = external dso_local global [2 x [21000 x i64]], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #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
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %19, %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr @n, align 4, !tbaa !5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %14, label %13

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

14:                                               ; preds = %9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %16
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %17)
  br label %19

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

22:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %23 = load i32, ptr @off, align 4, !tbaa !5
  %24 = load i32, ptr @off, align 4, !tbaa !5
  %25 = add nsw i32 %23, %24
  store i32 %25, ptr %4, align 4, !tbaa !5
  %26 = load i32, ptr @off, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [21000 x i64], ptr @dp, i64 0, i64 %27
  store i64 1, ptr %28, align 8, !tbaa !11
  %29 = load i32, ptr @off, align 4, !tbaa !5
  %30 = load i32, ptr @a, align 16, !tbaa !5
  %31 = add nsw i32 %29, %30
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [21000 x i64], ptr @dp, i64 0, i64 %32
  store i64 1, ptr %33, align 8, !tbaa !11
  %34 = load i32, ptr @off, align 4, !tbaa !5
  %35 = load i32, ptr @a, align 16, !tbaa !5
  %36 = sub nsw i32 %34, %35
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [21000 x i64], ptr @dp, i64 0, i64 %37
  store i64 1, ptr %38, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %152, %22
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = load i32, ptr @n, align 4, !tbaa !5
  %42 = icmp slt i32 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %155

44:                                               ; preds = %39
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = xor i32 %45, 1
  store i32 %46, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %129, %44
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = icmp sle i32 %48, %49
  br i1 %50, label %52, label %51

51:                                               ; preds = %47
  store i32 8, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %132

52:                                               ; preds = %47
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %54
  %56 = load i32, ptr %7, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [21000 x i64], ptr %55, i64 0, i64 %57
  store i64 0, ptr %58, align 8, !tbaa !11
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = load i32, ptr %5, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = sub nsw i32 %59, %63
  %65 = icmp sge i32 %64, 0
  br i1 %65, label %66, label %88

66:                                               ; preds = %52
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = sub nsw i32 1, %67
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %69
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = load i32, ptr %5, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = sub nsw i32 %71, %75
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [21000 x i64], ptr %70, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !11
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %81
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [21000 x i64], ptr %82, i64 0, i64 %84
  %86 = load i64, ptr %85, align 8, !tbaa !11
  %87 = add nsw i64 %86, %79
  store i64 %87, ptr %85, align 8, !tbaa !11
  br label %88

88:                                               ; preds = %66, %52
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = add nsw i32 %89, %93
  %95 = load i32, ptr %4, align 4, !tbaa !5
  %96 = icmp sle i32 %94, %95
  br i1 %96, label %97, label %119

97:                                               ; preds = %88
  %98 = load i32, ptr %3, align 4, !tbaa !5
  %99 = sub nsw i32 1, %98
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %100
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = load i32, ptr %5, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !5
  %107 = add nsw i32 %102, %106
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [21000 x i64], ptr %101, i64 0, i64 %108
  %110 = load i64, ptr %109, align 8, !tbaa !11
  %111 = load i32, ptr %3, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %112
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [21000 x i64], ptr %113, i64 0, i64 %115
  %117 = load i64, ptr %116, align 8, !tbaa !11
  %118 = add nsw i64 %117, %110
  store i64 %118, ptr %116, align 8, !tbaa !11
  br label %119

119:                                              ; preds = %97, %88
  %120 = load i64, ptr @MOD, align 8, !tbaa !11
  %121 = load i32, ptr %3, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %122
  %124 = load i32, ptr %7, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [21000 x i64], ptr %123, i64 0, i64 %125
  %127 = load i64, ptr %126, align 8, !tbaa !11
  %128 = srem i64 %127, %120
  store i64 %128, ptr %126, align 8, !tbaa !11
  br label %129

129:                                              ; preds = %119
  %130 = load i32, ptr %7, align 4, !tbaa !5
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr %7, align 4, !tbaa !5
  br label %47, !llvm.loop !13

132:                                              ; preds = %51
  %133 = load i64, ptr @ans, align 8, !tbaa !11
  %134 = load i32, ptr %3, align 4, !tbaa !5
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %135
  %137 = load i32, ptr @off, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [21000 x i64], ptr %136, i64 0, i64 %138
  %140 = load i64, ptr %139, align 8, !tbaa !11
  %141 = add nsw i64 %133, %140
  %142 = load i64, ptr @MOD, align 8, !tbaa !11
  %143 = srem i64 %141, %142
  store i64 %143, ptr @ans, align 8, !tbaa !11
  %144 = load i32, ptr %3, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %145
  %147 = load i32, ptr @off, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [21000 x i64], ptr %146, i64 0, i64 %148
  %150 = load i64, ptr %149, align 8, !tbaa !11
  %151 = add nsw i64 %150, 1
  store i64 %151, ptr %149, align 8, !tbaa !11
  br label %152

152:                                              ; preds = %132
  %153 = load i32, ptr %5, align 4, !tbaa !5
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr %5, align 4, !tbaa !5
  br label %39, !llvm.loop !14

155:                                              ; preds = %43
  %156 = load i64, ptr @ans, align 8, !tbaa !11
  %157 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %156)
  %158 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %157, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  %159 = load i32, ptr %1, align 4
  ret i32 %159
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #1

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #4

attributes #0 = { mustprogress norecurse 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 = { "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 willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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_ostream" = type { ptr, %"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 }

@n = external dso_local global i32, align 4
@a = external dso_local global [1001 x i32], align 16
@off = external dso_local local_unnamed_addr global i32, align 4
@MOD = external dso_local local_unnamed_addr global i64, align 8
@dp = external dso_local local_unnamed_addr global [2 x [21000 x i64]], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  %.lcssa = phi i32 [ %2, %0 ], [ %34, %.lr.ph ]
  %4 = load i32, ptr @off, align 4, !tbaa !5
  %5 = shl i32 %4, 1
  %6 = sext i32 %4 to i64
  %7 = getelementptr inbounds [21000 x i64], ptr @dp, i64 0, i64 %6
  store i64 1, ptr %7, align 8, !tbaa !9
  %8 = load i32, ptr @a, align 16, !tbaa !5
  %9 = add nsw i32 %8, %4
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [21000 x i64], ptr @dp, i64 0, i64 %10
  store i64 1, ptr %11, align 8, !tbaa !9
  %12 = sub nsw i32 %4, %8
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [21000 x i64], ptr @dp, i64 0, i64 %13
  store i64 1, ptr %14, align 8, !tbaa !9
  %15 = icmp sgt i32 %.lcssa, 1
  %ans.promoted = load i64, ptr @ans, align 8, !tbaa !9
  br i1 %15, label %.lr.ph47, label %._crit_edge._crit_edge

.lr.ph47:                                         ; preds = %._crit_edge
  %.not39 = icmp slt i32 %4, 0
  %16 = load i64, ptr @MOD, align 8
  br i1 %.not39, label %.lr.ph47.split.us.preheader, label %.lr.ph42.preheader

.lr.ph47.split.us.preheader:                      ; preds = %.lr.ph47
  %17 = add nsw i32 %.lcssa, -1
  %xtraiter = and i32 %17, 1
  %18 = icmp eq i32 %.lcssa, 2
  br i1 %18, label %._crit_edge48.loopexit.unr-lcssa, label %.lr.ph47.split.us.preheader.new

.lr.ph47.split.us.preheader.new:                  ; preds = %.lr.ph47.split.us.preheader
  %unroll_iter = and i32 %17, -2
  %19 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 1, i64 %6
  %20 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 0, i64 %6
  %.promoted = load i64, ptr %19, align 8, !tbaa !9
  %.promoted81 = load i64, ptr %20, align 8, !tbaa !9
  br label %.lr.ph47.split.us

.lr.ph42.preheader:                               ; preds = %.lr.ph47
  %21 = sext i32 %5 to i64
  %smax = tail call i32 @llvm.smax.i32(i32 %5, i32 0)
  %22 = or disjoint i32 %smax, 1
  %wide.trip.count61 = zext nneg i32 %.lcssa to i64
  %wide.trip.count = zext nneg i32 %22 to i64
  br label %.lr.ph42

.lr.ph47.split.us:                                ; preds = %.lr.ph47.split.us, %.lr.ph47.split.us.preheader.new
  %23 = phi i64 [ %.promoted81, %.lr.ph47.split.us.preheader.new ], [ %31, %.lr.ph47.split.us ]
  %24 = phi i64 [ %.promoted, %.lr.ph47.split.us.preheader.new ], [ %28, %.lr.ph47.split.us ]
  %25 = phi i64 [ %ans.promoted, %.lr.ph47.split.us.preheader.new ], [ %30, %.lr.ph47.split.us ]
  %niter = phi i32 [ 0, %.lr.ph47.split.us.preheader.new ], [ %niter.next.1, %.lr.ph47.split.us ]
  %26 = add nsw i64 %24, %25
  %27 = srem i64 %26, %16
  %28 = add nsw i64 %24, 1
  %29 = add nsw i64 %23, %27
  %30 = srem i64 %29, %16
  %31 = add nsw i64 %23, 1
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge48.loopexit.unr-lcssa.loopexit, label %.lr.ph47.split.us, !llvm.loop !11

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %32 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %indvars.iv
  %33 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %32)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = icmp slt i64 %indvars.iv.next, %35
  br i1 %36, label %.lr.ph, label %._crit_edge, !llvm.loop !13

._crit_edge48.loopexit.unr-lcssa.loopexit:        ; preds = %.lr.ph47.split.us
  store i64 %28, ptr %19, align 8, !tbaa !9
  store i64 %31, ptr %20, align 8, !tbaa !9
  br label %._crit_edge48.loopexit.unr-lcssa

._crit_edge48.loopexit.unr-lcssa:                 ; preds = %._crit_edge48.loopexit.unr-lcssa.loopexit, %.lr.ph47.split.us.preheader
  %.lcssa72.ph = phi i64 [ poison, %.lr.ph47.split.us.preheader ], [ %30, %._crit_edge48.loopexit.unr-lcssa.loopexit ]
  %.unr = phi i64 [ %ans.promoted, %.lr.ph47.split.us.preheader ], [ %30, %._crit_edge48.loopexit.unr-lcssa.loopexit ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge48, label %.lr.ph47.split.us.epil

.lr.ph47.split.us.epil:                           ; preds = %._crit_edge48.loopexit.unr-lcssa
  %37 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 1, i64 %6
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = add nsw i64 %38, %.unr
  %40 = srem i64 %39, %16
  %41 = add nsw i64 %38, 1
  store i64 %41, ptr %37, align 8, !tbaa !9
  br label %._crit_edge48

._crit_edge48:                                    ; preds = %._crit_edge43, %.lr.ph47.split.us.epil, %._crit_edge48.loopexit.unr-lcssa
  %.us-phi = phi i64 [ %.lcssa72.ph, %._crit_edge48.loopexit.unr-lcssa ], [ %40, %.lr.ph47.split.us.epil ], [ %56, %._crit_edge43 ]
  store i64 %.us-phi, ptr @ans, align 8, !tbaa !9
  br label %._crit_edge._crit_edge

._crit_edge._crit_edge:                           ; preds = %._crit_edge, %._crit_edge48
  %42 = phi i64 [ %.us-phi, %._crit_edge48 ], [ %ans.promoted, %._crit_edge ]
  %43 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %42)
  %44 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %43, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.lr.ph42:                                         ; preds = %.lr.ph42.preheader, %._crit_edge43
  %indvars.iv58 = phi i64 [ 1, %.lr.ph42.preheader ], [ %indvars.iv.next59, %._crit_edge43 ]
  %.03244 = phi i32 [ 0, %.lr.ph42.preheader ], [ %46, %._crit_edge43 ]
  %45 = phi i64 [ %ans.promoted, %.lr.ph42.preheader ], [ %56, %._crit_edge43 ]
  %46 = xor i32 %.03244, 1
  %47 = zext nneg i32 %46 to i64
  %48 = getelementptr inbounds [1001 x i32], ptr @a, i64 0, i64 %indvars.iv58
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = sub nuw nsw i32 1, %46
  %51 = zext nneg i32 %50 to i64
  %52 = sext i32 %49 to i64
  br label %58

._crit_edge43:                                    ; preds = %72
  %53 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %47, i64 %6
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = add nsw i64 %54, %45
  %56 = srem i64 %55, %16
  %57 = add nsw i64 %54, 1
  store i64 %57, ptr %53, align 8, !tbaa !9
  %indvars.iv.next59 = add nuw nsw i64 %indvars.iv58, 1
  %exitcond62.not = icmp eq i64 %indvars.iv.next59, %wide.trip.count61
  br i1 %exitcond62.not, label %._crit_edge48, label %.lr.ph42, !llvm.loop !11

58:                                               ; preds = %.lr.ph42, %72
  %indvars.iv55 = phi i64 [ 0, %.lr.ph42 ], [ %indvars.iv.next56, %72 ]
  %59 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %47, i64 %indvars.iv55
  store i64 0, ptr %59, align 8, !tbaa !9
  %60 = sub nsw i64 %indvars.iv55, %52
  %61 = icmp sgt i64 %60, -1
  br i1 %61, label %62, label %65

62:                                               ; preds = %58
  %63 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %51, i64 %60
  %64 = load i64, ptr %63, align 8, !tbaa !9
  store i64 %64, ptr %59, align 8, !tbaa !9
  br label %65

65:                                               ; preds = %62, %58
  %66 = phi i64 [ %64, %62 ], [ 0, %58 ]
  %67 = add nsw i64 %indvars.iv55, %52
  %.not37 = icmp sgt i64 %67, %21
  br i1 %.not37, label %72, label %68

68:                                               ; preds = %65
  %69 = getelementptr inbounds [2 x [21000 x i64]], ptr @dp, i64 0, i64 %51, i64 %67
  %70 = load i64, ptr %69, align 8, !tbaa !9
  %71 = add nsw i64 %66, %70
  br label %72

72:                                               ; preds = %68, %65
  %73 = phi i64 [ %71, %68 ], [ %66, %65 ]
  %74 = srem i64 %73, %16
  store i64 %74, ptr %59, align 8, !tbaa !9
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next56, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge43, label %58, !llvm.loop !14
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #2 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #2 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #4

attributes #0 = { mustprogress norecurse 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 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 #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 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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