; LLVM IR from Tunghohin/Competitive_Coding :: Codeforces/cf1519_D.ll (Z5solvev)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

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

@a = external dso_local global [5010 x i64], align 16
@b = external dso_local global [5010 x i64], align 16
@prefix_sum = external dso_local global [5010 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #5
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %26, %0
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = load i32, ptr %1, align 4, !tbaa !5
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %16
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %23
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %24)
  br label %26

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %2, align 4, !tbaa !5
  br label %16, !llvm.loop !9

29:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %40, %29
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = icmp sle i32 %31, %32
  br i1 %33, label %35, label %34

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

35:                                               ; preds = %30
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %37
  %39 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %38)
  br label %40

40:                                               ; preds = %35
  %41 = load i32, ptr %3, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %3, align 4, !tbaa !5
  br label %30, !llvm.loop !11

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

44:                                               ; preds = %68, %43
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = load i32, ptr %1, align 4, !tbaa !5
  %47 = icmp sle i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %71

49:                                               ; preds = %44
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %52
  %54 = load i64, ptr %53, align 8, !tbaa !12
  %55 = load i32, ptr %4, align 4, !tbaa !5
  %56 = sext i32 %55 to i64
  %57 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %56
  %58 = load i64, ptr %57, align 8, !tbaa !12
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %60
  %62 = load i64, ptr %61, align 8, !tbaa !12
  %63 = mul nsw i64 %58, %62
  %64 = add nsw i64 %54, %63
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %66
  store i64 %64, ptr %67, align 8, !tbaa !12
  br label %68

68:                                               ; preds = %49
  %69 = load i32, ptr %4, align 4, !tbaa !5
  %70 = add nsw i32 %69, 1
  store i32 %70, ptr %4, align 4, !tbaa !5
  br label %44, !llvm.loop !14

71:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %72 = load i32, ptr %1, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %73
  %75 = load i64, ptr %74, align 8, !tbaa !12
  store i64 %75, ptr %5, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #5
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %76

76:                                               ; preds = %214, %71
  %77 = load i32, ptr %6, align 4, !tbaa !5
  %78 = load i32, ptr %1, align 4, !tbaa !5
  %79 = icmp sle i32 %77, %78
  br i1 %79, label %81, label %80

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

81:                                               ; preds = %76
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  %82 = load i32, ptr %6, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %83
  %85 = load i64, ptr %84, align 8, !tbaa !12
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %87
  %89 = load i64, ptr %88, align 8, !tbaa !12
  %90 = mul nsw i64 %85, %89
  store i64 %90, ptr %8, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = sub nsw i32 %91, 1
  store i32 %92, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  %93 = load i32, ptr %6, align 4, !tbaa !5
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %10, align 4, !tbaa !5
  br label %95

95:                                               ; preds = %147, %81
  %96 = load i32, ptr %9, align 4, !tbaa !5
  %97 = icmp sge i32 %96, 1
  br i1 %97, label %98, label %102

98:                                               ; preds = %95
  %99 = load i32, ptr %10, align 4, !tbaa !5
  %100 = load i32, ptr %1, align 4, !tbaa !5
  %101 = icmp sle i32 %99, %100
  br label %102

102:                                              ; preds = %98, %95
  %103 = phi i1 [ false, %95 ], [ %101, %98 ]
  br i1 %103, label %105, label %104

104:                                              ; preds = %102
  store i32 14, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %152

