; LLVM IR from tangjz/acm-icpc :: 51nod (1486)

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

%struct.Point = type { [10 x i32] }

@d = external dso_local global i32, align 4
@p = external dso_local global i32, align 4
@fact = external dso_local global [1000100 x i32], align 16
@inv = external dso_local global [100010 x i32], align 16
@f = external dso_local global [2010 x i32], align 16
@a = external dso_local global [2010 x %struct.Point], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

12:                                               ; preds = %31, %0
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 1000100
  br i1 %14, label %16, label %15

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

16:                                               ; preds = %12
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sub nsw i32 %17, 1
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [1000100 x i32], ptr @fact, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = mul nsw i64 %22, %24
  %26 = srem i64 %25, 1000000007
  %27 = trunc i64 %26 to i32
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1000100 x i32], ptr @fact, i64 0, i64 %29
  store i32 %27, ptr %30, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %16
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !9

34:                                               ; preds = %15
  store i32 1, ptr getelementptr inbounds ([100010 x i32], ptr @inv, i64 0, i64 1), align 4, !tbaa !5
  store i32 1, ptr @inv, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 2, ptr %3, align 4, !tbaa !5
  br label %35

35:                                               ; preds = %56, %34
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = icmp slt i32 %36, 100010
  br i1 %37, label %39, label %38

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

39:                                               ; preds = %35
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = srem i32 1000000007, %40
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100010 x i32], ptr @inv, i64 0, i64 %42
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = load i32, ptr %3, align 4, !tbaa !5
  %47 = sdiv i32 1000000007, %46
  %48 = sub nsw i32 1000000007, %47
  %49 = sext i32 %48 to i64
  %50 = mul nsw i64 %45, %49
  %51 = srem i64 %50, 1000000007
  %52 = trunc i64 %51 to i32
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [100010 x i32], ptr @inv, i64 0, i64 %54
  store i32 %52, ptr %55, align 4, !tbaa !5
  br label %56

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

59:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 2, ptr %4, align 4, !tbaa !5
  br label %60

60:                                               ; preds = %82, %59
  %61 = load i32, ptr %4, align 4, !tbaa !5
  %62 = icmp slt i32 %61, 100010
  br i1 %62, label %64, label %63

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

64:                                               ; preds = %60
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = sub nsw i32 %65, 1
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [100010 x i32], ptr @inv, i64 0, i64 %67
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [100010 x i32], ptr @inv, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = mul nsw i64 %70, %75
  %77 = srem i64 %76, 1000000007
  %78 = trunc i64 %77 to i32
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100010 x i32], ptr @inv, i64 0, i64 %80
  store i32 %78, ptr %81, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %64
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %4, align 4, !tbaa !5
  br label %60, !llvm.loop !12

85:                                               ; preds = %63
  store i32 2, ptr @d, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  %86 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %5, ptr noundef %6, ptr noundef @p)
  store i32 1, ptr getelementptr inbounds ([10 x i32], ptr @a, i64 0, i64 1), align 4, !tbaa !5
  store i32 1, ptr @a, align 16, !tbaa !5
  %87 = load i32, ptr %5, align 4, !tbaa !5
  %88 = load i32, ptr @p, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [2010 x %struct.Point], ptr @a, i64 0, i64 %90
  %92 = getelementptr inbounds %struct.Point, ptr %91, i32 0, i32 0
  %93 = getelementptr inbounds [10 x i32], ptr %92, i64 0, i64 0
  store i32 %87, ptr %93, align 8, !tbaa !5
  %94 = load i32, ptr %6, align 4, !tbaa !5
  %95 = load i32, ptr @p, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [2010 x %struct.Point], ptr @a, i64 0, i64 %97
  %99 = getelementptr inbounds %struct.Point, ptr %98, i32 0, i32 0
  %100 = getelementptr inbounds [10 x i32], ptr %99, i64 0, i64 1
  store i32 %94, ptr %100, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %126, %85
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = load i32, ptr @p, align 4, !tbaa !5
  %104 = icmp sle i32 %102, %103
  br i1 %104, label %106, label %105

105:                                              ; preds = %101
  store i32 11, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %129

106:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %107

107:                                              ; preds = %122, %106
  %108 = load i32, ptr %9, align 4, !tbaa !5
  %109 = load i32, ptr @d, align 4, !tbaa !5
  %110 = icmp slt i32 %108, %109
  br i1 %110, label %112, label %111

111:                                              ; preds = %107
  store i32 14, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %125

112:                                              ; preds = %107
  %113 = load i32, ptr %7, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [2010 x %struct.Point], ptr @a, i64 0, i64 %114
  %116 = getelementptr inbounds %struct.Point, ptr %115, i32 0, i32 0
  %117 = getelementptr inbounds [10 x i32], ptr %116, i64 0, i64 0
  %118 = load i32, ptr %9, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds i32, ptr %117, i64 %119
  %121 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %120)
  br label %122

