; LLVM IR from eyangch/competitive-programming :: Codeforces/1553 (f)

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

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

@N = external dso_local global i64, align 8
@a = external dso_local global [200000 x i64], align 16
@pfx = external dso_local global [200000 x i64], align 16
@a1 = external dso_local global [200000 x i64], align 16
@a2 = external dso_local global [200000 x i64], align 16
@bit = external dso_local global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  %9 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %11
  %13 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %15 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #8
  store i64 0, ptr %2, align 8, !tbaa !8
  br label %16

16:                                               ; preds = %41, %0
  %17 = load i64, ptr %2, align 8, !tbaa !8
  %18 = load i64, ptr @N, align 8, !tbaa !8
  %19 = icmp slt i64 %17, %18
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %16
  %22 = load i64, ptr %2, align 8, !tbaa !8
  %23 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %22
  %24 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %23)
  %25 = load i64, ptr %2, align 8, !tbaa !8
  %26 = icmp eq i64 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %21
  br label %33

28:                                               ; preds = %21
  %29 = load i64, ptr %2, align 8, !tbaa !8
  %30 = sub nsw i64 %29, 1
  %31 = getelementptr inbounds [200000 x i64], ptr @pfx, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !8
  br label %33

33:                                               ; preds = %28, %27
  %34 = phi i64 [ 0, %27 ], [ %32, %28 ]
  %35 = load i64, ptr %2, align 8, !tbaa !8
  %36 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !8
  %38 = add nsw i64 %34, %37
  %39 = load i64, ptr %2, align 8, !tbaa !8
  %40 = getelementptr inbounds [200000 x i64], ptr @pfx, i64 0, i64 %39
  store i64 %38, ptr %40, align 8, !tbaa !8
  br label %41

41:                                               ; preds = %33
  %42 = load i64, ptr %2, align 8, !tbaa !8
  %43 = add nsw i64 %42, 1
  store i64 %43, ptr %2, align 8, !tbaa !8
  br label %16, !llvm.loop !11

44:                                               ; preds = %20
  %45 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 6400016) #9
  call void @llvm.memset.p0.i64(ptr align 16 %45, i8 0, i64 6400016, i1 false)
  store ptr %45, ptr @bit, align 8, !tbaa !13
  %46 = load ptr, ptr @bit, align 8, !tbaa !13
  call void @_ZN3BIT4initEx(ptr noundef nonnull align 8 dereferenceable(6400016) %46, i64 noundef 800001)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #8
  store i64 0, ptr %3, align 8, !tbaa !8
  br label %47

47:                                               ; preds = %98, %44
  %48 = load i64, ptr %3, align 8, !tbaa !8
  %49 = load i64, ptr @N, align 8, !tbaa !8
  %50 = icmp slt i64 %48, %49
  br i1 %50, label %52, label %51

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

52:                                               ; preds = %47
  %53 = load i64, ptr %3, align 8, !tbaa !8
  %54 = icmp eq i64 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %52
  br label %61

56:                                               ; preds = %52
  %57 = load i64, ptr %3, align 8, !tbaa !8
  %58 = sub nsw i64 %57, 1
  %59 = getelementptr inbounds [200000 x i64], ptr @a1, i64 0, i64 %58
  %60 = load i64, ptr %59, align 8, !tbaa !8
  br label %61

