; LLVM IR from tangjz/acm-icpc :: lydsy (4894)

; 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
@mat = external dso_local global [301 x [301 x i32]], align 16
@ans = external dso_local global i32, align 4
@buf = external dso_local global [301 x i8], align 16
@.str = external hidden unnamed_addr constant [3 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 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
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %56, %0
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %59

20:                                               ; preds = %15
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @buf)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %52, %20
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %55

27:                                               ; preds = %22
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [301 x i8], ptr @buf, i64 0, i64 %29
  %31 = load i8, ptr %30, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = icmp eq i32 %32, 49
  br i1 %33, label %34, label %51

34:                                               ; preds = %27
  %35 = load i32, ptr %4, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %36
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [301 x i32], ptr %37, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %40, align 4, !tbaa !5
  %43 = load i32, ptr %2, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %44
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [301 x i32], ptr %45, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = add nsw i32 %49, -1
  store i32 %50, ptr %48, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %34, %27
  br label %52

52:                                               ; preds = %51
  %53 = load i32, ptr %4, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr %4, align 4, !tbaa !5
  br label %22, !llvm.loop !10

55:                                               ; preds = %26
  br label %56

56:                                               ; preds = %55
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !12

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

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

64:                                               ; preds = %60
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %119

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

66:                                               ; preds = %112, %65
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = icmp slt i32 %67, %68
  br i1 %69, label %71, label %70

70:                                               ; preds = %66
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  br label %115

71:                                               ; preds = %66
  br label %72

72:                                               ; preds = %82, %71
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %74
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [301 x i32], ptr %75, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = icmp slt i32 %79, 0
  br i1 %80, label %81, label %91

81:                                               ; preds = %72
  br label %82

82:                                               ; preds = %81
  %83 = load i32, ptr %5, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %84
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [301 x i32], ptr %85, i64 0, i64 %87
  %89 = load i32, ptr %88, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1000000007
  store i32 %90, ptr %88, align 4, !tbaa !5
  br label %72, !llvm.loop !13

91:                                               ; preds = %72
  br label %92

92:                                               ; preds = %102, %91
  %93 = load i32, ptr %5, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %94
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [301 x i32], ptr %95, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = icmp sge i32 %99, 1000000007
  br i1 %100, label %101, label %111

101:                                              ; preds = %92
  br label %102

102:                                              ; preds = %101
  %103 = load i32, ptr %5, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %104
  %106 = load i32, ptr %6, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [301 x i32], ptr %105, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = sub nsw i32 %109, 1000000007
  store i32 %110, ptr %108, align 4, !tbaa !5
  br label %92, !llvm.loop !14

111:                                              ; preds = %92
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %6, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %6, align 4, !tbaa !5
  br label %66, !llvm.loop !15

115:                                              ; preds = %70
  br label %116

116:                                              ; preds = %115
  %117 = load i32, ptr %5, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %5, align 4, !tbaa !5
  br label %60, !llvm.loop !16

119:                                              ; preds = %64
  store i32 1, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %120

120:                                              ; preds = %271, %119
  %121 = load i32, ptr %7, align 4, !tbaa !5
  %122 = load i32, ptr @n, align 4, !tbaa !5
  %123 = icmp slt i32 %121, %122
  br i1 %123, label %125, label %124

124:                                              ; preds = %120
  store i32 20, ptr %3, align 4
  br label %274

125:                                              ; preds = %120
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 -1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %126 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %126, ptr %9, align 4, !tbaa !5
  br label %127

127:                                              ; preds = %144, %125
  %128 = load i32, ptr %9, align 4, !tbaa !5
  %129 = load i32, ptr @n, align 4, !tbaa !5
  %130 = icmp slt i32 %128, %129
  br i1 %130, label %132, label %131

131:                                              ; preds = %127
  store i32 23, ptr %3, align 4
  br label %147

132:                                              ; preds = %127
  %133 = load i32, ptr %9, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %134
  %136 = load i32, ptr %7, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [301 x i32], ptr %135, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = icmp ne i32 %139, 0
  br i1 %140, label %141, label %143

