; LLVM IR from kazunetakahashi/atcoder :: 2018/1229_AGC030/B.ll (Z5solvev)

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

@L = external dso_local global i64, align 8
@N = external dso_local global i32, align 4
@X = external dso_local global [200010 x i64], align 16
@sum = external dso_local global [200010 x i64], align 16
@sum_rev = external dso_local global [200010 x i64], align 16
@ans = external dso_local global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #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 i64, align 8
  %7 = alloca i32, align 4
  %8 = load i32, ptr @N, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds i64, ptr @X, i64 %9
  %11 = getelementptr inbounds i64, ptr %10, i64 1
  call void @_ZSt4sortIPxEvT_S1_(ptr noundef getelementptr inbounds (i64, ptr @X, i64 1), ptr noundef %11)
  store i64 0, ptr @sum, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %31, %0
  %13 = load i32, ptr %1, align 4, !tbaa !5
  %14 = load i32, ptr @N, align 4, !tbaa !5
  %15 = icmp sle i32 %13, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  br label %34

17:                                               ; preds = %12
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = sub nsw i32 %18, 1
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = load i32, ptr %1, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = add nsw i64 %22, %26
  %28 = load i32, ptr %1, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %29
  store i64 %27, ptr %30, align 8, !tbaa !9
  br label %31

31:                                               ; preds = %17
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %1, align 4, !tbaa !5
  br label %12, !llvm.loop !11

34:                                               ; preds = %16
  %35 = load i32, ptr @N, align 4, !tbaa !5
  %36 = add nsw i32 %35, 1
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %37
  store i64 0, ptr %38, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  %39 = load i32, ptr @N, align 4, !tbaa !5
  store i32 %39, ptr %2, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %60, %34
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = icmp sge i32 %41, 1
  br i1 %42, label %44, label %43

43:                                               ; preds = %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %63

44:                                               ; preds = %40
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %47
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = load i64, ptr @L, align 8, !tbaa !9
  %51 = add nsw i64 %49, %50
  %52 = load i32, ptr %2, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %53
  %55 = load i64, ptr %54, align 8, !tbaa !9
  %56 = sub nsw i64 %51, %55
  %57 = load i32, ptr %2, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %58
  store i64 %56, ptr %59, align 8, !tbaa !9
  br label %60

60:                                               ; preds = %44
  %61 = load i32, ptr %2, align 4, !tbaa !5
  %62 = add nsw i32 %61, -1
  store i32 %62, ptr %2, align 4, !tbaa !5
  br label %40, !llvm.loop !13

63:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %153, %63
  %65 = load i32, ptr %3, align 4, !tbaa !5
  %66 = load i32, ptr @N, align 4, !tbaa !5
  %67 = icmp sle i32 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %156

69:                                               ; preds = %64
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %70 = load i32, ptr @N, align 4, !tbaa !5
  %71 = load i32, ptr %3, align 4, !tbaa !5
  %72 = sub nsw i32 %70, %71
  store i32 %72, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  %73 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %74 = load i32, ptr %73, align 4, !tbaa !5
  store i32 %74, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %76
  %78 = load i64, ptr %77, align 8, !tbaa !9
  %79 = load i32, ptr %3, align 4, !tbaa !5
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = sub nsw i32 %79, %80
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %82
  %84 = load i64, ptr %83, align 8, !tbaa !9
  %85 = sub nsw i64 %78, %84
  %86 = load i32, ptr %3, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %88
  %90 = load i64, ptr %89, align 8, !tbaa !9
  %91 = add nsw i64 %85, %90
  %92 = load i32, ptr %3, align 4, !tbaa !5
  %93 = add nsw i32 %92, 1
  %94 = load i32, ptr %5, align 4, !tbaa !5
  %95 = add nsw i32 %93, %94
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %96
  %98 = load i64, ptr %97, align 8, !tbaa !9
  %99 = sub nsw i64 %91, %98
  store i64 %99, ptr %6, align 8, !tbaa !9
  %100 = load i64, ptr %6, align 8, !tbaa !9
  %101 = mul nsw i64 %100, 2
  store i64 %101, ptr %6, align 8, !tbaa !9
  %102 = load i64, ptr @L, align 8, !tbaa !9
  %103 = load i32, ptr %3, align 4, !tbaa !5
  %104 = add nsw i32 %103, 1
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %105
  %107 = load i64, ptr %106, align 8, !tbaa !9
  %108 = sub nsw i64 %102, %107
  %109 = load i64, ptr %6, align 8, !tbaa !9
  %110 = sub nsw i64 %109, %108
  store i64 %110, ptr %6, align 8, !tbaa !9
  %111 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) @ans)
  %112 = load i64, ptr %111, align 8, !tbaa !9
  store i64 %112, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %7, align 4, !tbaa !5
  %115 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %116 = load i32, ptr %115, align 4, !tbaa !5
  store i32 %116, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  %117 = load i32, ptr %3, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %118
  %120 = load i64, ptr %119, align 8, !tbaa !9
  %121 = load i32, ptr %3, align 4, !tbaa !5
  %122 = load i32, ptr %5, align 4, !tbaa !5
  %123 = sub nsw i32 %121, %122
  %124 = sext i32 %123 to i64
  %125 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %124
  %126 = load i64, ptr %125, align 8, !tbaa !9
  %127 = sub nsw i64 %120, %126
  %128 = load i32, ptr %3, align 4, !tbaa !5
  %129 = add nsw i32 %128, 1
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %130
  %132 = load i64, ptr %131, align 8, !tbaa !9
  %133 = add nsw i64 %127, %132
  %134 = load i32, ptr %3, align 4, !tbaa !5
  %135 = add nsw i32 %134, 1
  %136 = load i32, ptr %5, align 4, !tbaa !5
  %137 = sub nsw i32 %136, 1
  %138 = add nsw i32 %135, %137
  %139 = sext i32 %138 to i64
  %140 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %139
  %141 = load i64, ptr %140, align 8, !tbaa !9
  %142 = sub nsw i64 %133, %141
  store i64 %142, ptr %6, align 8, !tbaa !9
  %143 = load i64, ptr %6, align 8, !tbaa !9
  %144 = mul nsw i64 %143, 2
  store i64 %144, ptr %6, align 8, !tbaa !9
  %145 = load i32, ptr %3, align 4, !tbaa !5
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %146
  %148 = load i64, ptr %147, align 8, !tbaa !9
  %149 = load i64, ptr %6, align 8, !tbaa !9
  %150 = sub nsw i64 %149, %148
  store i64 %150, ptr %6, align 8, !tbaa !9
  %151 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) @ans)
  %152 = load i64, ptr %151, align 8, !tbaa !9
  store i64 %152, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %153

