; LLVM IR from VastoLorde95/Competitive-Programming :: Hackerrank/Company Contests/Epic Code/Problem D (D)

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

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@a = external dso_local global [3001 x i64], align 16
@cur = external dso_local global i64, align 8
@mx = external dso_local global i64, align 8
@inf = external dso_local global i64, align 8
@v = external dso_local global [3001 x i64], align 16
@v2 = external dso_local global [3000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; 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 i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %22, %0
  %13 = load i32, ptr %2, align 4, !tbaa !5
  %14 = load i32, ptr @n, align 4, !tbaa !5
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [3001 x i64], ptr @a, i64 0, i64 %19
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %20)
  br label %22

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

25:                                               ; preds = %16
  %26 = load i64, ptr @inf, align 8, !tbaa !11
  %27 = sub nsw i64 0, %26
  store i64 %27, ptr @mx, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %42, %25
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %45

33:                                               ; preds = %28
  %34 = load i64, ptr @inf, align 8, !tbaa !11
  %35 = sub nsw i64 0, %34
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [3001 x i64], ptr @v, i64 0, i64 %37
  store i64 %35, ptr %38, align 8, !tbaa !11
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [3000 x i64], ptr @v2, i64 0, i64 %40
  store i64 %35, ptr %41, align 8, !tbaa !11
  br label %42

42:                                               ; preds = %33
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = add nsw i32 %43, 1
  store i32 %44, ptr %3, align 4, !tbaa !5
  br label %28, !llvm.loop !13

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

46:                                               ; preds = %112, %45
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = load i32, ptr @n, align 4, !tbaa !5
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %51, label %50

50:                                               ; preds = %46
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %115

51:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %53 = sub nsw i32 %52, 1
  store i32 %53, ptr %6, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %91, %51
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = icmp sgt i32 %55, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %54
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %94

59:                                               ; preds = %54
  %60 = load i32, ptr %4, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [3001 x i64], ptr @a, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !11
  %64 = load i32, ptr %6, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [3001 x i64], ptr @a, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !11
  %68 = mul nsw i64 %63, %67
  store i64 %68, ptr @cur, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [3001 x i64], ptr @v, i64 0, i64 %71
  %73 = load i64, ptr %72, align 8, !tbaa !11
  %74 = load i64, ptr @cur, align 8, !tbaa !11
  %75 = add nsw i64 %73, %74
  store i64 %75, ptr %7, align 8, !tbaa !11
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @cur, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %77 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @mx, ptr noundef nonnull align 8 dereferenceable(8) %76)
  %78 = load i64, ptr %77, align 8, !tbaa !11
  store i64 %78, ptr @mx, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [3001 x i64], ptr @v, i64 0, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !11
  %84 = load i64, ptr @cur, align 8, !tbaa !11
  %85 = add nsw i64 %83, %84
  store i64 %85, ptr %8, align 8, !tbaa !11
  %86 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @cur, ptr noundef nonnull align 8 dereferenceable(8) %8)
  %87 = load i64, ptr %86, align 8, !tbaa !11
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [3000 x i64], ptr @v2, i64 0, i64 %89
  store i64 %87, ptr %90, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %91

91:                                               ; preds = %59
  %92 = load i32, ptr %6, align 4, !tbaa !5
  %93 = add nsw i32 %92, -1
  store i32 %93, ptr %6, align 4, !tbaa !5
  br label %54, !llvm.loop !14

94:                                               ; preds = %58
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %108, %94
  %96 = load i32, ptr %9, align 4, !tbaa !5
  %97 = load i32, ptr @n, align 4, !tbaa !5
  %98 = icmp slt i32 %96, %97
  br i1 %98, label %100, label %99

99:                                               ; preds = %95
  store i32 14, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %111

100:                                              ; preds = %95
  %101 = load i32, ptr %9, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [3000 x i64], ptr @v2, i64 0, i64 %102
  %104 = load i64, ptr %103, align 8, !tbaa !11
  %105 = load i32, ptr %9, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [3001 x i64], ptr @v, i64 0, i64 %106
  store i64 %104, ptr %107, align 8, !tbaa !11
  br label %108

108:                                              ; preds = %100
  %109 = load i32, ptr %9, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr %9, align 4, !tbaa !5
  br label %95, !llvm.loop !15

111:                                              ; preds = %99
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %4, align 4, !tbaa !5
  br label %46, !llvm.loop !16

115:                                              ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %116

116:                                              ; preds = %127, %115
  %117 = load i32, ptr %10, align 4, !tbaa !5
  %118 = load i32, ptr @n, align 4, !tbaa !5
  %119 = icmp slt i32 %117, %118
  br i1 %119, label %121, label %120

120:                                              ; preds = %116
  store i32 17, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %130

