; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2017-18/Jan 2018/Plat (sprinklers)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@N = external dso_local global i64, align 8
@hei = external dso_local global [100000 x i64], align 16
@lo = external dso_local global [100000 x i64], align 16
@hi = external dso_local global [100000 x i64], align 16
@cumlo = external dso_local global [100000 x [2 x i64]], align 16
@cumhi = external dso_local global [100000 x [2 x i64]], align 16
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5queryi(i32 noundef) #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = load ptr, ptr @stdin, align 8, !tbaa !5
  %12 = call ptr @freopen(ptr noundef @.str, ptr noundef @.str.1, ptr noundef %11)
  %13 = load ptr, ptr @stdout, align 8, !tbaa !5
  %14 = call ptr @freopen(ptr noundef @.str.2, ptr noundef @.str.3, ptr noundef %13)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %30, %0
  %17 = load i32, ptr %2, align 4, !tbaa !9
  %18 = sext i32 %17 to i64
  %19 = load i64, ptr @N, align 8, !tbaa !11
  %20 = icmp slt i64 %18, %19
  br i1 %20, label %22, label %21

21:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %33

22:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  %23 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %23, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %25 = load i32, ptr %4, align 4, !tbaa !9
  %26 = sext i32 %25 to i64
  %27 = load i32, ptr %3, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [100000 x i64], ptr @hei, i64 0, i64 %28
  store i64 %26, ptr %29, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %30

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

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

34:                                               ; preds = %65, %33
  %35 = load i32, ptr %5, align 4, !tbaa !9
  %36 = sext i32 %35 to i64
  %37 = load i64, ptr @N, align 8, !tbaa !11
  %38 = sub nsw i64 %37, 1
  %39 = icmp slt i64 %36, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %34
  %42 = load i32, ptr %5, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100000 x i64], ptr @hei, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !11
  %46 = load i32, ptr %5, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %47
  store i64 %45, ptr %48, align 8, !tbaa !11
  %49 = load i32, ptr %5, align 4, !tbaa !9
  %50 = icmp sgt i32 %49, 0
  br i1 %50, label %51, label %64

51:                                               ; preds = %41
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %53
  %55 = load i32, ptr %5, align 4, !tbaa !9
  %56 = sub nsw i32 %55, 1
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %57
  %59 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %54, ptr noundef nonnull align 8 dereferenceable(8) %58)
  %60 = load i64, ptr %59, align 8, !tbaa !11
  %61 = load i32, ptr %5, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %62
  store i64 %60, ptr %63, align 8, !tbaa !11
  br label %64

64:                                               ; preds = %51, %41
  br label %65

65:                                               ; preds = %64
  %66 = load i32, ptr %5, align 4, !tbaa !9
  %67 = add nsw i32 %66, 1
  store i32 %67, ptr %5, align 4, !tbaa !9
  br label %34, !llvm.loop !15

68:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %69 = load i64, ptr @N, align 8, !tbaa !11
  %70 = sub nsw i64 %69, 1
  %71 = sub nsw i64 %70, 1
  %72 = trunc i64 %71 to i32
  store i32 %72, ptr %6, align 4, !tbaa !9
  br label %73

73:                                               ; preds = %106, %68
  %74 = load i32, ptr %6, align 4, !tbaa !9
  %75 = icmp sge i32 %74, 0
  br i1 %75, label %77, label %76

76:                                               ; preds = %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %109

77:                                               ; preds = %73
  %78 = load i32, ptr %6, align 4, !tbaa !9
  %79 = add nsw i32 %78, 1
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100000 x i64], ptr @hei, i64 0, i64 %80
  %82 = load i64, ptr %81, align 8, !tbaa !11
  %83 = sub nsw i64 %82, 1
  %84 = load i32, ptr %6, align 4, !tbaa !9
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %85
  store i64 %83, ptr %86, align 8, !tbaa !11
  %87 = load i32, ptr %6, align 4, !tbaa !9
  %88 = sext i32 %87 to i64
  %89 = load i64, ptr @N, align 8, !tbaa !11
  %90 = sub nsw i64 %89, 2
  %91 = icmp slt i64 %88, %90
  br i1 %91, label %92, label %105

92:                                               ; preds = %77
  %93 = load i32, ptr %6, align 4, !tbaa !9
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %94
  %96 = load i32, ptr %6, align 4, !tbaa !9
  %97 = add nsw i32 %96, 1
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %98
  %100 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %95, ptr noundef nonnull align 8 dereferenceable(8) %99)
  %101 = load i64, ptr %100, align 8, !tbaa !11
  %102 = load i32, ptr %6, align 4, !tbaa !9
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %103
  store i64 %101, ptr %104, align 8, !tbaa !11
  br label %105

