; LLVM IR from Aryansh-S/USACO :: algo_ds/DP/CSES (bookshop)

; 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::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"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 }

@CLK = external dso_local global %"class.std::chrono::time_point", align 8
@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@pr = external dso_local global [1005 x i32], align 16
@pg = external dso_local global [1005 x i32], align 16
@dp = external dso_local global [1005 x [100005 x i32]], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

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

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

; Function Attrs: nounwind
declare i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca %"class.std::chrono::time_point", align 8
  %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
  store i32 0, ptr %1, align 4
  %9 = call noalias ptr @fopen(ptr noundef @.str, ptr noundef @.str.4)
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %16

11:                                               ; preds = %0
  %12 = load ptr, ptr @stdin, align 8, !tbaa !5
  %13 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.4, ptr noundef %12)
  %14 = load ptr, ptr @stdout, align 8, !tbaa !5
  %15 = call ptr @freopen(ptr noundef @.str.5, ptr noundef @.str.6, ptr noundef %14)
  br label %16

16:                                               ; preds = %11, %0
  %17 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %18 = getelementptr i8, ptr %17, i64 -24
  %19 = load i64, ptr %18, align 8
  %20 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %19
  %21 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %20, ptr noundef null)
  %22 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #8
  %23 = call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #8
  %24 = getelementptr inbounds %"class.std::chrono::time_point", ptr %2, i32 0, i32 0
  %25 = getelementptr inbounds %"class.std::chrono::duration", ptr %24, i32 0, i32 0
  store i64 %23, ptr %25, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 @CLK, ptr align 8 %2, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #8
  call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @x)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #8
  %26 = load i32, ptr @n, align 4, !tbaa !14
  %27 = add nsw i32 %26, 1
  %28 = icmp sgt i32 1, %27
  %29 = zext i1 %28 to i32
  %30 = sub nsw i32 1, %29
  store i32 %30, ptr %3, align 4, !tbaa !14
  br label %31

31:                                               ; preds = %56, %16
  %32 = load i32, ptr %3, align 4, !tbaa !14
  %33 = load i32, ptr @n, align 4, !tbaa !14
  %34 = add nsw i32 %33, 1
  %35 = load i32, ptr @n, align 4, !tbaa !14
  %36 = add nsw i32 %35, 1
  %37 = icmp sgt i32 1, %36
  %38 = zext i1 %37 to i32
  %39 = sub nsw i32 %34, %38
  %40 = icmp ne i32 %32, %39
  br i1 %40, label %42, label %41

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

42:                                               ; preds = %31
  %43 = load i32, ptr %3, align 4, !tbaa !14
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [1005 x i32], ptr @pr, i64 0, i64 %44
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %45)
  br label %46

46:                                               ; preds = %42
  %47 = load i32, ptr @n, align 4, !tbaa !14
  %48 = add nsw i32 %47, 1
  %49 = icmp sgt i32 1, %48
  br i1 %49, label %50, label %53

50:                                               ; preds = %46
  %51 = load i32, ptr %3, align 4, !tbaa !14
  %52 = add nsw i32 %51, -1
  store i32 %52, ptr %3, align 4, !tbaa !14
  br label %56

53:                                               ; preds = %46
  %54 = load i32, ptr %3, align 4, !tbaa !14
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %3, align 4, !tbaa !14
  br label %56

56:                                               ; preds = %53, %50
  %57 = phi ptr [ %3, %50 ], [ %3, %53 ]
  br label %31, !llvm.loop !16

58:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #8
  %59 = load i32, ptr @n, align 4, !tbaa !14
  %60 = add nsw i32 %59, 1
  %61 = icmp sgt i32 1, %60
  %62 = zext i1 %61 to i32
  %63 = sub nsw i32 1, %62
  store i32 %63, ptr %4, align 4, !tbaa !14
  br label %64

64:                                               ; preds = %89, %58
  %65 = load i32, ptr %4, align 4, !tbaa !14
  %66 = load i32, ptr @n, align 4, !tbaa !14
  %67 = add nsw i32 %66, 1
  %68 = load i32, ptr @n, align 4, !tbaa !14
  %69 = add nsw i32 %68, 1
  %70 = icmp sgt i32 1, %69
  %71 = zext i1 %70 to i32
  %72 = sub nsw i32 %67, %71
  %73 = icmp ne i32 %65, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #8
  br label %91

