; LLVM IR from kazunetakahashi/atcoder :: 2018/0526_ARC098 (C)

; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"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
@_Z1SB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@sum = external dso_local global [2 x [300010 x i32]], align 16
@cost = external dso_local global [300010 x i32], 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 i32, align 4
  %8 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %9 = 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)
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %11

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

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

16:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #7
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11, i64 noundef %18)
  %20 = load i8, ptr %19, align 1, !tbaa !9
  %21 = sext i8 %20 to i32
  %22 = icmp eq i32 %21, 69
  %23 = zext i1 %22 to i32
  store i32 %23, ptr %3, align 4, !tbaa !5
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [2 x [300010 x i32]], ptr @sum, i64 0, i64 %25
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [300010 x i32], ptr %26, i64 0, i64 %28
  store i32 1, ptr %29, align 4, !tbaa !5
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = sub nsw i32 1, %30
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [2 x [300010 x i32]], ptr @sum, i64 0, i64 %32
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [300010 x i32], ptr %33, i64 0, i64 %35
  store i32 0, ptr %36, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #7
  br label %37

37:                                               ; preds = %16
  %38 = load i32, ptr %2, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !10

40:                                               ; preds = %15
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %57, %40
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = load i32, ptr @N, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %60

46:                                               ; preds = %41
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = sub nsw i32 %47, 1
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !5
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !5
  %56 = add nsw i32 %55, %51
  store i32 %56, ptr %54, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %46
  %58 = load i32, ptr %4, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %4, align 4, !tbaa !5
  br label %41, !llvm.loop !12

60:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #7
  %61 = load i32, ptr @N, align 4, !tbaa !5
  %62 = sub nsw i32 %61, 2
  store i32 %62, ptr %5, align 4, !tbaa !5
  br label %63

63:                                               ; preds = %78, %60
  %64 = load i32, ptr %5, align 4, !tbaa !5
  %65 = icmp sge i32 %64, 0
  br i1 %65, label %67, label %66

66:                                               ; preds = %63
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %81

67:                                               ; preds = %63
  %68 = load i32, ptr %5, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds ([2 x [300010 x i32]], ptr @sum, i64 0, i64 1), i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = load i32, ptr %5, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds ([2 x [300010 x i32]], ptr @sum, i64 0, i64 1), i64 0, i64 %74
  %76 = load i32, ptr %75, align 4, !tbaa !5
  %77 = add nsw i32 %76, %72
  store i32 %77, ptr %75, align 4, !tbaa !5
  br label %78

78:                                               ; preds = %67
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = add nsw i32 %79, -1
  store i32 %80, ptr %5, align 4, !tbaa !5
  br label %63, !llvm.loop !13

81:                                               ; preds = %66
  %82 = load i32, ptr getelementptr inbounds ([300010 x i32], ptr getelementptr inbounds ([2 x [300010 x i32]], ptr @sum, i64 0, i64 1), i64 0, i64 1), align 4, !tbaa !5
  store i32 %82, ptr @cost, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %83

83:                                               ; preds = %104, %81
  %84 = load i32, ptr %6, align 4, !tbaa !5
  %85 = load i32, ptr @N, align 4, !tbaa !5
  %86 = sub nsw i32 %85, 1
  %87 = icmp slt i32 %84, %86
  br i1 %87, label %89, label %88

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

89:                                               ; preds = %83
  %90 = load i32, ptr %6, align 4, !tbaa !5
  %91 = sub nsw i32 %90, 1
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = load i32, ptr %6, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds ([2 x [300010 x i32]], ptr @sum, i64 0, i64 1), i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = add nsw i32 %94, %99
  %101 = load i32, ptr %6, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [300010 x i32], ptr @cost, i64 0, i64 %102
  store i32 %100, ptr %103, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %89
  %105 = load i32, ptr %6, align 4, !tbaa !5
  %106 = add nsw i32 %105, 1
  store i32 %106, ptr %6, align 4, !tbaa !5
  br label %83, !llvm.loop !14

107:                                              ; preds = %88
  %108 = load i32, ptr @N, align 4, !tbaa !5
  %109 = sub nsw i32 %108, 2
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %110
  %112 = load i32, ptr %111, align 4, !tbaa !5
  %113 = load i32, ptr @N, align 4, !tbaa !5
  %114 = sub nsw i32 %113, 1
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [300010 x i32], ptr @cost, i64 0, i64 %115
  store i32 %112, ptr %116, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #7
  %117 = load i32, ptr @N, align 4, !tbaa !5
  store i32 %117, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %118

118:                                              ; preds = %129, %107
  %119 = load i32, ptr %8, align 4, !tbaa !5
  %120 = load i32, ptr @N, align 4, !tbaa !5
  %121 = icmp slt i32 %119, %120
  br i1 %121, label %123, label %122

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

123:                                              ; preds = %118
  %124 = load i32, ptr %8, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [300010 x i32], ptr @cost, i64 0, i64 %125
  %127 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %126)
  %128 = load i32, ptr %127, align 4, !tbaa !5
  store i32 %128, ptr %7, align 4, !tbaa !5
  br label %129

129:                                              ; preds = %123
  %130 = load i32, ptr %8, align 4, !tbaa !5
  %131 = add nsw i32 %130, 1
  store i32 %131, ptr %8, align 4, !tbaa !5
  br label %118, !llvm.loop !15

132:                                              ; preds = %122
  %133 = load i32, ptr %7, align 4, !tbaa !5
  %134 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %133)
  %135 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %134, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  %136 = load i32, ptr %1, align 4
  ret i32 %136
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) #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 noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #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 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #1

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


; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"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
@_Z1SB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@sum = external dso_local local_unnamed_addr global [2 x [300010 x i32]], align 16
@cost = external dso_local global [300010 x i32], 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 i32, align 4
  %2 = 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)
  %3 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11)
  %4 = load i32, ptr @N, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph, label %._crit_edge37.thread

.preheader:                                       ; preds = %.lr.ph
  %6 = icmp sgt i32 %17, 1
  br i1 %6, label %.lr.ph33.preheader, label %._crit_edge37.thread

.lr.ph33.preheader:                               ; preds = %.preheader
  %wide.trip.count = zext nneg i32 %17 to i64
  %.pre = load i32, ptr @sum, align 16, !tbaa !5
  %7 = add nsw i64 %wide.trip.count, -1
  %8 = add nsw i64 %wide.trip.count, -2
  %xtraiter = and i64 %7, 3
  %9 = icmp ult i64 %8, 3
  br i1 %9, label %._crit_edge.unr-lcssa, label %.lr.ph33.preheader.new

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

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %10 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1SB5cxx11, i64 noundef %indvars.iv)
  %11 = load i8, ptr %10, align 1, !tbaa !9
  %12 = icmp eq i8 %11, 69
  %13 = zext i1 %12 to i64
  %14 = getelementptr inbounds [2 x [300010 x i32]], ptr @sum, i64 0, i64 %13, i64 %indvars.iv
  store i32 1, ptr %14, align 4, !tbaa !5
  %not. = xor i1 %12, true
  %15 = zext i1 %not. to i64
  %16 = getelementptr inbounds [2 x [300010 x i32]], ptr @sum, i64 0, i64 %15, i64 %indvars.iv
  store i32 0, ptr %16, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %17 = load i32, ptr @N, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = icmp slt i64 %indvars.iv.next, %18
  br i1 %19, label %.lr.ph, label %.preheader, !llvm.loop !10

._crit_edge37.thread:                             ; preds = %0, %.preheader
  %.ph62 = phi i32 [ %17, %.preheader ], [ %4, %0 ]
  %20 = add i32 %.ph62, -2
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @sum, i64 1200044), align 4, !tbaa !5
  store i32 %21, ptr @cost, align 16, !tbaa !5
  %22 = add i32 %.ph62, -1
  br label %._crit_edge41

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph33, %.lr.ph33.preheader
  %.unr = phi i32 [ %.pre, %.lr.ph33.preheader ], [ %47, %.lr.ph33 ]
  %indvars.iv48.unr = phi i64 [ 1, %.lr.ph33.preheader ], [ %indvars.iv.next49.3, %.lr.ph33 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph33.epil

.lr.ph33.epil:                                    ; preds = %._crit_edge.unr-lcssa, %.lr.ph33.epil
  %23 = phi i32 [ %26, %.lr.ph33.epil ], [ %.unr, %._crit_edge.unr-lcssa ]
  %indvars.iv48.epil = phi i64 [ %indvars.iv.next49.epil, %.lr.ph33.epil ], [ %indvars.iv48.unr, %._crit_edge.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph33.epil ], [ 0, %._crit_edge.unr-lcssa ]
  %24 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %indvars.iv48.epil
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = add nsw i32 %25, %23
  store i32 %26, ptr %24, align 4, !tbaa !5
  %indvars.iv.next49.epil = add nuw nsw i64 %indvars.iv48.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.ph33.epil, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph33.epil, %._crit_edge.unr-lcssa
  %27 = add nsw i32 %17, -2
  br i1 %6, label %.lr.ph36.preheader, label %._crit_edge37

.lr.ph36.preheader:                               ; preds = %._crit_edge
  %28 = zext i32 %27 to i64
  %29 = shl nuw nsw i64 %28, 2
  %scevgep = getelementptr i8, ptr getelementptr inbounds (i8, ptr @sum, i64 1200044), i64 %29
  %load_initial = load i32, ptr %scevgep, align 4
  %30 = add nuw nsw i64 %28, 1
  %xtraiter71 = and i64 %30, 3
  %lcmp.mod72.not = icmp eq i64 %xtraiter71, 0
  br i1 %lcmp.mod72.not, label %.lr.ph36.prol.loopexit, label %.lr.ph36.prol

.lr.ph36.prol:                                    ; preds = %.lr.ph36.preheader, %.lr.ph36.prol
  %store_forwarded.prol = phi i32 [ %33, %.lr.ph36.prol ], [ %load_initial, %.lr.ph36.preheader ]
  %indvars.iv51.prol = phi i64 [ %indvars.iv.next52.prol, %.lr.ph36.prol ], [ %28, %.lr.ph36.preheader ]
  %prol.iter = phi i64 [ %prol.iter.next, %.lr.ph36.prol ], [ 0, %.lr.ph36.preheader ]
  %31 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds (i8, ptr @sum, i64 1200040), i64 0, i64 %indvars.iv51.prol
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = add nsw i32 %32, %store_forwarded.prol
  store i32 %33, ptr %31, align 4, !tbaa !5
  %indvars.iv.next52.prol = add nsw i64 %indvars.iv51.prol, -1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter71
  br i1 %prol.iter.cmp.not, label %.lr.ph36.prol.loopexit, label %.lr.ph36.prol, !llvm.loop !14

.lr.ph36.prol.loopexit:                           ; preds = %.lr.ph36.prol, %.lr.ph36.preheader
  %store_forwarded.unr = phi i32 [ %load_initial, %.lr.ph36.preheader ], [ %33, %.lr.ph36.prol ]
  %indvars.iv51.unr = phi i64 [ %28, %.lr.ph36.preheader ], [ %indvars.iv.next52.prol, %.lr.ph36.prol ]
  %34 = icmp ult i32 %27, 3
  br i1 %34, label %._crit_edge37, label %.lr.ph36

.lr.ph33:                                         ; preds = %.lr.ph33, %.lr.ph33.preheader.new
  %35 = phi i32 [ %.pre, %.lr.ph33.preheader.new ], [ %47, %.lr.ph33 ]
  %indvars.iv48 = phi i64 [ 1, %.lr.ph33.preheader.new ], [ %indvars.iv.next49.3, %.lr.ph33 ]
  %niter = phi i64 [ 0, %.lr.ph33.preheader.new ], [ %niter.next.3, %.lr.ph33 ]
  %36 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %indvars.iv48
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = add nsw i32 %37, %35
  store i32 %38, ptr %36, align 4, !tbaa !5
  %indvars.iv.next49 = add nuw nsw i64 %indvars.iv48, 1
  %39 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %indvars.iv.next49
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = add nsw i32 %40, %38
  store i32 %41, ptr %39, align 4, !tbaa !5
  %indvars.iv.next49.1 = add nuw nsw i64 %indvars.iv48, 2
  %42 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %indvars.iv.next49.1
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = add nsw i32 %43, %41
  store i32 %44, ptr %42, align 4, !tbaa !5
  %indvars.iv.next49.2 = add nuw nsw i64 %indvars.iv48, 3
  %45 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %indvars.iv.next49.2
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = add nsw i32 %46, %44
  store i32 %47, ptr %45, align 4, !tbaa !5
  %indvars.iv.next49.3 = add nuw nsw i64 %indvars.iv48, 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.ph33, !llvm.loop !15

._crit_edge37:                                    ; preds = %.lr.ph36.prol.loopexit, %.lr.ph36, %._crit_edge
  %48 = load i32, ptr getelementptr inbounds (i8, ptr @sum, i64 1200044), align 4, !tbaa !5
  store i32 %48, ptr @cost, align 16, !tbaa !5
  %49 = add nsw i32 %17, -1
  %.not64 = icmp eq i32 %17, 2
  br i1 %.not64, label %._crit_edge41, label %.lr.ph40.preheader

.lr.ph40.preheader:                               ; preds = %._crit_edge37
  %wide.trip.count57 = zext nneg i32 %49 to i64
  %50 = add nsw i64 %wide.trip.count57, -1
  %min.iters.check = icmp ult i64 %50, 8
  br i1 %min.iters.check, label %.lr.ph40.preheader69, label %vector.ph

.lr.ph40.preheader69:                             ; preds = %middle.block, %.lr.ph40.preheader
  %indvars.iv54.ph = phi i64 [ 1, %.lr.ph40.preheader ], [ %ind.end, %middle.block ]
  br label %.lr.ph40

vector.ph:                                        ; preds = %.lr.ph40.preheader
  %n.vec = and i64 %50, -8
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %51 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %index
  %52 = getelementptr inbounds i8, ptr %51, i64 16
  %wide.load = load <4 x i32>, ptr %51, align 16, !tbaa !5
  %wide.load66 = load <4 x i32>, ptr %52, align 16, !tbaa !5
  %53 = or disjoint i64 %index, 2
  %54 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds (i8, ptr @sum, i64 1200040), i64 0, i64 %53
  %55 = getelementptr inbounds i8, ptr %54, i64 16
  %wide.load67 = load <4 x i32>, ptr %54, align 16, !tbaa !5
  %wide.load68 = load <4 x i32>, ptr %55, align 16, !tbaa !5
  %56 = add nsw <4 x i32> %wide.load67, %wide.load
  %57 = add nsw <4 x i32> %wide.load68, %wide.load66
  %58 = getelementptr inbounds [300010 x i32], ptr @cost, i64 0, i64 %offset.idx
  %59 = getelementptr inbounds i8, ptr %58, i64 16
  store <4 x i32> %56, ptr %58, align 4, !tbaa !5
  store <4 x i32> %57, ptr %59, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %60 = icmp eq i64 %index.next, %n.vec
  br i1 %60, label %middle.block, label %vector.body, !llvm.loop !16

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %50, %n.vec
  br i1 %cmp.n, label %._crit_edge41, label %.lr.ph40.preheader69

.lr.ph36:                                         ; preds = %.lr.ph36.prol.loopexit, %.lr.ph36
  %store_forwarded = phi i32 [ %72, %.lr.ph36 ], [ %store_forwarded.unr, %.lr.ph36.prol.loopexit ]
  %indvars.iv51 = phi i64 [ %indvars.iv.next52.3, %.lr.ph36 ], [ %indvars.iv51.unr, %.lr.ph36.prol.loopexit ]
  %61 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds (i8, ptr @sum, i64 1200040), i64 0, i64 %indvars.iv51
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = add nsw i32 %62, %store_forwarded
  store i32 %63, ptr %61, align 4, !tbaa !5
  %indvars.iv.next52 = add nsw i64 %indvars.iv51, -1
  %64 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds (i8, ptr @sum, i64 1200040), i64 0, i64 %indvars.iv.next52
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = add nsw i32 %65, %63
  store i32 %66, ptr %64, align 4, !tbaa !5
  %indvars.iv.next52.1 = add nsw i64 %indvars.iv51, -2
  %67 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds (i8, ptr @sum, i64 1200040), i64 0, i64 %indvars.iv.next52.1
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = add nsw i32 %68, %66
  store i32 %69, ptr %67, align 4, !tbaa !5
  %indvars.iv.next52.2 = add nsw i64 %indvars.iv51, -3
  %70 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds (i8, ptr @sum, i64 1200040), i64 0, i64 %indvars.iv.next52.2
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = add nsw i32 %71, %69
  store i32 %72, ptr %70, align 4, !tbaa !5
  %indvars.iv.next52.3 = add nsw i64 %indvars.iv51, -4
  %.not.3 = icmp eq i64 %indvars.iv.next52.2, 0
  br i1 %.not.3, label %._crit_edge37, label %.lr.ph36, !llvm.loop !19

._crit_edge41:                                    ; preds = %.lr.ph40, %middle.block, %._crit_edge37.thread, %._crit_edge37
  %73 = phi i32 [ %22, %._crit_edge37.thread ], [ %49, %._crit_edge37 ], [ %49, %middle.block ], [ %49, %.lr.ph40 ]
  %74 = phi i32 [ %.ph62, %._crit_edge37.thread ], [ %17, %._crit_edge37 ], [ %17, %middle.block ], [ %17, %.lr.ph40 ]
  %75 = phi i32 [ %20, %._crit_edge37.thread ], [ %27, %._crit_edge37 ], [ %27, %middle.block ], [ %27, %.lr.ph40 ]
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = sext i32 %73 to i64
  %80 = getelementptr inbounds [300010 x i32], ptr @cost, i64 0, i64 %79
  store i32 %78, ptr %80, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 %74, ptr %1, align 4, !tbaa !5
  %81 = icmp sgt i32 %74, 0
  br i1 %81, label %.lr.ph45, label %._crit_edge46

.lr.ph40:                                         ; preds = %.lr.ph40.preheader69, %.lr.ph40
  %indvars.iv54 = phi i64 [ %indvars.iv.next55, %.lr.ph40 ], [ %indvars.iv54.ph, %.lr.ph40.preheader69 ]
  %82 = add nsw i64 %indvars.iv54, -1
  %83 = getelementptr inbounds [300010 x i32], ptr @sum, i64 0, i64 %82
  %84 = load i32, ptr %83, align 4, !tbaa !5
  %indvars.iv.next55 = add nuw nsw i64 %indvars.iv54, 1
  %85 = getelementptr inbounds [300010 x i32], ptr getelementptr inbounds (i8, ptr @sum, i64 1200040), i64 0, i64 %indvars.iv.next55
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = add nsw i32 %86, %84
  %88 = getelementptr inbounds [300010 x i32], ptr @cost, i64 0, i64 %indvars.iv54
  store i32 %87, ptr %88, align 4, !tbaa !5
  %exitcond58.not = icmp eq i64 %indvars.iv.next55, %wide.trip.count57
  br i1 %exitcond58.not, label %._crit_edge41, label %.lr.ph40, !llvm.loop !20

._crit_edge46:                                    ; preds = %.lr.ph45, %._crit_edge41
  %89 = phi i32 [ %74, %._crit_edge41 ], [ %94, %.lr.ph45 ]
  %90 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %89)
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %90, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  ret i32 0

.lr.ph45:                                         ; preds = %._crit_edge41, %.lr.ph45
  %indvars.iv59 = phi i64 [ %indvars.iv.next60, %.lr.ph45 ], [ 0, %._crit_edge41 ]
  %92 = getelementptr inbounds [300010 x i32], ptr @cost, i64 0, i64 %indvars.iv59
  %93 = 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) %92)
  %94 = load i32, ptr %93, align 4, !tbaa !5
  store i32 %94, ptr %1, align 4, !tbaa !5
  %indvars.iv.next60 = add nuw nsw i64 %indvars.iv59, 1
  %95 = load i32, ptr @N, align 4, !tbaa !5
  %96 = sext i32 %95 to i64
  %97 = icmp slt i64 %indvars.iv.next60, %96
  br i1 %97, label %.lr.ph45, label %._crit_edge46, !llvm.loop !21
}

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) 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 noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) 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 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #1

; 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 #5 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 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 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 = { 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 = { 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 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11, !17, !18}
!17 = !{!"llvm.loop.isvectorized", i32 1}
!18 = !{!"llvm.loop.unroll.runtime.disable"}
!19 = distinct !{!19, !11}
!20 = distinct !{!20, !11, !18, !17}
!21 = distinct !{!21, !11}


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