141:                                              ; preds = %132
  %142 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %142, ptr %8, align 4, !tbaa !5
  store i32 23, ptr %3, align 4
  br label %147

143:                                              ; preds = %132
  br label %144

144:                                              ; preds = %143
  %145 = load i32, ptr %9, align 4, !tbaa !5
  %146 = add nsw i32 %145, 1
  store i32 %146, ptr %9, align 4, !tbaa !5
  br label %127, !llvm.loop !17

147:                                              ; preds = %141, %131
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %148

148:                                              ; preds = %147
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = icmp eq i32 %149, -1
  br i1 %150, label %151, label %152

151:                                              ; preds = %148
  store i32 0, ptr @ans, align 4, !tbaa !5
  store i32 20, ptr %3, align 4
  br label %268

152:                                              ; preds = %148
  %153 = load i32, ptr %7, align 4, !tbaa !5
  %154 = load i32, ptr %8, align 4, !tbaa !5
  %155 = icmp ne i32 %153, %154
  br i1 %155, label %156, label %182

156:                                              ; preds = %152
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %157 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %157, ptr %10, align 4, !tbaa !5
  br label %158

158:                                              ; preds = %176, %156
  %159 = load i32, ptr %10, align 4, !tbaa !5
  %160 = load i32, ptr @n, align 4, !tbaa !5
  %161 = icmp slt i32 %159, %160
  br i1 %161, label %163, label %162

162:                                              ; preds = %158
  store i32 26, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %179

163:                                              ; preds = %158
  %164 = load i32, ptr %7, align 4, !tbaa !5
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %165
  %167 = load i32, ptr %10, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [301 x i32], ptr %166, i64 0, i64 %168
  %170 = load i32, ptr %8, align 4, !tbaa !5
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %171
  %173 = load i32, ptr %10, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [301 x i32], ptr %172, i64 0, i64 %174
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %169, ptr noundef nonnull align 4 dereferenceable(4) %175) #4
  br label %176

176:                                              ; preds = %163
  %177 = load i32, ptr %10, align 4, !tbaa !5
  %178 = add nsw i32 %177, 1
  store i32 %178, ptr %10, align 4, !tbaa !5
  br label %158, !llvm.loop !18

179:                                              ; preds = %162
  %180 = load i32, ptr @ans, align 4, !tbaa !5
  %181 = sub nsw i32 1000000007, %180
  store i32 %181, ptr @ans, align 4, !tbaa !5
  br label %182

182:                                              ; preds = %179, %152
  %183 = load i32, ptr @ans, align 4, !tbaa !5
  %184 = sext i32 %183 to i64
  %185 = load i32, ptr %7, align 4, !tbaa !5
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %186
  %188 = load i32, ptr %7, align 4, !tbaa !5
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [301 x i32], ptr %187, i64 0, i64 %189
  %191 = load i32, ptr %190, align 4, !tbaa !5
  %192 = sext i32 %191 to i64
  %193 = mul nsw i64 %184, %192
  %194 = srem i64 %193, 1000000007
  %195 = trunc i64 %194 to i32
  store i32 %195, ptr @ans, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %196 = load i32, ptr %7, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %197
  %199 = load i32, ptr %7, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [301 x i32], ptr %198, i64 0, i64 %200
  %202 = load i32, ptr %201, align 4, !tbaa !5
  %203 = call noundef i32 @_Z7mod_invii(i32 noundef %202, i32 noundef 1000000007)
  %204 = sub nsw i32 1000000007, %203
  store i32 %204, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %205 = load i32, ptr %7, align 4, !tbaa !5
  %206 = add nsw i32 %205, 1
  store i32 %206, ptr %12, align 4, !tbaa !5
  br label %207

207:                                              ; preds = %264, %182
  %208 = load i32, ptr %12, align 4, !tbaa !5
  %209 = load i32, ptr @n, align 4, !tbaa !5
  %210 = icmp slt i32 %208, %209
  br i1 %210, label %212, label %211

211:                                              ; preds = %207
  store i32 29, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %267