61:                                               ; preds = %56, %55
  %62 = phi i64 [ 0, %55 ], [ %60, %56 ]
  %63 = load i64, ptr %3, align 8, !tbaa !8
  %64 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %63
  %65 = load i64, ptr %64, align 8, !tbaa !8
  %66 = load i64, ptr %3, align 8, !tbaa !8
  %67 = mul nsw i64 %65, %66
  %68 = add nsw i64 %62, %67
  %69 = load ptr, ptr @bit, align 8, !tbaa !13
  %70 = load i64, ptr %3, align 8, !tbaa !8
  %71 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %70
  %72 = load i64, ptr %71, align 8, !tbaa !8
  %73 = call noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(6400016) %69, i64 noundef %72)
  %74 = add nsw i64 %68, %73
  %75 = load i64, ptr %3, align 8, !tbaa !8
  %76 = getelementptr inbounds [200000 x i64], ptr @a1, i64 0, i64 %75
  store i64 %74, ptr %76, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #8
  %77 = load i64, ptr %3, align 8, !tbaa !8
  %78 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %77
  %79 = load i64, ptr %78, align 8, !tbaa !8
  store i64 %79, ptr %5, align 8, !tbaa !8
  br label %80

80:                                               ; preds = %91, %61
  %81 = load i64, ptr %5, align 8, !tbaa !8
  %82 = icmp sle i64 %81, 300000
  br i1 %82, label %84, label %83

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

84:                                               ; preds = %80
  %85 = load ptr, ptr @bit, align 8, !tbaa !13
  %86 = load i64, ptr %5, align 8, !tbaa !8
  %87 = load i64, ptr %3, align 8, !tbaa !8
  %88 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %87
  %89 = load i64, ptr %88, align 8, !tbaa !8
  %90 = sub nsw i64 0, %89
  call void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(6400016) %85, i64 noundef %86, i64 noundef %90)
  br label %91

91:                                               ; preds = %84
  %92 = load i64, ptr %3, align 8, !tbaa !8
  %93 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %92
  %94 = load i64, ptr %93, align 8, !tbaa !8
  %95 = load i64, ptr %5, align 8, !tbaa !8
  %96 = add nsw i64 %95, %94
  store i64 %96, ptr %5, align 8, !tbaa !8
  br label %80, !llvm.loop !15

97:                                               ; preds = %83
  br label %98

98:                                               ; preds = %97
  %99 = load i64, ptr %3, align 8, !tbaa !8
  %100 = add nsw i64 %99, 1
  store i64 %100, ptr %3, align 8, !tbaa !8
  br label %47, !llvm.loop !16

101:                                              ; preds = %51
  %102 = load ptr, ptr @bit, align 8, !tbaa !13
  call void @_ZN3BIT4initEx(ptr noundef nonnull align 8 dereferenceable(6400016) %102, i64 noundef 800001)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #8
  store i64 0, ptr %6, align 8, !tbaa !8
  br label %103

103:                                              ; preds = %164, %101
  %104 = load i64, ptr %6, align 8, !tbaa !8
  %105 = load i64, ptr @N, align 8, !tbaa !8
  %106 = icmp slt i64 %104, %105
  br i1 %106, label %108, label %107

107:                                              ; preds = %103
  store i32 11, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  br label %167

108:                                              ; preds = %103
  %109 = load i64, ptr %6, align 8, !tbaa !8
  %110 = icmp eq i64 %109, 0
  br i1 %110, label %111, label %112

111:                                              ; preds = %108
  br label %122

112:                                              ; preds = %108
  %113 = load i64, ptr %6, align 8, !tbaa !8
  %114 = sub nsw i64 %113, 1
  %115 = getelementptr inbounds [200000 x i64], ptr @a2, i64 0, i64 %114
  %116 = load i64, ptr %115, align 8, !tbaa !8
  %117 = load i64, ptr %6, align 8, !tbaa !8
  %118 = sub nsw i64 %117, 1
  %119 = getelementptr inbounds [200000 x i64], ptr @pfx, i64 0, i64 %118
  %120 = load i64, ptr %119, align 8, !tbaa !8
  %121 = add nsw i64 %116, %120
  br label %122

122:                                              ; preds = %112, %111
  %123 = phi i64 [ 0, %111 ], [ %121, %112 ]
  %124 = load i64, ptr %6, align 8, !tbaa !8
  %125 = getelementptr inbounds [200000 x i64], ptr @a2, i64 0, i64 %124
  store i64 %123, ptr %125, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #8
  %126 = load i64, ptr %6, align 8, !tbaa !8
  %127 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %126
  %128 = load i64, ptr %127, align 8, !tbaa !8
  store i64 %128, ptr %7, align 8, !tbaa !8
  br label %129

