; LLVM IR from tangjz/acm-icpc :: codeforces/complete (3B)

; 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, [100001 x %struct.Pair] }
%struct.Pair = type { i32, i32 }

@boat = external dso_local global [2 x %struct.Node], align 16
@n = external dso_local global i32, align 4
@v = external dso_local global i32, align 4
@sum = external dso_local global [2 x i32], align 4
@tmp = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 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 %struct.Pair, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @v)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  br label %10

10:                                               ; preds = %33, %0
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = load i32, ptr @n, align 4, !tbaa !5
  %13 = icmp sle i32 %11, %12
  br i1 %13, label %15, label %14

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

15:                                               ; preds = %10
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %3, ptr noundef %4)
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = add nsw i32 %17, -1
  store i32 %18, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %19 = load i32, ptr %4, align 4, !tbaa !5
  %20 = load i32, ptr %2, align 4, !tbaa !5
  call void @_ZN4PairC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %5, i32 noundef %19, i32 noundef %20)
  %21 = load i32, ptr %3, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [2 x %struct.Node], ptr @boat, i64 0, i64 %22
  %24 = getelementptr inbounds %struct.Node, ptr %23, i32 0, i32 2
  %25 = load i32, ptr %3, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [2 x %struct.Node], ptr @boat, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.Node, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %28, align 16, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 16, !tbaa !9
  %31 = sext i32 %29 to i64
  %32 = getelementptr inbounds [100001 x %struct.Pair], ptr %24, i64 0, i64 %31
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %32, ptr align 4 %5, i64 8, i1 false), !tbaa.struct !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  br label %33

33:                                               ; preds = %15
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %2, align 4, !tbaa !5
  br label %10, !llvm.loop !12

36:                                               ; preds = %14
  call void @_ZN4Node4SortEv(ptr noundef nonnull align 4 dereferenceable(800016) @boat)
  call void @_ZN4Node4SortEv(ptr noundef nonnull align 4 dereferenceable(800016) getelementptr inbounds ([2 x %struct.Node], ptr @boat, i64 0, i64 1))
  br label %37

37:                                               ; preds = %47, %36
  %38 = load i32, ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 1), align 4, !tbaa !14
  %39 = load i32, ptr @boat, align 16, !tbaa !9
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %41, label %45

41:                                               ; preds = %37
  %42 = load i32, ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 1), align 4, !tbaa !14
  %43 = load i32, ptr @v, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br label %45

45:                                               ; preds = %41, %37
  %46 = phi i1 [ false, %37 ], [ %44, %41 ]
  br i1 %46, label %47, label %57

47:                                               ; preds = %45
  %48 = load i32, ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 1), align 4, !tbaa !14
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 1), align 4, !tbaa !14
  %50 = sext i32 %48 to i64
  %51 = getelementptr inbounds [100001 x %struct.Pair], ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 2), i64 0, i64 %50
  %52 = getelementptr inbounds %struct.Pair, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 8, !tbaa !15
  %54 = sext i32 %53 to i64
  %55 = load i64, ptr @tmp, align 8, !tbaa !17
  %56 = add nsw i64 %55, %54
  store i64 %56, ptr @tmp, align 8, !tbaa !17
  br label %37, !llvm.loop !19

57:                                               ; preds = %45
  br label %58

58:                                               ; preds = %94, %57
  %59 = load i32, ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 1), align 4, !tbaa !14
  %60 = icmp sge i32 %59, 0
  br i1 %60, label %61, label %104

61:                                               ; preds = %58
  br label %62

62:                                               ; preds = %76, %61
  %63 = load i32, ptr getelementptr inbounds (%struct.Node, ptr getelementptr inbounds ([2 x %struct.Node], ptr @boat, i64 0, i64 1), i32 0, i32 1), align 4, !tbaa !14
  %64 = load i32, ptr getelementptr inbounds ([2 x %struct.Node], ptr @boat, i64 0, i64 1), align 16, !tbaa !9
  %65 = icmp slt i32 %63, %64
  br i1 %65, label %66, label %74

66:                                               ; preds = %62
  %67 = load i32, ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 1), align 4, !tbaa !14
  %68 = load i32, ptr getelementptr inbounds (%struct.Node, ptr getelementptr inbounds ([2 x %struct.Node], ptr @boat, i64 0, i64 1), i32 0, i32 1), align 4, !tbaa !14
  %69 = add nsw i32 %68, 1
  %70 = mul nsw i32 2, %69
  %71 = add nsw i32 %67, %70
  %72 = load i32, ptr @v, align 4, !tbaa !5
  %73 = icmp sle i32 %71, %72
  br label %74