105:                                              ; preds = %92, %77
  br label %106

106:                                              ; preds = %105
  %107 = load i32, ptr %6, align 4, !tbaa !9
  %108 = add nsw i32 %107, -1
  store i32 %108, ptr %6, align 4, !tbaa !9
  br label %73, !llvm.loop !16

109:                                              ; preds = %76
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %110

110:                                              ; preds = %223, %109
  %111 = load i32, ptr %7, align 4, !tbaa !9
  %112 = sext i32 %111 to i64
  %113 = load i64, ptr @N, align 8, !tbaa !11
  %114 = sub nsw i64 %113, 1
  %115 = icmp slt i64 %112, %114
  br i1 %115, label %117, label %116

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

117:                                              ; preds = %110
  %118 = load i32, ptr %7, align 4, !tbaa !9
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %119
  %121 = load i64, ptr %120, align 8, !tbaa !11
  %122 = load i32, ptr %7, align 4, !tbaa !9
  %123 = add nsw i32 %122, 1
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumlo, i64 0, i64 %124
  %126 = getelementptr inbounds [2 x i64], ptr %125, i64 0, i64 0
  store i64 %121, ptr %126, align 16, !tbaa !11
  %127 = load i32, ptr %7, align 4, !tbaa !9
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %128
  %130 = load i64, ptr %129, align 8, !tbaa !11
  %131 = load i32, ptr %7, align 4, !tbaa !9
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %132
  %134 = load i64, ptr %133, align 8, !tbaa !11
  %135 = mul nsw i64 %130, %134
  %136 = load i32, ptr %7, align 4, !tbaa !9
  %137 = add nsw i32 %136, 1
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumlo, i64 0, i64 %138
  %140 = getelementptr inbounds [2 x i64], ptr %139, i64 0, i64 1
  store i64 %135, ptr %140, align 8, !tbaa !11
  %141 = load i32, ptr %7, align 4, !tbaa !9
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %142
  %144 = load i64, ptr %143, align 8, !tbaa !11
  %145 = load i32, ptr %7, align 4, !tbaa !9
  %146 = add nsw i32 %145, 1
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumhi, i64 0, i64 %147
  %149 = getelementptr inbounds [2 x i64], ptr %148, i64 0, i64 0
  store i64 %144, ptr %149, align 16, !tbaa !11
  %150 = load i32, ptr %7, align 4, !tbaa !9
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %151
  %153 = load i64, ptr %152, align 8, !tbaa !11
  %154 = load i32, ptr %7, align 4, !tbaa !9
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %155
  %157 = load i64, ptr %156, align 8, !tbaa !11
  %158 = mul nsw i64 %153, %157
  %159 = load i32, ptr %7, align 4, !tbaa !9
  %160 = add nsw i32 %159, 1
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumhi, i64 0, i64 %161
  %163 = getelementptr inbounds [2 x i64], ptr %162, i64 0, i64 1
  store i64 %158, ptr %163, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !9
  br label %164

164:                                              ; preds = %219, %117
  %165 = load i32, ptr %9, align 4, !tbaa !9
  %166 = icmp slt i32 %165, 2
  br i1 %166, label %168, label %167

167:                                              ; preds = %164
  store i32 14, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %222

