; LLVM IR from tangjz/acm-icpc :: buaa/oj3rd (1126)

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

@n = external dso_local global i32, align 4
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@now = external dso_local global i32, align 4
@mat = external dso_local global [1001 x [1001 x i32]], align 16
@ans = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %2

2:                                                ; preds = %171, %0
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  %4 = icmp eq i32 %3, 1
  br i1 %4, label %5, label %174

5:                                                ; preds = %2
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @now, align 4, !tbaa !5
  store i32 0, ptr @y, align 4, !tbaa !5
  store i32 0, ptr @x, align 4, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 16 @mat, i8 0, i64 4008004, i1 false)
  %6 = load i32, ptr @now, align 4, !tbaa !5
  %7 = add nsw i32 %6, 1
  store i32 %7, ptr @now, align 4, !tbaa !5
  %8 = load i32, ptr @x, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %9
  %11 = load i32, ptr @y, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [1001 x i32], ptr %10, i64 0, i64 %12
  store i32 %7, ptr %13, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %134, %5
  %15 = load i32, ptr @now, align 4, !tbaa !5
  %16 = load i32, ptr @n, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = mul nsw i32 %16, %17
  %19 = icmp slt i32 %15, %18
  br i1 %19, label %20, label %135

20:                                               ; preds = %14
  br label %21

21:                                               ; preds = %39, %20
  %22 = load i32, ptr @y, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %26, label %37

26:                                               ; preds = %21
  %27 = load i32, ptr @x, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %28
  %30 = load i32, ptr @y, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [1001 x i32], ptr %29, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = icmp ne i32 %34, 0
  %36 = xor i1 %35, true
  br label %37

37:                                               ; preds = %26, %21
  %38 = phi i1 [ false, %21 ], [ %36, %26 ]
  br i1 %38, label %39, label %49

39:                                               ; preds = %37
  %40 = load i32, ptr @now, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  store i32 %41, ptr @now, align 4, !tbaa !5
  %42 = load i32, ptr @x, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %43
  %45 = load i32, ptr @y, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr @y, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [1001 x i32], ptr %44, i64 0, i64 %47
  store i32 %41, ptr %48, align 4, !tbaa !5
  br label %21, !llvm.loop !9

49:                                               ; preds = %37
  br label %50

50:                                               ; preds = %68, %49
  %51 = load i32, ptr @x, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  %53 = load i32, ptr @n, align 4, !tbaa !5
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %55, label %66

55:                                               ; preds = %50
  %56 = load i32, ptr @x, align 4, !tbaa !5
  %57 = add nsw i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %58
  %60 = load i32, ptr @y, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1001 x i32], ptr %59, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp ne i32 %63, 0
  %65 = xor i1 %64, true
  br label %66

66:                                               ; preds = %55, %50
  %67 = phi i1 [ false, %50 ], [ %65, %55 ]
  br i1 %67, label %68, label %78

68:                                               ; preds = %66
  %69 = load i32, ptr @now, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr @now, align 4, !tbaa !5
  %71 = load i32, ptr @x, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr @x, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %73
  %75 = load i32, ptr @y, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [1001 x i32], ptr %74, i64 0, i64 %76
  store i32 %70, ptr %77, align 4, !tbaa !5
  br label %50, !llvm.loop !11

78:                                               ; preds = %66
  br label %79

79:                                               ; preds = %96, %78
  %80 = load i32, ptr @y, align 4, !tbaa !5
  %81 = sub nsw i32 %80, 1
  %82 = icmp sge i32 %81, 0
  br i1 %82, label %83, label %94

83:                                               ; preds = %79
  %84 = load i32, ptr @x, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %85
  %87 = load i32, ptr @y, align 4, !tbaa !5
  %88 = sub nsw i32 %87, 1
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [1001 x i32], ptr %86, i64 0, i64 %89
  %91 = load i32, ptr %90, align 4, !tbaa !5
  %92 = icmp ne i32 %91, 0
  %93 = xor i1 %92, true
  br label %94

94:                                               ; preds = %83, %79
  %95 = phi i1 [ false, %79 ], [ %93, %83 ]
  br i1 %95, label %96, label %106

