; LLVM IR from tangjz/acm-icpc :: hdu (6087)

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

%struct.Treap = type { i32, i32, i32, i32, i64 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [200001 x i32], align 16
@b = external dso_local global [200001 x i32], align 16
@tot = external dso_local global i32, align 4
@pool = external dso_local global [2500001 x %struct.Treap], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5Mergeii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3Powii(i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7Segmentiii(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7Replaceiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5BuildiPi(i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7RebuildiPi(i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %14 = call i64 @time(ptr noundef null) #5
  %15 = trunc i64 %14 to i32
  call void @srand(i32 noundef %15) #5
  br label %16

16:                                               ; preds = %129, %0
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %18 = icmp eq i32 %17, 2
  br i1 %18, label %19, label %130

19:                                               ; preds = %16
  store i32 1, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %20

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

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

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

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

33:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  %34 = load i32, ptr @n, align 4, !tbaa !5
  %35 = call noundef i32 @_Z5BuildiPi(i32 noundef %34, ptr noundef @a)
  store i32 %35, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  %36 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %36, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  %37 = load i32, ptr @tot, align 4, !tbaa !5
  store i32 %37, ptr %5, align 4, !tbaa !5
  br label %38

38:                                               ; preds = %128, %33
  %39 = load i32, ptr @m, align 4, !tbaa !5
  %40 = add nsw i32 %39, -1
  store i32 %40, ptr @m, align 4, !tbaa !5
  %41 = icmp ne i32 %39, 0
  br i1 %41, label %42, label %129

42:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %6, ptr noundef %7, ptr noundef %8)
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = icmp eq i32 %44, 1
  br i1 %45, label %46, label %59

46:                                               ; preds = %42
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %47 = load i32, ptr @tot, align 4, !tbaa !5
  store i32 %47, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %48 = load i32, ptr %4, align 4, !tbaa !5
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = load i32, ptr %8, align 4, !tbaa !5
  %51 = call noundef i32 @_Z7Segmentiii(i32 noundef %48, i32 noundef %49, i32 noundef %50)
  store i32 %51, ptr %11, align 4, !tbaa !5
  %52 = load i32, ptr %11, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [2500001 x %struct.Treap], ptr @pool, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.Treap, ptr %54, i32 0, i32 4
  %56 = load i64, ptr %55, align 8, !tbaa !11
  %57 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %56)
  %58 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %58, ptr @tot, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %119

59:                                               ; preds = %42
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = icmp eq i32 %60, 2
  br i1 %61, label %62, label %108

62:                                               ; preds = %59
  %63 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %9)
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = load i32, ptr %9, align 4, !tbaa !5
  %67 = sub nsw i32 %65, %66
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = sub nsw i32 %68, 1
  %70 = call noundef i32 @_Z7Segmentiii(i32 noundef %64, i32 noundef %67, i32 noundef %69)
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = sub nsw i32 %71, %72
  %74 = add nsw i32 %73, 1
  %75 = load i32, ptr %9, align 4, !tbaa !5
  %76 = sdiv i32 %74, %75
  %77 = call noundef i32 @_Z3Powii(i32 noundef %70, i32 noundef %76)
  store i32 %77, ptr %12, align 4, !tbaa !5
  %78 = load i32, ptr %8, align 4, !tbaa !5
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = sub nsw i32 %78, %79
  %81 = add nsw i32 %80, 1
  %82 = load i32, ptr %9, align 4, !tbaa !5
  %83 = srem i32 %81, %82
  %84 = icmp sgt i32 %83, 0
  br i1 %84, label %85, label %102

85:                                               ; preds = %62
  %86 = load i32, ptr %12, align 4, !tbaa !5
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = load i32, ptr %7, align 4, !tbaa !5
  %89 = load i32, ptr %9, align 4, !tbaa !5
  %90 = sub nsw i32 %88, %89
  %91 = load i32, ptr %7, align 4, !tbaa !5
  %92 = load i32, ptr %9, align 4, !tbaa !5
  %93 = sub nsw i32 %91, %92
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = load i32, ptr %7, align 4, !tbaa !5
  %96 = sub nsw i32 %94, %95
  %97 = load i32, ptr %9, align 4, !tbaa !5
  %98 = srem i32 %96, %97
  %99 = add nsw i32 %93, %98
  %100 = call noundef i32 @_Z7Segmentiii(i32 noundef %87, i32 noundef %90, i32 noundef %99)
  %101 = call noundef i32 @_Z5Mergeii(i32 noundef %86, i32 noundef %100)
  store i32 %101, ptr %12, align 4, !tbaa !5
  br label %102

102:                                              ; preds = %85, %62
  %103 = load i32, ptr %4, align 4, !tbaa !5
  %104 = load i32, ptr %7, align 4, !tbaa !5
  %105 = load i32, ptr %8, align 4, !tbaa !5
  %106 = load i32, ptr %12, align 4, !tbaa !5
  %107 = call noundef i32 @_Z7Replaceiiii(i32 noundef %103, i32 noundef %104, i32 noundef %105, i32 noundef %106)
  store i32 %107, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %118

108:                                              ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %109 = load i32, ptr %3, align 4, !tbaa !5
  %110 = load i32, ptr %7, align 4, !tbaa !5
  %111 = load i32, ptr %8, align 4, !tbaa !5
  %112 = call noundef i32 @_Z7Segmentiii(i32 noundef %109, i32 noundef %110, i32 noundef %111)
  store i32 %112, ptr %13, align 4, !tbaa !5
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = load i32, ptr %8, align 4, !tbaa !5
  %116 = load i32, ptr %13, align 4, !tbaa !5
  %117 = call noundef i32 @_Z7Replaceiiii(i32 noundef %113, i32 noundef %114, i32 noundef %115, i32 noundef %116)
  store i32 %117, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %118

118:                                              ; preds = %108, %102
  br label %119

119:                                              ; preds = %118, %46
  %120 = load i32, ptr @tot, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1001
  %122 = icmp sgt i32 %121, 2500001
  br i1 %122, label %123, label %128

123:                                              ; preds = %119
  %124 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z7RebuildiPi(i32 noundef %124, ptr noundef @b)
  %125 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %125, ptr @tot, align 4, !tbaa !5
  %126 = load i32, ptr @n, align 4, !tbaa !5
  %127 = call noundef i32 @_Z5BuildiPi(i32 noundef %126, ptr noundef @b)
  store i32 %127, ptr %4, align 4, !tbaa !5
  br label %128

128:                                              ; preds = %123, %119
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #5
  br label %38, !llvm.loop !14

129:                                              ; preds = %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %16, !llvm.loop !15

130:                                              ; preds = %16
  ret i32 0
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) #3

; Function Attrs: nounwind
declare i64 @time(ptr noundef) #3

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

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

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

%struct.Treap = type { i32, i32, i32, i32, i64 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [200001 x i32], align 16
@b = external dso_local global [200001 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@pool = external dso_local local_unnamed_addr global [2500001 x %struct.Treap], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5Mergeii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z3Powii(i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7Segmentiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z7Replaceiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z5BuildiPi(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z7RebuildiPi(i32 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = tail call i64 @time(ptr noundef null) #5
  %6 = trunc i64 %5 to i32
  tail call void @srand(i32 noundef %6) #5
  %7 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %8 = icmp eq i32 %7, 2
  br i1 %8, label %.lr.ph27, label %._crit_edge28

.loopexit:                                        ; preds = %77, %._crit_edge
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %10 = icmp eq i32 %9, 2
  br i1 %10, label %.lr.ph27, label %._crit_edge28, !llvm.loop !5

.lr.ph27:                                         ; preds = %0, %.loopexit
  store i32 1, ptr @tot, align 4, !tbaa !7
  %11 = load i32, ptr @n, align 4, !tbaa !7
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph27
  %.lcssa = phi i32 [ %11, %.lr.ph27 ], [ %19, %.lr.ph ]
  %13 = call noundef i32 @_Z5BuildiPi(i32 noundef %.lcssa, ptr noundef nonnull @a)
  %14 = load i32, ptr @tot, align 4, !tbaa !7
  %15 = load i32, ptr @m, align 4, !tbaa !7
  %16 = add nsw i32 %15, -1
  store i32 %16, ptr @m, align 4, !tbaa !7
  %.not22 = icmp eq i32 %15, 0
  br i1 %.not22, label %.loopexit, label %.lr.ph25

.lr.ph:                                           ; preds = %.lr.ph27, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph27 ]
  %17 = getelementptr inbounds i32, ptr @a, i64 %indvars.iv
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %17)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr @n, align 4, !tbaa !7
  %20 = sext i32 %19 to i64
  %21 = icmp slt i64 %indvars.iv.next, %20
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !11

.lr.ph25:                                         ; preds = %._crit_edge, %77
  %.01823 = phi i32 [ %.2, %77 ], [ %13, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #5
  %22 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %23 = load i32, ptr %1, align 4, !tbaa !7
  switch i32 %23, label %64 [
    i32 1, label %24
    i32 2, label %33
  ]

24:                                               ; preds = %.lr.ph25
  %25 = load i32, ptr @tot, align 4, !tbaa !7
  %26 = load i32, ptr %2, align 4, !tbaa !7
  %27 = load i32, ptr %3, align 4, !tbaa !7
  %28 = call noundef i32 @_Z7Segmentiii(i32 noundef %.01823, i32 noundef %26, i32 noundef %27)
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [2500001 x %struct.Treap], ptr @pool, i64 0, i64 %29, i32 4
  %31 = load i64, ptr %30, align 8, !tbaa !12
  %32 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %31)
  store i32 %25, ptr @tot, align 4, !tbaa !7
  br label %71

33:                                               ; preds = %.lr.ph25
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %4)
  %35 = load i32, ptr %2, align 4, !tbaa !7
  %36 = load i32, ptr %4, align 4, !tbaa !7
  %37 = sub nsw i32 %35, %36
  %38 = add nsw i32 %35, -1
  %39 = call noundef i32 @_Z7Segmentiii(i32 noundef %.01823, i32 noundef %37, i32 noundef %38)
  %40 = load i32, ptr %3, align 4, !tbaa !7
  %41 = load i32, ptr %2, align 4, !tbaa !7
  %42 = add i32 %40, 1
  %43 = sub i32 %42, %41
  %44 = load i32, ptr %4, align 4, !tbaa !7
  %45 = sdiv i32 %43, %44
  %46 = call noundef i32 @_Z3Powii(i32 noundef %39, i32 noundef %45)
  %47 = load i32, ptr %3, align 4, !tbaa !7
  %48 = load i32, ptr %2, align 4, !tbaa !7
  %49 = sub nsw i32 %47, %48
  %50 = add nsw i32 %49, 1
  %51 = load i32, ptr %4, align 4, !tbaa !7
  %52 = srem i32 %50, %51
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %54, label %60

54:                                               ; preds = %33
  %55 = sub nsw i32 %48, %51
  %56 = srem i32 %49, %51
  %57 = add nsw i32 %56, %55
  %58 = call noundef i32 @_Z7Segmentiii(i32 noundef %.01823, i32 noundef %55, i32 noundef %57)
  %59 = call noundef i32 @_Z5Mergeii(i32 noundef %46, i32 noundef %58)
  %.pre = load i32, ptr %2, align 4, !tbaa !7
  %.pre31 = load i32, ptr %3, align 4, !tbaa !7
  br label %60

60:                                               ; preds = %54, %33
  %61 = phi i32 [ %.pre31, %54 ], [ %47, %33 ]
  %62 = phi i32 [ %.pre, %54 ], [ %48, %33 ]
  %.017 = phi i32 [ %59, %54 ], [ %46, %33 ]
  %63 = call noundef i32 @_Z7Replaceiiii(i32 noundef %.01823, i32 noundef %62, i32 noundef %61, i32 noundef %.017)
  br label %thread-pre-split

64:                                               ; preds = %.lr.ph25
  %65 = load i32, ptr %2, align 4, !tbaa !7
  %66 = load i32, ptr %3, align 4, !tbaa !7
  %67 = call noundef i32 @_Z7Segmentiii(i32 noundef %13, i32 noundef %65, i32 noundef %66)
  %68 = load i32, ptr %2, align 4, !tbaa !7
  %69 = load i32, ptr %3, align 4, !tbaa !7
  %70 = call noundef i32 @_Z7Replaceiiii(i32 noundef %.01823, i32 noundef %68, i32 noundef %69, i32 noundef %67)
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %64, %60
  %.1.ph = phi i32 [ %70, %64 ], [ %63, %60 ]
  %.pr = load i32, ptr @tot, align 4, !tbaa !7
  br label %71

71:                                               ; preds = %thread-pre-split, %24
  %72 = phi i32 [ %.pr, %thread-pre-split ], [ %25, %24 ]
  %.1 = phi i32 [ %.1.ph, %thread-pre-split ], [ %.01823, %24 ]
  %73 = icmp sgt i32 %72, 2499000
  br i1 %73, label %74, label %77

74:                                               ; preds = %71
  call void @_Z7RebuildiPi(i32 noundef %.1, ptr noundef nonnull @b)
  store i32 %14, ptr @tot, align 4, !tbaa !7
  %75 = load i32, ptr @n, align 4, !tbaa !7
  %76 = call noundef i32 @_Z5BuildiPi(i32 noundef %75, ptr noundef nonnull @b)
  br label %77

77:                                               ; preds = %74, %71
  %.2 = phi i32 [ %76, %74 ], [ %.1, %71 ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  %78 = load i32, ptr @m, align 4, !tbaa !7
  %79 = add nsw i32 %78, -1
  store i32 %79, ptr @m, align 4, !tbaa !7
  %.not = icmp eq i32 %78, 0
  br i1 %.not, label %.loopexit, label %.lr.ph25, !llvm.loop !15

._crit_edge28:                                    ; preds = %.loopexit, %0
  ret i32 0
}

; Function Attrs: nounwind
declare void @srand(i32 noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare i64 @time(ptr noundef) local_unnamed_addr #3

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

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

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass