; LLVM IR from tangjz/acm-icpc :: codeforces/1545D.ll (Z5solvev)

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

@_ZZ5solvevE3mat = external hidden global [1001 x [1001 x i32]], align 16
@_ZZ5solvevE3sum = external hidden global [1001 x i32], align 16
@_ZZ5solvevE4diff = external hidden global [1001 x i32], align 16
@_ZZ5solvevE4sum2 = external hidden global [1001 x i64], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@stdout = external global ptr, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #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 i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i64, align 8
  %16 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %90, %0
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

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

23:                                               ; preds = %18
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %25
  store i64 0, ptr %26, align 8, !tbaa !9
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3sum, i64 0, i64 %28
  store i32 0, ptr %29, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %69, %23
  %31 = load i32, ptr %5, align 4, !tbaa !5
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %30
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %72

35:                                               ; preds = %30
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %37
  %39 = getelementptr inbounds [1001 x i32], ptr %38, i64 0, i64 0
  %40 = load i32, ptr %5, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds i32, ptr %39, i64 %41
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %42)
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %45
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [1001 x i32], ptr %46, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3sum, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = add nsw i32 %54, %50
  store i32 %55, ptr %53, align 4, !tbaa !5
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %57
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [1001 x i32], ptr %58, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = call noundef i64 @_Z3sqri(i32 noundef %62)
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !9
  %68 = add nsw i64 %67, %63
  store i64 %68, ptr %66, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %35
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  store i32 %71, ptr %5, align 4, !tbaa !5
  br label %30, !llvm.loop !11

72:                                               ; preds = %34
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = icmp sgt i32 %73, 0
  br i1 %74, label %75, label %89

75:                                               ; preds = %72
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3sum, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = sub nsw i32 %80, 1
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3sum, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = sub nsw i32 %79, %84
  %86 = load i32, ptr %3, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE4diff, i64 0, i64 %87
  store i32 %85, ptr %88, align 4, !tbaa !5
  br label %89

89:                                               ; preds = %75, %72
  br label %90

90:                                               ; preds = %89
  %91 = load i32, ptr %3, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %3, align 4, !tbaa !5
  br label %18, !llvm.loop !13

93:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %94 = load i32, ptr %1, align 4, !tbaa !5
  %95 = sub nsw i32 %94, 1
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3sum, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = load i32, ptr @_ZZ5solvevE3sum, align 16, !tbaa !5
  %100 = sub nsw i32 %98, %99
  %101 = load i32, ptr %1, align 4, !tbaa !5
  %102 = sub nsw i32 %101, 1
  %103 = sdiv i32 %100, %102
  store i32 %103, ptr %7, align 4, !tbaa !5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %119, %93
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = load i32, ptr %1, align 4, !tbaa !5
  %107 = sub nsw i32 %106, 1
  %108 = icmp slt i32 %105, %107
  br i1 %108, label %109, label %116

109:                                              ; preds = %104
  %110 = load i32, ptr %6, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE4diff, i64 0, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = icmp eq i32 %113, %114
  br label %116

116:                                              ; preds = %109, %104
  %117 = phi i1 [ false, %104 ], [ %115, %109 ]
  br i1 %117, label %118, label %122

118:                                              ; preds = %116
  br label %119

119:                                              ; preds = %118
  %120 = load i32, ptr %6, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %6, align 4, !tbaa !5
  br label %104, !llvm.loop !14

122:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %123 = load i32, ptr %6, align 4, !tbaa !5
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE4diff, i64 0, i64 %124
  %126 = load i32, ptr %125, align 4, !tbaa !5
  %127 = load i32, ptr %7, align 4, !tbaa !5
  %128 = sub nsw i32 %126, %127
  store i32 %128, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %129 = load i32, ptr %6, align 4, !tbaa !5
  %130 = icmp sge i32 %129, 3
  br i1 %130, label %131, label %171

131:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %132 = load i32, ptr %6, align 4, !tbaa !5
  %133 = sub nsw i32 %132, 2
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %134
  %136 = load i64, ptr %135, align 8, !tbaa !9
  %137 = load i32, ptr %6, align 4, !tbaa !5
  %138 = sub nsw i32 %137, 3
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %139
  %141 = load i64, ptr %140, align 8, !tbaa !9
  %142 = sub nsw i64 %136, %141
  store i64 %142, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %143 = load i32, ptr %6, align 4, !tbaa !5
  %144 = sub nsw i32 %143, 1
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %145
  %147 = load i64, ptr %146, align 8, !tbaa !9
  %148 = load i32, ptr %6, align 4, !tbaa !5
  %149 = sub nsw i32 %148, 2
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %150
  %152 = load i64, ptr %151, align 8, !tbaa !9
  %153 = sub nsw i64 %147, %152
  store i64 %153, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %154 = load i64, ptr %11, align 8, !tbaa !9
  %155 = load i64, ptr %10, align 8, !tbaa !9
  %156 = sub nsw i64 %154, %155
  %157 = load i64, ptr %11, align 8, !tbaa !9
  %158 = add nsw i64 %156, %157
  store i64 %158, ptr %12, align 8, !tbaa !9
  %159 = load i32, ptr %6, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %160
  %162 = load i64, ptr %161, align 8, !tbaa !9
  %163 = load i32, ptr %6, align 4, !tbaa !5
  %164 = sub nsw i32 %163, 1
  %165 = sext i32 %164 to i64
  %166 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %165
  %167 = load i64, ptr %166, align 8, !tbaa !9
  %168 = load i64, ptr %12, align 8, !tbaa !9
  %169 = add nsw i64 %167, %168
  %170 = sub nsw i64 %162, %169
  store i64 %170, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %211

171:                                              ; preds = %122
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %172 = load i32, ptr %6, align 4, !tbaa !5
  %173 = add nsw i32 %172, 3
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %174
  %176 = load i64, ptr %175, align 8, !tbaa !9
  %177 = load i32, ptr %6, align 4, !tbaa !5
  %178 = add nsw i32 %177, 2
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %179
  %181 = load i64, ptr %180, align 8, !tbaa !9
  %182 = sub nsw i64 %176, %181
  store i64 %182, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %183 = load i32, ptr %6, align 4, !tbaa !5
  %184 = add nsw i32 %183, 2
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %185
  %187 = load i64, ptr %186, align 8, !tbaa !9
  %188 = load i32, ptr %6, align 4, !tbaa !5
  %189 = add nsw i32 %188, 1
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %190
  %192 = load i64, ptr %191, align 8, !tbaa !9
  %193 = sub nsw i64 %187, %192
  store i64 %193, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %194 = load i64, ptr %14, align 8, !tbaa !9
  %195 = load i64, ptr %13, align 8, !tbaa !9
  %196 = sub nsw i64 %194, %195
  %197 = load i64, ptr %14, align 8, !tbaa !9
  %198 = add nsw i64 %196, %197
  store i64 %198, ptr %15, align 8, !tbaa !9
  %199 = load i32, ptr %6, align 4, !tbaa !5
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %200
  %202 = load i64, ptr %201, align 8, !tbaa !9
  %203 = load i32, ptr %6, align 4, !tbaa !5
  %204 = add nsw i32 %203, 1
  %205 = sext i32 %204 to i64
  %206 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %205
  %207 = load i64, ptr %206, align 8, !tbaa !9
  %208 = load i64, ptr %15, align 8, !tbaa !9
  %209 = sub nsw i64 %207, %208
  %210 = sub nsw i64 %202, %209
  store i64 %210, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %211

211:                                              ; preds = %171, %131
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %212

212:                                              ; preds = %241, %211
  %213 = load i32, ptr %16, align 4, !tbaa !5
  %214 = load i32, ptr %2, align 4, !tbaa !5
  %215 = icmp slt i32 %213, %214
  br i1 %215, label %216, label %238

216:                                              ; preds = %212
  %217 = load i32, ptr %6, align 4, !tbaa !5
  %218 = sext i32 %217 to i64
  %219 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %218
  %220 = load i32, ptr %16, align 4, !tbaa !5
  %221 = sext i32 %220 to i64
  %222 = getelementptr inbounds [1001 x i32], ptr %219, i64 0, i64 %221
  %223 = load i32, ptr %222, align 4, !tbaa !5
  %224 = call noundef i64 @_Z3sqri(i32 noundef %223)
  %225 = load i32, ptr %6, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %226
  %228 = load i32, ptr %16, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [1001 x i32], ptr %227, i64 0, i64 %229
  %231 = load i32, ptr %230, align 4, !tbaa !5
  %232 = load i32, ptr %8, align 4, !tbaa !5
  %233 = sub nsw i32 %231, %232
  %234 = call noundef i64 @_Z3sqri(i32 noundef %233)
  %235 = sub nsw i64 %224, %234
  %236 = load i64, ptr %9, align 8, !tbaa !9
  %237 = icmp ne i64 %235, %236
  br label %238

238:                                              ; preds = %216, %212
  %239 = phi i1 [ false, %212 ], [ %237, %216 ]
  br i1 %239, label %240, label %244

240:                                              ; preds = %238
  br label %241

241:                                              ; preds = %240
  %242 = load i32, ptr %16, align 4, !tbaa !5
  %243 = add nsw i32 %242, 1
  store i32 %243, ptr %16, align 4, !tbaa !5
  br label %212, !llvm.loop !15

244:                                              ; preds = %238
  %245 = load i32, ptr %6, align 4, !tbaa !5
  %246 = load i32, ptr %6, align 4, !tbaa !5
  %247 = sext i32 %246 to i64
  %248 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %247
  %249 = load i32, ptr %16, align 4, !tbaa !5
  %250 = sext i32 %249 to i64
  %251 = getelementptr inbounds [1001 x i32], ptr %248, i64 0, i64 %250
  %252 = load i32, ptr %251, align 4, !tbaa !5
  %253 = load i32, ptr %8, align 4, !tbaa !5
  %254 = sub nsw i32 %252, %253
  %255 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %245, i32 noundef %254)
  %256 = load ptr, ptr @stdout, align 8, !tbaa !16
  %257 = call i32 @fflush(ptr noundef %256)
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

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

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

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

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

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

declare i32 @fflush(ptr noundef) #2

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress 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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = !{!17, !17, i64 0}
!17 = !{!"any pointer", !7, i64 0}


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

@_ZZ5solvevE3mat = external hidden global [1001 x [1001 x i32]], align 16
@_ZZ5solvevE3sum = external hidden local_unnamed_addr global [1001 x i32], align 16
@_ZZ5solvevE4diff = external hidden local_unnamed_addr global [1001 x i32], align 16
@_ZZ5solvevE4sum2 = external hidden local_unnamed_addr global [1001 x i64], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  %3 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %2, ptr noundef nonnull %1)
  %4 = load i32, ptr %1, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph78, label %._crit_edge79

.lr.ph78:                                         ; preds = %0
  %6 = load i32, ptr %2, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph78.split, label %8

8:                                                ; preds = %.lr.ph78
  %9 = zext nneg i32 %4 to i64
  %10 = shl nuw nsw i64 %9, 3
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(1) @_ZZ5solvevE4sum2, i8 0, i64 %10, i1 false), !tbaa !9
  store i32 0, ptr @_ZZ5solvevE3sum, align 16, !tbaa !5
  %exitcond.peel.not = icmp eq i32 %4, 1
  br i1 %exitcond.peel.not, label %._crit_edge79, label %.peel.next.preheader

.peel.next.preheader:                             ; preds = %8
  %load_initial = load i32, ptr @_ZZ5solvevE3sum, align 16
  store i32 0, ptr getelementptr inbounds (i8, ptr @_ZZ5solvevE3sum, i64 4), align 4, !tbaa !5
  %11 = sub nsw i32 0, %load_initial
  store i32 %11, ptr getelementptr inbounds (i8, ptr @_ZZ5solvevE4diff, i64 4), align 4, !tbaa !5
  %exitcond.not.peel = icmp eq i32 %4, 2
  br i1 %exitcond.not.peel, label %._crit_edge79, label %.peel.next

.peel.next:                                       ; preds = %.peel.next.preheader, %.peel.next
  %indvars.iv = phi i64 [ %indvars.iv.next, %.peel.next ], [ 2, %.peel.next.preheader ]
  %12 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3sum, i64 0, i64 %indvars.iv
  store i32 0, ptr %12, align 4, !tbaa !5
  %13 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE4diff, i64 0, i64 %indvars.iv
  store i32 0, ptr %13, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %9
  br i1 %exitcond.not, label %._crit_edge79, label %.peel.next, !llvm.loop !11

._crit_edge79:                                    ; preds = %.peel.next.preheader, %.peel.next, %50, %8, %0
  %.lcssa = phi i32 [ %4, %0 ], [ 1, %8 ], [ %51, %50 ], [ %4, %.peel.next ], [ %4, %.peel.next.preheader ]
  %14 = add nsw i32 %.lcssa, -1
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3sum, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = load i32, ptr @_ZZ5solvevE3sum, align 16, !tbaa !5
  %19 = sub nsw i32 %17, %18
  %20 = sdiv i32 %19, %14
  %21 = icmp sgt i32 %.lcssa, 2
  br i1 %21, label %.lr.ph82.preheader, label %.critedge.thread

.critedge.thread:                                 ; preds = %._crit_edge79
  %22 = load i32, ptr getelementptr inbounds (i8, ptr @_ZZ5solvevE4diff, i64 4), align 4, !tbaa !5
  %23 = sub nsw i32 %22, %20
  br label %68

