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

; 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.Node = type { i32, i32, i32, i32, i32, i32 }
%"struct.std::pair" = type { i32, i32 }

@tot = external dso_local global i32, align 4
@rt = external dso_local global i32, align 4
@pw = external dso_local global [100001 x i32], align 16
@pool = external dso_local global [100001 x %struct.Node], align 16
@_ZZ4mainE3buf = external hidden global [100001 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 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 %"struct.std::pair", align 4
  %10 = alloca %"struct.std::pair", align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr @pw, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %25, %0
  %12 = load i32, ptr %5, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 100001
  br i1 %13, label %15, label %14

14:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %28

15:                                               ; preds = %11
  %16 = load i32, ptr %5, align 4, !tbaa !5
  %17 = sub nsw i32 %16, 1
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = mul nsw i32 %20, 29
  %22 = load i32, ptr %5, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %23
  store i32 %21, ptr %24, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %15
  %26 = load i32, ptr %5, align 4, !tbaa !5
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %5, align 4, !tbaa !5
  br label %11, !llvm.loop !9

28:                                               ; preds = %14
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @_ZZ4mainE3buf)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %48, %28
  %31 = load i32, ptr %6, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [100001 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %32
  %34 = load i8, ptr %33, align 1, !tbaa !11
  %35 = icmp ne i8 %34, 0
  br i1 %35, label %37, label %36

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

37:                                               ; preds = %30
  %38 = load i32, ptr @rt, align 4, !tbaa !5
  %39 = load i32, ptr %6, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [100001 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !11
  %43 = sext i8 %42 to i32
  %44 = sub nsw i32 %43, 97
  %45 = add nsw i32 %44, 1
  %46 = call noundef i32 @_Z7newNodei(i32 noundef %45)
  %47 = call noundef i32 @_Z5mergeii(i32 noundef %38, i32 noundef %46)
  store i32 %47, ptr @rt, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %37
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %6, align 4, !tbaa !5
  br label %30, !llvm.loop !12

51:                                               ; preds = %36
  %52 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %2)
  br label %53

53:                                               ; preds = %161, %51
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr %2, align 4, !tbaa !5
  %56 = icmp ne i32 %54, 0
  br i1 %56, label %57, label %162

57:                                               ; preds = %53
  %58 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef @_ZZ4mainE3buf, ptr noundef %3)
  %59 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !11
  %60 = sext i8 %59 to i32
  %61 = icmp eq i32 %60, 81
  br i1 %61, label %62, label %113

62:                                               ; preds = %57
  %63 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = icmp sgt i32 %64, %65
  br i1 %66, label %67, label %68

67:                                               ; preds = %62
  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) %3, ptr noundef nonnull align 4 dereferenceable(4) %4) #5
  br label %68

68:                                               ; preds = %67, %62
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 16, ptr %8, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %107, %68
  %70 = load i32, ptr %8, align 4, !tbaa !5
  %71 = icmp sge i32 %70, 0
  br i1 %71, label %73, label %72

72:                                               ; preds = %69
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %110

73:                                               ; preds = %69
  %74 = load i32, ptr %8, align 4, !tbaa !5
  %75 = shl i32 1, %74
  %76 = load i32, ptr @tot, align 4, !tbaa !5
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = sub nsw i32 %76, %77
  %79 = add nsw i32 %78, 1
  %80 = icmp sle i32 %75, %79
  br i1 %80, label %81, label %106

81:                                               ; preds = %73
  %82 = load i32, ptr %3, align 4, !tbaa !5
  %83 = sub nsw i32 %82, 1
  %84 = load i32, ptr %8, align 4, !tbaa !5
  %85 = shl i32 1, %84
  %86 = call noundef i32 @_Z6getValii(i32 noundef %83, i32 noundef %85)
  %87 = load i32, ptr %4, align 4, !tbaa !5
  %88 = sub nsw i32 %87, 1
  %89 = load i32, ptr %8, align 4, !tbaa !5
  %90 = shl i32 1, %89
  %91 = call noundef i32 @_Z6getValii(i32 noundef %88, i32 noundef %90)
  %92 = icmp eq i32 %86, %91
  br i1 %92, label %93, label %106

93:                                               ; preds = %81
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = shl i32 1, %94
  %96 = load i32, ptr %7, align 4, !tbaa !5
  %97 = add nsw i32 %96, %95
  store i32 %97, ptr %7, align 4, !tbaa !5
  %98 = load i32, ptr %8, align 4, !tbaa !5
  %99 = shl i32 1, %98
  %100 = load i32, ptr %3, align 4, !tbaa !5
  %101 = add nsw i32 %100, %99
  store i32 %101, ptr %3, align 4, !tbaa !5
  %102 = load i32, ptr %8, align 4, !tbaa !5
  %103 = shl i32 1, %102
  %104 = load i32, ptr %4, align 4, !tbaa !5
  %105 = add nsw i32 %104, %103
  store i32 %105, ptr %4, align 4, !tbaa !5
  br label %106

