; LLVM IR from kazunetakahashi/atcoder :: 201610_12/1225_AGC008 (B)

; 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
@K = external dso_local global i32, align 4
@a = external dso_local global [100010 x i64], align 16
@memo = external dso_local global [100010 x i64], align 16
@positive = external dso_local global [100010 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 nounwind uwtable
declare dso_local noundef i64 @_Z3sumi(i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z12positive_sumii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %10 = 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)
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %10, ptr noundef nonnull align 4 dereferenceable(4) @K)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  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) #7
  br label %25

17:                                               ; preds = %12
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100010 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
  store i64 0, ptr @memo, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %46, %25
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = load i32, ptr @N, align 4, !tbaa !5
  %29 = icmp sle i32 %27, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %49

31:                                               ; preds = %26
  %32 = load i32, ptr %3, align 4, !tbaa !5
  %33 = sub nsw i32 %32, 1
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [100010 x i64], ptr @memo, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !11
  %37 = load i32, ptr %3, align 4, !tbaa !5
  %38 = sub nsw i32 %37, 1
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %39
  %41 = load i64, ptr %40, align 8, !tbaa !11
  %42 = add nsw i64 %36, %41
  %43 = load i32, ptr %3, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [100010 x i64], ptr @memo, i64 0, i64 %44
  store i64 %42, ptr %45, align 8, !tbaa !11
  br label %46

46:                                               ; preds = %31
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %3, align 4, !tbaa !5
  br label %26, !llvm.loop !13

49:                                               ; preds = %30
  store i64 0, ptr @positive, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %87, %49
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = load i32, ptr @N, align 4, !tbaa !5
  %53 = icmp sle i32 %51, %52
  br i1 %53, label %55, label %54

54:                                               ; preds = %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %90

55:                                               ; preds = %50
  %56 = load i32, ptr %4, align 4, !tbaa !5
  %57 = sub nsw i32 %56, 1
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !11
  %61 = icmp sge i64 %60, 0
  br i1 %61, label %62, label %77

62:                                               ; preds = %55
  %63 = load i32, ptr %4, align 4, !tbaa !5
  %64 = sub nsw i32 %63, 1
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [100010 x i64], ptr @positive, i64 0, i64 %65
  %67 = load i64, ptr %66, align 8, !tbaa !11
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = sub nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !11
  %73 = add nsw i64 %67, %72
  %74 = load i32, ptr %4, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [100010 x i64], ptr @positive, i64 0, i64 %75
  store i64 %73, ptr %76, align 8, !tbaa !11
  br label %86

77:                                               ; preds = %55
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = sub nsw i32 %78, 1
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [100010 x i64], ptr @positive, i64 0, i64 %80
  %82 = load i64, ptr %81, align 8, !tbaa !11
  %83 = load i32, ptr %4, align 4, !tbaa !5
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [100010 x i64], ptr @positive, i64 0, i64 %84
  store i64 %82, ptr %85, align 8, !tbaa !11
  br label %86

86:                                               ; preds = %77, %62
  br label %87

87:                                               ; preds = %86
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %4, align 4, !tbaa !5
  br label %50, !llvm.loop !14

90:                                               ; preds = %54
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  store i64 0, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %115, %90
  %92 = load i32, ptr %6, align 4, !tbaa !5
  %93 = load i32, ptr @N, align 4, !tbaa !5
  %94 = load i32, ptr @K, align 4, !tbaa !5
  %95 = sub nsw i32 %93, %94
  %96 = add nsw i32 %95, 1
  %97 = icmp slt i32 %92, %96
  br i1 %97, label %99, label %98

98:                                               ; preds = %91
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %118

99:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %100 = load i32, ptr %6, align 4, !tbaa !5
  %101 = call noundef i64 @_Z12positive_sumii(i32 noundef 0, i32 noundef %100)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #7
  %102 = load i32, ptr %6, align 4, !tbaa !5
  %103 = call noundef i64 @_Z3sumi(i32 noundef %102)
  store i64 %103, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #7
  store i64 0, ptr %9, align 8, !tbaa !11
  %104 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %8, ptr noundef nonnull align 8 dereferenceable(8) %9)
  %105 = load i64, ptr %104, align 8, !tbaa !11
  %106 = add nsw i64 %101, %105
  %107 = load i32, ptr %6, align 4, !tbaa !5
  %108 = load i32, ptr @K, align 4, !tbaa !5
  %109 = add nsw i32 %107, %108
  %110 = load i32, ptr @N, align 4, !tbaa !5
  %111 = call noundef i64 @_Z12positive_sumii(i32 noundef %109, i32 noundef %110)
  %112 = add nsw i64 %106, %111
  store i64 %112, ptr %7, align 8, !tbaa !11
  %113 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %114 = load i64, ptr %113, align 8, !tbaa !11
  store i64 %114, ptr %5, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %115

115:                                              ; preds = %99
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = add nsw i32 %116, 1
  store i32 %117, ptr %6, align 4, !tbaa !5
  br label %91, !llvm.loop !15

118:                                              ; preds = %98
  %119 = load i64, ptr %5, align 8, !tbaa !11
  %120 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %119)
  %121 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %120, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  %122 = load i32, ptr %1, align 4
  ret i32 %122
}

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #2

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #4 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) #4 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)) #6

attributes #0 = { 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 #1 = { 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 #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #6 = { 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 #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 = 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}


; 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
@K = external dso_local global i32, align 4
@a = external dso_local global [100010 x i64], align 16
@memo = external dso_local local_unnamed_addr global [100010 x i64], align 16
@positive = external dso_local local_unnamed_addr global [100010 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 nounwind uwtable
declare dso_local noundef i64 @_Z3sumi(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_Z12positive_sumii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = 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)
  %6 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef nonnull align 4 dereferenceable(4) @K)
  %7 = load i32, ptr @N, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0
  store i64 0, ptr @memo, align 16, !tbaa !9
  br label %._crit_edge33.thread

._crit_edge:                                      ; preds = %.lr.ph
  store i64 0, ptr @memo, align 16, !tbaa !9
  %.not29 = icmp slt i32 %13, 1
  br i1 %.not29, label %._crit_edge33.thread, label %.lr.ph32.preheader

.lr.ph32.preheader:                               ; preds = %._crit_edge
  %9 = zext nneg i32 %13 to i64
  %xtraiter = and i64 %9, 3
  %10 = icmp ult i32 %13, 4
  br i1 %10, label %._crit_edge33.unr-lcssa, label %.lr.ph32.preheader.new

.lr.ph32.preheader.new:                           ; preds = %.lr.ph32.preheader
  %unroll_iter = and i64 %9, 2147483644
  br label %.lr.ph32

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %11 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %indvars.iv
  %12 = 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) %11)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %13 = load i32, ptr @N, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = icmp slt i64 %indvars.iv.next, %14
  br i1 %15, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge33.thread:                             ; preds = %._crit_edge.thread, %._crit_edge
  %.ph = phi i32 [ %13, %._crit_edge ], [ %7, %._crit_edge.thread ]
  store i64 0, ptr @positive, align 16, !tbaa !9
  br label %._crit_edge38

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

.lr.ph32.epil:                                    ; preds = %._crit_edge33.unr-lcssa, %.lr.ph32.epil
  %16 = phi i64 [ %20, %.lr.ph32.epil ], [ %.unr, %._crit_edge33.unr-lcssa ]
  %indvars.iv46.epil = phi i64 [ %indvars.iv.next47.epil, %.lr.ph32.epil ], [ %indvars.iv46.unr, %._crit_edge33.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph32.epil ], [ 0, %._crit_edge33.unr-lcssa ]
  %17 = add nsw i64 %indvars.iv46.epil, -1
  %18 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %17
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = add nsw i64 %19, %16
  %21 = getelementptr inbounds [100010 x i64], ptr @memo, i64 0, i64 %indvars.iv46.epil
  store i64 %20, ptr %21, align 8, !tbaa !9
  %indvars.iv.next47.epil = add nuw nsw i64 %indvars.iv46.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_edge33, label %.lr.ph32.epil, !llvm.loop !13

._crit_edge33:                                    ; preds = %.lr.ph32.epil, %._crit_edge33.unr-lcssa
  store i64 0, ptr @positive, align 16, !tbaa !9
  br i1 %.not29, label %._crit_edge38, label %.lr.ph37.preheader