74:                                               ; preds = %66, %62
  %75 = phi i1 [ false, %62 ], [ %73, %66 ]
  br i1 %75, label %76, label %86

76:                                               ; preds = %74
  %77 = load i32, ptr getelementptr inbounds (%struct.Node, ptr getelementptr inbounds ([2 x %struct.Node], ptr @boat, i64 0, i64 1), i32 0, i32 1), align 4, !tbaa !14
  %78 = add nsw i32 %77, 1
  store i32 %78, ptr getelementptr inbounds (%struct.Node, ptr getelementptr inbounds ([2 x %struct.Node], ptr @boat, i64 0, i64 1), i32 0, i32 1), align 4, !tbaa !14
  %79 = sext i32 %77 to i64
  %80 = getelementptr inbounds [100001 x %struct.Pair], ptr getelementptr inbounds (%struct.Node, ptr getelementptr inbounds ([2 x %struct.Node], ptr @boat, i64 0, i64 1), i32 0, i32 2), i64 0, i64 %79
  %81 = getelementptr inbounds %struct.Pair, ptr %80, i32 0, i32 0
  %82 = load i32, ptr %81, align 8, !tbaa !15
  %83 = sext i32 %82 to i64
  %84 = load i64, ptr @tmp, align 8, !tbaa !17
  %85 = add nsw i64 %84, %83
  store i64 %85, ptr @tmp, align 8, !tbaa !17
  br label %62, !llvm.loop !20

86:                                               ; preds = %74
  %87 = load i64, ptr @tmp, align 8, !tbaa !17
  %88 = load i64, ptr @ans, align 8, !tbaa !17
  %89 = icmp sgt i64 %87, %88
  br i1 %89, label %90, label %94

90:                                               ; preds = %86
  %91 = load i64, ptr @tmp, align 8, !tbaa !17
  store i64 %91, ptr @ans, align 8, !tbaa !17
  %92 = load i32, ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 1), align 4, !tbaa !14
  store i32 %92, ptr @sum, align 4, !tbaa !5
  %93 = load i32, ptr getelementptr inbounds (%struct.Node, ptr getelementptr inbounds ([2 x %struct.Node], ptr @boat, i64 0, i64 1), i32 0, i32 1), align 4, !tbaa !14
  store i32 %93, ptr getelementptr inbounds ([2 x i32], ptr @sum, i64 0, i64 1), align 4, !tbaa !5
  br label %94

94:                                               ; preds = %90, %86
  %95 = load i32, ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 1), align 4, !tbaa !14
  %96 = add nsw i32 %95, -1
  store i32 %96, ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 1), align 4, !tbaa !14
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [100001 x %struct.Pair], ptr getelementptr inbounds (%struct.Node, ptr @boat, i32 0, i32 2), i64 0, i64 %97
  %99 = getelementptr inbounds %struct.Pair, ptr %98, i32 0, i32 0
  %100 = load i32, ptr %99, align 8, !tbaa !15
  %101 = sext i32 %100 to i64
  %102 = load i64, ptr @tmp, align 8, !tbaa !17
  %103 = sub nsw i64 %102, %101
  store i64 %103, ptr @tmp, align 8, !tbaa !17
  br label %58, !llvm.loop !21

104:                                              ; preds = %58
  %105 = load i64, ptr @ans, align 8, !tbaa !17
  %106 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i64 noundef %105)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %107

107:                                              ; preds = %135, %104
  %108 = load i32, ptr %6, align 4, !tbaa !5
  %109 = icmp slt i32 %108, 2
  br i1 %109, label %111, label %110

110:                                              ; preds = %107
  store i32 11, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %138

111:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #6
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %131, %111
  %113 = load i32, ptr %8, align 4, !tbaa !5
  %114 = load i32, ptr %6, align 4, !tbaa !5
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [2 x i32], ptr @sum, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = icmp slt i32 %113, %117
  br i1 %118, label %120, label %119

119:                                              ; preds = %112
  store i32 14, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %134