105:                                              ; preds = %102
  %106 = load i32, ptr %9, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %107
  %109 = load i64, ptr %108, align 8, !tbaa !12
  %110 = load i32, ptr %10, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %111
  %113 = load i64, ptr %112, align 8, !tbaa !12
  %114 = mul nsw i64 %109, %113
  %115 = load i64, ptr %8, align 8, !tbaa !12
  %116 = add nsw i64 %115, %114
  store i64 %116, ptr %8, align 8, !tbaa !12
  %117 = load i32, ptr %10, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %118
  %120 = load i64, ptr %119, align 8, !tbaa !12
  %121 = load i32, ptr %9, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %122
  %124 = load i64, ptr %123, align 8, !tbaa !12
  %125 = mul nsw i64 %120, %124
  %126 = load i64, ptr %8, align 8, !tbaa !12
  %127 = add nsw i64 %126, %125
  store i64 %127, ptr %8, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %128 = load i64, ptr %8, align 8, !tbaa !12
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = sub nsw i32 %129, 1
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %131
  %133 = load i64, ptr %132, align 8, !tbaa !12
  %134 = add nsw i64 %128, %133
  %135 = load i32, ptr %1, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %136
  %138 = load i64, ptr %137, align 8, !tbaa !12
  %139 = load i32, ptr %10, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %140
  %142 = load i64, ptr %141, align 8, !tbaa !12
  %143 = sub nsw i64 %138, %142
  %144 = add nsw i64 %134, %143
  store i64 %144, ptr %11, align 8, !tbaa !12
  %145 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %11)
  %146 = load i64, ptr %145, align 8, !tbaa !12
  store i64 %146, ptr %5, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  br label %147

147:                                              ; preds = %105
  %148 = load i32, ptr %9, align 4, !tbaa !5
  %149 = add nsw i32 %148, -1
  store i32 %149, ptr %9, align 4, !tbaa !5
  %150 = load i32, ptr %10, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  store i32 %151, ptr %10, align 4, !tbaa !5
  br label %95, !llvm.loop !15

152:                                              ; preds = %104
  store i64 0, ptr %8, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #5
  %153 = load i32, ptr %6, align 4, !tbaa !5
  store i32 %153, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #5
  %154 = load i32, ptr %6, align 4, !tbaa !5
  %155 = add nsw i32 %154, 1
  store i32 %155, ptr %13, align 4, !tbaa !5
  br label %156

156:                                              ; preds = %208, %152
  %157 = load i32, ptr %12, align 4, !tbaa !5
  %158 = icmp sge i32 %157, 1
  br i1 %158, label %159, label %163

159:                                              ; preds = %156
  %160 = load i32, ptr %13, align 4, !tbaa !5
  %161 = load i32, ptr %1, align 4, !tbaa !5
  %162 = icmp sle i32 %160, %161
  br label %163

163:                                              ; preds = %159, %156
  %164 = phi i1 [ false, %156 ], [ %162, %159 ]
  br i1 %164, label %166, label %165

165:                                              ; preds = %163
  store i32 17, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #5
  br label %213

166:                                              ; preds = %163
  %167 = load i32, ptr %12, align 4, !tbaa !5
  %168 = sext i32 %167 to i64
  %169 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %168
  %170 = load i64, ptr %169, align 8, !tbaa !12
  %171 = load i32, ptr %13, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %172
  %174 = load i64, ptr %173, align 8, !tbaa !12
  %175 = mul nsw i64 %170, %174
  %176 = load i64, ptr %8, align 8, !tbaa !12
  %177 = add nsw i64 %176, %175
  store i64 %177, ptr %8, align 8, !tbaa !12
  %178 = load i32, ptr %13, align 4, !tbaa !5
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %179
  %181 = load i64, ptr %180, align 8, !tbaa !12
  %182 = load i32, ptr %12, align 4, !tbaa !5
  %183 = sext i32 %182 to i64
  %184 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %183
  %185 = load i64, ptr %184, align 8, !tbaa !12
  %186 = mul nsw i64 %181, %185
  %187 = load i64, ptr %8, align 8, !tbaa !12
  %188 = add nsw i64 %187, %186
  store i64 %188, ptr %8, align 8, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %189 = load i64, ptr %8, align 8, !tbaa !12
  %190 = load i32, ptr %12, align 4, !tbaa !5
  %191 = sub nsw i32 %190, 1
  %192 = sext i32 %191 to i64
  %193 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %192
  %194 = load i64, ptr %193, align 8, !tbaa !12
  %195 = add nsw i64 %189, %194
  %196 = load i32, ptr %1, align 4, !tbaa !5
  %197 = sext i32 %196 to i64
  %198 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %197
  %199 = load i64, ptr %198, align 8, !tbaa !12
  %200 = load i32, ptr %13, align 4, !tbaa !5
  %201 = sext i32 %200 to i64
  %202 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %201
  %203 = load i64, ptr %202, align 8, !tbaa !12
  %204 = sub nsw i64 %199, %203
  %205 = add nsw i64 %195, %204
  store i64 %205, ptr %14, align 8, !tbaa !12
  %206 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %14)
  %207 = load i64, ptr %206, align 8, !tbaa !12
  store i64 %207, ptr %5, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %208

