; LLVM IR from tangjz/acm-icpc :: 51nod (1521)

; 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
@k = external dso_local global i32, align 4
@a = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@x = external dso_local global [200010 x i32], align 16
@id = external dso_local global [200010 x i32], align 16
@L = external dso_local global [200010 x i32], align 16
@R = external dso_local global [200010 x i32], align 16
@sum = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %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 ptr, align 8
  %7 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @k, ptr noundef @a, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %9

9:                                                ; preds = %23, %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr @m, align 4, !tbaa !5
  %12 = icmp slt i32 %10, %11
  br i1 %12, label %14, label %13

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %26

14:                                               ; preds = %9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds i32, ptr @x, i64 %16
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %17)
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr %2, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %21
  store i32 %19, ptr %22, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %14
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %2, align 4, !tbaa !5
  br label %9, !llvm.loop !9

26:                                               ; preds = %13
  %27 = load i32, ptr @m, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds i32, ptr @id, i64 %28
  call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef @id, ptr noundef %29, ptr noundef @_Z3cmpRKiS0_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %152, %26
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = load i32, ptr @m, align 4, !tbaa !5
  %33 = icmp slt i32 %31, %32
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %30
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = icmp sgt i32 %36, 0
  br i1 %37, label %38, label %56

38:                                               ; preds = %35
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sub nsw i32 %39, 1
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %54
  store i32 %46, ptr %55, align 4, !tbaa !5
  br label %66

56:                                               ; preds = %35
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %64
  store i32 0, ptr %65, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %56, %38
  %67 = load i32, ptr %3, align 4, !tbaa !5
  %68 = load i32, ptr @m, align 4, !tbaa !5
  %69 = sub nsw i32 %68, 1
  %70 = icmp slt i32 %67, %69
  br i1 %70, label %71, label %89

71:                                               ; preds = %66
  %72 = load i32, ptr %3, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %87
  store i32 %79, ptr %88, align 4, !tbaa !5
  br label %101

89:                                               ; preds = %66
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  %92 = load i32, ptr %3, align 4, !tbaa !5
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %93
  %95 = load i32, ptr %94, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %96
  %98 = load i32, ptr %97, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %99
  store i32 %91, ptr %100, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %89, %71
  %102 = load i32, ptr %3, align 4, !tbaa !5
  %103 = icmp ne i32 %102, 0
  br i1 %103, label %128, label %104

104:                                              ; preds = %101
  %105 = load i32, ptr %3, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %106
  %108 = load i32, ptr %107, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = load i32, ptr %3, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %113
  %115 = load i32, ptr %114, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %116
  %118 = load i32, ptr %117, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = sub nsw i32 %111, %121
  %123 = load i32, ptr @a, align 4, !tbaa !5
  %124 = add nsw i32 %123, 1
  %125 = sdiv i32 %122, %124
  %126 = load i32, ptr @sum, align 4, !tbaa !5
  %127 = add nsw i32 %126, %125
  store i32 %127, ptr @sum, align 4, !tbaa !5
  br label %128

128:                                              ; preds = %104, %101
  %129 = load i32, ptr %3, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %136
  %138 = load i32, ptr %137, align 4, !tbaa !5
  %139 = load i32, ptr %3, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = sext i32 %142 to i64
  %144 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %143
  %145 = load i32, ptr %144, align 4, !tbaa !5
  %146 = sub nsw i32 %138, %145
  %147 = load i32, ptr @a, align 4, !tbaa !5
  %148 = add nsw i32 %147, 1
  %149 = sdiv i32 %146, %148
  %150 = load i32, ptr @sum, align 4, !tbaa !5
  %151 = add nsw i32 %150, %149
  store i32 %151, ptr @sum, align 4, !tbaa !5
  br label %152

152:                                              ; preds = %128
  %153 = load i32, ptr %3, align 4, !tbaa !5
  %154 = add nsw i32 %153, 1
  store i32 %154, ptr %3, align 4, !tbaa !5
  br label %30, !llvm.loop !11

