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

; 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 [13 x i32], align 16
@len = external dso_local global i32, align 4
@seq = external dso_local global [500001 x i32], align 16
@vis = external dso_local global [500001 x i32], align 16
@dis = external dso_local global [500001 x i64], align 16
@L = external dso_local global i64, align 8
@R = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 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
  store i32 0, ptr %1, align 4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @L, ptr noundef @R)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %14

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

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

19:                                               ; preds = %14
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds i32, ptr @a, i64 %21
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %22)
  %24 = load i32, ptr @a, align 16, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [13 x i32], ptr @a, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = icmp sgt i32 %24, %28
  br i1 %29, label %30, label %34

30:                                               ; preds = %19
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [13 x i32], ptr @a, i64 0, i64 %32
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @a, ptr noundef nonnull align 4 dereferenceable(4) %33) #6
  br label %34

34:                                               ; preds = %30, %19
  br label %35

35:                                               ; preds = %34
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %2, align 4, !tbaa !5
  br label %14, !llvm.loop !9

38:                                               ; preds = %18
  %39 = load i32, ptr @a, align 16, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = mul i64 %40, 8
  call void @llvm.memset.p0.i64(ptr align 16 @dis, i8 63, i64 %41, i1 false)
  store i64 0, ptr @dis, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  %42 = load i32, ptr @a, align 16, !tbaa !5
  store i32 %42, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %179, %38
  %44 = load i32, ptr %4, align 4, !tbaa !5
  %45 = load i32, ptr @n, align 4, !tbaa !5
  %46 = icmp slt i32 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %43
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %182

48:                                               ; preds = %43
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [13 x i32], ptr @a, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %49, i32 noundef %53)
  store i32 %54, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [13 x i32], ptr @a, i64 0, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = load i32, ptr @a, align 16, !tbaa !5
  %60 = srem i32 %58, %59
  store i32 %60, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %174, %48
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = load i32, ptr @a, align 16, !tbaa !5
  %64 = icmp slt i32 %62, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %61
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %178

66:                                               ; preds = %61
  %67 = load i32, ptr %7, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [500001 x i32], ptr @vis, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = icmp eq i32 %70, %71
  br i1 %72, label %73, label %74

73:                                               ; preds = %66
  br label %174

74:                                               ; preds = %66
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr @len, align 4, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %75 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %75, ptr %9, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %125, %74
  %77 = load i32, ptr %9, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [500001 x i32], ptr @vis, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = icmp ne i32 %80, %81
  br i1 %82, label %84, label %83

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

84:                                               ; preds = %76
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = load i32, ptr %9, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [500001 x i32], ptr @vis, i64 0, i64 %87
  store i32 %85, ptr %88, align 4, !tbaa !5
  %89 = load i32, ptr %9, align 4, !tbaa !5
  %90 = load i32, ptr @len, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr @len, align 4, !tbaa !5
  %92 = sext i32 %90 to i64
  %93 = getelementptr inbounds [500001 x i32], ptr @seq, i64 0, i64 %92
  store i32 %89, ptr %93, align 4, !tbaa !5
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [500001 x i32], ptr @seq, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %98
  %100 = load i64, ptr %99, align 8, !tbaa !11
  %101 = load i32, ptr @len, align 4, !tbaa !5
  %102 = sub nsw i32 %101, 1
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [500001 x i32], ptr @seq, i64 0, i64 %103
  %105 = load i32, ptr %104, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %106
  %108 = load i64, ptr %107, align 8, !tbaa !11
  %109 = icmp sgt i64 %100, %108
  br i1 %109, label %110, label %113

110:                                              ; preds = %84
  %111 = load i32, ptr @len, align 4, !tbaa !5
  %112 = sub nsw i32 %111, 1
  store i32 %112, ptr %8, align 4, !tbaa !5
  br label %113

113:                                              ; preds = %110, %84
  br label %114

114:                                              ; preds = %113
  %115 = load i32, ptr %6, align 4, !tbaa !5
  %116 = load i32, ptr %9, align 4, !tbaa !5
  %117 = add nsw i32 %116, %115
  store i32 %117, ptr %9, align 4, !tbaa !5
  %118 = load i32, ptr @a, align 16, !tbaa !5
  %119 = icmp sge i32 %117, %118
  br i1 %119, label %120, label %125