208:                                              ; preds = %166
  %209 = load i32, ptr %12, align 4, !tbaa !5
  %210 = add nsw i32 %209, -1
  store i32 %210, ptr %12, align 4, !tbaa !5
  %211 = load i32, ptr %13, align 4, !tbaa !5
  %212 = add nsw i32 %211, 1
  store i32 %212, ptr %13, align 4, !tbaa !5
  br label %156, !llvm.loop !16

213:                                              ; preds = %165
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  br label %214

214:                                              ; preds = %213
  %215 = load i32, ptr %6, align 4, !tbaa !5
  %216 = add nsw i32 %215, 1
  store i32 %216, ptr %6, align 4, !tbaa !5
  br label %76, !llvm.loop !17

217:                                              ; preds = %80
  %218 = load i64, ptr %5, align 8, !tbaa !12
  %219 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %218)
  %220 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %219, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #5
  ret void
}

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

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

; Function Attrs: 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)) #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #3

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) #4

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { 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 #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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"long long", !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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

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

@a = external dso_local global [5010 x i64], align 16
@b = external dso_local global [5010 x i64], align 16
@prefix_sum = external dso_local local_unnamed_addr global [5010 x i64], align 16
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z5solvev() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  %5 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %6 = load i32, ptr %1, align 4
  %.not60 = icmp slt i32 %6, 1
  br i1 %.not60, label %.preheader58.thread, label %.lr.ph

.preheader59:                                     ; preds = %.lr.ph
  %.not5462 = icmp slt i32 %9, 1
  br i1 %.not5462, label %.preheader58.thread, label %.lr.ph64

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %7 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %indvars.iv
  %8 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %7)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %9 = load i32, ptr %1, align 4
  %10 = sext i32 %9 to i64
  %.not.not = icmp slt i64 %indvars.iv, %10
  br i1 %.not.not, label %.lr.ph, label %.preheader59, !llvm.loop !5

.preheader58.thread:                              ; preds = %.preheader59, %0
  %.ph = phi i32 [ %9, %.preheader59 ], [ %6, %0 ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %11 = sext i32 %.ph to i64
  %12 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %11
  %13 = load i64, ptr %12, align 8, !tbaa !7
  store i64 %13, ptr %2, align 8, !tbaa !7
  br label %._crit_edge81

.preheader58:                                     ; preds = %.lr.ph64
  %.not5565 = icmp slt i32 %21, 1
  br i1 %.not5565, label %._crit_edge.thread, label %.lr.ph67.preheader

._crit_edge.thread:                               ; preds = %.preheader58
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %14 = sext i32 %21 to i64
  %15 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %14
  %16 = load i64, ptr %15, align 8, !tbaa !7
  store i64 %16, ptr %2, align 8, !tbaa !7
  br label %._crit_edge81

.lr.ph67.preheader:                               ; preds = %.preheader58
  %.pre = load i64, ptr @prefix_sum, align 16, !tbaa !7
  %17 = zext nneg i32 %21 to i64
  %xtraiter = and i64 %17, 1
  %18 = icmp eq i32 %21, 1
  br i1 %18, label %._crit_edge.unr-lcssa, label %.lr.ph67.preheader.new

.lr.ph67.preheader.new:                           ; preds = %.lr.ph67.preheader
  %unroll_iter = and i64 %17, 2147483646
  br label %.lr.ph67

.lr.ph64:                                         ; preds = %.preheader59, %.lr.ph64
  %indvars.iv85 = phi i64 [ %indvars.iv.next86, %.lr.ph64 ], [ 1, %.preheader59 ]
  %19 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %indvars.iv85
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %19)
  %indvars.iv.next86 = add nuw nsw i64 %indvars.iv85, 1
  %21 = load i32, ptr %1, align 4
  %22 = sext i32 %21 to i64
  %.not54.not = icmp slt i64 %indvars.iv85, %22
  br i1 %.not54.not, label %.lr.ph64, label %.preheader58, !llvm.loop !11

._crit_edge.unr-lcssa:                            ; preds = %.lr.ph67, %.lr.ph67.preheader
  %.unr = phi i64 [ %.pre, %.lr.ph67.preheader ], [ %46, %.lr.ph67 ]
  %indvars.iv88.unr = phi i64 [ 1, %.lr.ph67.preheader ], [ %indvars.iv.next89.1, %.lr.ph67 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph67.epil

.lr.ph67.epil:                                    ; preds = %._crit_edge.unr-lcssa
  %23 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %indvars.iv88.unr
  %24 = load i64, ptr %23, align 8, !tbaa !7
  %25 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %indvars.iv88.unr
  %26 = load i64, ptr %25, align 8, !tbaa !7
  %27 = mul nsw i64 %26, %24
  %28 = add nsw i64 %27, %.unr
  %29 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %indvars.iv88.unr
  store i64 %28, ptr %29, align 8, !tbaa !7
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.unr-lcssa, %.lr.ph67.epil
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  %30 = zext nneg i32 %21 to i64
  %31 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !7
  store i64 %32, ptr %2, align 8, !tbaa !7
  br i1 %.not5565, label %._crit_edge81, label %.lr.ph80

.lr.ph67:                                         ; preds = %.lr.ph67, %.lr.ph67.preheader.new
  %33 = phi i64 [ %.pre, %.lr.ph67.preheader.new ], [ %46, %.lr.ph67 ]
  %indvars.iv88 = phi i64 [ 1, %.lr.ph67.preheader.new ], [ %indvars.iv.next89.1, %.lr.ph67 ]
  %niter = phi i64 [ 0, %.lr.ph67.preheader.new ], [ %niter.next.1, %.lr.ph67 ]
  %34 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %indvars.iv88
  %35 = load i64, ptr %34, align 8, !tbaa !7
  %36 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %indvars.iv88
  %37 = load i64, ptr %36, align 8, !tbaa !7
  %38 = mul nsw i64 %37, %35
  %39 = add nsw i64 %38, %33
  %40 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %indvars.iv88
  store i64 %39, ptr %40, align 8, !tbaa !7
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %41 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %indvars.iv.next89
  %42 = load i64, ptr %41, align 8, !tbaa !7
  %43 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %indvars.iv.next89
  %44 = load i64, ptr %43, align 8, !tbaa !7
  %45 = mul nsw i64 %44, %42
  %46 = add nsw i64 %45, %39
  %47 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %indvars.iv.next89
  store i64 %46, ptr %47, align 8, !tbaa !7
  %indvars.iv.next89.1 = add nuw nsw i64 %indvars.iv88, 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.unr-lcssa, label %.lr.ph67, !llvm.loop !12

.loopexit.loopexit:                               ; preds = %.lr.ph76
  %.pre111 = sext i32 %126 to i64
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %.preheader
  %.pre-phi112 = phi i64 [ %.pre111, %.loopexit.loopexit ], [ %.pre-phi, %.preheader ]
  %48 = phi i64 [ %124, %.loopexit.loopexit ], [ %64, %.preheader ]
  %49 = phi i32 [ %126, %.loopexit.loopexit ], [ %65, %.preheader ]
  %.not56.not = icmp slt i64 %indvars.iv95, %.pre-phi112
  %indvars.iv.next92 = add nuw nsw i64 %indvars.iv91, 1
  br i1 %.not56.not, label %.lr.ph80, label %._crit_edge81, !llvm.loop !13

._crit_edge81:                                    ; preds = %.loopexit, %.preheader58.thread, %._crit_edge.thread, %._crit_edge
  %50 = phi i64 [ %32, %._crit_edge ], [ %16, %._crit_edge.thread ], [ %13, %.preheader58.thread ], [ %48, %.loopexit ]
  %51 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %50)
  %52 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %51, i8 noundef signext 10)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret void

.lr.ph80:                                         ; preds = %._crit_edge, %.loopexit
  %53 = phi i64 [ %48, %.loopexit ], [ %32, %._crit_edge ]
  %54 = phi i32 [ %49, %.loopexit ], [ %21, %._crit_edge ]
  %indvars.iv95 = phi i64 [ %indvars.iv.next96, %.loopexit ], [ 1, %._crit_edge ]
  %indvars.iv91 = phi i64 [ %indvars.iv.next92, %.loopexit ], [ 2, %._crit_edge ]
  %indvars.iv.next96 = add nuw nsw i64 %indvars.iv95, 1
  %55 = icmp ugt i64 %indvars.iv95, 1
  %56 = sext i32 %54 to i64
  %57 = icmp slt i64 %indvars.iv95, %56
  %58 = select i1 %55, i1 %57, i1 false
  br i1 %58, label %.lr.ph72.preheader, label %.preheader

.lr.ph72.preheader:                               ; preds = %.lr.ph80
  %59 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %indvars.iv95
  %60 = load i64, ptr %59, align 8, !tbaa !7
  %61 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %indvars.iv95
  %62 = load i64, ptr %61, align 8, !tbaa !7
  %63 = mul nsw i64 %60, %62
  br label %.lr.ph72

.preheader.loopexit:                              ; preds = %.lr.ph72
  %.pre110 = sext i32 %95 to i64
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit, %.lr.ph80
  %.pre-phi = phi i64 [ %.pre110, %.preheader.loopexit ], [ %56, %.lr.ph80 ]
  %64 = phi i64 [ %93, %.preheader.loopexit ], [ %53, %.lr.ph80 ]
  %65 = phi i32 [ %95, %.preheader.loopexit ], [ %54, %.lr.ph80 ]
  %.not.not82 = icmp slt i64 %indvars.iv95, %.pre-phi
  br i1 %.not.not82, label %.lr.ph76, label %.loopexit

.lr.ph72:                                         ; preds = %.lr.ph72.preheader, %.lr.ph72
  %indvars.iv97 = phi i64 [ %indvars.iv95, %.lr.ph72.preheader ], [ %indvars.iv.next98, %.lr.ph72 ]
  %indvars.iv93 = phi i64 [ %indvars.iv91, %.lr.ph72.preheader ], [ %indvars.iv.next94, %.lr.ph72 ]
  %66 = phi i32 [ %54, %.lr.ph72.preheader ], [ %95, %.lr.ph72 ]
  %.04968 = phi i64 [ %63, %.lr.ph72.preheader ], [ %79, %.lr.ph72 ]
  %indvars.iv.next98 = add nsw i64 %indvars.iv97, -1
  %67 = and i64 %indvars.iv.next98, 4294967295
  %68 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %67
  %69 = load i64, ptr %68, align 8, !tbaa !7
  %70 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %indvars.iv93
  %71 = load i64, ptr %70, align 8, !tbaa !7
  %72 = mul nsw i64 %71, %69
  %73 = add nsw i64 %72, %.04968
  %74 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %indvars.iv93
  %75 = load i64, ptr %74, align 8, !tbaa !7
  %76 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %67
  %77 = load i64, ptr %76, align 8, !tbaa !7
  %78 = mul nsw i64 %77, %75
  %79 = add nsw i64 %73, %78
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %80 = add i64 %indvars.iv97, 4294967294
  %81 = and i64 %80, 4294967295
  %82 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %81
  %83 = load i64, ptr %82, align 8, !tbaa !7
  %84 = sext i32 %66 to i64
  %85 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %84
  %86 = load i64, ptr %85, align 8, !tbaa !7
  %87 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %indvars.iv93
  %88 = load i64, ptr %87, align 8, !tbaa !7
  %89 = add i64 %79, %83
  %90 = add i64 %89, %86
  %91 = sub i64 %90, %88
  store i64 %91, ptr %3, align 8, !tbaa !7
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %93 = load i64, ptr %92, align 8, !tbaa !7
  store i64 %93, ptr %2, align 8, !tbaa !7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  %indvars.iv.next94 = add nuw nsw i64 %indvars.iv93, 1
  %94 = icmp sgt i64 %indvars.iv97, 2
  %95 = load i32, ptr %1, align 4
  %96 = trunc nuw i64 %indvars.iv93 to i32
  %97 = icmp sgt i32 %95, %96
  %98 = select i1 %94, i1 %97, i1 false
  br i1 %98, label %.lr.ph72, label %.preheader.loopexit, !llvm.loop !14

