; LLVM IR from tangjz/acm-icpc :: codeforces/complete (1334F)

; 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
@a = external dso_local global [500003 x i32], align 16
@p = external dso_local global [500003 x i32], align 16
@m = external dso_local global i32, align 4
@b = external dso_local global [500003 x i32], align 16
@pos = external dso_local global [500003 x i32], align 16
@bit = external dso_local global [500003 x i64], align 16
@f = external dso_local global [500003 x i64], align 16
@g = external dso_local global [500003 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 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 i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %19

19:                                               ; preds = %29, %0
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = load i32, ptr @n, align 4, !tbaa !5
  %22 = icmp sle i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %32

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds i32, ptr @a, i64 %26
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %27)
  br label %29

29:                                               ; preds = %24
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !5
  br label %19, !llvm.loop !9

32:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %43, %32
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = load i32, ptr @n, align 4, !tbaa !5
  %36 = icmp sle i32 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %46

38:                                               ; preds = %33
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds i32, ptr @p, i64 %40
  %42 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %41)
  br label %43

43:                                               ; preds = %38
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %3, align 4, !tbaa !5
  br label %33, !llvm.loop !11

46:                                               ; preds = %37
  %47 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %68, %46
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = load i32, ptr @m, align 4, !tbaa !5
  %51 = icmp sle i32 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %71

53:                                               ; preds = %48
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds i32, ptr @b, i64 %55
  %57 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %56)
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [500003 x i32], ptr @b, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [500003 x i32], ptr @pos, i64 0, i64 %63
  store i32 %58, ptr %64, align 4, !tbaa !5
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %66
  store i64 4557430888798830399, ptr %67, align 8, !tbaa !12
  br label %68

68:                                               ; preds = %53
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %4, align 4, !tbaa !5
  br label %48, !llvm.loop !14

71:                                               ; preds = %52
  store i32 0, ptr @b, align 16, !tbaa !5
  store i64 4557430888798830399, ptr @g, align 16, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %182, %71
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = load i32, ptr @n, align 4, !tbaa !5
  %75 = icmp sle i32 %73, %74
  br i1 %75, label %77, label %76

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

77:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [500003 x i32], ptr @a, i64 0, i64 %79
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [500003 x i32], ptr @pos, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  store i32 %84, ptr %7, align 4, !tbaa !5
  %85 = load i32, ptr %5, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [500003 x i64], ptr @f, i64 0, i64 %86
  store i64 0, ptr %87, align 8, !tbaa !12
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = icmp sgt i32 %88, 0
  br i1 %89, label %90, label %146

90:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = sub nsw i32 %91, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [500003 x i32], ptr @b, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  store i32 %95, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [500003 x i32], ptr @b, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  store i32 %99, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %100 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %100, ptr %10, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %115, %90
  %102 = load i32, ptr %10, align 4, !tbaa !5
  %103 = icmp sgt i32 %102, 0
  br i1 %103, label %105, label %104

104:                                              ; preds = %101
  store i32 14, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %122

105:                                              ; preds = %101
  %106 = load i32, ptr %10, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [500003 x i64], ptr @bit, i64 0, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !12
  %110 = load i32, ptr %5, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [500003 x i64], ptr @f, i64 0, i64 %111
  %113 = load i64, ptr %112, align 8, !tbaa !12
  %114 = sub nsw i64 %113, %109
  store i64 %114, ptr %112, align 8, !tbaa !12
  br label %115

115:                                              ; preds = %105
  %116 = load i32, ptr %10, align 4, !tbaa !5
  %117 = load i32, ptr %10, align 4, !tbaa !5
  %118 = sub nsw i32 0, %117
  %119 = and i32 %116, %118
  %120 = load i32, ptr %10, align 4, !tbaa !5
  %121 = sub nsw i32 %120, %119
  store i32 %121, ptr %10, align 4, !tbaa !5
  br label %101, !llvm.loop !15

122:                                              ; preds = %104
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %123 = load i32, ptr %9, align 4, !tbaa !5
  store i32 %123, ptr %11, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %138, %122
  %125 = load i32, ptr %11, align 4, !tbaa !5
  %126 = icmp sgt i32 %125, 0
  br i1 %126, label %128, label %127

127:                                              ; preds = %124
  store i32 17, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  br label %145

128:                                              ; preds = %124
  %129 = load i32, ptr %11, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [500003 x i64], ptr @bit, i64 0, i64 %130
  %132 = load i64, ptr %131, align 8, !tbaa !12
  %133 = load i32, ptr %5, align 4, !tbaa !5
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [500003 x i64], ptr @f, i64 0, i64 %134
  %136 = load i64, ptr %135, align 8, !tbaa !12
  %137 = add nsw i64 %136, %132
  store i64 %137, ptr %135, align 8, !tbaa !12
  br label %138

138:                                              ; preds = %128
  %139 = load i32, ptr %11, align 4, !tbaa !5
  %140 = load i32, ptr %11, align 4, !tbaa !5
  %141 = sub nsw i32 0, %140
  %142 = and i32 %139, %141
  %143 = load i32, ptr %11, align 4, !tbaa !5
  %144 = sub nsw i32 %143, %142
  store i32 %144, ptr %11, align 4, !tbaa !5
  br label %124, !llvm.loop !16

145:                                              ; preds = %127
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %146

146:                                              ; preds = %145, %77
  %147 = load i32, ptr %5, align 4, !tbaa !5
  %148 = sext i32 %147 to i64
  %149 = getelementptr inbounds [500003 x i32], ptr @p, i64 0, i64 %148
  %150 = load i32, ptr %149, align 4, !tbaa !5
  %151 = icmp sgt i32 %150, 0
  br i1 %151, label %152, label %181

152:                                              ; preds = %146
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %153 = load i32, ptr %5, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [500003 x i32], ptr @a, i64 0, i64 %154
  %156 = load i32, ptr %155, align 4, !tbaa !5
  store i32 %156, ptr %12, align 4, !tbaa !5
  br label %157

157:                                              ; preds = %173, %152
  %158 = load i32, ptr %12, align 4, !tbaa !5
  %159 = load i32, ptr @n, align 4, !tbaa !5
  %160 = icmp sle i32 %158, %159
  br i1 %160, label %162, label %161

161:                                              ; preds = %157
  store i32 20, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  br label %180

162:                                              ; preds = %157
  %163 = load i32, ptr %5, align 4, !tbaa !5
  %164 = sext i32 %163 to i64
  %165 = getelementptr inbounds [500003 x i32], ptr @p, i64 0, i64 %164
  %166 = load i32, ptr %165, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = load i32, ptr %12, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [500003 x i64], ptr @bit, i64 0, i64 %169
  %171 = load i64, ptr %170, align 8, !tbaa !12
  %172 = add nsw i64 %171, %167
  store i64 %172, ptr %170, align 8, !tbaa !12
  br label %173

173:                                              ; preds = %162
  %174 = load i32, ptr %12, align 4, !tbaa !5
  %175 = load i32, ptr %12, align 4, !tbaa !5
  %176 = sub nsw i32 0, %175
  %177 = and i32 %174, %176
  %178 = load i32, ptr %12, align 4, !tbaa !5
  %179 = add nsw i32 %178, %177
  store i32 %179, ptr %12, align 4, !tbaa !5
  br label %157, !llvm.loop !17

180:                                              ; preds = %161
  br label %181

181:                                              ; preds = %180, %146
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %182

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

185:                                              ; preds = %76
  %186 = load i32, ptr @m, align 4, !tbaa !5
  %187 = sext i32 %186 to i64
  %188 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %187
  store i64 0, ptr %188, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store i64 0, ptr %14, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %189 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %189, ptr %15, align 4, !tbaa !5
  br label %190

190:                                              ; preds = %284, %185
  %191 = load i32, ptr %15, align 4, !tbaa !5
  %192 = icmp sge i32 %191, 1
  br i1 %192, label %194, label %193

193:                                              ; preds = %190
  store i32 23, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %287

194:                                              ; preds = %190
  %195 = load i32, ptr %15, align 4, !tbaa !5
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [500003 x i32], ptr @p, i64 0, i64 %196
  %198 = load i32, ptr %197, align 4, !tbaa !5
  %199 = icmp slt i32 %198, 0
  br i1 %199, label %200, label %208