96:                                               ; preds = %94
  %97 = load i32, ptr @now, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr @now, align 4, !tbaa !5
  %99 = load i32, ptr @x, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %100
  %102 = load i32, ptr @y, align 4, !tbaa !5
  %103 = add nsw i32 %102, -1
  store i32 %103, ptr @y, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [1001 x i32], ptr %101, i64 0, i64 %104
  store i32 %98, ptr %105, align 4, !tbaa !5
  br label %79, !llvm.loop !12

106:                                              ; preds = %94
  br label %107

107:                                              ; preds = %124, %106
  %108 = load i32, ptr @x, align 4, !tbaa !5
  %109 = sub nsw i32 %108, 1
  %110 = icmp sge i32 %109, 0
  br i1 %110, label %111, label %122

111:                                              ; preds = %107
  %112 = load i32, ptr @x, align 4, !tbaa !5
  %113 = sub nsw i32 %112, 1
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %114
  %116 = load i32, ptr @y, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [1001 x i32], ptr %115, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = icmp ne i32 %119, 0
  %121 = xor i1 %120, true
  br label %122

122:                                              ; preds = %111, %107
  %123 = phi i1 [ false, %107 ], [ %121, %111 ]
  br i1 %123, label %124, label %134

124:                                              ; preds = %122
  %125 = load i32, ptr @now, align 4, !tbaa !5
  %126 = add nsw i32 %125, 1
  store i32 %126, ptr @now, align 4, !tbaa !5
  %127 = load i32, ptr @x, align 4, !tbaa !5
  %128 = add nsw i32 %127, -1
  store i32 %128, ptr @x, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %129
  %131 = load i32, ptr @y, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [1001 x i32], ptr %130, i64 0, i64 %132
  store i32 %126, ptr %133, align 4, !tbaa !5
  br label %107, !llvm.loop !13

134:                                              ; preds = %122
  br label %14, !llvm.loop !14

135:                                              ; preds = %14
  store i32 0, ptr @x, align 4, !tbaa !5
  br label %136

136:                                              ; preds = %168, %135
  %137 = load i32, ptr @x, align 4, !tbaa !5
  %138 = load i32, ptr @n, align 4, !tbaa !5
  %139 = icmp slt i32 %137, %138
  br i1 %139, label %140, label %171

140:                                              ; preds = %136
  %141 = load i32, ptr @x, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %142
  %144 = load i32, ptr @x, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [1001 x i32], ptr %143, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = load i32, ptr @ans, align 4, !tbaa !5
  %149 = add nsw i32 %148, %147
  store i32 %149, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @y, align 4, !tbaa !5
  br label %150

150:                                              ; preds = %163, %140
  %151 = load i32, ptr @y, align 4, !tbaa !5
  %152 = load i32, ptr @n, align 4, !tbaa !5
  %153 = icmp slt i32 %151, %152
  br i1 %153, label %154, label %166

154:                                              ; preds = %150
  %155 = load i32, ptr @x, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %156
  %158 = load i32, ptr @y, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [1001 x i32], ptr %157, i64 0, i64 %159
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %161)
  br label %163

163:                                              ; preds = %154
  %164 = load i32, ptr @y, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr @y, align 4, !tbaa !5
  br label %150, !llvm.loop !15

166:                                              ; preds = %150
  %167 = call i32 @putchar(i32 noundef 10)
  br label %168

168:                                              ; preds = %166
  %169 = load i32, ptr @x, align 4, !tbaa !5
  %170 = add nsw i32 %169, 1
  store i32 %170, ptr @x, align 4, !tbaa !5
  br label %136, !llvm.loop !16

171:                                              ; preds = %136
  %172 = load i32, ptr @ans, align 4, !tbaa !5
  %173 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %172)
  br label %2, !llvm.loop !17

174:                                              ; preds = %2
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare i32 @putchar(i32 noundef) #3

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 nounwind willreturn memory(argmem: write) }
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" }

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

@n = external dso_local global i32, align 4
@x = external dso_local local_unnamed_addr global i32, align 4
@y = external dso_local local_unnamed_addr global i32, align 4
@now = external dso_local local_unnamed_addr global i32, align 4
@mat = external dso_local local_unnamed_addr global [1001 x [1001 x i32]], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind 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 = icmp eq i32 %1, 1
  br i1 %2, label %.lr.ph86, label %._crit_edge87