120:                                              ; preds = %112
  %121 = load i32, ptr %6, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [2 x %struct.Node], ptr @boat, i64 0, i64 %122
  %124 = getelementptr inbounds %struct.Node, ptr %123, i32 0, i32 2
  %125 = load i32, ptr %8, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [100001 x %struct.Pair], ptr %124, i64 0, i64 %126
  %128 = getelementptr inbounds %struct.Pair, ptr %127, i32 0, i32 1
  %129 = load i32, ptr %128, align 4, !tbaa !22
  %130 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %129)
  br label %131

131:                                              ; preds = %120
  %132 = load i32, ptr %8, align 4, !tbaa !5
  %133 = add nsw i32 %132, 1
  store i32 %133, ptr %8, align 4, !tbaa !5
  br label %112, !llvm.loop !23

134:                                              ; preds = %119
  br label %135

135:                                              ; preds = %134
  %136 = load i32, ptr %6, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %6, align 4, !tbaa !5
  br label %107, !llvm.loop !24

138:                                              ; preds = %110
  %139 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  ret i32 0
}

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: mustprogress nounwind uwtable
declare dso_local void @_ZN4PairC2Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Node4SortEv(ptr noundef nonnull align 4 dereferenceable(800016)) #5 align 2

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 = { 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: readwrite) }
attributes #5 = { 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 #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 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !7, i64 8}
!11 = !{i64 0, i64 4, !5, i64 4, i64 4, !5}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 4}
!15 = !{!16, !6, i64 0}
!16 = !{!"_ZTS4Pair", !6, i64 0, !6, i64 4}
!17 = !{!18, !18, i64 0}
!18 = !{!"long long", !7, i64 0}
!19 = distinct !{!19, !13}
!20 = distinct !{!20, !13}
!21 = distinct !{!21, !13}
!22 = !{!16, !6, i64 4}
!23 = distinct !{!23, !13}
!24 = distinct !{!24, !13}


; 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, [100001 x %struct.Pair] }
%struct.Pair = type { i32, i32 }

@boat = external dso_local global [2 x %struct.Node], align 16
@n = external dso_local global i32, align 4
@v = external dso_local global i32, align 4
@sum = external dso_local local_unnamed_addr global [2 x i32], align 4
@tmp = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local local_unnamed_addr global i64, align 8
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [2 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 %struct.Pair, align 8
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @v)
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not19 = icmp slt i32 %5, 1
  br i1 %.not19, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  call void @_ZN4Node4SortEv(ptr noundef nonnull align 4 dereferenceable(800016) @boat)
  call void @_ZN4Node4SortEv(ptr noundef nonnull align 4 dereferenceable(800016) getelementptr inbounds (i8, ptr @boat, i64 800016))
  %6 = load i32, ptr @boat, align 16, !tbaa !9
  %7 = load i32, ptr @v, align 4
  %.fr = freeze i32 %7
  %invariant.smin = call i32 @llvm.smin.i32(i32 %6, i32 %.fr)
  %.promoted = load i32, ptr getelementptr inbounds (i8, ptr @boat, i64 4), align 4
  %tmp.promoted = load i64, ptr @tmp, align 8, !tbaa !11
  %8 = icmp slt i32 %.promoted, %invariant.smin
  br i1 %8, label %.lr.ph22.preheader, label %.preheader17

.lr.ph22.preheader:                               ; preds = %._crit_edge
  %9 = sext i32 %.promoted to i64
  %wide.trip.count = sext i32 %invariant.smin to i64
  %10 = sub nsw i64 %wide.trip.count, %9
  %min.iters.check = icmp ult i64 %10, 5
  br i1 %min.iters.check, label %.lr.ph22.preheader92, label %vector.ph

.lr.ph22.preheader92:                             ; preds = %middle.block, %.lr.ph22.preheader
  %indvars.iv.ph = phi i64 [ %9, %.lr.ph22.preheader ], [ %ind.end, %middle.block ]
  %.ph = phi i64 [ %tmp.promoted, %.lr.ph22.preheader ], [ %22, %middle.block ]
  br label %.lr.ph22