168:                                              ; preds = %164
  %169 = load i32, ptr %7, align 4, !tbaa !9
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumlo, i64 0, i64 %170
  %172 = load i32, ptr %9, align 4, !tbaa !9
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [2 x i64], ptr %171, i64 0, i64 %173
  %175 = load i64, ptr %174, align 8, !tbaa !11
  %176 = load i32, ptr %7, align 4, !tbaa !9
  %177 = add nsw i32 %176, 1
  %178 = sext i32 %177 to i64
  %179 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumlo, i64 0, i64 %178
  %180 = load i32, ptr %9, align 4, !tbaa !9
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [2 x i64], ptr %179, i64 0, i64 %181
  %183 = load i64, ptr %182, align 8, !tbaa !11
  %184 = add nsw i64 %183, %175
  store i64 %184, ptr %182, align 8, !tbaa !11
  %185 = load i32, ptr %7, align 4, !tbaa !9
  %186 = add nsw i32 %185, 1
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumlo, i64 0, i64 %187
  %189 = load i32, ptr %9, align 4, !tbaa !9
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [2 x i64], ptr %188, i64 0, i64 %190
  %192 = load i64, ptr %191, align 8, !tbaa !11
  %193 = srem i64 %192, 1000000007
  store i64 %193, ptr %191, align 8, !tbaa !11
  %194 = load i32, ptr %7, align 4, !tbaa !9
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumhi, i64 0, i64 %195
  %197 = load i32, ptr %9, align 4, !tbaa !9
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds [2 x i64], ptr %196, i64 0, i64 %198
  %200 = load i64, ptr %199, align 8, !tbaa !11
  %201 = load i32, ptr %7, align 4, !tbaa !9
  %202 = add nsw i32 %201, 1
  %203 = sext i32 %202 to i64
  %204 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumhi, i64 0, i64 %203
  %205 = load i32, ptr %9, align 4, !tbaa !9
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [2 x i64], ptr %204, i64 0, i64 %206
  %208 = load i64, ptr %207, align 8, !tbaa !11
  %209 = add nsw i64 %208, %200
  store i64 %209, ptr %207, align 8, !tbaa !11
  %210 = load i32, ptr %7, align 4, !tbaa !9
  %211 = add nsw i32 %210, 1
  %212 = sext i32 %211 to i64
  %213 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumhi, i64 0, i64 %212
  %214 = load i32, ptr %9, align 4, !tbaa !9
  %215 = sext i32 %214 to i64
  %216 = getelementptr inbounds [2 x i64], ptr %213, i64 0, i64 %215
  %217 = load i64, ptr %216, align 8, !tbaa !11
  %218 = srem i64 %217, 1000000007
  store i64 %218, ptr %216, align 8, !tbaa !11
  br label %219

219:                                              ; preds = %168
  %220 = load i32, ptr %9, align 4, !tbaa !9
  %221 = add nsw i32 %220, 1
  store i32 %221, ptr %9, align 4, !tbaa !9
  br label %164, !llvm.loop !17

222:                                              ; preds = %167
  br label %223

223:                                              ; preds = %222
  %224 = load i32, ptr %7, align 4, !tbaa !9
  %225 = add nsw i32 %224, 1
  store i32 %225, ptr %7, align 4, !tbaa !9
  br label %110, !llvm.loop !18

226:                                              ; preds = %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !9
  br label %227

227:                                              ; preds = %236, %226
  %228 = load i32, ptr %10, align 4, !tbaa !9
  %229 = sext i32 %228 to i64
  %230 = load i64, ptr @N, align 8, !tbaa !11
  %231 = sub nsw i64 %230, 1
  %232 = icmp slt i64 %229, %231
  br i1 %232, label %234, label %233

233:                                              ; preds = %227
  store i32 17, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %239

234:                                              ; preds = %227
  %235 = load i32, ptr %10, align 4, !tbaa !9
  call void @_Z5queryi(i32 noundef %235)
  br label %236

236:                                              ; preds = %234
  %237 = load i32, ptr %10, align 4, !tbaa !9
  %238 = add nsw i32 %237, 1
  store i32 %238, ptr %10, align 4, !tbaa !9
  br label %227, !llvm.loop !19

