; LLVM IR from VastoLorde95/Competitive-Programming :: Hackerrank/Codesprints 2016/Codesprint April/Problem H/H.ll (Z6updateiixxx)

; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.10" = type { %"struct.std::_Vector_base.11" }
%"struct.std::_Vector_base.11" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }
%"struct.std::pair" = type { i64, i64 }

@g = external dso_local global [262144 x %"class.std::vector"], align 16
@c = external dso_local global [262144 x i64], align 16
@up = external dso_local global [262144 x %"class.std::vector.10"], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) #1 align 2

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updateiixxx(i32 noundef %0, i32 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4) #3 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i64, align 8
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %16 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !9
  store i64 %4, ptr %10, align 8, !tbaa !9
  %17 = load i64, ptr %10, align 8, !tbaa !9
  %18 = load i32, ptr %6, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [262144 x i64], ptr @c, i64 0, i64 %19
  %21 = load i64, ptr %20, align 8, !tbaa !9
  %22 = add nsw i64 %21, %17
  store i64 %22, ptr %20, align 8, !tbaa !9
  %23 = load i32, ptr %6, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [262144 x i64], ptr @c, i64 0, i64 %24
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = icmp sge i64 %26, 1000000007
  br i1 %27, label %28, label %34

28:                                               ; preds = %5
  %29 = load i32, ptr %6, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [262144 x i64], ptr @c, i64 0, i64 %30
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = sub nsw i64 %32, 1000000007
  store i64 %33, ptr %31, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %28, %5
  %35 = load i64, ptr %8, align 8, !tbaa !9
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [262144 x i64], ptr @c, i64 0, i64 %37
  %39 = load i64, ptr %38, align 8, !tbaa !9
  %40 = add nsw i64 %39, %35
  store i64 %40, ptr %38, align 8, !tbaa !9
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [262144 x i64], ptr @c, i64 0, i64 %42
  %44 = load i64, ptr %43, align 8, !tbaa !9
  %45 = icmp sge i64 %44, 1000000007
  br i1 %45, label %46, label %52

46:                                               ; preds = %34
  %47 = load i32, ptr %6, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [262144 x i64], ptr @c, i64 0, i64 %48
  %50 = load i64, ptr %49, align 8, !tbaa !9
  %51 = sub nsw i64 %50, 1000000007
  store i64 %51, ptr %49, align 8, !tbaa !9
  br label %52

52:                                               ; preds = %46, %34
  %53 = load i64, ptr %8, align 8, !tbaa !9
  %54 = load i64, ptr %10, align 8, !tbaa !9
  %55 = add nsw i64 %54, %53
  store i64 %55, ptr %10, align 8, !tbaa !9
  %56 = load i64, ptr %10, align 8, !tbaa !9
  %57 = icmp sge i64 %56, 1000000007
  br i1 %57, label %58, label %61

58:                                               ; preds = %52
  %59 = load i64, ptr %10, align 8, !tbaa !9
  %60 = sub nsw i64 %59, 1000000007
  store i64 %60, ptr %10, align 8, !tbaa !9
  br label %61

61:                                               ; preds = %58, %52
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %62 = load i64, ptr %8, align 8, !tbaa !9
  %63 = load i64, ptr %9, align 8, !tbaa !9
  %64 = add nsw i64 %62, %63
  %65 = srem i64 %64, 1000000007
  store i64 %65, ptr %11, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %66 = load i64, ptr %8, align 8, !tbaa !9
  store i64 %66, ptr %12, align 8, !tbaa !9
  br label %67

67:                                               ; preds = %120, %61
  %68 = load i32, ptr %6, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [262144 x %"class.std::vector.10"], ptr @up, i64 0, i64 %69
  %71 = call noundef zeroext i1 @_ZNKSt6vectorISt4pairIxxESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %70) #4
  %72 = xor i1 %71, true
  br i1 %72, label %73, label %121

73:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [262144 x %"class.std::vector.10"], ptr @up, i64 0, i64 %75
  %77 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %76) #4
  %78 = getelementptr inbounds %"struct.std::pair", ptr %77, i32 0, i32 0
  %79 = load i64, ptr %78, align 8, !tbaa !11
  store i64 %79, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [262144 x %"class.std::vector.10"], ptr @up, i64 0, i64 %81
  %83 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %82) #4
  %84 = getelementptr inbounds %"struct.std::pair", ptr %83, i32 0, i32 1
  %85 = load i64, ptr %84, align 8, !tbaa !13
  store i64 %85, ptr %14, align 8, !tbaa !9
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds [262144 x %"class.std::vector.10"], ptr @up, i64 0, i64 %87
  call void @_ZNSt6vectorISt4pairIxxESaIS1_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24) %88) #4
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [262144 x i64], ptr @c, i64 0, i64 %90
  %92 = load i64, ptr %91, align 8, !tbaa !9
  %93 = load i64, ptr %14, align 8, !tbaa !9
  %94 = add nsw i64 %92, %93
  %95 = srem i64 %94, 1000000007
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [262144 x i64], ptr @c, i64 0, i64 %97
  store i64 %95, ptr %98, align 8, !tbaa !9
  %99 = load i64, ptr %10, align 8, !tbaa !9
  %100 = load i64, ptr %14, align 8, !tbaa !9
  %101 = add nsw i64 %99, %100
  %102 = srem i64 %101, 1000000007
  store i64 %102, ptr %10, align 8, !tbaa !9
  %103 = load i64, ptr %13, align 8, !tbaa !9
  %104 = load i64, ptr %11, align 8, !tbaa !9
  %105 = add nsw i64 %104, %103
  store i64 %105, ptr %11, align 8, !tbaa !9
  %106 = load i64, ptr %11, align 8, !tbaa !9
  %107 = icmp sge i64 %106, 1000000007
  br i1 %107, label %108, label %111

108:                                              ; preds = %73
  %109 = load i64, ptr %11, align 8, !tbaa !9
  %110 = sub nsw i64 %109, 1000000007
  store i64 %110, ptr %11, align 8, !tbaa !9
  br label %111

111:                                              ; preds = %108, %73
  %112 = load i64, ptr %14, align 8, !tbaa !9
  %113 = load i64, ptr %12, align 8, !tbaa !9
  %114 = add nsw i64 %113, %112
  store i64 %114, ptr %12, align 8, !tbaa !9
  %115 = load i64, ptr %12, align 8, !tbaa !9
  %116 = icmp sge i64 %115, 1000000007
  br i1 %116, label %117, label %120

117:                                              ; preds = %111
  %118 = load i64, ptr %12, align 8, !tbaa !9
  %119 = sub nsw i64 %118, 1000000007
  store i64 %119, ptr %12, align 8, !tbaa !9
  br label %120

120:                                              ; preds = %117, %111
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %67, !llvm.loop !14

121:                                              ; preds = %67
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %122 = load i32, ptr %6, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [262144 x %"class.std::vector"], ptr @g, i64 0, i64 %123
  %125 = call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %124) #4
  %126 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %15, i32 0, i32 0
  store ptr %125, ptr %126, align 8
  br label %127

127:                                              ; preds = %148, %121
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %128 = load i32, ptr %6, align 4, !tbaa !5
  %129 = sext i32 %128 to i64
  %130 = getelementptr inbounds [262144 x %"class.std::vector"], ptr @g, i64 0, i64 %129
  %131 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %130) #4
  %132 = getelementptr inbounds %"class.__gnu_cxx::__normal_iterator", ptr %16, i32 0, i32 0
  store ptr %131, ptr %132, align 8
  %133 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %15, ptr noundef nonnull align 8 dereferenceable(8) %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  br i1 %133, label %135, label %134

134:                                              ; preds = %127
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %150

135:                                              ; preds = %127
  %136 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %15) #4
  %137 = load i32, ptr %136, align 4, !tbaa !5
  %138 = load i32, ptr %7, align 4, !tbaa !5
  %139 = icmp eq i32 %137, %138
  br i1 %139, label %140, label %141

140:                                              ; preds = %135
  br label %148

141:                                              ; preds = %135
  %142 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %15) #4
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = load i32, ptr %6, align 4, !tbaa !5
  %145 = load i64, ptr %11, align 8, !tbaa !9
  %146 = load i64, ptr %12, align 8, !tbaa !9
  %147 = load i64, ptr %10, align 8, !tbaa !9
  call void @_Z6updateiixxx(i32 noundef %143, i32 noundef %144, i64 noundef %145, i64 noundef %146, i64 noundef %147)
  br label %148

148:                                              ; preds = %141, %140
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %15) #4
  br label %127, !llvm.loop !16