153:                                              ; preds = %69
  %154 = load i32, ptr %3, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %3, align 4, !tbaa !5
  br label %64, !llvm.loop !14

156:                                              ; preds = %68
  ret void
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #3

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

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}


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

@L = external dso_local local_unnamed_addr global i64, align 8
@N = external dso_local local_unnamed_addr global i32, align 4
@X = external dso_local global [200010 x i64], align 16
@sum = external dso_local local_unnamed_addr global [200010 x i64], align 16
@sum_rev = external dso_local local_unnamed_addr global [200010 x i64], align 16
@ans = external dso_local global i64, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = load i32, ptr @N, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds i64, ptr @X, i64 %6
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  tail call void @_ZSt4sortIPxEvT_S1_(ptr noundef nonnull getelementptr inbounds (i8, ptr @X, i64 8), ptr noundef nonnull %8)
  store i64 0, ptr @sum, align 16, !tbaa !9
  %9 = load i32, ptr @N, align 4, !tbaa !5
  %.not25 = icmp slt i32 %9, 1
  %.pre = add i32 %9, 1
  br i1 %.not25, label %._crit_edge.thread, label %.lr.ph.preheader

._crit_edge.thread:                               ; preds = %0
  %10 = sext i32 %.pre to i64
  %11 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %10
  store i64 0, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  br label %._crit_edge35