.lr.ph82.preheader:                               ; preds = %._crit_edge79
  %wide.trip.count107 = zext nneg i32 %14 to i64
  br label %.lr.ph82

.lr.ph78.split:                                   ; preds = %.lr.ph78, %50
  %24 = phi i32 [ %29, %50 ], [ %6, %.lr.ph78 ]
  %indvars.iv101 = phi i64 [ %indvars.iv.next102, %50 ], [ 0, %.lr.ph78 ]
  %25 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %indvars.iv101
  store i64 0, ptr %25, align 8, !tbaa !9
  %26 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3sum, i64 0, i64 %indvars.iv101
  store i32 0, ptr %26, align 4, !tbaa !5
  %27 = icmp sgt i32 %24, 0
  br i1 %27, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.lr.ph78.split
  %28 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %indvars.iv101
  br label %30

._crit_edge:                                      ; preds = %30, %.lr.ph78.split
  %29 = phi i32 [ %24, %.lr.ph78.split ], [ %40, %30 ]
  %.not66 = icmp eq i64 %indvars.iv101, 0
  br i1 %.not66, label %50, label %43

30:                                               ; preds = %.lr.ph, %30
  %indvars.iv98 = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next99, %30 ]
  %31 = getelementptr inbounds i32, ptr %28, i64 %indvars.iv98
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %31)
  %33 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %indvars.iv101, i64 %indvars.iv98
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = load i32, ptr %26, align 4, !tbaa !5
  %36 = add nsw i32 %35, %34
  store i32 %36, ptr %26, align 4, !tbaa !5
  %37 = call noundef i64 @_Z3sqri(i32 noundef %34)
  %38 = load i64, ptr %25, align 8, !tbaa !9
  %39 = add nsw i64 %38, %37
  store i64 %39, ptr %25, align 8, !tbaa !9
  %indvars.iv.next99 = add nuw nsw i64 %indvars.iv98, 1
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = icmp slt i64 %indvars.iv.next99, %41
  br i1 %42, label %30, label %._crit_edge, !llvm.loop !14

43:                                               ; preds = %._crit_edge
  %44 = load i32, ptr %26, align 4, !tbaa !5
  %45 = add nsw i64 %indvars.iv101, -1
  %46 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE3sum, i64 0, i64 %45
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = sub nsw i32 %44, %47
  %49 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE4diff, i64 0, i64 %indvars.iv101
  store i32 %48, ptr %49, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %._crit_edge, %43
  %indvars.iv.next102 = add nuw nsw i64 %indvars.iv101, 1
  %51 = load i32, ptr %1, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = icmp slt i64 %indvars.iv.next102, %52
  br i1 %53, label %.lr.ph78.split, label %._crit_edge79, !llvm.loop !15

.lr.ph82:                                         ; preds = %.lr.ph82.preheader, %57
  %indvars.iv104 = phi i64 [ 1, %.lr.ph82.preheader ], [ %indvars.iv.next105, %57 ]
  %54 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE4diff, i64 0, i64 %indvars.iv104
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = icmp eq i32 %55, %20
  br i1 %56, label %57, label %.critedge.split.loop.exit

57:                                               ; preds = %.lr.ph82
  %indvars.iv.next105 = add nuw nsw i64 %indvars.iv104, 1
  %exitcond108.not = icmp eq i64 %indvars.iv.next105, %wide.trip.count107
  br i1 %exitcond108.not, label %.critedge, label %.lr.ph82, !llvm.loop !17

.critedge.split.loop.exit:                        ; preds = %.lr.ph82
  %58 = trunc nuw nsw i64 %indvars.iv104 to i32
  br label %.critedge

.critedge:                                        ; preds = %57, %.critedge.split.loop.exit
  %.061.lcssa = phi i32 [ %58, %.critedge.split.loop.exit ], [ %14, %57 ]
  %59 = zext nneg i32 %.061.lcssa to i64
  %60 = getelementptr inbounds [1001 x i32], ptr @_ZZ5solvevE4diff, i64 0, i64 %59
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = sub nsw i32 %61, %20
  %63 = icmp ugt i32 %.061.lcssa, 2
  br i1 %63, label %64, label %68

64:                                               ; preds = %.critedge
  %65 = add nsw i32 %.061.lcssa, -2
  %66 = add nsw i32 %.061.lcssa, -3
  %67 = add nsw i32 %.061.lcssa, -1
  br label %74

68:                                               ; preds = %.critedge.thread, %.critedge
  %69 = phi i32 [ %23, %.critedge.thread ], [ %62, %.critedge ]
  %70 = phi i64 [ 1, %.critedge.thread ], [ %59, %.critedge ]
  %.061.lcssa114 = phi i32 [ 1, %.critedge.thread ], [ %.061.lcssa, %.critedge ]
  %71 = add nuw nsw i32 %.061.lcssa114, 3
  %72 = add nuw nsw i32 %.061.lcssa114, 2
  %73 = add nuw nsw i32 %.061.lcssa114, 1
  br label %74

74:                                               ; preds = %68, %64
  %.sink130 = phi i32 [ %73, %68 ], [ %67, %64 ]
  %.pn.in = phi i32 [ %72, %68 ], [ %65, %64 ]
  %.sink = phi i64 [ %70, %68 ], [ %59, %64 ]
  %.pn131.in = phi i32 [ %71, %68 ], [ %66, %64 ]
  %75 = phi i32 [ %69, %68 ], [ %62, %64 ]
  %.061.lcssa115 = phi i32 [ %.061.lcssa114, %68 ], [ %.061.lcssa, %64 ]
  %.pn131 = zext i32 %.pn131.in to i64
  %.sink123.in = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %.pn131
  %.sink123 = load i64, ptr %.sink123.in, align 8, !tbaa !9
  %.pn = zext i32 %.pn.in to i64
  %.sink126.in = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %.pn
  %.sink126 = load i64, ptr %.sink126.in, align 8, !tbaa !9
  %76 = zext nneg i32 %.sink130 to i64
  %77 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !9
  %.neg64.neg = sub i64 %.sink126, %78
  %79 = getelementptr inbounds [1001 x i64], ptr @_ZZ5solvevE4sum2, i64 0, i64 %.sink
  %80 = load i64, ptr %79, align 8, !tbaa !9
  %reass.add.neg.neg = shl i64 %.neg64.neg, 1
  %81 = add i64 %.sink123, %78
  %.neg65.neg = sub i64 %.sink126, %81
  %.neg70 = add i64 %.neg65.neg, %80
  %82 = add i64 %.neg70, %reass.add.neg.neg
  %83 = load i32, ptr %2, align 4, !tbaa !5
  %84 = icmp sgt i32 %83, 0
  br i1 %84, label %.lr.ph88, label %.critedge2

.lr.ph88:                                         ; preds = %74, %92
  %indvars.iv109 = phi i64 [ %indvars.iv.next110, %92 ], [ 0, %74 ]
  %85 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %.sink, i64 %indvars.iv109
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = call noundef i64 @_Z3sqri(i32 noundef %86)
  %88 = load i32, ptr %85, align 4, !tbaa !5
  %89 = sub nsw i32 %88, %75
  %90 = call noundef i64 @_Z3sqri(i32 noundef %89)
  %91 = sub nsw i64 %87, %90
  %.not = icmp eq i64 %91, %82
  br i1 %.not, label %.critedge2.loopexit, label %92

92:                                               ; preds = %.lr.ph88
  %indvars.iv.next110 = add nuw nsw i64 %indvars.iv109, 1
  %93 = load i32, ptr %2, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = icmp slt i64 %indvars.iv.next110, %94
  br i1 %95, label %.lr.ph88, label %.critedge2.loopexit, !llvm.loop !18

.critedge2.loopexit:                              ; preds = %92, %.lr.ph88
  %.0.lcssa.ph.in = phi i64 [ %indvars.iv109, %.lr.ph88 ], [ %indvars.iv.next110, %92 ]
  %96 = and i64 %.0.lcssa.ph.in, 4294967295
  br label %.critedge2

.critedge2:                                       ; preds = %.critedge2.loopexit, %74
  %.0.lcssa = phi i64 [ 0, %74 ], [ %96, %.critedge2.loopexit ]
  %97 = getelementptr inbounds [1001 x [1001 x i32]], ptr @_ZZ5solvevE3mat, i64 0, i64 %.sink, i64 %.0.lcssa
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = sub nsw i32 %98, %75
  %100 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.061.lcssa115, i32 noundef %99)
  %101 = load ptr, ptr @stdout, align 8, !tbaa !19
  %102 = call i32 @fflush(ptr noundef %101)
  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 void
}

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z3sqri(i32 noundef) local_unnamed_addr #3

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fflush(ptr nocapture noundef) local_unnamed_addr #2

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12, !13}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.peeled.count", i32 2}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12, !16}
!16 = !{!"llvm.loop.unswitch.partial.disable"}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = !{!20, !20, i64 0}
!20 = !{!"any pointer", !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopFullUnrollPass,LoopIdiomRecognizePass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimpleLoopUnswitchPass,SimplifyCFGPass