.lr.ph37.preheader:                               ; preds = %._crit_edge33
  %xtraiter60 = and i64 %9, 1
  %22 = icmp eq i32 %13, 1
  br i1 %22, label %._crit_edge38.loopexit.unr-lcssa, label %.lr.ph37.preheader.new

.lr.ph37.preheader.new:                           ; preds = %.lr.ph37.preheader
  %unroll_iter64 = and i64 %9, 2147483646
  br label %.lr.ph37

.lr.ph32:                                         ; preds = %.lr.ph32, %.lr.ph32.preheader.new
  %23 = phi i64 [ 0, %.lr.ph32.preheader.new ], [ %41, %.lr.ph32 ]
  %indvars.iv46 = phi i64 [ 1, %.lr.ph32.preheader.new ], [ %indvars.iv.next47.3, %.lr.ph32 ]
  %niter = phi i64 [ 0, %.lr.ph32.preheader.new ], [ %niter.next.3, %.lr.ph32 ]
  %24 = add nsw i64 %indvars.iv46, -1
  %25 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = add nsw i64 %26, %23
  %28 = getelementptr inbounds [100010 x i64], ptr @memo, i64 0, i64 %indvars.iv46
  store i64 %27, ptr %28, align 8, !tbaa !9
  %indvars.iv.next47 = add nuw nsw i64 %indvars.iv46, 1
  %29 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %indvars.iv46
  %30 = load i64, ptr %29, align 8, !tbaa !9
  %31 = add nsw i64 %30, %27
  %32 = getelementptr inbounds [100010 x i64], ptr @memo, i64 0, i64 %indvars.iv.next47
  store i64 %31, ptr %32, align 8, !tbaa !9
  %indvars.iv.next47.1 = add nuw nsw i64 %indvars.iv46, 2
  %33 = add nuw nsw i64 %indvars.iv46, 1
  %34 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %33
  %35 = load i64, ptr %34, align 8, !tbaa !9
  %36 = add nsw i64 %35, %31
  %37 = getelementptr inbounds [100010 x i64], ptr @memo, i64 0, i64 %indvars.iv.next47.1
  store i64 %36, ptr %37, align 8, !tbaa !9
  %indvars.iv.next47.2 = add nuw nsw i64 %indvars.iv46, 3
  %38 = add nuw nsw i64 %indvars.iv46, 2
  %39 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = add nsw i64 %40, %36
  %42 = getelementptr inbounds [100010 x i64], ptr @memo, i64 0, i64 %indvars.iv.next47.2
  store i64 %41, ptr %42, align 8, !tbaa !9
  %indvars.iv.next47.3 = add nuw nsw i64 %indvars.iv46, 4
  %niter.next.3 = add nuw i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge33.unr-lcssa, label %.lr.ph32, !llvm.loop !15

._crit_edge38.loopexit.unr-lcssa:                 ; preds = %.lr.ph37, %.lr.ph37.preheader
  %.unr62 = phi i64 [ 0, %.lr.ph37.preheader ], [ %spec.select.1, %.lr.ph37 ]
  %indvars.iv49.unr = phi i64 [ 1, %.lr.ph37.preheader ], [ %indvars.iv.next50.1, %.lr.ph37 ]
  %lcmp.mod63.not = icmp eq i64 %xtraiter60, 0
  br i1 %lcmp.mod63.not, label %._crit_edge38, label %.lr.ph37.epil

.lr.ph37.epil:                                    ; preds = %._crit_edge38.loopexit.unr-lcssa
  %43 = add nsw i64 %indvars.iv49.unr, -1
  %44 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %43
  %45 = load i64, ptr %44, align 8, !tbaa !9
  %46 = tail call i64 @llvm.smax.i64(i64 %45, i64 0)
  %spec.select.epil = add nuw nsw i64 %.unr62, %46
  %47 = getelementptr inbounds [100010 x i64], ptr @positive, i64 0, i64 %indvars.iv49.unr
  store i64 %spec.select.epil, ptr %47, align 8
  br label %._crit_edge38

._crit_edge38:                                    ; preds = %.lr.ph37.epil, %._crit_edge38.loopexit.unr-lcssa, %._crit_edge33.thread, %._crit_edge33
  %48 = phi i32 [ %.ph, %._crit_edge33.thread ], [ %13, %._crit_edge33 ], [ %13, %._crit_edge38.loopexit.unr-lcssa ], [ %13, %.lr.ph37.epil ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #8
  store i64 0, ptr %1, align 8, !tbaa !9
  %49 = load i32, ptr @K, align 4, !tbaa !5
  %.not2739 = icmp slt i32 %48, %49
  br i1 %.not2739, label %._crit_edge43, label %.lr.ph42

.lr.ph37:                                         ; preds = %.lr.ph37, %.lr.ph37.preheader.new
  %50 = phi i64 [ 0, %.lr.ph37.preheader.new ], [ %spec.select.1, %.lr.ph37 ]
  %indvars.iv49 = phi i64 [ 1, %.lr.ph37.preheader.new ], [ %indvars.iv.next50.1, %.lr.ph37 ]
  %niter65 = phi i64 [ 0, %.lr.ph37.preheader.new ], [ %niter65.next.1, %.lr.ph37 ]
  %51 = add nsw i64 %indvars.iv49, -1
  %52 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %51
  %53 = load i64, ptr %52, align 8, !tbaa !9
  %54 = tail call i64 @llvm.smax.i64(i64 %53, i64 0)
  %spec.select = add nuw nsw i64 %50, %54
  %55 = getelementptr inbounds [100010 x i64], ptr @positive, i64 0, i64 %indvars.iv49
  store i64 %spec.select, ptr %55, align 8
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %56 = getelementptr inbounds [100010 x i64], ptr @a, i64 0, i64 %indvars.iv49
  %57 = load i64, ptr %56, align 8, !tbaa !9
  %58 = tail call i64 @llvm.smax.i64(i64 %57, i64 0)
  %spec.select.1 = add nuw nsw i64 %spec.select, %58
  %59 = getelementptr inbounds [100010 x i64], ptr @positive, i64 0, i64 %indvars.iv.next50
  store i64 %spec.select.1, ptr %59, align 8
  %indvars.iv.next50.1 = add nuw nsw i64 %indvars.iv49, 2
  %niter65.next.1 = add i64 %niter65, 2
  %niter65.ncmp.1 = icmp eq i64 %niter65.next.1, %unroll_iter64
  br i1 %niter65.ncmp.1, label %._crit_edge38.loopexit.unr-lcssa, label %.lr.ph37, !llvm.loop !16

._crit_edge43:                                    ; preds = %.lr.ph42, %._crit_edge38
  %60 = phi i64 [ 0, %._crit_edge38 ], [ %74, %.lr.ph42 ]
  %61 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %60)
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %61, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #8
  ret i32 0

.lr.ph42:                                         ; preds = %._crit_edge38, %.lr.ph42
  %.040 = phi i32 [ %75, %.lr.ph42 ], [ 0, %._crit_edge38 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #8
  %63 = call noundef i64 @_Z12positive_sumii(i32 noundef 0, i32 noundef %.040)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #8
  %64 = call noundef i64 @_Z3sumi(i32 noundef %.040)
  store i64 %64, ptr %3, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #8
  store i64 0, ptr %4, align 8, !tbaa !9
  %65 = 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) %4)
  %66 = load i64, ptr %65, align 8, !tbaa !9
  %67 = add nsw i64 %66, %63
  %68 = load i32, ptr @K, align 4, !tbaa !5
  %69 = add nsw i32 %68, %.040
  %70 = load i32, ptr @N, align 4, !tbaa !5
  %71 = call noundef i64 @_Z12positive_sumii(i32 noundef %69, i32 noundef %70)
  %72 = add nsw i64 %67, %71
  store i64 %72, ptr %2, align 8, !tbaa !9
  %73 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %74 = load i64, ptr %73, align 8, !tbaa !9
  store i64 %74, ptr %1, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #8
  %75 = add nuw nsw i32 %.040, 1
  %76 = load i32, ptr @N, align 4, !tbaa !5
  %77 = load i32, ptr @K, align 4, !tbaa !5
  %78 = sub nsw i32 %76, %77
  %.not27.not = icmp slt i32 %.040, %78
  br i1 %.not27.not, label %.lr.ph42, label %._crit_edge43, !llvm.loop !17
}

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 #2

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.smax.i64(i64, i64) #7

attributes #0 = { 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 #1 = { 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 #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #6 = { 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 #7 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #8 = { 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, !14}
!14 = !{!"llvm.loop.unroll.disable"}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}


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