75:                                               ; preds = %64
  %76 = load i32, ptr %4, align 4, !tbaa !14
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1005 x i32], ptr @pg, i64 0, i64 %77
  call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %78)
  br label %79

79:                                               ; preds = %75
  %80 = load i32, ptr @n, align 4, !tbaa !14
  %81 = add nsw i32 %80, 1
  %82 = icmp sgt i32 1, %81
  br i1 %82, label %83, label %86

83:                                               ; preds = %79
  %84 = load i32, ptr %4, align 4, !tbaa !14
  %85 = add nsw i32 %84, -1
  store i32 %85, ptr %4, align 4, !tbaa !14
  br label %89

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

89:                                               ; preds = %86, %83
  %90 = phi ptr [ %4, %83 ], [ %4, %86 ]
  br label %64, !llvm.loop !18

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

92:                                               ; preds = %158, %91
  %93 = load i32, ptr %5, align 4, !tbaa !14
  %94 = icmp ne i32 %93, 1000
  br i1 %94, label %96, label %95

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

96:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #8
  store i32 1, ptr %7, align 4, !tbaa !14
  br label %97

97:                                               ; preds = %154, %96
  %98 = load i32, ptr %7, align 4, !tbaa !14
  %99 = icmp ne i32 %98, 100001
  br i1 %99, label %101, label %100

100:                                              ; preds = %97
  store i32 11, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #8
  br label %157

101:                                              ; preds = %97
  %102 = load i32, ptr %5, align 4, !tbaa !14
  %103 = add nsw i32 %102, 1
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [1005 x i32], ptr @pr, i64 0, i64 %104
  %106 = load i32, ptr %105, align 4, !tbaa !14
  %107 = load i32, ptr %7, align 4, !tbaa !14
  %108 = icmp sgt i32 %106, %107
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #8
  br i1 %108, label %109, label %117

109:                                              ; preds = %101
  %110 = load i32, ptr %5, align 4, !tbaa !14
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1005 x [100005 x i32]], ptr @dp, i64 0, i64 %111
  %113 = load i32, ptr %7, align 4, !tbaa !14
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [100005 x i32], ptr %112, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !14
  br label %145

117:                                              ; preds = %101
  %118 = load i32, ptr %5, align 4, !tbaa !14
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [1005 x [100005 x i32]], ptr @dp, i64 0, i64 %119
  %121 = load i32, ptr %7, align 4, !tbaa !14
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [100005 x i32], ptr %120, i64 0, i64 %122
  %124 = load i32, ptr %5, align 4, !tbaa !14
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [1005 x [100005 x i32]], ptr @dp, i64 0, i64 %125
  %127 = load i32, ptr %7, align 4, !tbaa !14
  %128 = load i32, ptr %5, align 4, !tbaa !14
  %129 = add nsw i32 %128, 1
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [1005 x i32], ptr @pr, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !14
  %133 = sub nsw i32 %127, %132
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [100005 x i32], ptr %126, i64 0, i64 %134
  %136 = load i32, ptr %135, align 4, !tbaa !14
  %137 = load i32, ptr %5, align 4, !tbaa !14
  %138 = add nsw i32 %137, 1
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1005 x i32], ptr @pg, i64 0, i64 %139
  %141 = load i32, ptr %140, align 4, !tbaa !14
  %142 = add nsw i32 %136, %141
  store i32 %142, ptr %8, align 4, !tbaa !14
  %143 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %123, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %144 = load i32, ptr %143, align 4, !tbaa !14
  br label %145

145:                                              ; preds = %117, %109
  %146 = phi i32 [ %116, %109 ], [ %144, %117 ]
  %147 = load i32, ptr %5, align 4, !tbaa !14
  %148 = add nsw i32 %147, 1
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [1005 x [100005 x i32]], ptr @dp, i64 0, i64 %149
  %151 = load i32, ptr %7, align 4, !tbaa !14
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [100005 x i32], ptr %150, i64 0, i64 %152
  store i32 %146, ptr %153, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #8
  br label %154

154:                                              ; preds = %145
  %155 = load i32, ptr %7, align 4, !tbaa !14
  %156 = add nsw i32 %155, 1
  store i32 %156, ptr %7, align 4, !tbaa !14
  br label %97, !llvm.loop !19