212:                                              ; preds = %207
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %213 = load i32, ptr %12, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %214
  %216 = load i32, ptr %7, align 4, !tbaa !5
  %217 = sext i32 %216 to i64
  %218 = getelementptr inbounds [301 x i32], ptr %215, i64 0, i64 %217
  %219 = load i32, ptr %218, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = load i32, ptr %11, align 4, !tbaa !5
  %222 = sext i32 %221 to i64
  %223 = mul nsw i64 %220, %222
  %224 = srem i64 %223, 1000000007
  %225 = trunc i64 %224 to i32
  store i32 %225, ptr %13, align 4, !tbaa !5
  %226 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %226, ptr %8, align 4, !tbaa !5
  br label %227

227:                                              ; preds = %260, %212
  %228 = load i32, ptr %8, align 4, !tbaa !5
  %229 = load i32, ptr @n, align 4, !tbaa !5
  %230 = icmp slt i32 %228, %229
  br i1 %230, label %231, label %263

231:                                              ; preds = %227
  %232 = load i32, ptr %12, align 4, !tbaa !5
  %233 = sext i32 %232 to i64
  %234 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %233
  %235 = load i32, ptr %8, align 4, !tbaa !5
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [301 x i32], ptr %234, i64 0, i64 %236
  %238 = load i32, ptr %237, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = load i32, ptr %7, align 4, !tbaa !5
  %241 = sext i32 %240 to i64
  %242 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %241
  %243 = load i32, ptr %8, align 4, !tbaa !5
  %244 = sext i32 %243 to i64
  %245 = getelementptr inbounds [301 x i32], ptr %242, i64 0, i64 %244
  %246 = load i32, ptr %245, align 4, !tbaa !5
  %247 = sext i32 %246 to i64
  %248 = load i32, ptr %13, align 4, !tbaa !5
  %249 = sext i32 %248 to i64
  %250 = mul nsw i64 %247, %249
  %251 = add nsw i64 %239, %250
  %252 = srem i64 %251, 1000000007
  %253 = trunc i64 %252 to i32
  %254 = load i32, ptr %12, align 4, !tbaa !5
  %255 = sext i32 %254 to i64
  %256 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %255
  %257 = load i32, ptr %8, align 4, !tbaa !5
  %258 = sext i32 %257 to i64
  %259 = getelementptr inbounds [301 x i32], ptr %256, i64 0, i64 %258
  store i32 %253, ptr %259, align 4, !tbaa !5
  br label %260

260:                                              ; preds = %231
  %261 = load i32, ptr %8, align 4, !tbaa !5
  %262 = add nsw i32 %261, 1
  store i32 %262, ptr %8, align 4, !tbaa !5
  br label %227, !llvm.loop !19

263:                                              ; preds = %227
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  br label %264

264:                                              ; preds = %263
  %265 = load i32, ptr %12, align 4, !tbaa !5
  %266 = add nsw i32 %265, 1
  store i32 %266, ptr %12, align 4, !tbaa !5
  br label %207, !llvm.loop !20

267:                                              ; preds = %211
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  store i32 0, ptr %3, align 4
  br label %268

268:                                              ; preds = %267, %151
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %269 = load i32, ptr %3, align 4
  switch i32 %269, label %274 [
    i32 0, label %270
  ]

270:                                              ; preds = %268
  br label %271

271:                                              ; preds = %270
  %272 = load i32, ptr %7, align 4, !tbaa !5
  %273 = add nsw i32 %272, 1
  store i32 %273, ptr %7, align 4, !tbaa !5
  br label %120, !llvm.loop !21

274:                                              ; preds = %268, %124
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %275

275:                                              ; preds = %274
  %276 = load i32, ptr @ans, align 4, !tbaa !5
  %277 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %276)
  ret i32 0
}

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: inlinehint mustprogress nounwind uwtable
declare dso_local void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_invii(i32 noundef, i32 noundef) #3

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

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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11}
!17 = distinct !{!17, !11}
!18 = distinct !{!18, !11}
!19 = distinct !{!19, !11}
!20 = distinct !{!20, !11}
!21 = distinct !{!21, !11}