200:                                              ; preds = %194
  %201 = load i32, ptr %15, align 4, !tbaa !5
  %202 = sext i32 %201 to i64
  %203 = getelementptr inbounds [500003 x i32], ptr @p, i64 0, i64 %202
  %204 = load i32, ptr %203, align 4, !tbaa !5
  %205 = sext i32 %204 to i64
  %206 = load i64, ptr %14, align 8, !tbaa !12
  %207 = add nsw i64 %206, %205
  store i64 %207, ptr %14, align 8, !tbaa !12
  br label %227

208:                                              ; preds = %194
  %209 = load i32, ptr %15, align 4, !tbaa !5
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [500003 x i32], ptr @a, i64 0, i64 %210
  %212 = load i32, ptr %211, align 4, !tbaa !5
  %213 = load i32, ptr @m, align 4, !tbaa !5
  %214 = sext i32 %213 to i64
  %215 = getelementptr inbounds [500003 x i32], ptr @b, i64 0, i64 %214
  %216 = load i32, ptr %215, align 4, !tbaa !5
  %217 = icmp sgt i32 %212, %216
  br i1 %217, label %218, label %226

218:                                              ; preds = %208
  %219 = load i32, ptr %15, align 4, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds [500003 x i32], ptr @p, i64 0, i64 %220
  %222 = load i32, ptr %221, align 4, !tbaa !5
  %223 = sext i32 %222 to i64
  %224 = load i64, ptr %13, align 8, !tbaa !12
  %225 = add nsw i64 %224, %223
  store i64 %225, ptr %13, align 8, !tbaa !12
  br label %226

226:                                              ; preds = %218, %208
  br label %227

227:                                              ; preds = %226, %200
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %228 = load i32, ptr %15, align 4, !tbaa !5
  %229 = sext i32 %228 to i64
  %230 = getelementptr inbounds [500003 x i32], ptr @a, i64 0, i64 %229
  %231 = load i32, ptr %230, align 4, !tbaa !5
  %232 = sext i32 %231 to i64
  %233 = getelementptr inbounds [500003 x i32], ptr @pos, i64 0, i64 %232
  %234 = load i32, ptr %233, align 4, !tbaa !5
  store i32 %234, ptr %16, align 4, !tbaa !5
  %235 = load i32, ptr %15, align 4, !tbaa !5
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds [500003 x i32], ptr @a, i64 0, i64 %236
  %238 = load i32, ptr %237, align 4, !tbaa !5
  %239 = sext i32 %238 to i64
  %240 = getelementptr inbounds [500003 x i32], ptr @pos, i64 0, i64 %239
  %241 = load i32, ptr %240, align 4, !tbaa !5
  %242 = icmp ne i32 %241, 0
  br i1 %242, label %244, label %243

243:                                              ; preds = %227
  store i32 25, ptr %6, align 4
  br label %281

244:                                              ; preds = %227
  %245 = load i32, ptr %15, align 4, !tbaa !5
  %246 = sext i32 %245 to i64
  %247 = getelementptr inbounds [500003 x i32], ptr @p, i64 0, i64 %246
  %248 = load i32, ptr %247, align 4, !tbaa !5
  %249 = icmp slt i32 %248, 0
  br i1 %249, label %250, label %261

250:                                              ; preds = %244
  %251 = load i32, ptr %15, align 4, !tbaa !5
  %252 = sext i32 %251 to i64
  %253 = getelementptr inbounds [500003 x i32], ptr @p, i64 0, i64 %252
  %254 = load i32, ptr %253, align 4, !tbaa !5
  %255 = sext i32 %254 to i64
  %256 = load i32, ptr %15, align 4, !tbaa !5
  %257 = sext i32 %256 to i64
  %258 = getelementptr inbounds [500003 x i64], ptr @f, i64 0, i64 %257
  %259 = load i64, ptr %258, align 8, !tbaa !12
  %260 = sub nsw i64 %259, %255
  store i64 %260, ptr %258, align 8, !tbaa !12
  br label %261