106:                                              ; preds = %93, %81, %73
  br label %107

107:                                              ; preds = %106
  %108 = load i32, ptr %8, align 4, !tbaa !5
  %109 = add nsw i32 %108, -1
  store i32 %109, ptr %8, align 4, !tbaa !5
  br label %69, !llvm.loop !13

110:                                              ; preds = %72
  %111 = load i32, ptr %7, align 4, !tbaa !5
  %112 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %111)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %161

113:                                              ; preds = %57
  %114 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef getelementptr inbounds (i8, ptr @_ZZ4mainE3buf, i64 2))
  %115 = load i8, ptr getelementptr inbounds ([100001 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 2), align 2, !tbaa !11
  %116 = sext i8 %115 to i32
  %117 = sub nsw i32 %116, 97
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  %119 = load i32, ptr @rt, align 4, !tbaa !5
  %120 = load i32, ptr %3, align 4, !tbaa !5
  %121 = call i64 @_Z5splitii(i32 noundef %119, i32 noundef %120)
  store i64 %121, ptr %9, align 4
  %122 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !11
  %123 = sext i8 %122 to i32
  %124 = icmp eq i32 %123, 82
  br i1 %124, label %125, label %148

125:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #5
  %126 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %127 = load i32, ptr %126, align 4, !tbaa !14
  %128 = load i32, ptr %3, align 4, !tbaa !5
  %129 = sub nsw i32 %128, 1
  %130 = call i64 @_Z5splitii(i32 noundef %127, i32 noundef %129)
  store i64 %130, ptr %10, align 4
  %131 = load i32, ptr %4, align 4, !tbaa !5
  %132 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 1
  %133 = load i32, ptr %132, align 4, !tbaa !16
  %134 = sext i32 %133 to i64
  %135 = getelementptr inbounds [100001 x %struct.Node], ptr @pool, i64 0, i64 %134
  %136 = getelementptr inbounds %struct.Node, ptr %135, i32 0, i32 5
  store i32 %131, ptr %136, align 4, !tbaa !17
  %137 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 1
  %138 = load i32, ptr %137, align 4, !tbaa !16
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [100001 x %struct.Node], ptr @pool, i64 0, i64 %139
  %141 = getelementptr inbounds %struct.Node, ptr %140, i32 0, i32 4
  store i32 %131, ptr %141, align 8, !tbaa !19
  %142 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 0
  %143 = load i32, ptr %142, align 4, !tbaa !14
  %144 = getelementptr inbounds %"struct.std::pair", ptr %10, i32 0, i32 1
  %145 = load i32, ptr %144, align 4, !tbaa !16
  %146 = call noundef i32 @_Z5mergeii(i32 noundef %143, i32 noundef %145)
  %147 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  store i32 %146, ptr %147, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #5
  br label %155

148:                                              ; preds = %113
  %149 = load i32, ptr %4, align 4, !tbaa !5
  %150 = call noundef i32 @_Z7newNodei(i32 noundef %149)
  %151 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 1
  %152 = load i32, ptr %151, align 4, !tbaa !16
  %153 = call noundef i32 @_Z5mergeii(i32 noundef %150, i32 noundef %152)
  %154 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 1
  store i32 %153, ptr %154, align 4, !tbaa !16
  br label %155

155:                                              ; preds = %148, %125
  %156 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 0
  %157 = load i32, ptr %156, align 4, !tbaa !14
  %158 = getelementptr inbounds %"struct.std::pair", ptr %9, i32 0, i32 1
  %159 = load i32, ptr %158, align 4, !tbaa !16
  %160 = call noundef i32 @_Z5mergeii(i32 noundef %157, i32 noundef %159)
  store i32 %160, ptr @rt, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  br label %161

161:                                              ; preds = %155, %110
  br label %53, !llvm.loop !20

162:                                              ; preds = %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z5mergeii(i32 noundef, i32 noundef) #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z7newNodei(i32 noundef) #3

; 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)) #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z6getValii(i32 noundef, i32 noundef) #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i64 @_Z5splitii(i32 noundef, i32 noundef) #3

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTSSt4pairIiiE", !6, i64 0, !6, i64 4}
!16 = !{!15, !6, i64 4}
!17 = !{!18, !6, i64 20}
!18 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20}
!19 = !{!18, !6, i64 16}
!20 = distinct !{!20, !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.Node = type { i32, i32, i32, i32, i32, i32 }

@tot = external dso_local local_unnamed_addr global i32, align 4
@rt = external dso_local local_unnamed_addr global i32, align 4
@pw = external dso_local local_unnamed_addr global [100001 x i32], align 16
@pool = external dso_local local_unnamed_addr global [100001 x %struct.Node], align 16
@_ZZ4mainE3buf = external hidden global [100001 x i8], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  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
  store i32 1, ptr @pw, align 16, !tbaa !5
  br label %7

4:                                                ; preds = %7
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @_ZZ4mainE3buf)
  %6 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !9
  %.not30 = icmp eq i8 %6, 0
  br i1 %.not30, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %4
  %.pre = load i32, ptr @rt, align 4, !tbaa !5
  br label %.lr.ph