vector.ph:                                        ; preds = %.lr.ph22.preheader
  %n.mod.vf = and i64 %10, 3
  %11 = icmp eq i64 %n.mod.vf, 0
  %12 = select i1 %11, i64 4, i64 %n.mod.vf
  %n.vec = sub nsw i64 %10, %12
  %ind.end = add nsw i64 %n.vec, %9
  %13 = insertelement <2 x i64> <i64 poison, i64 0>, i64 %tmp.promoted, i64 0
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <2 x i64> [ %13, %vector.ph ], [ %19, %vector.body ]
  %vec.phi85 = phi <2 x i64> [ zeroinitializer, %vector.ph ], [ %20, %vector.body ]
  %offset.idx = add i64 %index, %9
  %14 = add i64 %offset.idx, 2
  %15 = getelementptr inbounds [100001 x %struct.Pair], ptr getelementptr inbounds (i8, ptr @boat, i64 8), i64 0, i64 %offset.idx
  %16 = getelementptr inbounds [100001 x %struct.Pair], ptr getelementptr inbounds (i8, ptr @boat, i64 8), i64 0, i64 %14
  %wide.vec = load <4 x i32>, ptr %15, align 8, !tbaa !13
  %wide.vec86 = load <4 x i32>, ptr %16, align 8, !tbaa !13
  %strided.vec = shufflevector <4 x i32> %wide.vec, <4 x i32> poison, <2 x i32> <i32 0, i32 2>
  %strided.vec87 = shufflevector <4 x i32> %wide.vec86, <4 x i32> poison, <2 x i32> <i32 0, i32 2>
  %17 = sext <2 x i32> %strided.vec to <2 x i64>
  %18 = sext <2 x i32> %strided.vec87 to <2 x i64>
  %19 = add <2 x i64> %vec.phi, %17
  %20 = add <2 x i64> %vec.phi85, %18
  %index.next = add nuw i64 %index, 4
  %21 = icmp eq i64 %index.next, %n.vec
  br i1 %21, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %bin.rdx = add <2 x i64> %20, %19
  %22 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
  br label %.lr.ph22.preheader92

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01120 = phi i32 [ %36, %.lr.ph ], [ 1, %0 ]
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = add nsw i32 %24, -1
  store i32 %25, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %26 = load i32, ptr %2, align 4, !tbaa !5
  call void @_ZN4PairC2Eii(ptr noundef nonnull align 4 dereferenceable(8) %3, i32 noundef %26, i32 noundef %.01120)
  %27 = load i32, ptr %1, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [2 x %struct.Node], ptr @boat, i64 0, i64 %28
  %30 = getelementptr inbounds i8, ptr %29, i64 8
  %31 = load i32, ptr %29, align 16, !tbaa !9
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %29, align 16, !tbaa !9
  %33 = sext i32 %31 to i64
  %34 = getelementptr inbounds [100001 x %struct.Pair], ptr %30, i64 0, i64 %33
  %35 = load i64, ptr %3, align 8
  store i64 %35, ptr %34, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  %36 = add nuw nsw i32 %.01120, 1
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %.not.not = icmp slt i32 %.01120, %37
  br i1 %.not.not, label %.lr.ph, label %._crit_edge, !llvm.loop !19

..preheader17_crit_edge:                          ; preds = %.lr.ph22
  store i32 %invariant.smin, ptr getelementptr inbounds (i8, ptr @boat, i64 4), align 4, !tbaa !20
  store i64 %47, ptr @tmp, align 8, !tbaa !11
  br label %.preheader17

.preheader17:                                     ; preds = %..preheader17_crit_edge, %._crit_edge
  %tmp.promoted36 = phi i64 [ %47, %..preheader17_crit_edge ], [ %tmp.promoted, %._crit_edge ]
  %.promoted31 = phi i32 [ %invariant.smin, %..preheader17_crit_edge ], [ %.promoted, %._crit_edge ]
  %38 = icmp sgt i32 %.promoted31, -1
  %ans.promoted = load i64, ptr @ans, align 8, !tbaa !11
  br i1 %38, label %.preheader16.lr.ph, label %.preheader

.preheader16.lr.ph:                               ; preds = %.preheader17
  %.promoted32 = load i32, ptr getelementptr inbounds (i8, ptr @boat, i64 800020), align 4, !tbaa !20
  %39 = load i32, ptr getelementptr inbounds (i8, ptr @boat, i64 800016), align 16, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = sext i32 %.fr to i64
  %42 = zext nneg i32 %.promoted31 to i64
  br label %.preheader16