.lr.ph86:                                         ; preds = %0, %._crit_edge84
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @y, align 4, !tbaa !5
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(4008004) @mat, i8 0, i64 4008004, i1 false)
  store i32 1, ptr @now, align 4, !tbaa !5
  store i32 1, ptr @mat, align 16, !tbaa !5
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %4 = mul nsw i32 %3, %3
  %5 = icmp ugt i32 %4, 1
  br i1 %5, label %.preheader.preheader, label %.preheader17

.preheader.preheader:                             ; preds = %.lr.ph86
  %6 = sext i32 %3 to i64
  %7 = add i32 %3, -1
  br label %.preheader

.preheader17:                                     ; preds = %.critedge6, %.lr.ph86
  store i32 0, ptr @x, align 4, !tbaa !5
  %8 = icmp sgt i32 %3, 0
  br i1 %8, label %.lr.ph83, label %._crit_edge84

.preheader:                                       ; preds = %.preheader.preheader, %.critedge6
  %now.promoted324479 = phi i32 [ %now.promoted3236, %.critedge6 ], [ 1, %.preheader.preheader ]
  %x.promoted5078 = phi i32 [ %x.promoted46, %.critedge6 ], [ 0, %.preheader.preheader ]
  %y.promoted5677 = phi i32 [ %y.promoted52, %.critedge6 ], [ 0, %.preheader.preheader ]
  %9 = add nsw i32 %y.promoted5677, 1
  %10 = icmp slt i32 %9, %3
  br i1 %10, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %.preheader
  %11 = sext i32 %x.promoted5078 to i64
  %12 = sext i32 %y.promoted5677 to i64
  %13 = add nsw i64 %12, 1
  %14 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %11, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %.not110 = icmp eq i32 %15, 0
  br i1 %.not110, label %.lr.ph113, label %.critedge

16:                                               ; preds = %.lr.ph113
  %17 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %11, i64 %indvars.iv.next
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not = icmp eq i32 %18, 0
  br i1 %.not, label %.lr.ph113, label %.critedge.loopexit, !llvm.loop !9

.lr.ph113:                                        ; preds = %.lr.ph, %16
  %19 = phi ptr [ %17, %16 ], [ %14, %.lr.ph ]
  %now.promoted3243112 = phi i32 [ %20, %16 ], [ %now.promoted324479, %.lr.ph ]
  %indvars.iv111 = phi i64 [ %indvars.iv.next, %16 ], [ %13, %.lr.ph ]
  %20 = add nsw i32 %now.promoted3243112, 1
  %21 = trunc nsw i64 %indvars.iv111 to i32
  store i32 %20, ptr %19, align 4, !tbaa !5
  %indvars.iv.next = add nsw i64 %indvars.iv111, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %6
  br i1 %exitcond.not, label %.critedge.loopexit, label %16, !llvm.loop !9

.critedge.loopexit:                               ; preds = %16, %.lr.ph113
  %y.promoted54.ph = phi i32 [ %21, %16 ], [ %7, %.lr.ph113 ]
  store i32 %20, ptr @now, align 4, !tbaa !5
  store i32 %21, ptr @y, align 4, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %.lr.ph, %.preheader
  %y.promoted54 = phi i32 [ %y.promoted5677, %.preheader ], [ %y.promoted5677, %.lr.ph ], [ %y.promoted54.ph, %.critedge.loopexit ]
  %now.promoted3242 = phi i32 [ %now.promoted324479, %.preheader ], [ %now.promoted324479, %.lr.ph ], [ %20, %.critedge.loopexit ]
  %22 = add nsw i32 %x.promoted5078, 1
  %23 = icmp slt i32 %22, %3
  br i1 %23, label %.lr.ph23, label %.critedge2

.lr.ph23:                                         ; preds = %.critedge
  %24 = sext i32 %y.promoted54 to i64
  %25 = sext i32 %22 to i64
  %26 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %25, i64 %24
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %.not13118 = icmp eq i32 %27, 0
  br i1 %.not13118, label %.lr.ph121, label %.critedge2

28:                                               ; preds = %.lr.ph121
  %29 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %indvars.iv.next90, i64 %24
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %.not13 = icmp eq i32 %30, 0
  br i1 %.not13, label %.lr.ph121, label %..critedge2.loopexit_crit_edge124, !llvm.loop !11