.lr.ph.preheader:                                 ; preds = %0
  %wide.trip.count = zext i32 %.pre to i64
  %12 = add nsw i64 %wide.trip.count, -1
  %13 = add nsw i64 %wide.trip.count, -2
  %xtraiter = and i64 %12, 3
  %14 = icmp ult i64 %13, 3
  br i1 %14, label %._crit_edge.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %12, -4
  br label %.lr.ph

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph, %.lr.ph.preheader
  %.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %41, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.unr-lcssa, %.lr.ph.epil
  %15 = phi i64 [ %18, %.lr.ph.epil ], [ %.unr, %._crit_edge.unr-lcssa ]
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.unr-lcssa ]
  %16 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %indvars.iv.epil
  %17 = load i64, ptr %16, align 8, !tbaa !9
  %18 = add nsw i64 %17, %15
  %19 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %indvars.iv.epil
  store i64 %18, ptr %19, align 8, !tbaa !9
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge, label %.lr.ph.epil, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.unr-lcssa
  %20 = sext i32 %.pre to i64
  %21 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %20
  store i64 0, ptr %21, align 8, !tbaa !9
  %22 = load i64, ptr @L, align 8, !tbaa !9
  %23 = zext nneg i32 %9 to i64
  %24 = shl nuw nsw i64 %23, 3
  %25 = getelementptr i8, ptr @sum_rev, i64 %24
  %scevgep = getelementptr i8, ptr %25, i64 8
  %load_initial = load i64, ptr %scevgep, align 8
  br label %43

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %26 = phi i64 [ 0, %.lr.ph.preheader.new ], [ %41, %.lr.ph ]
  %indvars.iv = phi i64 [ 1, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %27 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %indvars.iv
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = add nsw i64 %28, %26
  %30 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %indvars.iv
  store i64 %29, ptr %30, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %31 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %indvars.iv.next
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = add nsw i64 %32, %29
  %34 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %indvars.iv.next
  store i64 %33, ptr %34, align 8, !tbaa !9
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %35 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %indvars.iv.next.1
  %36 = load i64, ptr %35, align 8, !tbaa !9
  %37 = add nsw i64 %36, %33
  %38 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %indvars.iv.next.1
  store i64 %37, ptr %38, align 8, !tbaa !9
  %indvars.iv.next.2 = add nuw nsw i64 %indvars.iv, 3
  %39 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %indvars.iv.next.2
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = add nsw i64 %40, %37
  %42 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %indvars.iv.next.2
  store i64 %41, ptr %42, align 8, !tbaa !9
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge.unr-lcssa, label %.lr.ph, !llvm.loop !13

._crit_edge30:                                    ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  store i32 1, ptr %1, align 4, !tbaa !5
  br i1 %.not25, label %._crit_edge35, label %.lr.ph34

43:                                               ; preds = %._crit_edge, %43
  %store_forwarded = phi i64 [ %load_initial, %._crit_edge ], [ %47, %43 ]
  %indvars.iv37 = phi i64 [ %23, %._crit_edge ], [ %indvars.iv.next38, %43 ]
  %44 = add nsw i64 %22, %store_forwarded
  %45 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %indvars.iv37
  %46 = load i64, ptr %45, align 8, !tbaa !9
  %47 = sub i64 %44, %46
  %48 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %indvars.iv37
  store i64 %47, ptr %48, align 8, !tbaa !9
  %indvars.iv.next38 = add nsw i64 %indvars.iv37, -1
  %49 = icmp ugt i64 %indvars.iv37, 1
  br i1 %49, label %43, label %._crit_edge30, !llvm.loop !15

._crit_edge35:                                    ; preds = %.lr.ph34, %._crit_edge.thread, %._crit_edge30
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret void

.lr.ph34:                                         ; preds = %._crit_edge30, %.lr.ph34
  %50 = phi i32 [ %111, %.lr.ph34 ], [ %9, %._crit_edge30 ]
  %storemerge32 = phi i32 [ %110, %.lr.ph34 ], [ 1, %._crit_edge30 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %51 = sub nsw i32 %50, %storemerge32
  store i32 %51, ptr %2, align 4, !tbaa !5
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %53 = load i32, ptr %52, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %54 = load i32, ptr %1, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %55
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = sub nsw i32 %54, %53
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %59
  %61 = load i64, ptr %60, align 8, !tbaa !9
  %62 = add nsw i32 %54, 1
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !9
  %66 = add nsw i32 %62, %53
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !9
  %70 = add i64 %57, %65
  %71 = add i64 %61, %69
  %72 = sub i64 %70, %71
  %73 = shl nsw i64 %72, 1
  %74 = load i64, ptr @L, align 8, !tbaa !9
  %75 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %63
  %76 = load i64, ptr %75, align 8, !tbaa !9
  %.neg = sub i64 %73, %74
  %77 = add i64 %.neg, %76
  store i64 %77, ptr %3, align 8, !tbaa !9
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) @ans)
  %79 = load i64, ptr %78, align 8, !tbaa !9
  store i64 %79, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %80 = load i32, ptr %2, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %4, align 4, !tbaa !5
  %82 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %1, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %83 = load i32, ptr %82, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  %84 = load i32, ptr %1, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %85
  %87 = load i64, ptr %86, align 8, !tbaa !9
  %88 = sub nsw i32 %84, %83
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [200010 x i64], ptr @sum, i64 0, i64 %89
  %91 = load i64, ptr %90, align 8, !tbaa !9
  %92 = add nsw i32 %84, 1
  %93 = sext i32 %92 to i64
  %94 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %93
  %95 = load i64, ptr %94, align 8, !tbaa !9
  %96 = add i32 %84, %83
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [200010 x i64], ptr @sum_rev, i64 0, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !9
  %100 = add i64 %87, %95
  %101 = add i64 %91, %99
  %102 = sub i64 %100, %101
  %103 = shl nsw i64 %102, 1
  %104 = getelementptr inbounds [200010 x i64], ptr @X, i64 0, i64 %85
  %105 = load i64, ptr %104, align 8, !tbaa !9
  %106 = sub nsw i64 %103, %105
  store i64 %106, ptr %3, align 8, !tbaa !9
  %107 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr noundef nonnull align 8 dereferenceable(8) @ans)
  %108 = load i64, ptr %107, align 8, !tbaa !9
  store i64 %108, ptr @ans, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  %109 = load i32, ptr %1, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %1, align 4, !tbaa !5
  %111 = load i32, ptr @N, align 4, !tbaa !5
  %.not16.not = icmp slt i32 %109, %111
  br i1 %.not16.not, label %.lr.ph34, label %._crit_edge35, !llvm.loop !16
}

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_ZSt4sortIPxEvT_S1_(ptr noundef, ptr noundef) 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

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

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

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

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


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