120:                                              ; preds = %114
  %121 = load i32, ptr @a, align 16, !tbaa !5
  %122 = load i32, ptr %9, align 4, !tbaa !5
  %123 = sub nsw i32 %122, %121
  store i32 %123, ptr %9, align 4, !tbaa !5
  %124 = icmp ne i32 %123, 0
  br label %125

125:                                              ; preds = %120, %114
  %126 = phi i1 [ false, %114 ], [ %124, %120 ]
  br label %76, !llvm.loop !13

127:                                              ; preds = %83
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  %128 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %128, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  %129 = load i32, ptr %8, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  %131 = load i32, ptr @len, align 4, !tbaa !5
  %132 = icmp slt i32 %130, %131
  br i1 %132, label %133, label %136

133:                                              ; preds = %127
  %134 = load i32, ptr %8, align 4, !tbaa !5
  %135 = add nsw i32 %134, 1
  br label %137

136:                                              ; preds = %127
  br label %137

137:                                              ; preds = %136, %133
  %138 = phi i32 [ %135, %133 ], [ 0, %136 ]
  store i32 %138, ptr %11, align 4, !tbaa !5
  br label %139

139:                                              ; preds = %171, %137
  %140 = load i32, ptr %11, align 4, !tbaa !5
  %141 = load i32, ptr %8, align 4, !tbaa !5
  %142 = icmp ne i32 %140, %141
  br i1 %142, label %144, label %143

143:                                              ; preds = %139
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %173

144:                                              ; preds = %139
  %145 = load i32, ptr %11, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [500001 x i32], ptr @seq, i64 0, i64 %146
  %148 = load i32, ptr %147, align 4, !tbaa !5
  %149 = sext i32 %148 to i64
  %150 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %149
  %151 = load i32, ptr %10, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [500001 x i32], ptr @seq, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = sext i32 %154 to i64
  %156 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %155
  %157 = load i64, ptr %156, align 8, !tbaa !11
  %158 = load i32, ptr %4, align 4, !tbaa !5
  %159 = sext i32 %158 to i64
  %160 = getelementptr inbounds [13 x i32], ptr @a, i64 0, i64 %159
  %161 = load i32, ptr %160, align 4, !tbaa !5
  %162 = sext i32 %161 to i64
  %163 = add nsw i64 %157, %162
  call void @_Z3updRxx(ptr noundef nonnull align 8 dereferenceable(8) %150, i64 noundef %163)
  br label %164

164:                                              ; preds = %144
  %165 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %165, ptr %10, align 4, !tbaa !5
  %166 = load i32, ptr %11, align 4, !tbaa !5
  %167 = add nsw i32 %166, 1
  store i32 %167, ptr %11, align 4, !tbaa !5
  %168 = load i32, ptr @len, align 4, !tbaa !5
  %169 = icmp eq i32 %167, %168
  br i1 %169, label %170, label %171

170:                                              ; preds = %164
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %171

171:                                              ; preds = %170, %164
  %172 = phi i1 [ false, %164 ], [ false, %170 ]
  br label %139, !llvm.loop !14

173:                                              ; preds = %143
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %174

174:                                              ; preds = %173, %73
  %175 = load i32, ptr %3, align 4, !tbaa !5
  %176 = load i32, ptr %7, align 4, !tbaa !5
  %177 = add nsw i32 %176, %175
  store i32 %177, ptr %7, align 4, !tbaa !5
  br label %61, !llvm.loop !15

178:                                              ; preds = %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %179

179:                                              ; preds = %178
  %180 = load i32, ptr %4, align 4, !tbaa !5
  %181 = add nsw i32 %180, 1
  store i32 %181, ptr %4, align 4, !tbaa !5
  br label %43, !llvm.loop !16

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

183:                                              ; preds = %229, %182
  %184 = load i32, ptr %12, align 4, !tbaa !5
  %185 = load i32, ptr @a, align 16, !tbaa !5
  %186 = icmp slt i32 %184, %185
  br i1 %186, label %188, label %187

187:                                              ; preds = %183
  store i32 17, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %232

188:                                              ; preds = %183
  %189 = load i32, ptr %12, align 4, !tbaa !5
  %190 = sext i32 %189 to i64
  %191 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %190
  %192 = load i64, ptr %191, align 8, !tbaa !11
  %193 = load i64, ptr @R, align 8, !tbaa !11
  %194 = icmp sle i64 %192, %193
  br i1 %194, label %195, label %228