155:                                              ; preds = %34
  %156 = load i32, ptr @sum, align 4, !tbaa !5
  %157 = load i32, ptr @k, align 4, !tbaa !5
  %158 = icmp sge i32 %156, %157
  br i1 %158, label %159, label %161

159:                                              ; preds = %155
  %160 = call i32 @puts(ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  br label %243

161:                                              ; preds = %155
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %162 = load i32, ptr @m, align 4, !tbaa !5
  %163 = sub nsw i32 %162, 1
  store i32 %163, ptr %4, align 4, !tbaa !5
  br label %164

164:                                              ; preds = %238, %161
  %165 = load i32, ptr %4, align 4, !tbaa !5
  %166 = icmp sge i32 %165, 0
  br i1 %166, label %168, label %167

167:                                              ; preds = %164
  store i32 8, ptr %5, align 4
  br label %241

168:                                              ; preds = %164
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %169 = load i32, ptr %4, align 4, !tbaa !5
  %170 = sext i32 %169 to i64
  %171 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %170
  %172 = load i32, ptr %171, align 4, !tbaa !5
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %173
  store ptr %174, ptr %6, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %175 = load i32, ptr %4, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %176
  %178 = load i32, ptr %177, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %179
  store ptr %180, ptr %7, align 8, !tbaa !12
  %181 = load ptr, ptr %7, align 8, !tbaa !12
  %182 = load i32, ptr %181, align 4, !tbaa !5
  %183 = load ptr, ptr %6, align 8, !tbaa !12
  %184 = load i32, ptr %183, align 4, !tbaa !5
  %185 = sext i32 %184 to i64
  %186 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %185
  store i32 %182, ptr %186, align 4, !tbaa !5
  %187 = load ptr, ptr %6, align 8, !tbaa !12
  %188 = load i32, ptr %187, align 4, !tbaa !5
  %189 = load ptr, ptr %7, align 8, !tbaa !12
  %190 = load i32, ptr %189, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %191
  store i32 %188, ptr %192, align 4, !tbaa !5
  %193 = load ptr, ptr %7, align 8, !tbaa !12
  %194 = load i32, ptr %193, align 4, !tbaa !5
  %195 = load i32, ptr %4, align 4, !tbaa !5
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %196
  %198 = load i32, ptr %197, align 4, !tbaa !5
  %199 = sub nsw i32 %194, %198
  %200 = load i32, ptr @a, align 4, !tbaa !5
  %201 = add nsw i32 %200, 1
  %202 = sdiv i32 %199, %201
  %203 = load i32, ptr @sum, align 4, !tbaa !5
  %204 = sub nsw i32 %203, %202
  store i32 %204, ptr @sum, align 4, !tbaa !5
  %205 = load i32, ptr %4, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %206
  %208 = load i32, ptr %207, align 4, !tbaa !5
  %209 = load ptr, ptr %6, align 8, !tbaa !12
  %210 = load i32, ptr %209, align 4, !tbaa !5
  %211 = sub nsw i32 %208, %210
  %212 = load i32, ptr @a, align 4, !tbaa !5
  %213 = add nsw i32 %212, 1
  %214 = sdiv i32 %211, %213
  %215 = load i32, ptr @sum, align 4, !tbaa !5
  %216 = sub nsw i32 %215, %214
  store i32 %216, ptr @sum, align 4, !tbaa !5
  %217 = load ptr, ptr %7, align 8, !tbaa !12
  %218 = load i32, ptr %217, align 4, !tbaa !5
  %219 = load ptr, ptr %6, align 8, !tbaa !12
  %220 = load i32, ptr %219, align 4, !tbaa !5
  %221 = sub nsw i32 %218, %220
  %222 = load i32, ptr @a, align 4, !tbaa !5
  %223 = add nsw i32 %222, 1
  %224 = sdiv i32 %221, %223
  %225 = load i32, ptr @sum, align 4, !tbaa !5
  %226 = add nsw i32 %225, %224
  store i32 %226, ptr @sum, align 4, !tbaa !5
  %227 = load i32, ptr @sum, align 4, !tbaa !5
  %228 = load i32, ptr @k, align 4, !tbaa !5
  %229 = icmp sge i32 %227, %228
  br i1 %229, label %230, label %234

230:                                              ; preds = %168
  %231 = load i32, ptr %4, align 4, !tbaa !5
  %232 = add nsw i32 %231, 1
  %233 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %232)
  store i32 8, ptr %5, align 4
  br label %235

234:                                              ; preds = %168
  store i32 0, ptr %5, align 4
  br label %235

235:                                              ; preds = %234, %230
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %236 = load i32, ptr %5, align 4
  switch i32 %236, label %241 [
    i32 0, label %237
  ]

237:                                              ; preds = %235
  br label %238

238:                                              ; preds = %237
  %239 = load i32, ptr %4, align 4, !tbaa !5
  %240 = add nsw i32 %239, -1
  store i32 %240, ptr %4, align 4, !tbaa !5
  br label %164, !llvm.loop !14

241:                                              ; preds = %235, %167
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %242

242:                                              ; preds = %241
  store i32 0, ptr %1, align 4
  br label %243

243:                                              ; preds = %242, %159
  %244 = load i32, ptr %1, align 4
  ret i32 %244
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) #4

declare i32 @puts(ptr noundef) #2

declare i32 @printf(ptr noundef, ...) #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 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { inlinehint 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 = { 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 = !{!"any pointer", !7, i64 0}
!14 = distinct !{!14, !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
@k = external dso_local global i32, align 4
@a = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@x = external dso_local global [200010 x i32], align 16
@id = external dso_local global [200010 x i32], align 16
@L = external dso_local local_unnamed_addr global [200010 x i32], align 16
@R = external dso_local local_unnamed_addr global [200010 x i32], align 16
@sum = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [9 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z3cmpRKiS0_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #0

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

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre67 = sext i32 %2 to i64
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.._crit_edge_crit_edge
  %.pre-phi68 = phi i64 [ %.pre67, %.._crit_edge_crit_edge ], [ %43, %.lr.ph ]
  %4 = getelementptr inbounds i32, ptr @id, i64 %.pre-phi68
  tail call void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef nonnull @id, ptr noundef nonnull %4, ptr noundef nonnull @_Z3cmpRKiS0_)
  %5 = load i32, ptr @m, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  %sum.promoted = load i32, ptr @sum, align 4, !tbaa !5
  br i1 %6, label %7, label %._crit_edge._crit_edge

7:                                                ; preds = %._crit_edge
  %8 = add nsw i32 %5, -1
  %9 = load i32, ptr @n, align 4
  %10 = add nsw i32 %9, 1
  %11 = load i32, ptr @id, align 16
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %12
  %14 = load i32, ptr @a, align 4
  %15 = add nsw i32 %14, 1
  %16 = zext nneg i32 %8 to i64
  %wide.trip.count = zext nneg i32 %5 to i64
  %17 = load i32, ptr %13, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %18
  store i32 0, ptr %19, align 4, !tbaa !5
  %.not69 = icmp eq i32 %5, 1
  br i1 %.not69, label %25, label %20

20:                                               ; preds = %7
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @id, i64 4), align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %7, %20
  %.sink = phi i32 [ %24, %20 ], [ %10, %7 ]
  %26 = load i32, ptr %13, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %27
  store i32 %.sink, ptr %28, align 4, !tbaa !5
  %29 = sext i32 %26 to i64
  %30 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = sub nsw i32 %26, %31
  %33 = sdiv i32 %32, %15
  %34 = add nsw i32 %sum.promoted, %33
  %35 = sub nsw i32 %.sink, %26
  %36 = sdiv i32 %35, %15
  %37 = add nsw i32 %34, %36
  %exitcond.peel.not = icmp eq i32 %5, 1
  br i1 %exitcond.peel.not, label %._crit_edge50, label %.peel.next

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %38 = getelementptr inbounds i32, ptr @x, i64 %indvars.iv
  %39 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %38)
  %40 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %indvars.iv
  %41 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %41, ptr %40, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %42 = load i32, ptr @m, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = icmp slt i64 %indvars.iv.next, %43
  br i1 %44, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge50:                                    ; preds = %66, %25
  %.lcssa = phi i32 [ %37, %25 ], [ %71, %66 ]
  store i32 %.lcssa, ptr @sum, align 4, !tbaa !5
  br label %._crit_edge._crit_edge

._crit_edge._crit_edge:                           ; preds = %._crit_edge, %._crit_edge50
  %sum.promoted53 = phi i32 [ %.lcssa, %._crit_edge50 ], [ %sum.promoted, %._crit_edge ]
  %45 = load i32, ptr @k, align 4, !tbaa !5
  %.not = icmp slt i32 %sum.promoted53, %45
  br i1 %.not, label %.critedge.preheader, label %72

.critedge.preheader:                              ; preds = %._crit_edge._crit_edge
  %46 = load i32, ptr @a, align 4
  %47 = add nsw i32 %46, 1
  %48 = zext i32 %5 to i64
  br label %.critedge

.peel.next:                                       ; preds = %25, %66
  %49 = phi i32 [ %55, %66 ], [ %26, %25 ]
  %indvars.iv57 = phi i64 [ %indvars.iv.next58, %66 ], [ 1, %25 ]
  %50 = phi i32 [ %71, %66 ], [ %37, %25 ]
  %51 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %indvars.iv57
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %56
  store i32 %49, ptr %57, align 4, !tbaa !5
  %58 = icmp ult i64 %indvars.iv57, %16
  br i1 %58, label %59, label %66

59:                                               ; preds = %.peel.next
  %60 = add nuw nsw i64 %indvars.iv57, 1
  %61 = getelementptr inbounds [200010 x i32], ptr @id, i64 0, i64 %60
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %63
  %65 = load i32, ptr %64, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %.peel.next, %59
  %.sink77 = phi i32 [ %65, %59 ], [ %10, %.peel.next ]
  %67 = sext i32 %55 to i64
  %68 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %67
  store i32 %.sink77, ptr %68, align 4, !tbaa !5
  %69 = sub nsw i32 %.sink77, %55
  %70 = sdiv i32 %69, %15
  %71 = add nsw i32 %50, %70
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next58, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge50, label %.peel.next, !llvm.loop !11

72:                                               ; preds = %._crit_edge._crit_edge
  %73 = tail call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %.loopexit

.critedge:                                        ; preds = %.critedge.preheader, %77
  %indvars.iv61 = phi i64 [ %48, %.critedge.preheader ], [ %78, %77 ]
  %74 = phi i32 [ %sum.promoted53, %.critedge.preheader ], [ %98, %77 ]
  %75 = trunc nuw i64 %indvars.iv61 to i32
  %76 = icmp sgt i32 %75, 0
  br i1 %76, label %77, label %.loopexit

77:                                               ; preds = %.critedge
  %78 = add nsw i64 %indvars.iv61, -1
  %79 = getelementptr inbounds [200010 x i32], ptr @x, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %81
  %83 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %81
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %85 = load i32, ptr %82, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [200010 x i32], ptr @R, i64 0, i64 %86
  store i32 %84, ptr %87, align 4, !tbaa !5
  %88 = sext i32 %84 to i64
  %89 = getelementptr inbounds [200010 x i32], ptr @L, i64 0, i64 %88
  store i32 %85, ptr %89, align 4, !tbaa !5
  %90 = sub nsw i32 %84, %80
  %91 = sdiv i32 %90, %47
  %92 = sub nsw i32 %80, %85
  %93 = sdiv i32 %92, %47
  %94 = add i32 %91, %93
  %95 = sub i32 %74, %94
  %96 = sub nsw i32 %84, %85
  %97 = sdiv i32 %96, %47
  %98 = add nsw i32 %95, %97
  store i32 %98, ptr @sum, align 4, !tbaa !5
  %.not41 = icmp slt i32 %98, %45
  br i1 %.not41, label %.critedge, label %99, !llvm.loop !13

99:                                               ; preds = %77
  %100 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %75)
  br label %.loopexit

.loopexit:                                        ; preds = %.critedge, %99, %72
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPiPFbRKiS2_EEvT_S5_T0_(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 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 #2 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { inlinehint mustprogress 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" }

!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}
!12 = !{!"llvm.loop.peeled.count", i32 1}
!13 = distinct !{!13, !10}


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