.lr.ph121:                                        ; preds = %.lr.ph23, %28
  %31 = phi ptr [ %29, %28 ], [ %26, %.lr.ph23 ]
  %now.promoted3241120 = phi i32 [ %32, %28 ], [ %now.promoted3242, %.lr.ph23 ]
  %indvars.iv89119 = phi i64 [ %indvars.iv.next90, %28 ], [ %25, %.lr.ph23 ]
  %32 = add nsw i32 %now.promoted3241120, 1
  store i32 %32, ptr %31, align 4, !tbaa !5
  %indvars.iv.next90 = add nsw i64 %indvars.iv89119, 1
  %exitcond92.not = icmp eq i64 %indvars.iv.next90, %6
  br i1 %exitcond92.not, label %.critedge2.loopexit, label %28, !llvm.loop !11

..critedge2.loopexit_crit_edge124:                ; preds = %28
  store i32 %32, ptr @now, align 4, !tbaa !5
  %33 = trunc nsw i64 %indvars.iv89119 to i32
  br label %.critedge2

.critedge2.loopexit:                              ; preds = %.lr.ph121
  store i32 %32, ptr @now, align 4, !tbaa !5
  br label %.critedge2

.critedge2:                                       ; preds = %.critedge2.loopexit, %.lr.ph23, %..critedge2.loopexit_crit_edge124, %.critedge
  %x.promoted48 = phi i32 [ %x.promoted5078, %.critedge ], [ %33, %..critedge2.loopexit_crit_edge124 ], [ %x.promoted5078, %.lr.ph23 ], [ %7, %.critedge2.loopexit ]
  %now.promoted3240 = phi i32 [ %now.promoted3242, %.critedge ], [ %32, %..critedge2.loopexit_crit_edge124 ], [ %now.promoted3242, %.lr.ph23 ], [ %32, %.critedge2.loopexit ]
  %34 = icmp sgt i32 %y.promoted54, 0
  br i1 %34, label %.lr.ph28, label %.critedge4

.lr.ph28:                                         ; preds = %.critedge2
  %35 = sext i32 %x.promoted48 to i64
  %36 = zext nneg i32 %y.promoted54 to i64
  br label %37

37:                                               ; preds = %.lr.ph28, %40
  %indvars.iv93 = phi i64 [ %36, %.lr.ph28 ], [ %indvars.iv.next94, %40 ]
  %now.promoted3239 = phi i32 [ %now.promoted3240, %.lr.ph28 ], [ %41, %40 ]
  %indvars.iv.next94 = add nsw i64 %indvars.iv93, -1
  %38 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %35, i64 %indvars.iv.next94
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %.not14 = icmp eq i32 %39, 0
  br i1 %.not14, label %40, label %.critedge4.loopexit.split.loop.exit99

40:                                               ; preds = %37
  %41 = add nsw i32 %now.promoted3239, 1
  store i32 %41, ptr @now, align 4, !tbaa !5
  %42 = trunc nuw nsw i64 %indvars.iv.next94 to i32
  store i32 %42, ptr @y, align 4, !tbaa !5
  store i32 %41, ptr %38, align 4, !tbaa !5
  %43 = icmp ugt i64 %indvars.iv93, 1
  br i1 %43, label %37, label %.critedge4, !llvm.loop !12

.critedge4.loopexit.split.loop.exit99:            ; preds = %37
  %44 = trunc nuw nsw i64 %indvars.iv93 to i32
  br label %.critedge4

.critedge4:                                       ; preds = %40, %.critedge4.loopexit.split.loop.exit99, %.critedge2
  %y.promoted52 = phi i32 [ %y.promoted54, %.critedge2 ], [ %44, %.critedge4.loopexit.split.loop.exit99 ], [ 0, %40 ]
  %now.promoted3238 = phi i32 [ %now.promoted3240, %.critedge2 ], [ %now.promoted3239, %.critedge4.loopexit.split.loop.exit99 ], [ %41, %40 ]
  %45 = icmp sgt i32 %x.promoted48, 0
  br i1 %45, label %.lr.ph33, label %.critedge6

.lr.ph33:                                         ; preds = %.critedge4
  %46 = sext i32 %y.promoted52 to i64
  %47 = zext nneg i32 %x.promoted48 to i64
  br label %48

48:                                               ; preds = %.lr.ph33, %51
  %indvars.iv96 = phi i64 [ %47, %.lr.ph33 ], [ %indvars.iv.next97, %51 ]
  %now.promoted3237 = phi i32 [ %now.promoted3238, %.lr.ph33 ], [ %52, %51 ]
  %indvars.iv.next97 = add nsw i64 %indvars.iv96, -1
  %49 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %indvars.iv.next97, i64 %46
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %.not15 = icmp eq i32 %50, 0
  br i1 %.not15, label %51, label %.critedge6.loopexit.split.loop.exit102

51:                                               ; preds = %48
  %52 = add nsw i32 %now.promoted3237, 1
  store i32 %52, ptr @now, align 4, !tbaa !5
  %53 = trunc nuw nsw i64 %indvars.iv.next97 to i32
  store i32 %53, ptr @x, align 4, !tbaa !5
  store i32 %52, ptr %49, align 4, !tbaa !5
  %54 = icmp ugt i64 %indvars.iv96, 1
  br i1 %54, label %48, label %.critedge6, !llvm.loop !13

.critedge6.loopexit.split.loop.exit102:           ; preds = %48
  %55 = trunc nuw nsw i64 %indvars.iv96 to i32
  br label %.critedge6

.critedge6:                                       ; preds = %51, %.critedge6.loopexit.split.loop.exit102, %.critedge4
  %x.promoted46 = phi i32 [ %x.promoted48, %.critedge4 ], [ %55, %.critedge6.loopexit.split.loop.exit102 ], [ 0, %51 ]
  %now.promoted3236 = phi i32 [ %now.promoted3238, %.critedge4 ], [ %now.promoted3237, %.critedge6.loopexit.split.loop.exit102 ], [ %52, %51 ]
  %56 = icmp slt i32 %now.promoted3236, %4
  br i1 %56, label %.preheader, label %.preheader17, !llvm.loop !14

.lr.ph83:                                         ; preds = %.preheader17, %._crit_edge
  %57 = phi i32 [ %77, %._crit_edge ], [ %3, %.preheader17 ]
  %storemerge82 = phi i32 [ %76, %._crit_edge ], [ 0, %.preheader17 ]
  %58 = sext i32 %storemerge82 to i64
  %59 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %58, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = load i32, ptr @ans, align 4, !tbaa !5
  %62 = add nsw i32 %61, %60
  store i32 %62, ptr @ans, align 4, !tbaa !5
  store i32 0, ptr @y, align 4, !tbaa !5
  %63 = icmp sgt i32 %57, 0
  br i1 %63, label %.lr.ph81, label %._crit_edge

.lr.ph81:                                         ; preds = %.lr.ph83, %.lr.ph81
  %storemerge1280 = phi i32 [ %71, %.lr.ph81 ], [ 0, %.lr.ph83 ]
  %64 = load i32, ptr @x, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = sext i32 %storemerge1280 to i64
  %67 = getelementptr inbounds [1001 x [1001 x i32]], ptr @mat, i64 0, i64 %65, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %68)
  %70 = load i32, ptr @y, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr @y, align 4, !tbaa !5
  %72 = load i32, ptr @n, align 4, !tbaa !5
  %73 = icmp slt i32 %71, %72
  br i1 %73, label %.lr.ph81, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph81, %.lr.ph83
  %74 = tail call i32 @putchar(i32 noundef 10)
  %75 = load i32, ptr @x, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr @x, align 4, !tbaa !5
  %77 = load i32, ptr @n, align 4, !tbaa !5
  %78 = icmp slt i32 %76, %77
  br i1 %78, label %.lr.ph83, label %._crit_edge84.loopexit, !llvm.loop !16

._crit_edge84.loopexit:                           ; preds = %._crit_edge
  %.pre = load i32, ptr @ans, align 4, !tbaa !5
  br label %._crit_edge84

._crit_edge84:                                    ; preds = %._crit_edge84.loopexit, %.preheader17
  %79 = phi i32 [ %.pre, %._crit_edge84.loopexit ], [ 0, %.preheader17 ]
  %80 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %79)
  %81 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %82 = icmp eq i32 %81, 1
  br i1 %82, label %.lr.ph86, label %._crit_edge87, !llvm.loop !17

._crit_edge87:                                    ; preds = %._crit_edge84, %0
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress nofree nounwind uwtable
declare noundef i32 @putchar(i32 noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nofree norecurse 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 #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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { inlinehint mustprogress nofree 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" }

!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}


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