261:                                              ; preds = %250, %244
  %262 = load i32, ptr %16, align 4, !tbaa !5
  %263 = sub nsw i32 %262, 1
  %264 = sext i32 %263 to i64
  %265 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %264
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #4
  %266 = load i32, ptr %16, align 4, !tbaa !5
  %267 = sext i32 %266 to i64
  %268 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %267
  %269 = load i64, ptr %268, align 8, !tbaa !12
  %270 = load i32, ptr %15, align 4, !tbaa !5
  %271 = sext i32 %270 to i64
  %272 = getelementptr inbounds [500003 x i64], ptr @f, i64 0, i64 %271
  %273 = load i64, ptr %272, align 8, !tbaa !12
  %274 = add nsw i64 %269, %273
  store i64 %274, ptr %17, align 8, !tbaa !12
  %275 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %265, ptr noundef nonnull align 8 dereferenceable(8) %17)
  %276 = load i64, ptr %275, align 8, !tbaa !12
  %277 = load i32, ptr %16, align 4, !tbaa !5
  %278 = sub nsw i32 %277, 1
  %279 = sext i32 %278 to i64
  %280 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %279
  store i64 %276, ptr %280, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #4
  store i32 0, ptr %6, align 4
  br label %281

281:                                              ; preds = %261, %243
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  %282 = load i32, ptr %6, align 4
  switch i32 %282, label %301 [
    i32 0, label %283
    i32 25, label %284
  ]

283:                                              ; preds = %281
  br label %284

284:                                              ; preds = %283, %281
  %285 = load i32, ptr %15, align 4, !tbaa !5
  %286 = add nsw i32 %285, -1
  store i32 %286, ptr %15, align 4, !tbaa !5
  br label %190, !llvm.loop !19

287:                                              ; preds = %193
  %288 = load i64, ptr @g, align 16, !tbaa !12
  %289 = icmp slt i64 %288, 4557430888798830399
  br i1 %289, label %290, label %297

290:                                              ; preds = %287
  %291 = load i64, ptr @g, align 16, !tbaa !12
  %292 = load i64, ptr %13, align 8, !tbaa !12
  %293 = add nsw i64 %291, %292
  %294 = load i64, ptr %14, align 8, !tbaa !12
  %295 = add nsw i64 %293, %294
  %296 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %295)
  br label %299

297:                                              ; preds = %287
  %298 = call i32 @puts(ptr noundef @.str.2)
  br label %299

299:                                              ; preds = %297, %290
  store i32 0, ptr %1, align 4
  store i32 1, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  %300 = load i32, ptr %1, align 4
  ret i32 %300

301:                                              ; preds = %281
  unreachable
}

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 noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

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

declare i32 @puts(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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !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}


; 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
@a = external dso_local global [500003 x i32], align 16
@p = external dso_local global [500003 x i32], align 16
@m = external dso_local global i32, align 4
@b = external dso_local global [500003 x i32], align 16
@pos = external dso_local local_unnamed_addr global [500003 x i32], align 16
@bit = external dso_local local_unnamed_addr global [500003 x i64], align 16
@f = external dso_local local_unnamed_addr global [500003 x i64], align 16
@g = external dso_local global [500003 x i64], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: mustprogress norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n)
  %3 = load i32, ptr @n, align 4, !tbaa !5
  %.not102 = icmp slt i32 %3, 1
  br i1 %.not102, label %._crit_edge, label %.lr.ph

.preheader100:                                    ; preds = %.lr.ph
  %4 = icmp slt i32 %7, 1
  br i1 %4, label %._crit_edge, label %.lr.ph106

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %5 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %6 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %5)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %.not.not = icmp slt i64 %indvars.iv, %8
  br i1 %.not.not, label %.lr.ph, label %.preheader100, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph106, %0, %.preheader100
  %9 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @m)
  %10 = load i32, ptr @m, align 4, !tbaa !5
  %.not78107 = icmp slt i32 %10, 1
  br i1 %.not78107, label %._crit_edge111, label %.lr.ph110