.lr.ph22:                                         ; preds = %.lr.ph22.preheader92, %.lr.ph22
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph22 ], [ %indvars.iv.ph, %.lr.ph22.preheader92 ]
  %43 = phi i64 [ %47, %.lr.ph22 ], [ %.ph, %.lr.ph22.preheader92 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %44 = getelementptr inbounds [100001 x %struct.Pair], ptr getelementptr inbounds (i8, ptr @boat, i64 8), i64 0, i64 %indvars.iv
  %45 = load i32, ptr %44, align 8, !tbaa !13
  %46 = sext i32 %45 to i64
  %47 = add nsw i64 %43, %46
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %..preheader17_crit_edge, label %.lr.ph22, !llvm.loop !21

.preheader16:                                     ; preds = %.preheader16.lr.ph, %63
  %indvars.iv65 = phi i64 [ %42, %.preheader16.lr.ph ], [ %indvars.iv.next66, %63 ]
  %.promoted253549 = phi i32 [ %.promoted32, %.preheader16.lr.ph ], [ %.promoted2533, %63 ]
  %tmp.promoted263748 = phi i64 [ %tmp.promoted36, %.preheader16.lr.ph ], [ %67, %63 ]
  %tmp.promoted26384047 = phi i64 [ %ans.promoted, %.preheader16.lr.ph ], [ %tmp.promoted263839, %63 ]
  %48 = icmp slt i32 %.promoted253549, %39
  br i1 %48, label %.lr.ph27.preheader, label %.critedge

.lr.ph27.preheader:                               ; preds = %.preheader16
  %49 = sext i32 %.promoted253549 to i64
  br label %.lr.ph27

.lr.ph27:                                         ; preds = %.lr.ph27.preheader, %53
  %indvars.iv61 = phi i64 [ %49, %.lr.ph27.preheader ], [ %indvars.iv.next62, %53 ]
  %50 = phi i64 [ %tmp.promoted263748, %.lr.ph27.preheader ], [ %58, %53 ]
  %indvars.iv.next62 = add nsw i64 %indvars.iv61, 1
  %51 = shl nsw i64 %indvars.iv.next62, 1
  %52 = add nsw i64 %51, %indvars.iv65
  %.not15 = icmp sgt i64 %52, %41
  br i1 %.not15, label %.critedge.loopexit.split.loop.exit77, label %53

53:                                               ; preds = %.lr.ph27
  %54 = trunc nsw i64 %indvars.iv.next62 to i32
  store i32 %54, ptr getelementptr inbounds (i8, ptr @boat, i64 800020), align 4, !tbaa !20
  %55 = getelementptr inbounds [100001 x %struct.Pair], ptr getelementptr inbounds (i8, ptr @boat, i64 800024), i64 0, i64 %indvars.iv61
  %56 = load i32, ptr %55, align 8, !tbaa !13
  %57 = sext i32 %56 to i64
  %58 = add nsw i64 %50, %57
  %exitcond64.not = icmp eq i64 %indvars.iv.next62, %40
  br i1 %exitcond64.not, label %.critedge, label %.lr.ph27, !llvm.loop !22

.critedge.loopexit.split.loop.exit77:             ; preds = %.lr.ph27
  %59 = trunc nsw i64 %indvars.iv61 to i32
  br label %.critedge

.critedge:                                        ; preds = %53, %.critedge.loopexit.split.loop.exit77, %.preheader16
  %tmp.promoted2638 = phi i64 [ %tmp.promoted263748, %.preheader16 ], [ %50, %.critedge.loopexit.split.loop.exit77 ], [ %58, %53 ]
  %.promoted2533 = phi i32 [ %.promoted253549, %.preheader16 ], [ %59, %.critedge.loopexit.split.loop.exit77 ], [ %39, %53 ]
  %60 = icmp sgt i64 %tmp.promoted2638, %tmp.promoted26384047
  br i1 %60, label %61, label %63

61:                                               ; preds = %.critedge
  store i64 %tmp.promoted2638, ptr @ans, align 8, !tbaa !11
  %62 = trunc nuw nsw i64 %indvars.iv65 to i32
  store i32 %62, ptr @sum, align 4, !tbaa !5
  store i32 %.promoted2533, ptr getelementptr inbounds (i8, ptr @sum, i64 4), align 4, !tbaa !5
  br label %63

63:                                               ; preds = %61, %.critedge
  %tmp.promoted263839 = phi i64 [ %tmp.promoted2638, %61 ], [ %tmp.promoted26384047, %.critedge ]
  %indvars.iv.next66 = add nsw i64 %indvars.iv65, -1
  %64 = getelementptr inbounds [100001 x %struct.Pair], ptr getelementptr inbounds (i8, ptr @boat, i64 8), i64 0, i64 %indvars.iv.next66
  %65 = load i32, ptr %64, align 8, !tbaa !13
  %66 = sext i32 %65 to i64
  %67 = sub nsw i64 %tmp.promoted2638, %66
  %68 = icmp sgt i64 %indvars.iv65, 0
  br i1 %68, label %.preheader16, label %._crit_edge50, !llvm.loop !23

._crit_edge50:                                    ; preds = %63
  %69 = trunc nsw i64 %indvars.iv.next66 to i32
  store i64 %67, ptr @tmp, align 8, !tbaa !11
  store i32 %69, ptr getelementptr inbounds (i8, ptr @boat, i64 4), align 4, !tbaa !20
  br label %.preheader

.preheader:                                       ; preds = %.preheader17, %._crit_edge50
  %70 = phi i64 [ %tmp.promoted263839, %._crit_edge50 ], [ %ans.promoted, %.preheader17 ]
  %71 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %70)
  %72 = load i32, ptr @sum, align 4, !tbaa !5
  %73 = icmp sgt i32 %72, 0
  br i1 %73, label %.lr.ph54, label %._crit_edge55