121:                                              ; preds = %116
  %122 = load i32, ptr %10, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [3001 x i64], ptr @v, i64 0, i64 %123
  %125 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @mx, ptr noundef nonnull align 8 dereferenceable(8) %124)
  %126 = load i64, ptr %125, align 8, !tbaa !11
  store i64 %126, ptr @mx, align 8, !tbaa !11
  br label %127

127:                                              ; preds = %121
  %128 = load i32, ptr %10, align 4, !tbaa !5
  %129 = add nsw i32 %128, 1
  store i32 %129, ptr %10, align 4, !tbaa !5
  br label %116, !llvm.loop !17

130:                                              ; preds = %120
  %131 = load i64, ptr @mx, align 8, !tbaa !11
  %132 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %131)
  %133 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %132, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #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 uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 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 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #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 = { "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 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 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !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"

%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@a = external dso_local global [3001 x i64], align 16
@cur = external dso_local global i64, align 8
@mx = external dso_local global i64, align 8
@inf = external dso_local local_unnamed_addr global i64, align 8
@v = external dso_local global [3001 x i64], align 16
@v2 = external dso_local local_unnamed_addr global [3000 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0
  %6 = load i64, ptr @inf, align 8, !tbaa !9
  %7 = sub nsw i64 0, %6
  store i64 %7, ptr @mx, align 8, !tbaa !9
  br label %.preheader.._crit_edge47_crit_edge

._crit_edge:                                      ; preds = %.lr.ph
  %8 = load i64, ptr @inf, align 8, !tbaa !9
  %9 = sub nsw i64 0, %8
  store i64 %9, ptr @mx, align 8, !tbaa !9
  %10 = icmp sgt i32 %18, 0
  br i1 %10, label %.lr.ph36.preheader, label %.preheader.._crit_edge47_crit_edge

.lr.ph36.preheader:                               ; preds = %._crit_edge
  %wide.trip.count = zext nneg i32 %18 to i64
  %min.iters.check = icmp ult i32 %18, 4
  br i1 %min.iters.check, label %.lr.ph36.preheader76, label %vector.ph

.lr.ph36.preheader76:                             ; preds = %middle.block, %.lr.ph36.preheader
  %indvars.iv50.ph = phi i64 [ 0, %.lr.ph36.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph36

vector.ph:                                        ; preds = %.lr.ph36.preheader
  %n.vec = and i64 %wide.trip.count, 2147483644
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %9, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %11 = getelementptr inbounds [3001 x i64], ptr @v, i64 0, i64 %index
  %12 = getelementptr inbounds i8, ptr %11, i64 16
  store <2 x i64> %broadcast.splat, ptr %11, align 16, !tbaa !9
  store <2 x i64> %broadcast.splat, ptr %12, align 16, !tbaa !9
  %13 = getelementptr inbounds [3000 x i64], ptr @v2, i64 0, i64 %index
  %14 = getelementptr inbounds i8, ptr %13, i64 16
  store <2 x i64> %broadcast.splat, ptr %13, align 16, !tbaa !9
  store <2 x i64> %broadcast.splat, ptr %14, align 16, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %15 = icmp eq i64 %index.next, %n.vec
  br i1 %15, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %.preheader32, label %.lr.ph36.preheader76

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %16 = getelementptr inbounds [3001 x i64], ptr @a, i64 0, i64 %indvars.iv
  %17 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %16)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !15

.preheader32:                                     ; preds = %.lr.ph36, %middle.block
  br i1 %10, label %.preheader31, label %.preheader.._crit_edge47_crit_edge

.lr.ph36:                                         ; preds = %.lr.ph36.preheader76, %.lr.ph36
  %indvars.iv50 = phi i64 [ %indvars.iv.next51, %.lr.ph36 ], [ %indvars.iv50.ph, %.lr.ph36.preheader76 ]
  %21 = getelementptr inbounds [3001 x i64], ptr @v, i64 0, i64 %indvars.iv50
  store i64 %9, ptr %21, align 8, !tbaa !9
  %22 = getelementptr inbounds [3000 x i64], ptr @v2, i64 0, i64 %indvars.iv50
  store i64 %9, ptr %22, align 8, !tbaa !9
  %indvars.iv.next51 = add nuw nsw i64 %indvars.iv50, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next51, %wide.trip.count
  br i1 %exitcond.not, label %.preheader32, label %.lr.ph36, !llvm.loop !16

.preheader31:                                     ; preds = %.preheader32, %._crit_edge43
  %23 = phi i32 [ %30, %._crit_edge43 ], [ %18, %.preheader32 ]
  %indvars.iv63 = phi i64 [ %indvars.iv.next64, %._crit_edge43 ], [ 0, %.preheader32 ]
  %.02537 = add nsw i32 %23, -1
  %24 = sext i32 %.02537 to i64
  %25 = icmp slt i64 %indvars.iv63, %24
  br i1 %25, label %.lr.ph40, label %.preheader30

.lr.ph40:                                         ; preds = %.preheader31
  %26 = getelementptr inbounds [3001 x i64], ptr @a, i64 0, i64 %indvars.iv63
  %27 = sext i32 %23 to i64
  %28 = add nsw i64 %27, -1
  br label %34

.preheader:                                       ; preds = %._crit_edge43
  %29 = icmp sgt i32 %30, 0
  br i1 %29, label %.lr.ph46, label %.preheader.._crit_edge47_crit_edge

.preheader.._crit_edge47_crit_edge:               ; preds = %._crit_edge, %._crit_edge.thread, %.preheader32, %.preheader
  %.pre69 = load i64, ptr @mx, align 8, !tbaa !9
  br label %._crit_edge47

.preheader30.loopexit:                            ; preds = %34
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %.preheader30

.preheader30:                                     ; preds = %.preheader30.loopexit, %.preheader31
  %30 = phi i32 [ %.pre, %.preheader30.loopexit ], [ %23, %.preheader31 ]
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph42.preheader, label %._crit_edge43

.lr.ph42.preheader:                               ; preds = %.preheader30
  %32 = zext nneg i32 %30 to i64
  %33 = shl nuw nsw i64 %32, 3
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 16 @v, ptr nonnull align 16 @v2, i64 %33, i1 false), !tbaa !9
  br label %._crit_edge43