195:                                              ; preds = %188
  %196 = load i64, ptr @R, align 8, !tbaa !11
  %197 = load i32, ptr %12, align 4, !tbaa !5
  %198 = sext i32 %197 to i64
  %199 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %198
  %200 = load i64, ptr %199, align 8, !tbaa !11
  %201 = sub nsw i64 %196, %200
  %202 = load i32, ptr @a, align 16, !tbaa !5
  %203 = sext i32 %202 to i64
  %204 = sdiv i64 %201, %203
  %205 = load i32, ptr %12, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %206
  %208 = load i64, ptr %207, align 8, !tbaa !11
  %209 = load i64, ptr @L, align 8, !tbaa !11
  %210 = icmp slt i64 %208, %209
  br i1 %210, label %211, label %222

211:                                              ; preds = %195
  %212 = load i64, ptr @L, align 8, !tbaa !11
  %213 = sub nsw i64 %212, 1
  %214 = load i32, ptr %12, align 4, !tbaa !5
  %215 = sext i32 %214 to i64
  %216 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %215
  %217 = load i64, ptr %216, align 8, !tbaa !11
  %218 = sub nsw i64 %213, %217
  %219 = load i32, ptr @a, align 16, !tbaa !5
  %220 = sext i32 %219 to i64
  %221 = sdiv i64 %218, %220
  br label %223

222:                                              ; preds = %195
  br label %223

223:                                              ; preds = %222, %211
  %224 = phi i64 [ %221, %211 ], [ -1, %222 ]
  %225 = sub nsw i64 %204, %224
  %226 = load i64, ptr @ans, align 8, !tbaa !11
  %227 = add nsw i64 %226, %225
  store i64 %227, ptr @ans, align 8, !tbaa !11
  br label %228

228:                                              ; preds = %223, %188
  br label %229

229:                                              ; preds = %228
  %230 = load i32, ptr %12, align 4, !tbaa !5
  %231 = add nsw i32 %230, 1
  store i32 %231, ptr %12, align 4, !tbaa !5
  br label %183, !llvm.loop !17

232:                                              ; preds = %187
  %233 = load i64, ptr @ans, align 8, !tbaa !11
  %234 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i64 noundef %233)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  %235 = load i32, ptr %1, align 4
  ret i32 %235
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef, i32 noundef) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z3updRxx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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

@n = external dso_local global i32, align 4
@a = external dso_local global [13 x i32], align 16
@len = external dso_local local_unnamed_addr global i32, align 4
@seq = external dso_local local_unnamed_addr global [500001 x i32], align 16
@vis = external dso_local local_unnamed_addr global [500001 x i32], align 16
@dis = external dso_local global [500001 x i64], align 16
@L = external dso_local global i64, align 8
@R = external dso_local global i64, align 8
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [11 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [6 x i8], align 1

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

._crit_edge.thread:                               ; preds = %0
  %4 = load i32, ptr @a, align 16, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = shl nsw i64 %5, 3
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @dis, i8 63, i64 %6, i1 false)
  store i64 0, ptr @dis, align 16, !tbaa !9
  br label %.preheader

._crit_edge:                                      ; preds = %17
  %7 = icmp sgt i32 %18, 1
  %8 = load i32, ptr @a, align 16, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = shl nsw i64 %9, 3
  tail call void @llvm.memset.p0.i64(ptr nonnull align 16 @dis, i8 63, i64 %10, i1 false)
  store i64 0, ptr @dis, align 16, !tbaa !9
  br i1 %7, label %.lr.ph81, label %.preheader

.lr.ph:                                           ; preds = %0, %17
  %indvars.iv = phi i64 [ %indvars.iv.next, %17 ], [ 0, %0 ]
  %11 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %12 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %11)
  %13 = load i32, ptr @a, align 16, !tbaa !5
  %14 = load i32, ptr %11, align 4, !tbaa !5
  %15 = icmp sgt i32 %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %.lr.ph
  tail call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) @a, ptr noundef nonnull align 4 dereferenceable(4) %11) #5
  br label %17

17:                                               ; preds = %.lr.ph, %16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.preheader:                                       ; preds = %._crit_edge77, %._crit_edge.thread, %._crit_edge
  %21 = phi i32 [ %8, %._crit_edge ], [ %4, %._crit_edge.thread ], [ %35, %._crit_edge77 ]
  %22 = icmp sgt i32 %21, 0
  %ans.promoted = load i64, ptr @ans, align 8, !tbaa !9
  br i1 %22, label %.lr.ph83, label %._crit_edge84