7:                                                ; preds = %7, %0
  %8 = phi i32 [ 1, %0 ], [ %17, %7 ]
  %indvars.iv = phi i64 [ 1, %0 ], [ %indvars.iv.next.4, %7 ]
  %9 = mul nuw nsw i32 %8, 29
  %10 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %indvars.iv
  store i32 %9, ptr %10, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %11 = mul nuw i32 %8, 841
  %12 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %indvars.iv.next
  store i32 %11, ptr %12, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %13 = mul nuw i32 %8, 24389
  %14 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %indvars.iv.next.1
  store i32 %13, ptr %14, align 4, !tbaa !5
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %15 = mul nuw i32 %8, 707281
  %16 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %indvars.iv.next.2
  store i32 %15, ptr %16, align 4, !tbaa !5
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %17 = mul nuw i32 %8, 20511149
  %18 = getelementptr inbounds [100001 x i32], ptr @pw, i64 0, i64 %indvars.iv.next.3
  store i32 %17, ptr %18, align 4, !tbaa !5
  %indvars.iv.next.4 = add nuw nsw i64 %indvars.iv, 5
  %exitcond.not.4 = icmp eq i64 %indvars.iv.next.4, 100001
  br i1 %exitcond.not.4, label %4, label %7, !llvm.loop !10

._crit_edge:                                      ; preds = %.lr.ph, %4
  %19 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = add nsw i32 %20, -1
  store i32 %21, ptr %1, align 4, !tbaa !5
  %.not2734 = icmp eq i32 %20, 0
  br i1 %.not2734, label %._crit_edge37, label %.lr.ph36

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %22 = phi i32 [ %.pre, %.lr.ph.preheader ], [ %27, %.lr.ph ]
  %indvars.iv39 = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next40, %.lr.ph ]
  %23 = phi i8 [ %6, %.lr.ph.preheader ], [ %29, %.lr.ph ]
  %24 = sext i8 %23 to i32
  %25 = add nsw i32 %24, -96
  %26 = tail call noundef i32 @_Z7newNodei(i32 noundef %25)
  %27 = tail call noundef i32 @_Z5mergeii(i32 noundef %22, i32 noundef %26)
  store i32 %27, ptr @rt, align 4, !tbaa !5
  %indvars.iv.next40 = add nuw nsw i64 %indvars.iv39, 1
  %28 = getelementptr inbounds [100001 x i8], ptr @_ZZ4mainE3buf, i64 0, i64 %indvars.iv.next40
  %29 = load i8, ptr %28, align 1, !tbaa !9
  %.not = icmp eq i8 %29, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph, !llvm.loop !12

.lr.ph36:                                         ; preds = %._crit_edge, %91
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull @_ZZ4mainE3buf, ptr noundef nonnull %2)
  %31 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !9
  %32 = icmp eq i8 %31, 81
  br i1 %32, label %33, label %65

33:                                               ; preds = %.lr.ph36
  %34 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = icmp sgt i32 %35, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %33
  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) %2, ptr noundef nonnull align 4 dereferenceable(4) %3) #5
  br label %39

39:                                               ; preds = %38, %33
  %.pre42 = load i32, ptr @tot, align 4, !tbaa !5
  br label %42

40:                                               ; preds = %62
  %41 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.1)
  br label %91

42:                                               ; preds = %39, %62
  %43 = phi i32 [ %.pre42, %39 ], [ %63, %62 ]
  %.02333 = phi i32 [ 16, %39 ], [ %64, %62 ]
  %.02432 = phi i32 [ 0, %39 ], [ %.1, %62 ]
  %44 = shl nuw i32 1, %.02333
  %45 = load i32, ptr %3, align 4, !tbaa !5
  %46 = add i32 %43, 1
  %47 = sub i32 %46, %45
  %.not28 = icmp sgt i32 %44, %47
  br i1 %.not28, label %62, label %48

48:                                               ; preds = %42
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = add nsw i32 %49, -1
  %51 = call noundef i32 @_Z6getValii(i32 noundef %50, i32 noundef %44)
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = add nsw i32 %52, -1
  %54 = call noundef i32 @_Z6getValii(i32 noundef %53, i32 noundef %44)
  %55 = icmp eq i32 %51, %54
  %.pre41 = load i32, ptr @tot, align 4, !tbaa !5
  br i1 %55, label %56, label %62