34:                                               ; preds = %.lr.ph40, %34
  %indvars.iv55 = phi i64 [ %27, %.lr.ph40 ], [ %indvars.iv.next56, %34 ]
  %indvars.iv53 = phi i64 [ %28, %.lr.ph40 ], [ %indvars.iv.next54, %34 ]
  %35 = load i64, ptr %26, align 8, !tbaa !9
  %36 = getelementptr inbounds [3001 x i64], ptr @a, i64 0, i64 %indvars.iv53
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = mul nsw i64 %37, %35
  store i64 %38, ptr @cur, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #7
  %39 = getelementptr inbounds [3001 x i64], ptr @v, i64 0, i64 %indvars.iv55
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = add nsw i64 %40, %38
  store i64 %41, ptr %1, align 8, !tbaa !9
  %42 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @cur, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @mx, ptr noundef nonnull align 8 dereferenceable(8) %42)
  %44 = load i64, ptr %43, align 8, !tbaa !9
  store i64 %44, ptr @mx, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #7
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  %45 = load i64, ptr %39, align 8, !tbaa !9
  %46 = load i64, ptr @cur, align 8, !tbaa !9
  %47 = add nsw i64 %46, %45
  store i64 %47, ptr %2, align 8, !tbaa !9
  %48 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @cur, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = getelementptr inbounds [3000 x i64], ptr @v2, i64 0, i64 %indvars.iv53
  store i64 %49, ptr %50, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  %indvars.iv.next54 = add nsw i64 %indvars.iv53, -1
  %51 = icmp sgt i64 %indvars.iv.next54, %indvars.iv63
  %indvars.iv.next56 = add nsw i64 %indvars.iv55, -1
  br i1 %51, label %34, label %.preheader30.loopexit, !llvm.loop !17

._crit_edge43:                                    ; preds = %.lr.ph42.preheader, %.preheader30
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %52 = sext i32 %30 to i64
  %53 = icmp slt i64 %indvars.iv.next64, %52
  br i1 %53, label %.preheader31, label %.preheader, !llvm.loop !18

._crit_edge47:                                    ; preds = %.lr.ph46, %.preheader.._crit_edge47_crit_edge
  %54 = phi i64 [ %.pre69, %.preheader.._crit_edge47_crit_edge ], [ %59, %.lr.ph46 ]
  %55 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %54)
  %56 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %55, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.lr.ph46:                                         ; preds = %.preheader, %.lr.ph46
  %indvars.iv66 = phi i64 [ %indvars.iv.next67, %.lr.ph46 ], [ 0, %.preheader ]
  %57 = getelementptr inbounds [3001 x i64], ptr @v, i64 0, i64 %indvars.iv66
  %58 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @mx, ptr noundef nonnull align 8 dereferenceable(8) %57)
  %59 = load i64, ptr %58, align 8, !tbaa !9
  store i64 %59, ptr @mx, align 8, !tbaa !9
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %60 = load i32, ptr @n, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = icmp slt i64 %indvars.iv.next67, %61
  br i1 %62, label %.lr.ph46, label %._crit_edge47, !llvm.loop !19
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) 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 uwtable
declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(8)) local_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: 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 #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #3 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #5

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

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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 #6 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #7 = { 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, !13, !14}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!"llvm.loop.isvectorized", i32 1}
!14 = !{!"llvm.loop.unroll.runtime.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12, !14, !13}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12}


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