; LLVM IR from bqi343/cp-notebook :: Contests/USACO Solutions/2013-14/Nov 2013 (13 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::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 }
%union.anon = 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 }

@cow = external dso_local global [3000000 x i32], align 16
@rec = external dso_local global [3000000 x i32], align 16
@N = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@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 i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 4 dereferenceable(4) @K)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %58, %0
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @K, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  br label %61

23:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @cin, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %24, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 8 dereferenceable(8) %6)
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 8 dereferenceable(8) %7)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 1, ptr %8, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %54, %23
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = load i64, ptr %5, align 8, !tbaa !9
  %32 = add nsw i64 %31, 1
  %33 = icmp slt i64 %30, %32
  br i1 %33, label %35, label %34

34:                                               ; preds = %28
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %57

35:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = mul nsw i64 %36, %38
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = add nsw i64 %39, %40
  %42 = load i32, ptr @N, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = srem i64 %41, %43
  %45 = trunc i64 %44 to i32
  store i32 %45, ptr %9, align 4, !tbaa !5
  %46 = load i64, ptr %4, align 8, !tbaa !9
  %47 = load i32, ptr %9, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %48
  %50 = load i32, ptr %49, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = add nsw i64 %51, %46
  %53 = trunc i64 %52 to i32
  store i32 %53, ptr %49, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %54

54:                                               ; preds = %35
  %55 = load i32, ptr %8, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %8, align 4, !tbaa !5
  br label %28, !llvm.loop !11

57:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %2, align 4, !tbaa !5
  br label %18, !llvm.loop !13

61:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 -1000000007, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %62 = load i32, ptr @N, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  %64 = sub nsw i32 %63, 1
  store i32 %64, ptr %12, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %110, %61
  %66 = load i32, ptr %12, align 4, !tbaa !5
  %67 = icmp sge i32 %66, 1
  br i1 %67, label %69, label %68

68:                                               ; preds = %65
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %113

69:                                               ; preds = %65
  %70 = load i32, ptr %12, align 4, !tbaa !5
  %71 = load i32, ptr @N, align 4, !tbaa !5
  %72 = icmp eq i32 %70, %71
  br i1 %72, label %73, label %85

73:                                               ; preds = %69
  %74 = load i32, ptr %12, align 4, !tbaa !5
  %75 = load i32, ptr @N, align 4, !tbaa !5
  %76 = sub nsw i32 %74, %75
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr %12, align 4, !tbaa !5
  %81 = load i32, ptr @N, align 4, !tbaa !5
  %82 = sub nsw i32 %80, %81
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %83
  store i32 %79, ptr %84, align 4, !tbaa !5
  br label %102

85:                                               ; preds = %69
  %86 = load i32, ptr %12, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  %88 = load i32, ptr @N, align 4, !tbaa !5
  %89 = srem i32 %87, %88
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = sub nsw i32 %92, 1
  %94 = load i32, ptr %12, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = add nsw i32 %93, %97
  %99 = load i32, ptr %12, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %100
  store i32 %98, ptr %101, align 4, !tbaa !5
  br label %102

102:                                              ; preds = %85, %73
  %103 = load i32, ptr %12, align 4, !tbaa !5
  %104 = load i32, ptr @N, align 4, !tbaa !5
  %105 = srem i32 %103, %104
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %106
  %108 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %107)
  %109 = load i32, ptr %108, align 4, !tbaa !5
  store i32 %109, ptr %10, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %102
  %111 = load i32, ptr %12, align 4, !tbaa !5
  %112 = add nsw i32 %111, -1
  store i32 %112, ptr %12, align 4, !tbaa !5
  br label %65, !llvm.loop !14

113:                                              ; preds = %68
  br label %114

114:                                              ; preds = %174, %113
  %115 = load i32, ptr %10, align 4, !tbaa !5
  %116 = load i32, ptr %11, align 4, !tbaa !5
  %117 = icmp sgt i32 %115, %116
  br i1 %117, label %118, label %178

118:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %119 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %119, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  %120 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %120, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %121 = load i32, ptr %13, align 4, !tbaa !5
  %122 = add nsw i32 %121, 1
  %123 = sub nsw i32 %122, 1
  store i32 %123, ptr %15, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %171, %118
  %125 = load i32, ptr %15, align 4, !tbaa !5
  %126 = load i32, ptr %11, align 4, !tbaa !5
  %127 = add nsw i32 %126, 1
  %128 = icmp sge i32 %125, %127
  br i1 %128, label %130, label %129

129:                                              ; preds = %124
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  br label %174

130:                                              ; preds = %124
  %131 = load i32, ptr %15, align 4, !tbaa !5
  %132 = load i32, ptr %13, align 4, !tbaa !5
  %133 = icmp eq i32 %131, %132
  br i1 %133, label %134, label %144

134:                                              ; preds = %130
  %135 = load i32, ptr %13, align 4, !tbaa !5
  %136 = load i32, ptr %15, align 4, !tbaa !5
  %137 = sext i32 %136 to i64
  %138 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %137
  %139 = load i32, ptr %138, align 4, !tbaa !5
  %140 = add nsw i32 %135, %139
  %141 = load i32, ptr %15, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %142
  store i32 %140, ptr %143, align 4, !tbaa !5
  br label %159

144:                                              ; preds = %130
  %145 = load i32, ptr %15, align 4, !tbaa !5
  %146 = add nsw i32 %145, 1
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %147
  %149 = load i32, ptr %148, align 4, !tbaa !5
  %150 = sub nsw i32 %149, 1
  %151 = load i32, ptr %15, align 4, !tbaa !5
  %152 = sext i32 %151 to i64
  %153 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %152
  %154 = load i32, ptr %153, align 4, !tbaa !5
  %155 = add nsw i32 %150, %154
  %156 = load i32, ptr %15, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %157
  store i32 %155, ptr %158, align 4, !tbaa !5
  br label %159

159:                                              ; preds = %144, %134
  %160 = load i32, ptr %15, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %161
  %163 = load i32, ptr %162, align 4, !tbaa !5
  %164 = load i32, ptr %14, align 4, !tbaa !5
  %165 = add nsw i32 %164, %163
  store i32 %165, ptr %14, align 4, !tbaa !5
  %166 = load i32, ptr %15, align 4, !tbaa !5
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %167
  %169 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %168)
  %170 = load i32, ptr %169, align 4, !tbaa !5
  store i32 %170, ptr %10, align 4, !tbaa !5
  br label %171

171:                                              ; preds = %159
  %172 = load i32, ptr %15, align 4, !tbaa !5
  %173 = add nsw i32 %172, -1
  store i32 %173, ptr %15, align 4, !tbaa !5
  br label %124, !llvm.loop !15

174:                                              ; preds = %129
  %175 = load i32, ptr %13, align 4, !tbaa !5
  store i32 %175, ptr %11, align 4, !tbaa !5
  %176 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %14, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %177 = load i32, ptr %176, align 4, !tbaa !5
  store i32 %177, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  br label %114, !llvm.loop !16

178:                                              ; preds = %114
  %179 = load i32, ptr %11, align 4, !tbaa !5
  %180 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @cout, i32 noundef %179)
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  %181 = load i32, ptr %1, align 4
  ret i32 %181
}

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_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

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

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"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 }
%union.anon = 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 }

@cow = external dso_local local_unnamed_addr global [3000000 x i32], align 16
@rec = external dso_local global [3000000 x i32], align 16
@N = external dso_local global i32, align 4
@K = external dso_local global i32, align 4
@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 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @cin, ptr noundef nonnull align 4 dereferenceable(4) @N)
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %7, ptr noundef nonnull align 4 dereferenceable(4) @K)
  %9 = load i32, ptr @K, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph44, label %._crit_edge45

._crit_edge45:                                    ; preds = %._crit_edge, %0
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #5
  store i32 -1000000007, ptr %5, align 4, !tbaa !5
  %11 = load i32, ptr @N, align 4, !tbaa !5
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph48.preheader, label %._crit_edge52