.lr.ph106:                                        ; preds = %.preheader100, %.lr.ph106
  %indvars.iv140 = phi i64 [ %indvars.iv.next141, %.lr.ph106 ], [ 1, %.preheader100 ]
  %11 = getelementptr inbounds i32, ptr @p, i64 %indvars.iv140
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %11)
  %indvars.iv.next141 = add nuw nsw i64 %indvars.iv140, 1
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %.not77.not = icmp slt i64 %indvars.iv140, %14
  br i1 %.not77.not, label %.lr.ph106, label %._crit_edge, !llvm.loop !11

._crit_edge111:                                   ; preds = %.lr.ph110, %._crit_edge
  %.lcssa101 = phi i32 [ %10, %._crit_edge ], [ %26, %.lr.ph110 ]
  store i32 0, ptr @b, align 16, !tbaa !5
  store i64 4557430888798830399, ptr @g, align 16, !tbaa !12
  %15 = load i32, ptr @n, align 4, !tbaa !5
  %.not79123 = icmp slt i32 %15, 1
  br i1 %.not79123, label %._crit_edge127.thread, label %.lr.ph126.preheader

._crit_edge127.thread:                            ; preds = %._crit_edge111
  %16 = sext i32 %.lcssa101 to i64
  %17 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %16
  store i64 0, ptr %17, align 8, !tbaa !12
  br label %._crit_edge134

.lr.ph126.preheader:                              ; preds = %._crit_edge111
  %18 = add nuw i32 %15, 1
  %wide.trip.count = zext i32 %18 to i64
  br label %.lr.ph126

.lr.ph110:                                        ; preds = %._crit_edge, %.lr.ph110
  %indvars.iv143 = phi i64 [ %indvars.iv.next144, %.lr.ph110 ], [ 1, %._crit_edge ]
  %19 = getelementptr inbounds i32, ptr @b, i64 %indvars.iv143
  %20 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %19)
  %21 = load i32, ptr %19, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [500003 x i32], ptr @pos, i64 0, i64 %22
  %24 = trunc nuw nsw i64 %indvars.iv143 to i32
  store i32 %24, ptr %23, align 4, !tbaa !5
  %25 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %indvars.iv143
  store i64 4557430888798830399, ptr %25, align 8, !tbaa !12
  %indvars.iv.next144 = add nuw nsw i64 %indvars.iv143, 1
  %26 = load i32, ptr @m, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %.not78.not = icmp slt i64 %indvars.iv143, %27
  br i1 %.not78.not, label %.lr.ph110, label %._crit_edge111, !llvm.loop !14

._crit_edge127:                                   ; preds = %.loopexit
  %28 = sext i32 %.lcssa101 to i64
  %29 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %28
  store i64 0, ptr %29, align 8, !tbaa !12
  %30 = zext nneg i32 %15 to i64
  br label %.lr.ph133

.lr.ph126:                                        ; preds = %.lr.ph126.preheader, %.loopexit
  %indvars.iv146 = phi i64 [ 1, %.lr.ph126.preheader ], [ %indvars.iv.next147, %.loopexit ]
  %31 = getelementptr inbounds [500003 x i32], ptr @a, i64 0, i64 %indvars.iv146
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [500003 x i32], ptr @pos, i64 0, i64 %33
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = getelementptr inbounds [500003 x i64], ptr @f, i64 0, i64 %indvars.iv146
  store i64 0, ptr %36, align 8, !tbaa !12
  %37 = icmp sgt i32 %35, 0
  br i1 %37, label %38, label %.loopexit99

38:                                               ; preds = %.lr.ph126
  %39 = add nsw i32 %35, -1
  %40 = zext nneg i32 %39 to i64
  %41 = getelementptr inbounds [500003 x i32], ptr @b, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = zext nneg i32 %35 to i64
  %44 = getelementptr inbounds [500003 x i32], ptr @b, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = icmp sgt i32 %42, 0
  br i1 %46, label %.lr.ph114, label %.preheader98

..preheader98_crit_edge:                          ; preds = %.lr.ph114
  store i64 %52, ptr %36, align 8, !tbaa !12
  br label %.preheader98