.lr.ph83:                                         ; preds = %.preheader
  %23 = load i64, ptr @R, align 8, !tbaa !9
  %24 = zext nneg i32 %21 to i64
  %25 = load i64, ptr @L, align 8
  br label %91

.lr.ph81:                                         ; preds = %._crit_edge, %._crit_edge77
  %indvars.iv92 = phi i64 [ %indvars.iv.next93, %._crit_edge77 ], [ 1, %._crit_edge ]
  %.04978 = phi i32 [ %28, %._crit_edge77 ], [ %8, %._crit_edge ]
  %26 = getelementptr inbounds [13 x i32], ptr @a, i64 0, i64 %indvars.iv92
  %27 = load i32, ptr %26, align 4, !tbaa !5
  %28 = tail call noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef %.04978, i32 noundef %27)
  %29 = load i32, ptr %26, align 4, !tbaa !5
  %30 = load i32, ptr @a, align 16, !tbaa !5
  %31 = srem i32 %29, %30
  %32 = icmp sgt i32 %30, 0
  br i1 %32, label %.lr.ph76.preheader, label %._crit_edge77

.lr.ph76.preheader:                               ; preds = %.lr.ph81
  %33 = sext i32 %28 to i64
  %34 = trunc nuw nsw i64 %indvars.iv92 to i32
  br label %.lr.ph76

._crit_edge77:                                    ; preds = %.loopexit, %.lr.ph81
  %35 = phi i32 [ %30, %.lr.ph81 ], [ %86, %.loopexit ]
  %indvars.iv.next93 = add nuw nsw i64 %indvars.iv92, 1
  %36 = load i32, ptr @n, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = icmp slt i64 %indvars.iv.next93, %37
  br i1 %38, label %.lr.ph81, label %.preheader, !llvm.loop !13

.lr.ph76:                                         ; preds = %.lr.ph76.preheader, %.loopexit
  %39 = phi i32 [ %30, %.lr.ph76.preheader ], [ %86, %.loopexit ]
  %indvars.iv89 = phi i64 [ 0, %.lr.ph76.preheader ], [ %indvars.iv.next90, %.loopexit ]
  %40 = getelementptr inbounds [500001 x i32], ptr @vis, i64 0, i64 %indvars.iv89
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = zext i32 %41 to i64
  %43 = icmp eq i64 %indvars.iv92, %42
  br i1 %43, label %.loopexit, label %.lr.ph66.preheader

.lr.ph66.preheader:                               ; preds = %.lr.ph76
  %44 = trunc nsw i64 %indvars.iv89 to i32
  br label %.lr.ph66

45:                                               ; preds = %.lr.ph66
  %46 = trunc nuw i64 %indvars.iv.next87 to i32
  store i32 %46, ptr @len, align 4, !tbaa !5
  %47 = add nsw i32 %spec.select, 1
  %48 = icmp slt i32 %47, %46
  %49 = select i1 %48, i32 %47, i32 0
  %.not5968 = icmp eq i32 %49, %spec.select
  br i1 %.not5968, label %.loopexit, label %.lr.ph72

.lr.ph66:                                         ; preds = %.lr.ph66.preheader, %.lr.ph66
  %indvars.iv86 = phi i64 [ 0, %.lr.ph66.preheader ], [ %indvars.iv.next87, %.lr.ph66 ]
  %50 = phi ptr [ %40, %.lr.ph66.preheader ], [ %66, %.lr.ph66 ]
  %51 = phi i64 [ %indvars.iv89, %.lr.ph66.preheader ], [ %65, %.lr.ph66 ]
  %.04464 = phi i32 [ %44, %.lr.ph66.preheader ], [ %.1, %.lr.ph66 ]
  %.04563 = phi i32 [ 0, %.lr.ph66.preheader ], [ %spec.select, %.lr.ph66 ]
  store i32 %34, ptr %50, align 4, !tbaa !5
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %52 = getelementptr inbounds [500001 x i32], ptr @seq, i64 0, i64 %indvars.iv86
  store i32 %.04464, ptr %52, align 4, !tbaa !5
  %53 = sext i32 %.04563 to i64
  %54 = getelementptr inbounds [500001 x i32], ptr @seq, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !9
  %59 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %51
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = icmp sgt i64 %58, %60
  %62 = trunc nuw nsw i64 %indvars.iv86 to i32
  %spec.select = select i1 %61, i32 %62, i32 %.04563
  %63 = add nsw i32 %.04464, %31
  %.not60 = icmp slt i32 %63, %39
  %64 = select i1 %.not60, i32 0, i32 %39
  %.1 = sub nsw i32 %63, %64
  %65 = sext i32 %.1 to i64
  %66 = getelementptr inbounds [500001 x i32], ptr @vis, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = zext i32 %67 to i64
  %.not58 = icmp eq i64 %indvars.iv92, %68
  br i1 %.not58, label %45, label %.lr.ph66, !llvm.loop !14