129:                                              ; preds = %153, %122
  %130 = load i64, ptr %7, align 8, !tbaa !8
  %131 = icmp sle i64 %130, 300000
  br i1 %131, label %133, label %132

132:                                              ; preds = %129
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #8
  br label %159

133:                                              ; preds = %129
  %134 = load ptr, ptr @bit, align 8, !tbaa !13
  %135 = load i64, ptr %7, align 8, !tbaa !8
  %136 = load i64, ptr %6, align 8, !tbaa !8
  %137 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %136
  %138 = load i64, ptr %137, align 8, !tbaa !8
  %139 = add nsw i64 %135, %138
  %140 = sub nsw i64 %139, 1
  %141 = call noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(6400016) %134, i64 noundef %140)
  %142 = load ptr, ptr @bit, align 8, !tbaa !13
  %143 = load i64, ptr %7, align 8, !tbaa !8
  %144 = sub nsw i64 %143, 1
  %145 = call noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(6400016) %142, i64 noundef %144)
  %146 = sub nsw i64 %141, %145
  %147 = load i64, ptr %7, align 8, !tbaa !8
  %148 = mul nsw i64 %146, %147
  %149 = load i64, ptr %6, align 8, !tbaa !8
  %150 = getelementptr inbounds [200000 x i64], ptr @a2, i64 0, i64 %149
  %151 = load i64, ptr %150, align 8, !tbaa !8
  %152 = add nsw i64 %151, %148
  store i64 %152, ptr %150, align 8, !tbaa !8
  br label %153

153:                                              ; preds = %133
  %154 = load i64, ptr %6, align 8, !tbaa !8
  %155 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %154
  %156 = load i64, ptr %155, align 8, !tbaa !8
  %157 = load i64, ptr %7, align 8, !tbaa !8
  %158 = add nsw i64 %157, %156
  store i64 %158, ptr %7, align 8, !tbaa !8
  br label %129, !llvm.loop !17

159:                                              ; preds = %132
  %160 = load ptr, ptr @bit, align 8, !tbaa !13
  %161 = load i64, ptr %6, align 8, !tbaa !8
  %162 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %161
  %163 = load i64, ptr %162, align 8, !tbaa !8
  call void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(6400016) %160, i64 noundef %163, i64 noundef -1)
  br label %164

164:                                              ; preds = %159
  %165 = load i64, ptr %6, align 8, !tbaa !8
  %166 = add nsw i64 %165, 1
  store i64 %166, ptr %6, align 8, !tbaa !8
  br label %103, !llvm.loop !18

167:                                              ; preds = %107
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  store i64 0, ptr %8, align 8, !tbaa !8
  br label %168

168:                                              ; preds = %183, %167
  %169 = load i64, ptr %8, align 8, !tbaa !8
  %170 = load i64, ptr @N, align 8, !tbaa !8
  %171 = icmp slt i64 %169, %170
  br i1 %171, label %173, label %172

172:                                              ; preds = %168
  store i32 17, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  br label %186

173:                                              ; preds = %168
  %174 = load i64, ptr %8, align 8, !tbaa !8
  %175 = getelementptr inbounds [200000 x i64], ptr @a1, i64 0, i64 %174
  %176 = load i64, ptr %175, align 8, !tbaa !8
  %177 = load i64, ptr %8, align 8, !tbaa !8
  %178 = getelementptr inbounds [200000 x i64], ptr @a2, i64 0, i64 %177
  %179 = load i64, ptr %178, align 8, !tbaa !8
  %180 = add nsw i64 %176, %179
  %181 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %180)
  %182 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %181, i8 noundef signext 32)
  br label %183