239:                                              ; preds = %233
  %240 = load i64, ptr @ans, align 8, !tbaa !11
  %241 = mul nsw i64 %240, 500000004
  store i64 %241, ptr @ans, align 8, !tbaa !11
  %242 = load i64, ptr @ans, align 8, !tbaa !11
  %243 = srem i64 %242, 1000000007
  %244 = add nsw i64 %243, 1000000007
  %245 = srem i64 %244, 1000000007
  store i64 %245, ptr @ans, align 8, !tbaa !11
  %246 = load i64, ptr @ans, align 8, !tbaa !11
  %247 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %246)
  %248 = load i32, ptr %1, align 4
  ret i32 %248
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #5

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { nounwind }

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@N = external dso_local global i64, align 8
@hei = external dso_local local_unnamed_addr global [100000 x i64], align 16
@lo = external dso_local global [100000 x i64], align 16
@hi = external dso_local global [100000 x i64], align 16
@cumlo = external dso_local local_unnamed_addr global [100000 x [2 x i64]], align 16
@cumhi = external dso_local local_unnamed_addr global [100000 x [2 x i64]], align 16
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [14 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [2 x i8], align 1
@stdin = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5queryi(i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = load ptr, ptr @stdin, align 8, !tbaa !5
  %4 = tail call ptr @freopen(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, ptr noundef %3)
  %5 = load ptr, ptr @stdout, align 8, !tbaa !5
  %6 = tail call ptr @freopen(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.3, ptr noundef %5)
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %8 = load i64, ptr @N, align 8, !tbaa !9
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %.lr.ph, label %._crit_edge

.preheader58:                                     ; preds = %.lr.ph
  %10 = icmp sgt i64 %20, 1
  br i1 %10, label %11, label %._crit_edge

11:                                               ; preds = %.preheader58
  %12 = load i64, ptr @hei, align 16, !tbaa !9
  store i64 %12, ptr @lo, align 16, !tbaa !9
  %.not = icmp eq i64 %20, 2
  br i1 %.not, label %.lr.ph64.preheader, label %.lr.ph61.peel.next

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %13 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %15 = load i32, ptr %2, align 4, !tbaa !11
  %16 = sext i32 %15 to i64
  %17 = load i32, ptr %1, align 4, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [100000 x i64], ptr @hei, i64 0, i64 %18
  store i64 %16, ptr %19, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = load i64, ptr @N, align 8, !tbaa !9
  %21 = icmp sgt i64 %20, %indvars.iv.next
  br i1 %21, label %.lr.ph, label %.preheader58, !llvm.loop !13

._crit_edge:                                      ; preds = %.lr.ph61.peel.next, %0, %.preheader58
  %.pre90 = phi i64 [ %20, %.preheader58 ], [ %8, %0 ], [ %.pre, %.lr.ph61.peel.next ]
  %22 = trunc i64 %.pre90 to i32
  %23 = add i32 %22, -2
  %24 = icmp sgt i32 %23, -1
  br i1 %24, label %.lr.ph64.preheader, label %.preheader57

.lr.ph64.preheader:                               ; preds = %11, %._crit_edge
  %25 = phi i32 [ %23, %._crit_edge ], [ 0, %11 ]
  %.pre9096 = phi i64 [ %.pre90, %._crit_edge ], [ 2, %11 ]
  %26 = zext nneg i32 %25 to i64
  br label %.lr.ph64

.lr.ph61.peel.next:                               ; preds = %11, %.lr.ph61.peel.next
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %.lr.ph61.peel.next ], [ 1, %11 ]
  %27 = getelementptr inbounds [100000 x i64], ptr @hei, i64 0, i64 %indvars.iv73
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %indvars.iv73
  store i64 %28, ptr %29, align 8, !tbaa !9
  %30 = add nsw i64 %indvars.iv73, -1
  %31 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %30
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %29, ptr noundef nonnull align 8 dereferenceable(8) %31)
  %33 = load i64, ptr %32, align 8, !tbaa !9
  store i64 %33, ptr %29, align 8, !tbaa !9
  %.pre = load i64, ptr @N, align 8, !tbaa !9
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %34 = add nsw i64 %.pre, -1
  %35 = icmp sgt i64 %34, %indvars.iv.next74
  br i1 %35, label %.lr.ph61.peel.next, label %._crit_edge, !llvm.loop !15

.preheader57:                                     ; preds = %51, %._crit_edge
  %36 = phi i64 [ %.pre90, %._crit_edge ], [ %52, %51 ]
  %37 = icmp sgt i64 %36, 1
  br i1 %37, label %.lr.ph67.preheader, label %._crit_edge70

.lr.ph67.preheader:                               ; preds = %.preheader57
  %.pre91 = load i64, ptr @cumlo, align 16, !tbaa !9
  %.pre92 = load i64, ptr @cumhi, align 16, !tbaa !9
  %.pre93 = load i64, ptr getelementptr inbounds (i8, ptr @cumlo, i64 8), align 8, !tbaa !9
  %.pre94 = load i64, ptr getelementptr inbounds (i8, ptr @cumhi, i64 8), align 8, !tbaa !9
  %38 = add nsw i64 %36, -2
  br label %.lr.ph67

.lr.ph64:                                         ; preds = %.lr.ph64.preheader, %51
  %39 = phi i64 [ %.pre9096, %.lr.ph64.preheader ], [ %52, %51 ]
  %indvars.iv77 = phi i64 [ %26, %.lr.ph64.preheader ], [ %indvars.iv.next78, %51 ]
  %40 = add nuw nsw i64 %indvars.iv77, 1
  %41 = getelementptr inbounds [100000 x i64], ptr @hei, i64 0, i64 %40
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = add nsw i64 %42, -1
  %44 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %indvars.iv77
  store i64 %43, ptr %44, align 8, !tbaa !9
  %45 = add nsw i64 %39, -2
  %46 = icmp sgt i64 %45, %indvars.iv77
  br i1 %46, label %47, label %51