.lr.ph48.preheader:                               ; preds = %._crit_edge45
  %13 = zext nneg i32 %11 to i64
  br label %.lr.ph48

.lr.ph44:                                         ; preds = %0, %._crit_edge
  %.03342 = phi i32 [ %32, %._crit_edge ], [ 0, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @cin, ptr noundef nonnull align 8 dereferenceable(8) %1)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %16 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %17 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %16, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %18 = load i64, ptr %2, align 8, !tbaa !9
  %.not40 = icmp slt i64 %18, 1
  br i1 %.not40, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph44
  %19 = load i64, ptr %3, align 8, !tbaa !9
  %20 = load i64, ptr %4, align 8, !tbaa !9
  %21 = load i32, ptr @N, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = load i64, ptr %1, align 8, !tbaa !9
  %24 = trunc i64 %23 to i32
  %xtraiter = and i64 %18, 1
  %25 = icmp eq i64 %18, 1
  br i1 %25, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %18, 9223372036854775806
  br label %35

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

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %26 = mul nsw i64 %19, %indvars.iv.unr
  %27 = add nsw i64 %26, %20
  %28 = srem i64 %27, %22
  %29 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = add i32 %30, %24
  store i32 %31, ptr %29, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %.lr.ph44
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #5
  %32 = add nuw nsw i32 %.03342, 1
  %33 = load i32, ptr @K, align 4, !tbaa !5
  %34 = icmp slt i32 %32, %33
  br i1 %34, label %.lr.ph44, label %._crit_edge45, !llvm.loop !11

35:                                               ; preds = %35, %.lr.ph.new
  %indvars.iv = phi i64 [ 1, %.lr.ph.new ], [ %indvars.iv.next.1, %35 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %35 ]
  %36 = mul nsw i64 %19, %indvars.iv
  %37 = add nsw i64 %36, %20
  %38 = srem i64 %37, %22
  %39 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %38
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = add i32 %40, %24
  store i32 %41, ptr %39, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %42 = mul nsw i64 %19, %indvars.iv.next
  %43 = add nsw i64 %42, %20
  %44 = srem i64 %43, %22
  %45 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = add i32 %46, %24
  store i32 %47, ptr %45, align 4, !tbaa !5
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %35, !llvm.loop !13

.preheader:                                       ; preds = %66
  %48 = icmp sgt i32 %72, 0
  br i1 %48, label %.lr.ph51.preheader, label %._crit_edge52

.lr.ph48:                                         ; preds = %.lr.ph48.preheader, %66
  %indvars.iv54 = phi i64 [ %13, %.lr.ph48.preheader ], [ %indvars.iv.next55, %66 ]
  %49 = load i32, ptr @N, align 4, !tbaa !5
  %50 = zext i32 %49 to i64
  %51 = icmp eq i64 %indvars.iv54, %50
  br i1 %51, label %52, label %54

52:                                               ; preds = %.lr.ph48
  %53 = load i32, ptr @cow, align 16, !tbaa !5
  store i32 %53, ptr @rec, align 16, !tbaa !5
  br label %66

54:                                               ; preds = %.lr.ph48
  %55 = trunc i64 %indvars.iv54 to i32
  %56 = add i32 %55, 1
  %57 = srem i32 %56, %49
  %58 = zext nneg i32 %57 to i64
  %59 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = add nsw i32 %60, -1
  %62 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %indvars.iv54
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = add nsw i32 %61, %63
  %65 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %indvars.iv54
  store i32 %64, ptr %65, align 4, !tbaa !5
  br label %66

66:                                               ; preds = %54, %52
  %67 = trunc nuw nsw i64 %indvars.iv54 to i32
  %68 = srem i32 %67, %49
  %69 = zext nneg i32 %68 to i64
  %70 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %69
  %71 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %70)
  %72 = load i32, ptr %71, align 4, !tbaa !5
  store i32 %72, ptr %5, align 4, !tbaa !5
  %indvars.iv.next55 = add nsw i64 %indvars.iv54, -1
  %73 = icmp sgt i64 %indvars.iv54, 1
  br i1 %73, label %.lr.ph48, label %.preheader, !llvm.loop !14