183:                                              ; preds = %173
  %184 = load i64, ptr %8, align 8, !tbaa !8
  %185 = add nsw i64 %184, 1
  store i64 %185, ptr %8, align 8, !tbaa !8
  br label %168, !llvm.loop !19

186:                                              ; preds = %172
  %187 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  %188 = load i32, ptr %1, align 4
  ret i32 %188
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #1 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #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.start.p0(i64 immarg, ptr nocapture) #4

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

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #5

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #6

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3BIT4initEx(ptr noundef nonnull align 8 dereferenceable(6400016), i64 noundef) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(6400016), i64 noundef) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(6400016), i64 noundef, i64 noundef) #1 align 2

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

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

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 = { 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { nobuiltin allocsize(0) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #6 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #7 = { 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 #8 = { nounwind }
attributes #9 = { builtin allocsize(0) }

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"any pointer", !10, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !12}
!17 = distinct !{!17, !12}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !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_istream" = type { ptr, i64, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }

@N = external dso_local global i64, align 8
@a = external dso_local global [200000 x i64], align 16
@pfx = external dso_local local_unnamed_addr global [200000 x i64], align 16
@a1 = external dso_local local_unnamed_addr global [200000 x i64], align 16
@a2 = external dso_local local_unnamed_addr global [200000 x i64], align 16
@bit = external dso_local local_unnamed_addr global ptr, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %2 = getelementptr i8, ptr %1, i64 -24
  %3 = load i64, ptr %2, align 8
  %4 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %3
  %5 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %4, ptr noundef null)
  %6 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @N)
  %8 = load i64, ptr @N, align 8, !tbaa !8
  %9 = icmp sgt i64 %8, 0
  br i1 %9, label %10, label %._crit_edge

10:                                               ; preds = %0
  %11 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) @a)
  %12 = load i64, ptr @a, align 16, !tbaa !8
  store i64 %12, ptr @pfx, align 16, !tbaa !8
  %13 = load i64, ptr @N, align 8, !tbaa !8
  %14 = icmp sgt i64 %13, 1
  br i1 %14, label %.lr.ph.peel.next, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.peel.next, %10, %0
  %15 = tail call noalias noundef nonnull dereferenceable(6400016) ptr @_Znwm(i64 noundef 6400016) #7
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(6400016) %15, i8 0, i64 6400016, i1 false)
  store ptr %15, ptr @bit, align 8, !tbaa !11
  tail call void @_ZN3BIT4initEx(ptr noundef nonnull align 8 dereferenceable(6400016) %15, i64 noundef 800001)
  %16 = load i64, ptr @N, align 8, !tbaa !8
  %17 = icmp sgt i64 %16, 0
  br i1 %17, label %.lr.ph54, label %._crit_edge55

.lr.ph.peel.next:                                 ; preds = %10, %.lr.ph.peel.next
  %.04647 = phi i64 [ %26, %.lr.ph.peel.next ], [ 1, %10 ]
  %18 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %.04647
  %19 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %18)
  %20 = add nsw i64 %.04647, -1
  %21 = getelementptr inbounds [200000 x i64], ptr @pfx, i64 0, i64 %20
  %22 = load i64, ptr %21, align 8, !tbaa !8
  %23 = load i64, ptr %18, align 8, !tbaa !8
  %24 = add nsw i64 %23, %22
  %25 = getelementptr inbounds [200000 x i64], ptr @pfx, i64 0, i64 %.04647
  store i64 %24, ptr %25, align 8, !tbaa !8
  %26 = add nuw nsw i64 %.04647, 1
  %27 = load i64, ptr @N, align 8, !tbaa !8
  %28 = icmp slt i64 %26, %27
  br i1 %28, label %.lr.ph.peel.next, label %._crit_edge, !llvm.loop !13

._crit_edge55:                                    ; preds = %._crit_edge51, %._crit_edge
  %29 = load ptr, ptr @bit, align 8, !tbaa !11
  tail call void @_ZN3BIT4initEx(ptr noundef nonnull align 8 dereferenceable(6400016) %29, i64 noundef 800001)
  %30 = load i64, ptr @N, align 8, !tbaa !8
  %31 = icmp sgt i64 %30, 0
  br i1 %31, label %.lr.ph62, label %._crit_edge65

.lr.ph54:                                         ; preds = %._crit_edge, %._crit_edge51
  %.04552 = phi i64 [ %49, %._crit_edge51 ], [ 0, %._crit_edge ]
  %32 = icmp eq i64 %.04552, 0
  br i1 %32, label %37, label %33

33:                                               ; preds = %.lr.ph54
  %34 = add nsw i64 %.04552, -1
  %35 = getelementptr inbounds [200000 x i64], ptr @a1, i64 0, i64 %34
  %36 = load i64, ptr %35, align 8, !tbaa !8
  br label %37

37:                                               ; preds = %.lr.ph54, %33
  %38 = phi i64 [ %36, %33 ], [ 0, %.lr.ph54 ]
  %39 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %.04552
  %40 = load i64, ptr %39, align 8, !tbaa !8
  %41 = mul nsw i64 %40, %.04552
  %42 = add nsw i64 %41, %38
  %43 = load ptr, ptr @bit, align 8, !tbaa !11
  %44 = tail call noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(6400016) %43, i64 noundef %40)
  %45 = add nsw i64 %42, %44
  %46 = getelementptr inbounds [200000 x i64], ptr @a1, i64 0, i64 %.04552
  store i64 %45, ptr %46, align 8, !tbaa !8
  %47 = load i64, ptr %39, align 8, !tbaa !8
  %48 = icmp slt i64 %47, 300001
  br i1 %48, label %.lr.ph50, label %._crit_edge51

._crit_edge51:                                    ; preds = %.lr.ph50, %37
  %49 = add nuw nsw i64 %.04552, 1
  %50 = load i64, ptr @N, align 8, !tbaa !8
  %51 = icmp slt i64 %49, %50
  br i1 %51, label %.lr.ph54, label %._crit_edge55, !llvm.loop !16

.lr.ph50:                                         ; preds = %37, %.lr.ph50
  %52 = phi i64 [ %55, %.lr.ph50 ], [ %47, %37 ]
  %.04448 = phi i64 [ %56, %.lr.ph50 ], [ %47, %37 ]
  %53 = load ptr, ptr @bit, align 8, !tbaa !11
  %54 = sub nsw i64 0, %52
  tail call void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(6400016) %53, i64 noundef %.04448, i64 noundef %54)
  %55 = load i64, ptr %39, align 8, !tbaa !8
  %56 = add nsw i64 %55, %.04448
  %57 = icmp slt i64 %56, 300001
  br i1 %57, label %.lr.ph50, label %._crit_edge51, !llvm.loop !17

.preheader:                                       ; preds = %._crit_edge59
  %58 = icmp sgt i64 %76, 0
  br i1 %58, label %.lr.ph64, label %._crit_edge65

.lr.ph62:                                         ; preds = %._crit_edge55, %._crit_edge59
  %.04360 = phi i64 [ %75, %._crit_edge59 ], [ 0, %._crit_edge55 ]
  %59 = icmp eq i64 %.04360, 0
  br i1 %59, label %67, label %60

60:                                               ; preds = %.lr.ph62
  %61 = add nsw i64 %.04360, -1
  %62 = getelementptr inbounds [200000 x i64], ptr @a2, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !8
  %64 = getelementptr inbounds [200000 x i64], ptr @pfx, i64 0, i64 %61
  %65 = load i64, ptr %64, align 8, !tbaa !8
  %66 = add nsw i64 %65, %63
  br label %67