122:                                              ; preds = %112
  %123 = load i32, ptr %9, align 4, !tbaa !5
  %124 = add nsw i32 %123, 1
  store i32 %124, ptr %9, align 4, !tbaa !5
  br label %107, !llvm.loop !13

125:                                              ; preds = %111
  br label %126

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

129:                                              ; preds = %105
  %130 = load i32, ptr @p, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds %struct.Point, ptr @a, i64 %131
  %133 = getelementptr inbounds %struct.Point, ptr %132, i64 1
  call void @_ZSt4sortIP5PointEvT_S2_(ptr noundef getelementptr inbounds (%struct.Point, ptr @a, i64 1), ptr noundef %133)
  store i32 1, ptr @f, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %186, %129
  %135 = load i32, ptr %10, align 4, !tbaa !5
  %136 = load i32, ptr @p, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  %138 = icmp sle i32 %135, %137
  br i1 %138, label %140, label %139

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

140:                                              ; preds = %134
  %141 = load i32, ptr %10, align 4, !tbaa !5
  %142 = call noundef i32 @_Z4calcii(i32 noundef 0, i32 noundef %141)
  %143 = load i32, ptr %10, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %144
  store i32 %142, ptr %145, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %146

146:                                              ; preds = %182, %140
  %147 = load i32, ptr %11, align 4, !tbaa !5
  %148 = load i32, ptr %10, align 4, !tbaa !5
  %149 = icmp slt i32 %147, %148
  br i1 %149, label %151, label %150

150:                                              ; preds = %146
  store i32 20, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %185

151:                                              ; preds = %146
  %152 = load i32, ptr %11, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = load i32, ptr %11, align 4, !tbaa !5
  %158 = load i32, ptr %10, align 4, !tbaa !5
  %159 = call noundef i32 @_Z4calcii(i32 noundef %157, i32 noundef %158)
  %160 = sext i32 %159 to i64
  %161 = mul nsw i64 %156, %160
  %162 = srem i64 %161, 1000000007
  %163 = load i32, ptr %10, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %164
  %166 = load i32, ptr %165, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = sub nsw i64 %167, %162
  %169 = trunc i64 %168 to i32
  store i32 %169, ptr %165, align 4, !tbaa !5
  %170 = load i32, ptr %10, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %171
  %173 = load i32, ptr %172, align 4, !tbaa !5
  %174 = icmp slt i32 %173, 0
  br i1 %174, label %175, label %181

175:                                              ; preds = %151
  %176 = load i32, ptr %10, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = add nsw i32 %179, 1000000007
  store i32 %180, ptr %178, align 4, !tbaa !5
  br label %181

181:                                              ; preds = %175, %151
  br label %182

182:                                              ; preds = %181
  %183 = load i32, ptr %11, align 4, !tbaa !5
  %184 = add nsw i32 %183, 1
  store i32 %184, ptr %11, align 4, !tbaa !5
  br label %146, !llvm.loop !15

185:                                              ; preds = %150
  br label %186

186:                                              ; preds = %185
  %187 = load i32, ptr %10, align 4, !tbaa !5
  %188 = add nsw i32 %187, 1
  store i32 %188, ptr %10, align 4, !tbaa !5
  br label %134, !llvm.loop !16

189:                                              ; preds = %139
  %190 = load i32, ptr @p, align 4, !tbaa !5
  %191 = add nsw i32 %190, 1
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %192
  %194 = load i32, ptr %193, align 4, !tbaa !5
  %195 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %194)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  %196 = load i32, ptr %1, align 4
  ret i32 %196
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5PointEvT_S2_(ptr noundef, ptr noundef) #4

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

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


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

%struct.Point = type { [10 x i32] }

@d = external dso_local local_unnamed_addr global i32, align 4
@p = external dso_local global i32, align 4
@fact = external dso_local local_unnamed_addr global [1000100 x i32], align 16
@inv = external dso_local local_unnamed_addr global [100010 x i32], align 16
@f = external dso_local local_unnamed_addr global [2010 x i32], align 16
@a = external dso_local global [2010 x %struct.Point], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z4calcii(i32 noundef, i32 noundef) 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 = alloca i32, align 4
  store i32 1, ptr @fact, align 16, !tbaa !5
  br label %4

3:                                                ; preds = %4
  store i32 1, ptr getelementptr inbounds (i8, ptr @inv, i64 4), align 4, !tbaa !5
  store i32 1, ptr @inv, align 16, !tbaa !5
  br label %15

4:                                                ; preds = %10, %0
  %5 = phi i64 [ 1, %0 ], [ %12, %10 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.1, %10 ]
  %6 = mul nsw i64 %5, %indvars.iv
  %7 = srem i64 %6, 1000000007
  %8 = trunc nsw i64 %7 to i32
  %9 = getelementptr inbounds [1000100 x i32], ptr @fact, i64 0, i64 %indvars.iv
  store i32 %8, ptr %9, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 1000100
  br i1 %exitcond.not, label %3, label %10, !llvm.loop !9

10:                                               ; preds = %4
  %11 = mul nsw i64 %7, %indvars.iv.next
  %12 = srem i64 %11, 1000000007
  %13 = trunc nsw i64 %12 to i32
  %14 = getelementptr inbounds [1000100 x i32], ptr @fact, i64 0, i64 %indvars.iv.next
  store i32 %13, ptr %14, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  br label %4

15:                                               ; preds = %3, %15
  %indvars.iv68 = phi i64 [ 2, %3 ], [ %indvars.iv.next69, %15 ]
  %16 = trunc nuw nsw i64 %indvars.iv68 to i32
  %17 = urem i32 1000000007, %16
  %18 = zext nneg i32 %17 to i64
  %19 = getelementptr inbounds [100010 x i32], ptr @inv, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = udiv i32 1000000007, %16
  %23 = sub nuw nsw i32 1000000007, %22
  %24 = zext nneg i32 %23 to i64
  %25 = mul nsw i64 %24, %21
  %26 = srem i64 %25, 1000000007
  %27 = trunc nsw i64 %26 to i32
  %28 = getelementptr inbounds [100010 x i32], ptr @inv, i64 0, i64 %indvars.iv68
  store i32 %27, ptr %28, align 4, !tbaa !5
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %exitcond71.not = icmp eq i64 %indvars.iv.next69, 100010
  br i1 %exitcond71.not, label %.preheader45.preheader, label %15, !llvm.loop !11

.preheader45.preheader:                           ; preds = %15
  %.pre = load i32, ptr getelementptr inbounds (i8, ptr @inv, i64 4), align 4, !tbaa !5
  br label %.preheader45

29:                                               ; preds = %.preheader45
  store i32 2, ptr @d, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull @p)
  store i32 1, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4, !tbaa !5
  store i32 1, ptr @a, align 16, !tbaa !5
  %31 = load i32, ptr %1, align 4, !tbaa !5
  %32 = load i32, ptr @p, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [2010 x %struct.Point], ptr @a, i64 0, i64 %34
  store i32 %31, ptr %35, align 8, !tbaa !5
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = getelementptr inbounds [2010 x %struct.Point], ptr @a, i64 0, i64 %34, i32 0, i64 1
  store i32 %36, ptr %37, align 4, !tbaa !5
  %.not51 = icmp sgt i32 %32, 0
  %38 = load i32, ptr @d, align 4
  %39 = icmp sgt i32 %38, 0
  %or.cond = select i1 %.not51, i1 %39, i1 false
  br i1 %or.cond, label %.preheader, label %._crit_edge53

.preheader45:                                     ; preds = %.preheader45, %.preheader45.preheader
  %40 = phi i32 [ %.pre, %.preheader45.preheader ], [ %53, %.preheader45 ]
  %indvars.iv72 = phi i64 [ 2, %.preheader45.preheader ], [ %indvars.iv.next73.1, %.preheader45 ]
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [100010 x i32], ptr @inv, i64 0, i64 %indvars.iv72
  %43 = load i32, ptr %42, align 8, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = mul nsw i64 %44, %41
  %46 = srem i64 %45, 1000000007
  %47 = trunc nsw i64 %46 to i32
  store i32 %47, ptr %42, align 8, !tbaa !5
  %indvars.iv.next73 = or disjoint i64 %indvars.iv72, 1
  %48 = getelementptr inbounds [100010 x i32], ptr @inv, i64 0, i64 %indvars.iv.next73
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = mul nsw i64 %46, %50
  %52 = srem i64 %51, 1000000007
  %53 = trunc nsw i64 %52 to i32
  store i32 %53, ptr %48, align 4, !tbaa !5
  %indvars.iv.next73.1 = add nuw nsw i64 %indvars.iv72, 2
  %exitcond75.not.1 = icmp eq i64 %indvars.iv.next73.1, 100010
  br i1 %exitcond75.not.1, label %29, label %.preheader45, !llvm.loop !12

.preheader:                                       ; preds = %29, %._crit_edge
  %54 = phi i32 [ %62, %._crit_edge ], [ %32, %29 ]
  %55 = phi i32 [ %63, %._crit_edge ], [ %38, %29 ]
  %indvars.iv79 = phi i64 [ %indvars.iv.next80, %._crit_edge ], [ 1, %29 ]
  %56 = icmp sgt i32 %55, 0
  br i1 %56, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %57 = getelementptr inbounds [2010 x %struct.Point], ptr @a, i64 0, i64 %indvars.iv79
  br label %65