56:                                               ; preds = %48
  %57 = add nsw i32 %44, %.02432
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = add nsw i32 %58, %44
  store i32 %59, ptr %2, align 4, !tbaa !5
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = add nsw i32 %60, %44
  store i32 %61, ptr %3, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %42, %48, %56
  %63 = phi i32 [ %.pre41, %56 ], [ %.pre41, %48 ], [ %43, %42 ]
  %.1 = phi i32 [ %57, %56 ], [ %.02432, %48 ], [ %.02432, %42 ]
  %64 = add nsw i32 %.02333, -1
  %.not43 = icmp eq i32 %.02333, 0
  br i1 %.not43, label %40, label %42, !llvm.loop !13

65:                                               ; preds = %.lr.ph36
  %66 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull getelementptr inbounds (i8, ptr @_ZZ4mainE3buf, i64 2))
  %67 = load i8, ptr getelementptr inbounds (i8, ptr @_ZZ4mainE3buf, i64 2), align 2, !tbaa !9
  %68 = sext i8 %67 to i32
  %69 = add nsw i32 %68, -96
  store i32 %69, ptr %3, align 4, !tbaa !5
  %70 = load i32, ptr @rt, align 4, !tbaa !5
  %71 = load i32, ptr %2, align 4, !tbaa !5
  %72 = call i64 @_Z5splitii(i32 noundef %70, i32 noundef %71)
  %.sroa.03.0.extract.trunc = trunc i64 %72 to i32
  %.sroa.6.0.extract.shift = lshr i64 %72, 32
  %.sroa.6.0.extract.trunc = trunc nuw i64 %.sroa.6.0.extract.shift to i32
  %73 = load i8, ptr @_ZZ4mainE3buf, align 16, !tbaa !9
  %74 = icmp eq i8 %73, 82
  br i1 %74, label %75, label %85

75:                                               ; preds = %65
  %76 = load i32, ptr %2, align 4, !tbaa !5
  %77 = add nsw i32 %76, -1
  %78 = call i64 @_Z5splitii(i32 noundef %.sroa.03.0.extract.trunc, i32 noundef %77)
  %.sroa.0.0.extract.trunc = trunc i64 %78 to i32
  %.sroa.4.0.extract.shift = lshr i64 %78, 32
  %.sroa.4.0.extract.trunc = trunc nuw i64 %.sroa.4.0.extract.shift to i32
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = ashr i64 %78, 32
  %81 = getelementptr inbounds [100001 x %struct.Node], ptr @pool, i64 0, i64 %80
  %82 = getelementptr inbounds i8, ptr %81, i64 20
  store i32 %79, ptr %82, align 4, !tbaa !14
  %83 = getelementptr inbounds i8, ptr %81, i64 16
  store i32 %79, ptr %83, align 8, !tbaa !16
  %84 = call noundef i32 @_Z5mergeii(i32 noundef %.sroa.0.0.extract.trunc, i32 noundef %.sroa.4.0.extract.trunc)
  br label %89

85:                                               ; preds = %65
  %86 = load i32, ptr %3, align 4, !tbaa !5
  %87 = call noundef i32 @_Z7newNodei(i32 noundef %86)
  %88 = call noundef i32 @_Z5mergeii(i32 noundef %87, i32 noundef %.sroa.6.0.extract.trunc)
  br label %89

89:                                               ; preds = %85, %75
  %.sroa.6.0 = phi i32 [ %.sroa.6.0.extract.trunc, %75 ], [ %88, %85 ]
  %.sroa.03.0 = phi i32 [ %84, %75 ], [ %.sroa.03.0.extract.trunc, %85 ]
  %90 = call noundef i32 @_Z5mergeii(i32 noundef %.sroa.03.0, i32 noundef %.sroa.6.0)
  store i32 %90, ptr @rt, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %89, %40
  %92 = load i32, ptr %1, align 4, !tbaa !5
  %93 = add nsw i32 %92, -1
  store i32 %93, ptr %1, align 4, !tbaa !5
  %.not27 = icmp eq i32 %92, 0
  br i1 %.not27, label %._crit_edge37, label %.lr.ph36, !llvm.loop !17

._crit_edge37:                                    ; preds = %91, %._crit_edge
  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
  ret i32 0
}

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

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

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z5mergeii(i32 noundef, i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z7newNodei(i32 noundef) local_unnamed_addr #3

; 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 #4

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local noundef i32 @_Z6getValii(i32 noundef, i32 noundef) local_unnamed_addr #3

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local i64 @_Z5splitii(i32 noundef, i32 noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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" }
attributes #4 = { 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 #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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = !{!15, !6, i64 20}
!15 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !6, i64 8, !6, i64 12, !6, i64 16, !6, i64 20}
!16 = !{!15, !6, i64 16}
!17 = distinct !{!17, !11}


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