.lr.ph51.preheader:                               ; preds = %.preheader, %.loopexit
  %74 = phi i32 [ %86, %.loopexit ], [ %72, %.preheader ]
  %.03550 = phi i32 [ %74, %.loopexit ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #5
  %75 = zext nneg i32 %74 to i64
  %76 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = add nsw i32 %77, %74
  %79 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %75
  store i32 %78, ptr %79, align 4, !tbaa !5
  %80 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %75
  store i32 %78, ptr %6, align 4, !tbaa !5
  %81 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %75
  %82 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %81)
  %83 = load i32, ptr %82, align 4, !tbaa !5
  store i32 %83, ptr %5, align 4, !tbaa !5
  %84 = add nsw i32 %74, -1
  %.not.not.peel = icmp sgt i32 %84, %.03550
  br i1 %.not.not.peel, label %.peel.next, label %.loopexit

.peel.next:                                       ; preds = %.lr.ph51.preheader
  %.pre58 = zext nneg i32 %74 to i64
  %.phi.trans.insert = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %.pre58
  br label %88

.loopexit:                                        ; preds = %104, %.lr.ph51.preheader
  %85 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %6, ptr noundef nonnull align 4 dereferenceable(4) %5)
  %86 = load i32, ptr %85, align 4, !tbaa !5
  store i32 %86, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #5
  %87 = icmp sgt i32 %86, %74
  br i1 %87, label %.lr.ph51.preheader, label %._crit_edge52, !llvm.loop !15

88:                                               ; preds = %.peel.next, %104
  %.049 = phi i32 [ %84, %.peel.next ], [ %111, %104 ]
  %89 = icmp eq i32 %.049, %74
  br i1 %89, label %90, label %93

90:                                               ; preds = %88
  %91 = load i32, ptr %80, align 4, !tbaa !5
  %92 = add nsw i32 %91, %74
  store i32 %92, ptr %81, align 4, !tbaa !5
  %.pre60 = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  br label %104

93:                                               ; preds = %88
  %94 = add nuw nsw i32 %.049, 1
  %95 = zext nneg i32 %94 to i64
  %96 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %95
  %97 = load i32, ptr %96, align 4, !tbaa !5
  %98 = add nsw i32 %97, -1
  %99 = zext nneg i32 %.049 to i64
  %100 = getelementptr inbounds [3000000 x i32], ptr @cow, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = add nsw i32 %98, %101
  %103 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %99
  store i32 %102, ptr %103, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %93, %90
  %105 = phi i32 [ %101, %93 ], [ %.pre60, %90 ]
  %.pre-phi59 = phi i64 [ %99, %93 ], [ %.pre58, %90 ]
  %106 = load i32, ptr %6, align 4, !tbaa !5
  %107 = add nsw i32 %106, %105
  store i32 %107, ptr %6, align 4, !tbaa !5
  %108 = getelementptr inbounds [3000000 x i32], ptr @rec, i64 0, i64 %.pre-phi59
  %109 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %5, ptr noundef nonnull align 4 dereferenceable(4) %108)
  %110 = load i32, ptr %109, align 4, !tbaa !5
  store i32 %110, ptr %5, align 4, !tbaa !5
  %111 = add nsw i32 %.049, -1
  %.not.not = icmp sgt i32 %111, %.03550
  br i1 %.not.not, label %88, label %.loopexit, !llvm.loop !16

._crit_edge52:                                    ; preds = %.loopexit, %._crit_edge45, %.preheader
  %.035.lcssa = phi i32 [ 0, %.preheader ], [ 0, %._crit_edge45 ], [ %74, %.loopexit ]
  %112 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @cout, i32 noundef %.035.lcssa)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #5
  ret i32 0
}

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

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

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

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_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

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

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

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


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