._crit_edge53:                                    ; preds = %._crit_edge, %29
  %.lcssa46 = phi i32 [ %32, %29 ], [ %62, %._crit_edge ]
  %58 = sext i32 %.lcssa46 to i64
  %59 = getelementptr inbounds %struct.Point, ptr @a, i64 %58
  %60 = getelementptr inbounds i8, ptr %59, i64 40
  call void @_ZSt4sortIP5PointEvT_S2_(ptr noundef nonnull getelementptr inbounds (i8, ptr @a, i64 40), ptr noundef nonnull %60)
  store i32 1, ptr @f, align 16, !tbaa !5
  %61 = load i32, ptr @p, align 4, !tbaa !5
  %.not4458 = icmp slt i32 %61, 0
  br i1 %.not4458, label %._crit_edge62, label %.lr.ph61

._crit_edge.loopexit:                             ; preds = %65
  %.pre89 = load i32, ptr @p, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader
  %62 = phi i32 [ %.pre89, %._crit_edge.loopexit ], [ %54, %.preheader ]
  %63 = phi i32 [ %68, %._crit_edge.loopexit ], [ %55, %.preheader ]
  %indvars.iv.next80 = add nuw nsw i64 %indvars.iv79, 1
  %64 = sext i32 %62 to i64
  %.not.not = icmp slt i64 %indvars.iv79, %64
  br i1 %.not.not, label %.preheader, label %._crit_edge53, !llvm.loop !13

65:                                               ; preds = %.lr.ph, %65
  %indvars.iv76 = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next77, %65 ]
  %66 = getelementptr inbounds i32, ptr %57, i64 %indvars.iv76
  %67 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %66)
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %68 = load i32, ptr @d, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = icmp slt i64 %indvars.iv.next77, %69
  br i1 %70, label %65, label %._crit_edge.loopexit, !llvm.loop !15

._crit_edge62:                                    ; preds = %._crit_edge57, %._crit_edge53
  %.lcssa.in = phi i32 [ %61, %._crit_edge53 ], [ %79, %._crit_edge57 ]
  %.lcssa = add nsw i32 %.lcssa.in, 1
  %71 = sext i32 %.lcssa to i64
  %72 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %73)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0

.lr.ph61:                                         ; preds = %._crit_edge53, %._crit_edge57
  %indvars.iv86 = phi i64 [ %indvars.iv.next87, %._crit_edge57 ], [ 1, %._crit_edge53 ]
  %75 = trunc nuw nsw i64 %indvars.iv86 to i32
  %76 = call noundef i32 @_Z4calcii(i32 noundef 0, i32 noundef %75)
  %77 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv86
  store i32 %76, ptr %77, align 4, !tbaa !5
  %78 = icmp ugt i64 %indvars.iv86, 1
  br i1 %78, label %.lr.ph56, label %._crit_edge57

._crit_edge57:                                    ; preds = %.lr.ph56, %.lr.ph61
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %79 = load i32, ptr @p, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %.not44 = icmp sgt i64 %indvars.iv86, %80
  br i1 %.not44, label %._crit_edge62, label %.lr.ph61, !llvm.loop !16

.lr.ph56:                                         ; preds = %.lr.ph61, %.lr.ph56
  %indvars.iv82 = phi i64 [ %indvars.iv.next83, %.lr.ph56 ], [ 1, %.lr.ph61 ]
  %81 = getelementptr inbounds [2010 x i32], ptr @f, i64 0, i64 %indvars.iv82
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = trunc nuw nsw i64 %indvars.iv82 to i32
  %85 = call noundef i32 @_Z4calcii(i32 noundef %84, i32 noundef %75)
  %86 = sext i32 %85 to i64
  %87 = mul nsw i64 %86, %83
  %88 = srem i64 %87, 1000000007
  %89 = load i32, ptr %77, align 4, !tbaa !5
  %90 = trunc nsw i64 %88 to i32
  %91 = sub i32 %89, %90
  %92 = icmp slt i32 %91, 0
  %93 = add nsw i32 %91, 1000000007
  %spec.select = select i1 %92, i32 %93, i32 %91
  store i32 %spec.select, ptr %77, align 4, !tbaa !5
  %indvars.iv.next83 = add nuw nsw i64 %indvars.iv82, 1
  %exitcond85.not = icmp eq i64 %indvars.iv.next83, %indvars.iv86
  br i1 %exitcond85.not, label %._crit_edge57, label %.lr.ph56, !llvm.loop !17
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIP5PointEvT_S2_(ptr noundef, ptr noundef) local_unnamed_addr #4

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 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 = { 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}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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