157:                                              ; preds = %100
  br label %158

158:                                              ; preds = %157
  %159 = load i32, ptr %5, align 4, !tbaa !14
  %160 = add nsw i32 %159, 1
  store i32 %160, ptr %5, align 4, !tbaa !14
  br label %92, !llvm.loop !20

161:                                              ; preds = %95
  %162 = load i32, ptr @n, align 4, !tbaa !14
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [1005 x [100005 x i32]], ptr @dp, i64 0, i64 %163
  %165 = load i32, ptr @x, align 4, !tbaa !14
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [100005 x i32], ptr %164, i64 0, i64 %166
  %168 = load i32, ptr %167, align 4, !tbaa !14
  call void @_ZN7aryansh9io_macros3outIiJEEEvT_DpT0_(i32 noundef %168)
  %169 = load i32, ptr %1, align 4
  ret i32 %169
}

declare noalias ptr @fopen(ptr noundef, ptr noundef) #3

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #4 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #5

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) #6

; 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)) #7

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros3outIiJEEEvT_DpT0_(i32 noundef) #6

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{i64 0, i64 8, !12}
!12 = !{!13, !13, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = distinct !{!18, !17}
!19 = distinct !{!19, !17}
!20 = distinct !{!20, !17}


; 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::chrono::time_point" = type { %"class.std::chrono::duration" }
%"class.std::chrono::duration" = type { i64 }
%"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 }

@CLK = external dso_local local_unnamed_addr global %"class.std::chrono::time_point", align 8
@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@pr = external dso_local global [1005 x i32], align 16
@pg = external dso_local global [1005 x i32], align 16
@dp = external dso_local global [1005 x [100005 x i32]], align 16
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

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

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

; Function Attrs: nounwind
declare i64 @_ZNSt6chrono3_V212steady_clock3nowEv() local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = tail call noalias ptr @fopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.4)
  %.not = icmp eq ptr %2, null
  br i1 %.not, label %8, label %3

3:                                                ; preds = %0
  %4 = load ptr, ptr @stdin, align 8, !tbaa !5
  %5 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.4, ptr noundef %4)
  %6 = load ptr, ptr @stdout, align 8, !tbaa !5
  %7 = tail call ptr @freopen(ptr noundef nonnull @.str.5, ptr noundef nonnull @.str.6, ptr noundef %6)
  br label %8

8:                                                ; preds = %3, %0
  %9 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !9
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %11
  %13 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %15 = tail call i64 @_ZNSt6chrono3_V212steady_clock3nowEv() #8
  store i64 %15, ptr @CLK, align 8, !tbaa !11
  tail call void @_ZN7aryansh9io_macros2inIiJiEEEvRT_DpRT0_(ptr noundef nonnull align 4 dereferenceable(4) @n, ptr noundef nonnull align 4 dereferenceable(4) @x)
  %16 = load i32, ptr @n, align 4, !tbaa !13
  %isnotneg = icmp sgt i32 %16, -1
  %17 = zext i1 %isnotneg to i32
  %18 = add nsw i32 %16, 1
  %.lobit36.neg = ashr i32 %16, 31
  %19 = add nsw i32 %18, %.lobit36.neg
  %.not2938 = icmp eq i32 %19, %17
  br i1 %.not2938, label %._crit_edge, label %.lr.ph

._crit_edge.loopexit:                             ; preds = %.lr.ph
  %.pre = zext i1 %.inv to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %8
  %.pre-phi54 = phi i32 [ %24, %._crit_edge.loopexit ], [ %19, %8 ]
  %.pre-phi = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %17, %8 ]
  %.not3141 = icmp eq i32 %.pre-phi54, %.pre-phi
  br i1 %.not3141, label %.preheader.preheader, label %.lr.ph44

.lr.ph:                                           ; preds = %8, %.lr.ph
  %.02739 = phi i32 [ %.128, %.lr.ph ], [ %17, %8 ]
  %20 = sext i32 %.02739 to i64
  %21 = getelementptr inbounds [1005 x i32], ptr @pr, i64 0, i64 %20
  tail call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %21)
  %22 = load i32, ptr @n, align 4, !tbaa !13
  %.inv = icmp sgt i32 %22, -1
  %.128.v = select i1 %.inv, i32 1, i32 -1
  %.128 = add nsw i32 %.128.v, %.02739
  %23 = add nsw i32 %22, 1
  %.lobit.neg47 = ashr i32 %22, 31
  %24 = add nsw i32 %23, %.lobit.neg47
  %.not29 = icmp eq i32 %.128, %24
  br i1 %.not29, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !15