.lr.ph76:                                         ; preds = %.preheader, %.lr.ph76
  %indvars.iv104 = phi i64 [ %indvars.iv.next105, %.lr.ph76 ], [ %indvars.iv95, %.preheader ]
  %indvars.iv102 = phi i64 [ %indvars.iv.next103, %.lr.ph76 ], [ %indvars.iv91, %.preheader ]
  %99 = phi i32 [ %126, %.lr.ph76 ], [ %65, %.preheader ]
  %.173 = phi i64 [ %111, %.lr.ph76 ], [ 0, %.preheader ]
  %100 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %indvars.iv104
  %101 = load i64, ptr %100, align 8, !tbaa !7
  %102 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %indvars.iv102
  %103 = load i64, ptr %102, align 8, !tbaa !7
  %104 = mul nsw i64 %103, %101
  %105 = add nsw i64 %104, %.173
  %106 = getelementptr inbounds [5010 x i64], ptr @a, i64 0, i64 %indvars.iv102
  %107 = load i64, ptr %106, align 8, !tbaa !7
  %108 = getelementptr inbounds [5010 x i64], ptr @b, i64 0, i64 %indvars.iv104
  %109 = load i64, ptr %108, align 8, !tbaa !7
  %110 = mul nsw i64 %109, %107
  %111 = add nsw i64 %105, %110
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %indvars.iv.next105 = add nsw i64 %indvars.iv104, -1
  %112 = and i64 %indvars.iv.next105, 4294967295
  %113 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %112
  %114 = load i64, ptr %113, align 8, !tbaa !7
  %115 = sext i32 %99 to i64
  %116 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %115
  %117 = load i64, ptr %116, align 8, !tbaa !7
  %118 = getelementptr inbounds [5010 x i64], ptr @prefix_sum, i64 0, i64 %indvars.iv102
  %119 = load i64, ptr %118, align 8, !tbaa !7
  %120 = add i64 %111, %114
  %121 = add i64 %120, %117
  %122 = sub i64 %121, %119
  store i64 %122, ptr %4, align 8, !tbaa !7
  %123 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %124 = load i64, ptr %123, align 8, !tbaa !7
  store i64 %124, ptr %2, align 8, !tbaa !7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  %indvars.iv.next103 = add nuw nsw i64 %indvars.iv102, 1
  %125 = icmp sgt i64 %indvars.iv104, 1
  %126 = load i32, ptr %1, align 4
  %127 = trunc nuw i64 %indvars.iv102 to i32
  %128 = icmp sgt i32 %126, %127
  %129 = select i1 %125, i1 %128, i1 false
  br i1 %129, label %.lr.ph76, label %.loopexit.loopexit, !llvm.loop !15
}

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

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

; Function Attrs: mustprogress 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 #0 align 2

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8), i8 noundef signext) local_unnamed_addr #4

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 #4 = { 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 #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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"long long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}
!12 = distinct !{!12, !6}
!13 = distinct !{!13, !6}
!14 = distinct !{!14, !6}
!15 = distinct !{!15, !6}


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