150:                                              ; preds = %134
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorISt4pairIxxESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt4pairIxxESaIS1_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24)) #1 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #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 = { 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 = !{!12, !10, i64 0}
!12 = !{!"_ZTSSt4pairIxxE", !10, i64 0, !10, i64 8}
!13 = !{!12, !10, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.std::vector.10" = type { %"struct.std::_Vector_base.11" }
%"struct.std::_Vector_base.11" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::pair<long long, long long>, std::allocator<std::pair<long long, long long>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"class.__gnu_cxx::__normal_iterator" = type { ptr }

@g = external dso_local global [262144 x %"class.std::vector"], align 16
@c = external dso_local local_unnamed_addr global [262144 x i64], align 16
@up = external dso_local global [262144 x %"class.std::vector.10"], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6updateiixxx(i32 noundef %0, i32 noundef %1, i64 noundef %2, i64 noundef %3, i64 noundef %4) local_unnamed_addr #1 {
  %6 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %7 = alloca %"class.__gnu_cxx::__normal_iterator", align 8
  %8 = sext i32 %0 to i64
  %9 = getelementptr inbounds [262144 x i64], ptr @c, i64 0, i64 %8
  %10 = load i64, ptr %9, align 8, !tbaa !5
  %11 = add nsw i64 %10, %4
  %12 = icmp sgt i64 %11, 1000000006
  %13 = add nsw i64 %11, -1000000007
  %spec.select = select i1 %12, i64 %13, i64 %11
  %14 = add nsw i64 %spec.select, %2
  %15 = icmp sgt i64 %14, 1000000006
  %16 = add nsw i64 %14, -1000000007
  %storemerge51 = select i1 %15, i64 %16, i64 %14
  store i64 %storemerge51, ptr %9, align 8, !tbaa !5
  %17 = add nsw i64 %4, %2
  %18 = icmp sgt i64 %17, 1000000006
  %19 = add nsw i64 %17, -1000000007
  %.0 = select i1 %18, i64 %19, i64 %17
  %20 = add nsw i64 %3, %2
  %21 = srem i64 %20, 1000000007
  %22 = getelementptr inbounds [262144 x %"class.std::vector.10"], ptr @up, i64 0, i64 %8
  %23 = tail call noundef zeroext i1 @_ZNKSt6vectorISt4pairIxxESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %22) #3
  br i1 %23, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %5, %.lr.ph
  %.155 = phi i64 [ %33, %.lr.ph ], [ %.0, %5 ]
  %.03954 = phi i64 [ %spec.select52, %.lr.ph ], [ %21, %5 ]
  %.04153 = phi i64 [ %.142, %.lr.ph ], [ %2, %5 ]
  %24 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %22) #3
  %25 = load i64, ptr %24, align 8, !tbaa !9
  %26 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24) %22) #3
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  %28 = load i64, ptr %27, align 8, !tbaa !11
  tail call void @_ZNSt6vectorISt4pairIxxESaIS1_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24) %22) #3
  %29 = load i64, ptr %9, align 8, !tbaa !5
  %30 = add nsw i64 %29, %28
  %31 = srem i64 %30, 1000000007
  store i64 %31, ptr %9, align 8, !tbaa !5
  %32 = add nsw i64 %28, %.155
  %33 = srem i64 %32, 1000000007
  %34 = add nsw i64 %25, %.03954
  %35 = icmp sgt i64 %34, 1000000006
  %36 = add nsw i64 %34, -1000000007
  %spec.select52 = select i1 %35, i64 %36, i64 %34
  %37 = add nsw i64 %28, %.04153
  %38 = icmp sgt i64 %37, 1000000006
  %39 = add nsw i64 %37, -1000000007
  %.142 = select i1 %38, i64 %39, i64 %37
  %40 = tail call noundef zeroext i1 @_ZNKSt6vectorISt4pairIxxESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24) %22) #3
  br i1 %40, label %._crit_edge, label %.lr.ph, !llvm.loop !12

._crit_edge:                                      ; preds = %.lr.ph, %5
  %.041.lcssa = phi i64 [ %2, %5 ], [ %.142, %.lr.ph ]
  %.039.lcssa = phi i64 [ %21, %5 ], [ %spec.select52, %.lr.ph ]
  %.1.lcssa = phi i64 [ %.0, %5 ], [ %33, %.lr.ph ]
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  %41 = getelementptr inbounds [262144 x %"class.std::vector"], ptr @g, i64 0, i64 %8
  %42 = tail call ptr @_ZNSt6vectorIiSaIiEE5beginEv(ptr noundef nonnull align 8 dereferenceable(24) %41) #3
  store ptr %42, ptr %6, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  %43 = tail call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %41) #3
  store ptr %43, ptr %7, align 8
  %44 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  br i1 %44, label %.lr.ph59, label %._crit_edge60

._crit_edge60:                                    ; preds = %51, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  ret void

.lr.ph59:                                         ; preds = %._crit_edge, %51
  %45 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  %46 = load i32, ptr %45, align 4, !tbaa !14
  %47 = icmp eq i32 %46, %1
  br i1 %47, label %51, label %48

48:                                               ; preds = %.lr.ph59
  %49 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNK9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  %50 = load i32, ptr %49, align 4, !tbaa !14
  call void @_Z6updateiixxx(i32 noundef %50, i32 noundef %0, i64 noundef %.039.lcssa, i64 noundef %.041.lcssa, i64 noundef %.1.lcssa)
  br label %51

51:                                               ; preds = %.lr.ph59, %48
  %52 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZN9__gnu_cxx17__normal_iteratorIPiSt6vectorIiSaIiEEEppEv(ptr noundef nonnull align 8 dereferenceable(8) %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  %53 = call ptr @_ZNSt6vectorIiSaIiEE3endEv(ptr noundef nonnull align 8 dereferenceable(24) %41) #3
  store ptr %53, ptr %7, align 8
  %54 = call noundef zeroext i1 @_ZN9__gnu_cxxneIPiSt6vectorIiSaIiEEEEbRKNS_17__normal_iteratorIT_T0_EESA_(ptr noundef nonnull align 8 dereferenceable(8) %6, ptr noundef nonnull align 8 dereferenceable(8) %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  br i1 %54, label %.lr.ph59, label %._crit_edge60, !llvm.loop !16
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZNKSt6vectorISt4pairIxxESaIS1_EE5emptyEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorISt4pairIxxESaIS1_EE4backEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZNSt6vectorISt4pairIxxESaIS1_EE8pop_backEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #1 align 2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #3 = { nounwind }

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

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


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