.preheader98:                                     ; preds = %..preheader98_crit_edge, %38
  %.promoted118 = phi i64 [ %52, %..preheader98_crit_edge ], [ 0, %38 ]
  %47 = icmp sgt i32 %45, 0
  br i1 %47, label %.lr.ph117, label %.loopexit99

.lr.ph114:                                        ; preds = %38, %.lr.ph114
  %48 = phi i64 [ %52, %.lr.ph114 ], [ 0, %38 ]
  %.066112 = phi i32 [ %53, %.lr.ph114 ], [ %42, %38 ]
  %49 = zext nneg i32 %.066112 to i64
  %50 = getelementptr inbounds [500003 x i64], ptr @bit, i64 0, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !12
  %52 = sub nsw i64 %48, %51
  %.not83 = add nsw i32 %.066112, -1
  %53 = and i32 %.not83, %.066112
  %.not = icmp eq i32 %53, 0
  br i1 %.not, label %..preheader98_crit_edge, label %.lr.ph114, !llvm.loop !15

.lr.ph117:                                        ; preds = %.preheader98, %.lr.ph117
  %54 = phi i64 [ %58, %.lr.ph117 ], [ %.promoted118, %.preheader98 ]
  %.065116 = phi i32 [ %59, %.lr.ph117 ], [ %45, %.preheader98 ]
  %55 = zext nneg i32 %.065116 to i64
  %56 = getelementptr inbounds [500003 x i64], ptr @bit, i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !12
  %58 = add nsw i64 %54, %57
  %.not82 = add nsw i32 %.065116, -1
  %59 = and i32 %.not82, %.065116
  %.not158 = icmp eq i32 %59, 0
  br i1 %.not158, label %..loopexit99_crit_edge, label %.lr.ph117, !llvm.loop !16

..loopexit99_crit_edge:                           ; preds = %.lr.ph117
  store i64 %58, ptr %36, align 8, !tbaa !12
  br label %.loopexit99

.loopexit99:                                      ; preds = %.preheader98, %..loopexit99_crit_edge, %.lr.ph126
  %60 = getelementptr inbounds [500003 x i32], ptr @p, i64 0, i64 %indvars.iv146
  %61 = load i32, ptr %60, align 4, !tbaa !5
  %62 = icmp slt i32 %61, 1
  %.not81120 = icmp sgt i32 %32, %15
  %or.cond = or i1 %62, %.not81120
  br i1 %or.cond, label %.loopexit, label %.lr.ph122

.lr.ph122:                                        ; preds = %.loopexit99
  %63 = zext nneg i32 %61 to i64
  br label %64

64:                                               ; preds = %.lr.ph122, %64
  %.064121 = phi i32 [ %32, %.lr.ph122 ], [ %71, %64 ]
  %65 = sext i32 %.064121 to i64
  %66 = getelementptr inbounds [500003 x i64], ptr @bit, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !12
  %68 = add nsw i64 %67, %63
  store i64 %68, ptr %66, align 8, !tbaa !12
  %69 = sub nsw i32 0, %.064121
  %70 = and i32 %.064121, %69
  %71 = add nsw i32 %70, %.064121
  %.not81 = icmp sgt i32 %71, %15
  br i1 %.not81, label %.loopexit, label %64, !llvm.loop !17

.loopexit:                                        ; preds = %64, %.loopexit99
  %indvars.iv.next147 = add nuw nsw i64 %indvars.iv146, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next147, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge127, label %.lr.ph126, !llvm.loop !18

._crit_edge134:                                   ; preds = %111, %._crit_edge127.thread
  %.062.lcssa = phi i64 [ 0, %._crit_edge127.thread ], [ %.16388, %111 ]
  %.061.lcssa = phi i64 [ 0, %._crit_edge127.thread ], [ %.190, %111 ]
  %72 = load i64, ptr @g, align 16, !tbaa !12
  %73 = icmp slt i64 %72, 4557430888798830399
  br i1 %73, label %113, label %117