.lr.ph72:                                         ; preds = %45, %.lr.ph72
  %.04270 = phi i32 [ %spec.store.select, %.lr.ph72 ], [ %49, %45 ]
  %.04369 = phi i32 [ %.04270, %.lr.ph72 ], [ %spec.select, %45 ]
  %69 = sext i32 %.04270 to i64
  %70 = getelementptr inbounds [500001 x i32], ptr @seq, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %72
  %74 = sext i32 %.04369 to i64
  %75 = getelementptr inbounds [500001 x i32], ptr @seq, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !9
  %80 = load i32, ptr %26, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = add nsw i64 %79, %81
  tail call void @_Z3updRxx(ptr noundef nonnull align 8 dereferenceable(8) %73, i64 noundef %82)
  %83 = add nsw i32 %.04270, 1
  %84 = load i32, ptr @len, align 4, !tbaa !5
  %85 = icmp eq i32 %83, %84
  %spec.store.select = select i1 %85, i32 0, i32 %83
  %.not59 = icmp eq i32 %spec.store.select, %spec.select
  br i1 %.not59, label %.loopexit.loopexit, label %.lr.ph72, !llvm.loop !15

.loopexit.loopexit:                               ; preds = %.lr.ph72
  %.pre = load i32, ptr @a, align 16, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %45, %.lr.ph76
  %86 = phi i32 [ %.pre, %.loopexit.loopexit ], [ %39, %45 ], [ %39, %.lr.ph76 ]
  %indvars.iv.next90 = add nsw i64 %indvars.iv89, %33
  %87 = sext i32 %86 to i64
  %88 = icmp slt i64 %indvars.iv.next90, %87
  br i1 %88, label %.lr.ph76, label %._crit_edge77, !llvm.loop !16

._crit_edge84:                                    ; preds = %107, %.preheader
  %89 = phi i64 [ %ans.promoted, %.preheader ], [ %108, %107 ]
  %90 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i64 noundef %89)
  ret i32 0

91:                                               ; preds = %.lr.ph83, %107
  %indvars.iv95 = phi i64 [ 0, %.lr.ph83 ], [ %indvars.iv.next96, %107 ]
  %92 = phi i64 [ %ans.promoted, %.lr.ph83 ], [ %108, %107 ]
  %93 = getelementptr inbounds [500001 x i64], ptr @dis, i64 0, i64 %indvars.iv95
  %94 = load i64, ptr %93, align 8, !tbaa !9
  %.not = icmp sgt i64 %94, %23
  br i1 %.not, label %107, label %95

95:                                               ; preds = %91
  %96 = sub nsw i64 %23, %94
  %97 = sdiv i64 %96, %24
  %98 = icmp slt i64 %94, %25
  br i1 %98, label %99, label %103

99:                                               ; preds = %95
  %100 = xor i64 %94, -1
  %101 = add i64 %25, %100
  %102 = sdiv i64 %101, %24
  br label %103

103:                                              ; preds = %95, %99
  %104 = phi i64 [ %102, %99 ], [ -1, %95 ]
  %105 = sub i64 %97, %104
  %106 = add nsw i64 %105, %92
  store i64 %106, ptr @ans, align 8, !tbaa !9
  br label %107

107:                                              ; preds = %91, %103
  %108 = phi i64 [ %92, %91 ], [ %106, %103 ]
  %indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next96, %24
  br i1 %exitcond.not, label %._crit_edge84, label %91, !llvm.loop !17
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZSt5__gcdIiET_S0_S0_(i32 noundef, i32 noundef) local_unnamed_addr #4

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { 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 #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}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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