._crit_edge55:                                    ; preds = %.lr.ph54, %.preheader
  %74 = load i32, ptr getelementptr inbounds (i8, ptr @sum, i64 4), align 4, !tbaa !5
  %75 = icmp sgt i32 %74, 0
  br i1 %75, label %.lr.ph54.1, label %._crit_edge55.1

.lr.ph54.1:                                       ; preds = %._crit_edge55, %.lr.ph54.1
  %indvars.iv68.1 = phi i64 [ %indvars.iv.next69.1, %.lr.ph54.1 ], [ 0, %._crit_edge55 ]
  %76 = getelementptr inbounds [2 x %struct.Node], ptr @boat, i64 0, i64 1, i32 2, i64 %indvars.iv68.1, i32 1
  %77 = load i32, ptr %76, align 4, !tbaa !24
  %78 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %77)
  %indvars.iv.next69.1 = add nuw nsw i64 %indvars.iv68.1, 1
  %79 = load i32, ptr getelementptr inbounds (i8, ptr @sum, i64 4), align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = icmp slt i64 %indvars.iv.next69.1, %80
  br i1 %81, label %.lr.ph54.1, label %._crit_edge55.1, !llvm.loop !25

._crit_edge55.1:                                  ; preds = %.lr.ph54.1, %._crit_edge55
  %82 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  ret i32 0

.lr.ph54:                                         ; preds = %.preheader, %.lr.ph54
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %.lr.ph54 ], [ 0, %.preheader ]
  %83 = getelementptr inbounds [2 x %struct.Node], ptr @boat, i64 0, i64 0, i32 2, i64 %indvars.iv68, i32 1
  %84 = load i32, ptr %83, align 4, !tbaa !24
  %85 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %84)
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %86 = load i32, ptr @sum, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = icmp slt i64 %indvars.iv.next69, %87
  br i1 %88, label %.lr.ph54, label %._crit_edge55, !llvm.loop !25
}

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN4PairC2Eii(ptr noundef nonnull align 4 dereferenceable(8), i32 noundef, i32 noundef) unnamed_addr #3 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN4Node4SortEv(ptr noundef nonnull align 4 dereferenceable(800016)) local_unnamed_addr #4 align 2

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smin.i32(i32, i32) #5

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>) #5

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 = { nofree nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Node", !6, i64 0, !6, i64 4, !7, i64 8}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTS4Pair", !6, i64 0, !6, i64 4}
!15 = distinct !{!15, !16, !17, !18}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.isvectorized", i32 1}
!18 = !{!"llvm.loop.unroll.runtime.disable"}
!19 = distinct !{!19, !16}
!20 = !{!10, !6, i64 4}
!21 = distinct !{!21, !16, !18, !17}
!22 = distinct !{!22, !16}
!23 = distinct !{!23, !16}
!24 = !{!14, !6, i64 4}
!25 = distinct !{!25, !16}


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