.lr.ph133:                                        ; preds = %._crit_edge127, %111
  %indvars.iv149 = phi i64 [ %30, %._crit_edge127 ], [ %indvars.iv.next150, %111 ]
  %.061130 = phi i64 [ 0, %._crit_edge127 ], [ %.190, %111 ]
  %.062129 = phi i64 [ 0, %._crit_edge127 ], [ %.16388, %111 ]
  %74 = getelementptr inbounds [500003 x i32], ptr @p, i64 0, i64 %indvars.iv149
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = icmp slt i32 %75, 0
  br i1 %76, label %.thread, label %77

77:                                               ; preds = %.lr.ph133
  %78 = getelementptr inbounds [500003 x i32], ptr @a, i64 0, i64 %indvars.iv149
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr @m, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [500003 x i32], ptr @b, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = icmp sgt i32 %79, %83
  %narrow = select i1 %84, i32 %75, i32 0
  %85 = zext nneg i32 %narrow to i64
  %.163 = add nsw i64 %.062129, %85
  %86 = sext i32 %79 to i64
  %87 = getelementptr inbounds [500003 x i32], ptr @pos, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %.not80 = icmp eq i32 %88, 0
  br i1 %.not80, label %111, label %._crit_edge153

._crit_edge153:                                   ; preds = %77
  %.phi.trans.insert = getelementptr inbounds [500003 x i64], ptr @f, i64 0, i64 %indvars.iv149
  %.pre = load i64, ptr %.phi.trans.insert, align 8, !tbaa !12
  br label %99

.thread:                                          ; preds = %.lr.ph133
  %89 = sext i32 %75 to i64
  %90 = add nsw i64 %.061130, %89
  %91 = getelementptr inbounds [500003 x i32], ptr @a, i64 0, i64 %indvars.iv149
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [500003 x i32], ptr @pos, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %.not8086 = icmp eq i32 %95, 0
  br i1 %.not8086, label %111, label %.thread91

.thread91:                                        ; preds = %.thread
  %96 = getelementptr inbounds [500003 x i64], ptr @f, i64 0, i64 %indvars.iv149
  %97 = load i64, ptr %96, align 8, !tbaa !12
  %98 = sub nsw i64 %97, %89
  store i64 %98, ptr %96, align 8, !tbaa !12
  br label %99

99:                                               ; preds = %._crit_edge153, %.thread91
  %100 = phi i64 [ %98, %.thread91 ], [ %.pre, %._crit_edge153 ]
  %.1638796 = phi i64 [ %.062129, %.thread91 ], [ %.163, %._crit_edge153 ]
  %.18994 = phi i64 [ %90, %.thread91 ], [ %.061130, %._crit_edge153 ]
  %101 = phi i32 [ %95, %.thread91 ], [ %88, %._crit_edge153 ]
  %102 = add nsw i32 %101, -1
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %103
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #4
  %105 = sext i32 %101 to i64
  %106 = getelementptr inbounds [500003 x i64], ptr @g, i64 0, i64 %105
  %107 = load i64, ptr %106, align 8, !tbaa !12
  %108 = add nsw i64 %100, %107
  store i64 %108, ptr %1, align 8, !tbaa !12
  %109 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %104, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %110 = load i64, ptr %109, align 8, !tbaa !12
  store i64 %110, ptr %104, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #4
  br label %111

111:                                              ; preds = %.thread, %77, %99
  %.190 = phi i64 [ %90, %.thread ], [ %.061130, %77 ], [ %.18994, %99 ]
  %.16388 = phi i64 [ %.062129, %.thread ], [ %.163, %77 ], [ %.1638796, %99 ]
  %indvars.iv.next150 = add nsw i64 %indvars.iv149, -1
  %112 = icmp sgt i64 %indvars.iv149, 1
  br i1 %112, label %.lr.ph133, label %._crit_edge134, !llvm.loop !19

113:                                              ; preds = %._crit_edge134
  %114 = add i64 %.061.lcssa, %.062.lcssa
  %115 = add i64 %114, %72
  %116 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %115)
  br label %119

117:                                              ; preds = %._crit_edge134
  %118 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %119

119:                                              ; preds = %117, %113
  ret i32 0
}

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

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

; Function Attrs: mustprogress 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 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 #3

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

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

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 = { mustprogress 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !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: BDCEPass,ConstraintEliminationPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass