; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2012-13/Nov 2012 (12 Nov G1)

; 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_ifstream" = type { %"class.std::basic_istream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon.0 }
%union.anon.0 = type { i32 }
%"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::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }

@sum = external dso_local global [1001 x i32], align 16
@dp = external dso_local global [1001 x [1001 x i32]], align 16
@N = external dso_local global i32, align 4
@_Z6secondB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@cin = external dso_local global %"class.std::basic_ifstream", align 8
@cout = external dso_local global %"class.std::basic_ofstream", 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
  store i32 0, ptr %1, align 4
  %6 = 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) @cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z6secondB5cxx11)
  %7 = call noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32) @_Z6secondB5cxx11) #4
  %8 = trunc i64 %7 to i32
  store i32 %8, ptr @N, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %9

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

13:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %51

14:                                               ; preds = %9
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z6secondB5cxx11, i64 noundef %16)
  %18 = load i8, ptr %17, align 1, !tbaa !9
  %19 = sext i8 %18 to i32
  %20 = icmp eq i32 %19, 40
  br i1 %20, label %21, label %27

21:                                               ; preds = %14
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %23
  %25 = load i32, ptr %24, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %24, align 4, !tbaa !5
  br label %33

27:                                               ; preds = %14
  %28 = load i32, ptr %2, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = add nsw i32 %31, -1
  store i32 %32, ptr %30, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %27, %21
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = icmp ne i32 %34, 0
  br i1 %35, label %36, label %47

36:                                               ; preds = %33
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sub nsw i32 %37, 1
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = add nsw i32 %45, %41
  store i32 %46, ptr %44, align 4, !tbaa !5
  br label %47

47:                                               ; preds = %36, %33
  br label %48

48:                                               ; preds = %47
  %49 = load i32, ptr %2, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %2, align 4, !tbaa !5
  br label %9, !llvm.loop !10

51:                                               ; preds = %13
  store i32 1, ptr getelementptr inbounds ([1001 x i32], ptr @dp, i64 0, i64 1), align 4, !tbaa !5
  store i32 1, ptr @dp, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %164, %51
  %53 = load i32, ptr %3, align 4, !tbaa !5
  %54 = load i32, ptr @N, align 4, !tbaa !5
  %55 = icmp slt i32 %53, %54
  br i1 %55, label %57, label %56

56:                                               ; preds = %52
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %167

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

58:                                               ; preds = %160, %57
  %59 = load i32, ptr %5, align 4, !tbaa !5
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  %65 = icmp slt i32 %59, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %58
  store i32 8, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %163

67:                                               ; preds = %58
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z6secondB5cxx11, i64 noundef %69)
  %71 = load i8, ptr %70, align 1, !tbaa !9
  %72 = sext i8 %71 to i32
  %73 = icmp eq i32 %72, 40
  br i1 %73, label %74, label %112

74:                                               ; preds = %67
  %75 = load i32, ptr %5, align 4, !tbaa !5
  %76 = icmp ne i32 %75, 0
  br i1 %76, label %77, label %95

77:                                               ; preds = %74
  %78 = load i32, ptr %3, align 4, !tbaa !5
  %79 = sub nsw i32 %78, 1
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %80
  %82 = load i32, ptr %5, align 4, !tbaa !5
  %83 = sub nsw i32 %82, 1
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [1001 x i32], ptr %81, i64 0, i64 %84
  %86 = load i32, ptr %85, align 4, !tbaa !5
  %87 = load i32, ptr %3, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %88
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [1001 x i32], ptr %89, i64 0, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = add nsw i32 %93, %86
  store i32 %94, ptr %92, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %77, %74
  %96 = load i32, ptr %3, align 4, !tbaa !5
  %97 = sub nsw i32 %96, 1
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %98
  %100 = load i32, ptr %5, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [1001 x i32], ptr %99, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = load i32, ptr %3, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %105
  %107 = load i32, ptr %5, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [1001 x i32], ptr %106, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = add nsw i32 %110, %103
  store i32 %111, ptr %109, align 4, !tbaa !5
  br label %151

112:                                              ; preds = %67
  %113 = load i32, ptr %5, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  %115 = icmp sle i32 %114, 1000
  br i1 %115, label %116, label %134

116:                                              ; preds = %112
  %117 = load i32, ptr %3, align 4, !tbaa !5
  %118 = sub nsw i32 %117, 1
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %119
  %121 = load i32, ptr %5, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [1001 x i32], ptr %120, i64 0, i64 %123
  %125 = load i32, ptr %124, align 4, !tbaa !5
  %126 = load i32, ptr %3, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %127
  %129 = load i32, ptr %5, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [1001 x i32], ptr %128, i64 0, i64 %130
  %132 = load i32, ptr %131, align 4, !tbaa !5
  %133 = add nsw i32 %132, %125
  store i32 %133, ptr %131, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %116, %112
  %135 = load i32, ptr %3, align 4, !tbaa !5
  %136 = sub nsw i32 %135, 1
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %137
  %139 = load i32, ptr %5, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [1001 x i32], ptr %138, i64 0, i64 %140
  %142 = load i32, ptr %141, align 4, !tbaa !5
  %143 = load i32, ptr %3, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %144
  %146 = load i32, ptr %5, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [1001 x i32], ptr %145, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = add nsw i32 %149, %142
  store i32 %150, ptr %148, align 4, !tbaa !5
  br label %151

151:                                              ; preds = %134, %95
  %152 = load i32, ptr %3, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %153
  %155 = load i32, ptr %5, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [1001 x i32], ptr %154, i64 0, i64 %156
  %158 = load i32, ptr %157, align 4, !tbaa !5
  %159 = srem i32 %158, 2012
  store i32 %159, ptr %157, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %151
  %161 = load i32, ptr %5, align 4, !tbaa !5
  %162 = add nsw i32 %161, 1
  store i32 %162, ptr %5, align 4, !tbaa !5
  br label %58, !llvm.loop !12

163:                                              ; preds = %66
  br label %164

164:                                              ; preds = %163
  %165 = load i32, ptr %3, align 4, !tbaa !5
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %3, align 4, !tbaa !5
  br label %52, !llvm.loop !13

167:                                              ; preds = %56
  %168 = load i32, ptr @sum, align 16, !tbaa !5
  %169 = icmp eq i32 %168, 1
  br i1 %169, label %170, label %185

170:                                              ; preds = %167
  %171 = load i32, ptr @N, align 4, !tbaa !5
  %172 = sub nsw i32 %171, 1
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %173
  %175 = load i32, ptr %174, align 4, !tbaa !5
  %176 = icmp eq i32 %175, 0
  br i1 %176, label %177, label %185

177:                                              ; preds = %170
  %178 = load i32, ptr @N, align 4, !tbaa !5
  %179 = sub nsw i32 %178, 1
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %180
  %182 = getelementptr inbounds [1001 x i32], ptr %181, i64 0, i64 0
  %183 = load i32, ptr %182, align 4, !tbaa !5
  %184 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @cout, i32 noundef %183)
  br label %185

185:                                              ; preds = %177, %170, %167
  %186 = load i32, ptr %1, align 4
  ret i32 %186
}

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: mustprogress nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32)) #2 align 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 nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #2 align 2

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

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !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_ifstream" = type { %"class.std::basic_istream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_istream.base" = type { ptr, i64 }
%"class.std::basic_filebuf" = type { %"class.std::basic_streambuf", %union.pthread_mutex_t, %"class.std::__basic_file", i32, %struct.__mbstate_t, %struct.__mbstate_t, %struct.__mbstate_t, ptr, i64, i8, i8, i8, i8, ptr, ptr, i8, ptr, ptr, i64, ptr, ptr }
%"class.std::basic_streambuf" = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %"class.std::locale" }
%"class.std::locale" = type { ptr }
%union.pthread_mutex_t = type { %struct.__pthread_mutex_s }
%struct.__pthread_mutex_s = type { i32, i32, i32, i32, i32, i16, i16, %struct.__pthread_internal_list }
%struct.__pthread_internal_list = type { ptr, ptr }
%"class.std::__basic_file" = type <{ ptr, i8, [7 x i8] }>
%struct.__mbstate_t = type { i32, %union.anon.0 }
%union.anon.0 = type { i32 }
%"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::basic_ofstream" = type { %"class.std::basic_ostream.base", %"class.std::basic_filebuf", %"class.std::basic_ios" }
%"class.std::basic_ostream.base" = type { ptr }

@sum = external dso_local local_unnamed_addr global [1001 x i32], align 16
@dp = external dso_local local_unnamed_addr global [1001 x [1001 x i32]], align 16
@N = external dso_local local_unnamed_addr global i32, align 4
@_Z6secondB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@cin = external dso_local global %"class.std::basic_ifstream", align 8
@cout = external dso_local global %"class.std::basic_ofstream", align 8

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

.lr.ph.preheader:                                 ; preds = %0
  %5 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z6secondB5cxx11, i64 noundef 0)
  %6 = load i8, ptr %5, align 1, !tbaa !9
  %7 = icmp eq i8 %6, 40
  %8 = load i32, ptr @sum, align 16, !tbaa !5
  %. = select i1 %7, i32 1, i32 -1
  %9 = add nsw i32 %8, %.
  store i32 %9, ptr @sum, align 16, !tbaa !5
  %10 = load i32, ptr @N, align 4, !tbaa !5
  %11 = icmp sgt i32 %10, 1
  br i1 %11, label %.lr.ph, label %._crit_edge.thread

._crit_edge.thread:                               ; preds = %0, %.lr.ph.preheader
  %.ph = phi i32 [ %10, %.lr.ph.preheader ], [ %3, %0 ]
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 4), align 4, !tbaa !5
  store i32 1, ptr @dp, align 16, !tbaa !5
  br label %._crit_edge47

._crit_edge:                                      ; preds = %.lr.ph
  store i32 1, ptr getelementptr inbounds (i8, ptr @dp, i64 4), align 4, !tbaa !5
  store i32 1, ptr @dp, align 16, !tbaa !5
  %12 = icmp sgt i32 %24, 1
  br i1 %12, label %.preheader, label %._crit_edge47

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %.lr.ph.preheader ]
  %13 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z6secondB5cxx11, i64 noundef %indvars.iv)
  %14 = load i8, ptr %13, align 1, !tbaa !9
  %15 = icmp eq i8 %14, 40
  %16 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %indvars.iv
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %.78 = select i1 %15, i32 1, i32 -1
  %18 = add nsw i32 %17, %.78
  %19 = add nsw i64 %indvars.iv, -1
  %20 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %19
  %21 = load i32, ptr %20, align 4, !tbaa !5
  %22 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %indvars.iv
  %23 = add nsw i32 %18, %21
  store i32 %23, ptr %22, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %24 = load i32, ptr @N, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next, %25
  br i1 %26, label %.lr.ph, label %._crit_edge, !llvm.loop !10

.preheader:                                       ; preds = %._crit_edge, %._crit_edge45
  %27 = phi i32 [ %49, %._crit_edge45 ], [ %24, %._crit_edge ]
  %indvars.iv55 = phi i64 [ %indvars.iv.next56, %._crit_edge45 ], [ 1, %._crit_edge ]
  %28 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %indvars.iv55
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %.not42 = icmp slt i32 %29, 0
  br i1 %.not42, label %._crit_edge45, label %.lr.ph44

.lr.ph44:                                         ; preds = %.preheader
  %30 = add nsw i64 %indvars.iv55, -1
  %31 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z6secondB5cxx11, i64 noundef %indvars.iv55)
  %32 = load i8, ptr %31, align 1, !tbaa !9
  %33 = icmp eq i8 %32, 40
  br i1 %33, label %._crit_edge60, label %34

34:                                               ; preds = %.lr.ph44
  %35 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %30, i64 1
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv55, i64 0
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = add nsw i32 %38, %36
  br label %40

._crit_edge60:                                    ; preds = %.lr.ph44
  %.phi.trans.insert61 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv55, i64 0
  %.pre62 = load i32, ptr %.phi.trans.insert61, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %._crit_edge60, %34
  %.pre62.sink = phi i32 [ %.pre62, %._crit_edge60 ], [ %39, %34 ]
  %41 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %30, i64 0
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = add nsw i32 %.pre62.sink, %42
  %44 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv55, i64 0
  %45 = srem i32 %43, 2012
  store i32 %45, ptr %44, align 4, !tbaa !5
  %46 = load i32, ptr %28, align 4, !tbaa !5
  %.not.not.peel = icmp sgt i32 %46, 0
  br i1 %.not.not.peel, label %.peel.next, label %._crit_edge45.loopexit

._crit_edge47:                                    ; preds = %._crit_edge45, %._crit_edge.thread, %._crit_edge
  %.lcssa = phi i32 [ %24, %._crit_edge ], [ %.ph, %._crit_edge.thread ], [ %49, %._crit_edge45 ]
  %47 = load i32, ptr @sum, align 16, !tbaa !5
  %48 = icmp eq i32 %47, 1
  br i1 %48, label %79, label %89

._crit_edge45.loopexit:                           ; preds = %71, %40
  %.pre69 = load i32, ptr @N, align 4, !tbaa !5
  br label %._crit_edge45

._crit_edge45:                                    ; preds = %._crit_edge45.loopexit, %.preheader
  %49 = phi i32 [ %.pre69, %._crit_edge45.loopexit ], [ %27, %.preheader ]
  %indvars.iv.next56 = add nuw nsw i64 %indvars.iv55, 1
  %50 = sext i32 %49 to i64
  %51 = icmp slt i64 %indvars.iv.next56, %50
  br i1 %51, label %.preheader, label %._crit_edge47, !llvm.loop !13

.peel.next:                                       ; preds = %40, %71
  %indvars.iv51 = phi i64 [ %indvars.iv.next52, %71 ], [ 1, %40 ]
  %52 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z6secondB5cxx11, i64 noundef %indvars.iv55)
  %53 = load i8, ptr %52, align 1, !tbaa !9
  %54 = icmp eq i8 %53, 40
  br i1 %54, label %55, label %62

55:                                               ; preds = %.peel.next
  %56 = add nsw i64 %indvars.iv51, -1
  %57 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %30, i64 %56
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv55, i64 %indvars.iv51
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = add nsw i32 %60, %58
  br label %71

62:                                               ; preds = %.peel.next
  %63 = icmp ult i64 %indvars.iv51, 1000
  br i1 %63, label %64, label %._crit_edge63

._crit_edge63:                                    ; preds = %62
  %.phi.trans.insert64 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv55, i64 %indvars.iv51
  %.pre65 = load i32, ptr %.phi.trans.insert64, align 4, !tbaa !5
  br label %71

64:                                               ; preds = %62
  %65 = add nuw nsw i64 %indvars.iv51, 1
  %66 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %30, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv55, i64 %indvars.iv51
  %69 = load i32, ptr %68, align 4, !tbaa !5
  %70 = add nsw i32 %69, %67
  br label %71

71:                                               ; preds = %64, %._crit_edge63, %55
  %.sink75 = phi i32 [ %61, %55 ], [ %.pre65, %._crit_edge63 ], [ %70, %64 ]
  %72 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %30, i64 %indvars.iv51
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = add nsw i32 %.sink75, %73
  %75 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %indvars.iv55, i64 %indvars.iv51
  %76 = srem i32 %74, 2012
  store i32 %76, ptr %75, align 4, !tbaa !5
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %77 = load i32, ptr %28, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %.not.not = icmp slt i64 %indvars.iv51, %78
  br i1 %.not.not, label %.peel.next, label %._crit_edge45.loopexit, !llvm.loop !14

79:                                               ; preds = %._crit_edge47
  %80 = add nsw i32 %.lcssa, -1
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [1001 x i32], ptr @sum, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = icmp eq i32 %83, 0
  br i1 %84, label %85, label %89

85:                                               ; preds = %79
  %86 = getelementptr inbounds [1001 x [1001 x i32]], ptr @dp, i64 0, i64 %81
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %88 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @cout, i32 noundef %87)
  br label %89

89:                                               ; preds = %85, %79, %._crit_edge47
  ret i32 0
}

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 nounwind uwtable
declare noundef i64 @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #2 align 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 #2 align 2

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { 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 #3 = { 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, !12}
!11 = !{!"llvm.loop.mustprogress"}
!12 = !{!"llvm.loop.peeled.count", i32 1}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11, !12}


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