47:                                               ; preds = %.lr.ph64
  %48 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %40
  %49 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %44, ptr noundef nonnull align 8 dereferenceable(8) %48)
  %50 = load i64, ptr %49, align 8, !tbaa !9
  store i64 %50, ptr %44, align 8, !tbaa !9
  %.pre89 = load i64, ptr @N, align 8, !tbaa !9
  br label %51

51:                                               ; preds = %.lr.ph64, %47
  %52 = phi i64 [ %39, %.lr.ph64 ], [ %.pre89, %47 ]
  %indvars.iv.next78 = add nsw i64 %indvars.iv77, -1
  %53 = icmp sgt i64 %indvars.iv77, 0
  br i1 %53, label %.lr.ph64, label %.preheader57, !llvm.loop !17

.preheader:                                       ; preds = %.lr.ph67
  br i1 %37, label %.lr.ph69, label %._crit_edge70

.lr.ph67:                                         ; preds = %.lr.ph67.preheader, %.lr.ph67
  %54 = phi i64 [ %.pre94, %.lr.ph67.preheader ], [ %75, %.lr.ph67 ]
  %55 = phi i64 [ %.pre93, %.lr.ph67.preheader ], [ %72, %.lr.ph67 ]
  %56 = phi i64 [ %.pre92, %.lr.ph67.preheader ], [ %69, %.lr.ph67 ]
  %57 = phi i64 [ %.pre91, %.lr.ph67.preheader ], [ %67, %.lr.ph67 ]
  %indvars.iv83 = phi i64 [ 0, %.lr.ph67.preheader ], [ %indvars.iv.next84, %.lr.ph67 ]
  %58 = getelementptr inbounds [100000 x i64], ptr @lo, i64 0, i64 %indvars.iv83
  %59 = load i64, ptr %58, align 8, !tbaa !9
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %60 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumlo, i64 0, i64 %indvars.iv.next84
  %61 = mul nsw i64 %59, %59
  %62 = getelementptr inbounds [100000 x i64], ptr @hi, i64 0, i64 %indvars.iv83
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumhi, i64 0, i64 %indvars.iv.next84
  %65 = mul nsw i64 %63, %63
  %66 = add nsw i64 %59, %57
  %67 = srem i64 %66, 1000000007
  store i64 %67, ptr %60, align 16, !tbaa !9
  %68 = add nsw i64 %63, %56
  %69 = srem i64 %68, 1000000007
  store i64 %69, ptr %64, align 16, !tbaa !9
  %70 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumlo, i64 0, i64 %indvars.iv.next84, i64 1
  %71 = add nsw i64 %61, %55
  %72 = srem i64 %71, 1000000007
  store i64 %72, ptr %70, align 8, !tbaa !9
  %73 = getelementptr inbounds [100000 x [2 x i64]], ptr @cumhi, i64 0, i64 %indvars.iv.next84, i64 1
  %74 = add nsw i64 %65, %54
  %75 = srem i64 %74, 1000000007
  store i64 %75, ptr %73, align 8, !tbaa !9
  %exitcond.not = icmp eq i64 %indvars.iv83, %38
  br i1 %exitcond.not, label %.preheader, label %.lr.ph67, !llvm.loop !18

._crit_edge70:                                    ; preds = %.lr.ph69, %.preheader57, %.preheader
  %76 = load i64, ptr @ans, align 8, !tbaa !9
  %.fr = freeze i64 %76
  %77 = mul i64 %.fr, 500000004
  %78 = srem i64 %77, 1000000007
  %79 = add nsw i64 %78, 1000000007
  %.cmp = icmp ugt i64 %78, -1000000008
  %80 = select i1 %.cmp, i64 %79, i64 %78
  store i64 %80, ptr @ans, align 8, !tbaa !9
  %81 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %80)
  ret i32 0

.lr.ph69:                                         ; preds = %.preheader, %.lr.ph69
  %indvars.iv86 = phi i64 [ %indvars.iv.next87, %.lr.ph69 ], [ 0, %.preheader ]
  %82 = trunc nuw nsw i64 %indvars.iv86 to i32
  call void @_Z5queryi(i32 noundef %82)
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %83 = load i64, ptr @N, align 8, !tbaa !9
  %84 = add nsw i64 %83, -1
  %85 = icmp sgt i64 %84, %indvars.iv.next87
  br i1 %85, label %.lr.ph69, label %._crit_edge70, !llvm.loop !19
}

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #4 align 2

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #4 align 2

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 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { 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 #6 = { nounwind }

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

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


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