67:                                               ; preds = %.lr.ph62, %60
  %68 = phi i64 [ %66, %60 ], [ 0, %.lr.ph62 ]
  %69 = getelementptr inbounds [200000 x i64], ptr @a2, i64 0, i64 %.04360
  store i64 %68, ptr %69, align 8, !tbaa !8
  %70 = getelementptr inbounds [200000 x i64], ptr @a, i64 0, i64 %.04360
  %71 = load i64, ptr %70, align 8, !tbaa !8
  %72 = icmp slt i64 %71, 300001
  br i1 %72, label %.lr.ph58, label %._crit_edge59

._crit_edge59:                                    ; preds = %.lr.ph58, %67
  %73 = phi i64 [ %71, %67 ], [ %89, %.lr.ph58 ]
  %74 = load ptr, ptr @bit, align 8, !tbaa !11
  tail call void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(6400016) %74, i64 noundef %73, i64 noundef -1)
  %75 = add nuw nsw i64 %.04360, 1
  %76 = load i64, ptr @N, align 8, !tbaa !8
  %77 = icmp slt i64 %75, %76
  br i1 %77, label %.lr.ph62, label %.preheader, !llvm.loop !18

.lr.ph58:                                         ; preds = %67, %.lr.ph58
  %78 = phi i64 [ %89, %.lr.ph58 ], [ %71, %67 ]
  %.04256 = phi i64 [ %90, %.lr.ph58 ], [ %71, %67 ]
  %79 = load ptr, ptr @bit, align 8, !tbaa !11
  %80 = add i64 %.04256, -1
  %81 = add i64 %80, %78
  %82 = tail call noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(6400016) %79, i64 noundef %81)
  %83 = load ptr, ptr @bit, align 8, !tbaa !11
  %84 = tail call noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(6400016) %83, i64 noundef %80)
  %85 = sub nsw i64 %82, %84
  %86 = mul nsw i64 %85, %.04256
  %87 = load i64, ptr %69, align 8, !tbaa !8
  %88 = add nsw i64 %86, %87
  store i64 %88, ptr %69, align 8, !tbaa !8
  %89 = load i64, ptr %70, align 8, !tbaa !8
  %90 = add nsw i64 %89, %.04256
  %91 = icmp slt i64 %90, 300001
  br i1 %91, label %.lr.ph58, label %._crit_edge59, !llvm.loop !19

._crit_edge65:                                    ; preds = %.lr.ph64, %._crit_edge55, %.preheader
  %92 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i8 noundef signext 10)
  ret i32 0

.lr.ph64:                                         ; preds = %.preheader, %.lr.ph64
  %.063 = phi i64 [ %100, %.lr.ph64 ], [ 0, %.preheader ]
  %93 = getelementptr inbounds [200000 x i64], ptr @a1, i64 0, i64 %.063
  %94 = load i64, ptr %93, align 8, !tbaa !8
  %95 = getelementptr inbounds [200000 x i64], ptr @a2, i64 0, i64 %.063
  %96 = load i64, ptr %95, align 8, !tbaa !8
  %97 = add nsw i64 %96, %94
  %98 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %97)
  %99 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %98, i8 noundef signext 32)
  %100 = add nuw nsw i64 %.063, 1
  %101 = load i64, ptr @N, align 8, !tbaa !8
  %102 = icmp slt i64 %100, %101
  br i1 %102, label %.lr.ph64, label %._crit_edge65, !llvm.loop !20
}

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) local_unnamed_addr #1 align 2

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) 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 #3 align 2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN3BIT4initEx(ptr noundef nonnull align 8 dereferenceable(6400016), i64 noundef) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i64 @_ZN3BIT3qryEx(ptr noundef nonnull align 8 dereferenceable(6400016), i64 noundef) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3BIT3updExx(ptr noundef nonnull align 8 dereferenceable(6400016), i64 noundef, i64 noundef) local_unnamed_addr #1 align 2

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

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

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

!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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"long long", !10, i64 0}
!10 = !{!"omnipotent char", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !10, i64 0}
!13 = distinct !{!13, !14, !15}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!"llvm.loop.peeled.count", i32 1}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}


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