; 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
@mat = external dso_local global [301 x [301 x i32]], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@buf = external dso_local global [301 x i8], align 16
@.str = external hidden unnamed_addr constant [3 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 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 = load i32, ptr @n, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph91, label %._crit_edge102.thread

.preheader84:                                     ; preds = %._crit_edge
  %4 = icmp sgt i32 %24, 0
  br i1 %4, label %.preheader83.us.preheader, label %._crit_edge102.thread

.preheader83.us.preheader:                        ; preds = %.preheader84
  %wide.trip.count132 = zext nneg i32 %24 to i64
  br label %.preheader83.us

.preheader83.us:                                  ; preds = %.preheader83.us.preheader, %._crit_edge100.us
  %indvars.iv129 = phi i64 [ 0, %.preheader83.us.preheader ], [ %indvars.iv.next130, %._crit_edge100.us ]
  br label %.preheader82.us

5:                                                ; preds = %.lr.ph96.us.preheader, %.preheader81.us
  %indvars.iv.next125 = add nuw nsw i64 %indvars.iv124, 1
  %exitcond128.not = icmp eq i64 %indvars.iv.next125, %wide.trip.count132
  br i1 %exitcond128.not, label %._crit_edge100.us, label %.preheader82.us, !llvm.loop !9

.preheader81.us:                                  ; preds = %.lr.ph92.us.preheader, %.preheader82.us
  %.lcssa.us = phi i32 [ %22, %.lr.ph92.us.preheader ], [ %.promoted.us, %.preheader82.us ]
  %.lcssa.us.fr = freeze i32 %.lcssa.us
  %6 = icmp sgt i32 %.lcssa.us.fr, 1000000006
  br i1 %6, label %.lr.ph96.us.preheader, label %5

.lr.ph96.us.preheader:                            ; preds = %.preheader81.us
  %7 = tail call i32 @llvm.usub.sat.i32(i32 %.lcssa.us.fr, i32 2000000013)
  %8 = add nuw i32 %7, 1000000006
  %9 = urem i32 %8, 1000000007
  %.neg = sub i32 %9, %8
  %10 = add nsw i32 %.lcssa.us.fr, -1000000007
  %11 = add i32 %.neg, %10
  store i32 %11, ptr %12, align 4, !tbaa !5
  br label %5

.preheader82.us:                                  ; preds = %.preheader83.us, %5
  %indvars.iv124 = phi i64 [ 0, %.preheader83.us ], [ %indvars.iv.next125, %5 ]
  %12 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %indvars.iv129, i64 %indvars.iv124
  %.promoted.us = load i32, ptr %12, align 4, !tbaa !5
  %13 = icmp slt i32 %.promoted.us, 0
  br i1 %13, label %.lr.ph92.us.preheader, label %.preheader81.us

.lr.ph92.us.preheader:                            ; preds = %.preheader82.us
  %14 = tail call i32 @llvm.umax.i32(i32 %.promoted.us, i32 -1000000007)
  %15 = icmp ult i32 %.promoted.us, -1000000007
  %umin = zext i1 %15 to i32
  %16 = add nsw i32 %.promoted.us, %umin
  %17 = sub nsw i32 %14, %16
  %18 = udiv i32 %17, 1000000007
  %19 = add nuw nsw i32 %18, %umin
  %20 = mul i32 %19, 1000000007
  %21 = add nsw i32 %.promoted.us, 1000000007
  %22 = add i32 %21, %20
  store i32 %22, ptr %12, align 4, !tbaa !5
  br label %.preheader81.us

._crit_edge100.us:                                ; preds = %5
  %indvars.iv.next130 = add nuw nsw i64 %indvars.iv129, 1
  %exitcond133.not = icmp eq i64 %indvars.iv.next130, %wide.trip.count132
  br i1 %exitcond133.not, label %._crit_edge102, label %.preheader83.us, !llvm.loop !11

.lr.ph91:                                         ; preds = %0, %._crit_edge
  %indvars.iv121 = phi i64 [ %indvars.iv.next122, %._crit_edge ], [ 0, %0 ]
  %23 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @buf)
  %24 = load i32, ptr @n, align 4, !tbaa !5
  %25 = icmp sgt i32 %24, 0
  br i1 %25, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph91
  %wide.trip.count = zext nneg i32 %24 to i64
  br label %28