.lr.ph44:                                         ; preds = %._crit_edge, %.lr.ph44
  %.02642 = phi i32 [ %.1, %.lr.ph44 ], [ %.pre-phi, %._crit_edge ]
  %25 = sext i32 %.02642 to i64
  %26 = getelementptr inbounds [1005 x i32], ptr @pg, i64 0, i64 %25
  tail call void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4) %26)
  %27 = load i32, ptr @n, align 4, !tbaa !13
  %.inv34 = icmp sgt i32 %27, -1
  %.1.v = select i1 %.inv34, i32 1, i32 -1
  %.1 = add nsw i32 %.1.v, %.02642
  %28 = add nsw i32 %27, 1
  %.lobit30.neg = ashr i32 %27, 31
  %29 = add nsw i32 %28, %.lobit30.neg
  %.not31 = icmp eq i32 %.1, %29
  br i1 %.not31, label %.preheader.preheader, label %.lr.ph44, !llvm.loop !17

.preheader.preheader:                             ; preds = %.lr.ph44, %._crit_edge
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %39
  %indvars.iv50 = phi i64 [ %indvars.iv.next51, %39 ], [ 0, %.preheader.preheader ]
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %30 = getelementptr inbounds [1005 x i32], ptr @pr, i64 0, i64 %indvars.iv.next51
  %31 = getelementptr inbounds [1005 x i32], ptr @pg, i64 0, i64 %indvars.iv.next51
  br label %40

32:                                               ; preds = %39
  %33 = load i32, ptr @n, align 4, !tbaa !13
  %34 = sext i32 %33 to i64
  %35 = load i32, ptr @x, align 4, !tbaa !13
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [1005 x [100005 x i32]], ptr @dp, i64 0, i64 %34, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !13
  call void @_ZN7aryansh9io_macros3outIiJEEEvT_DpT0_(i32 noundef %38)
  ret i32 0

39:                                               ; preds = %54
  %.not32 = icmp eq i64 %indvars.iv.next51, 1000
  br i1 %.not32, label %32, label %.preheader, !llvm.loop !18

40:                                               ; preds = %.preheader, %54
  %indvars.iv = phi i64 [ 1, %.preheader ], [ %indvars.iv.next, %54 ]
  %41 = load i32, ptr %30, align 4, !tbaa !13
  %42 = sext i32 %41 to i64
  %43 = icmp slt i64 %indvars.iv, %42
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #8
  %44 = getelementptr inbounds [1005 x [100005 x i32]], ptr @dp, i64 0, i64 %indvars.iv50, i64 %indvars.iv
  br i1 %43, label %54, label %45

45:                                               ; preds = %40
  %46 = trunc nuw nsw i64 %indvars.iv to i32
  %47 = sub nsw i32 %46, %41
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1005 x [100005 x i32]], ptr @dp, i64 0, i64 %indvars.iv50, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !13
  %51 = load i32, ptr %31, align 4, !tbaa !13
  %52 = add nsw i32 %51, %50
  store i32 %52, ptr %1, align 4, !tbaa !13
  %53 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %44, ptr noundef nonnull align 4 dereferenceable(4) %1)
  br label %54

54:                                               ; preds = %40, %45
  %.in = phi ptr [ %53, %45 ], [ %44, %40 ]
  %55 = load i32, ptr %.in, align 4, !tbaa !13
  %56 = getelementptr inbounds [1005 x [100005 x i32]], ptr @dp, i64 0, i64 %indvars.iv.next51, i64 %indvars.iv
  store i32 %55, ptr %56, align 4, !tbaa !13
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #8
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %.not33 = icmp eq i64 %indvars.iv.next, 100001
  br i1 %.not33, label %39, label %40, !llvm.loop !19
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

declare ptr @freopen(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

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

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #4

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros2inIivEEvRT_(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #6

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZN7aryansh9io_macros3outIiJEEEvT_DpT0_(i32 noundef) local_unnamed_addr #6

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}
!19 = distinct !{!19, !16}


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