._crit_edge:                                      ; preds = %39, %.lr.ph91
  %indvars.iv.next122 = add nuw nsw i64 %indvars.iv121, 1
  %26 = sext i32 %24 to i64
  %27 = icmp slt i64 %indvars.iv.next122, %26
  br i1 %27, label %.lr.ph91, label %.preheader84, !llvm.loop !12

28:                                               ; preds = %.lr.ph, %39
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %39 ]
  %29 = getelementptr inbounds [301 x i8], ptr @buf, i64 0, i64 %indvars.iv
  %30 = load i8, ptr %29, align 1, !tbaa !13
  %31 = icmp eq i8 %30, 49
  br i1 %31, label %32, label %39

32:                                               ; preds = %28
  %33 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %indvars.iv, i64 %indvars.iv
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %33, align 4, !tbaa !5
  %36 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %indvars.iv121, i64 %indvars.iv
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = add nsw i32 %37, -1
  store i32 %38, ptr %36, align 4, !tbaa !5
  br label %39

39:                                               ; preds = %28, %32
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %28, !llvm.loop !14

._crit_edge102.thread:                            ; preds = %.preheader84, %0
  store i32 1, ptr @ans, align 4, !tbaa !5
  br label %.loopexit80

._crit_edge102:                                   ; preds = %._crit_edge100.us
  store i32 1, ptr @ans, align 4, !tbaa !5
  %.not160 = icmp eq i32 %24, 1
  br i1 %.not160, label %.loopexit80, label %.preheader79

.preheader79:                                     ; preds = %._crit_edge102, %._crit_edge114
  %indvars.iv147 = phi i64 [ %indvars.iv.next148, %._crit_edge114 ], [ 2, %._crit_edge102 ]
  %indvars.iv134 = phi i64 [ %indvars.iv.next135, %._crit_edge114 ], [ 1, %._crit_edge102 ]
  %40 = phi i32 [ %66, %._crit_edge114 ], [ %24, %._crit_edge102 ]
  %sext = sext i32 %40 to i64
  br label %41

41:                                               ; preds = %.preheader79, %44
  %indvars.iv136 = phi i64 [ %indvars.iv134, %.preheader79 ], [ %indvars.iv.next137, %44 ]
  %42 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %indvars.iv136, i64 %indvars.iv134
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %.not = icmp eq i32 %43, 0
  br i1 %.not, label %44, label %46

44:                                               ; preds = %41
  %indvars.iv.next137 = add nuw nsw i64 %indvars.iv136, 1
  %45 = icmp slt i64 %indvars.iv.next137, %sext
  br i1 %45, label %41, label %.thread77, !llvm.loop !15

.thread77:                                        ; preds = %44
  store i32 0, ptr @ans, align 4, !tbaa !5
  br label %.loopexit80

46:                                               ; preds = %41
  %47 = and i64 %indvars.iv136, 4294967295
  %.not71 = icmp eq i64 %indvars.iv134, %47
  br i1 %.not71, label %._crit_edge155, label %.preheader

._crit_edge155:                                   ; preds = %46
  %.pre = load i32, ptr @ans, align 4, !tbaa !5
  br label %56

.preheader:                                       ; preds = %46
  %48 = icmp slt i64 %indvars.iv134, %sext
  br i1 %48, label %.lr.ph105, label %._crit_edge106

._crit_edge106:                                   ; preds = %.lr.ph105, %.preheader
  %49 = load i32, ptr @ans, align 4, !tbaa !5
  %50 = sub nsw i32 1000000007, %49
  br label %56

.lr.ph105:                                        ; preds = %.preheader, %.lr.ph105
  %indvars.iv139 = phi i64 [ %indvars.iv.next140, %.lr.ph105 ], [ %indvars.iv134, %.preheader ]
  %51 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %indvars.iv134, i64 %indvars.iv139
  %52 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %47, i64 %indvars.iv139
  tail call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %51, ptr noundef nonnull align 4 dereferenceable(4) %52) #4
  %indvars.iv.next140 = add nuw nsw i64 %indvars.iv139, 1
  %53 = load i32, ptr @n, align 4, !tbaa !5
  %54 = trunc nuw i64 %indvars.iv.next140 to i32
  %55 = icmp sgt i32 %53, %54
  br i1 %55, label %.lr.ph105, label %._crit_edge106, !llvm.loop !16

56:                                               ; preds = %._crit_edge155, %._crit_edge106
  %57 = phi i32 [ %.pre, %._crit_edge155 ], [ %50, %._crit_edge106 ]
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %indvars.iv134, i64 %indvars.iv134
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = mul nsw i64 %61, %58
  %63 = srem i64 %62, 1000000007
  %64 = trunc nsw i64 %63 to i32
  store i32 %64, ptr @ans, align 4, !tbaa !5
  %65 = tail call noundef i32 @_Z7mod_invii(i32 noundef %60, i32 noundef 1000000007)
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %indvars.iv.next135 = add nuw nsw i64 %indvars.iv134, 1
  %67 = sext i32 %66 to i64
  %68 = icmp slt i64 %indvars.iv.next135, %67
  br i1 %68, label %.lr.ph113, label %.loopexit80.loopexit

.lr.ph113:                                        ; preds = %56
  %69 = sub nsw i32 1000000007, %65
  %70 = sext i32 %69 to i64
  %wide.trip.count152 = zext i32 %66 to i64
  br label %.lr.ph109.us

.lr.ph109.us:                                     ; preds = %..loopexit_crit_edge.us, %.lr.ph113
  %indvars.iv149 = phi i64 [ %indvars.iv.next150, %..loopexit_crit_edge.us ], [ %indvars.iv147, %.lr.ph113 ]
  %71 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %indvars.iv149, i64 %indvars.iv134
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = mul nsw i64 %73, %70
  %75 = srem i64 %74, 1000000007
  br label %76

76:                                               ; preds = %.lr.ph109.us, %76
  %indvars.iv142 = phi i64 [ %indvars.iv134, %.lr.ph109.us ], [ %indvars.iv.next143, %76 ]
  %77 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %indvars.iv149, i64 %indvars.iv142
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [301 x [301 x i32]], ptr @mat, i64 0, i64 %indvars.iv134, i64 %indvars.iv142
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = mul nsw i64 %75, %82
  %84 = add nsw i64 %83, %79
  %85 = srem i64 %84, 1000000007
  %86 = trunc nsw i64 %85 to i32
  store i32 %86, ptr %77, align 4, !tbaa !5
  %indvars.iv.next143 = add nuw nsw i64 %indvars.iv142, 1
  %exitcond146.not = icmp eq i64 %indvars.iv.next143, %wide.trip.count152
  br i1 %exitcond146.not, label %..loopexit_crit_edge.us, label %76, !llvm.loop !17

..loopexit_crit_edge.us:                          ; preds = %76
  %indvars.iv.next150 = add nuw nsw i64 %indvars.iv149, 1
  %exitcond153.not = icmp eq i64 %indvars.iv.next150, %wide.trip.count152
  br i1 %exitcond153.not, label %._crit_edge114, label %.lr.ph109.us, !llvm.loop !18

._crit_edge114:                                   ; preds = %..loopexit_crit_edge.us
  %indvars.iv.next148 = add nuw nsw i64 %indvars.iv147, 1
  br i1 %68, label %.preheader79, label %.loopexit80.loopexit, !llvm.loop !19

.loopexit80.loopexit:                             ; preds = %56, %._crit_edge114
  %.pre156 = load i32, ptr @ans, align 4, !tbaa !5
  br label %.loopexit80

.loopexit80:                                      ; preds = %._crit_edge102.thread, %.loopexit80.loopexit, %._crit_edge102, %.thread77
  %87 = phi i32 [ %.pre156, %.loopexit80.loopexit ], [ 1, %._crit_edge102 ], [ 0, %.thread77 ], [ 1, %._crit_edge102.thread ]
  %88 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %87)
  ret i32 0
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z7mod_invii(i32 noundef, i32 noundef) local_unnamed_addr #2

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

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

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

attributes #0 = { mustprogress 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 = { 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 #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { 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 = !{!7, !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


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