; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/326 Division 2/Problem D (D)

; 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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree.0" }
%"class.std::_Rb_tree.0" = type { %"struct.std::_Rb_tree<long long, std::pair<const long long, long long>, std::_Select1st<std::pair<const long long, long long>>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, std::pair<const long long, long long>, std::_Select1st<std::pair<const long long, long long>>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"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" }
%"struct.std::pair" = type <{ %"struct.std::_Rb_tree_const_iterator", i8, [7 x i8] }>
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i64, align 8
@l = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@a = external dso_local global [1001000 x i64], align 16
@cont = external dso_local global [1001000 x i64], align 16
@MOD = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@comp = external dso_local global %"class.std::set", align 8
@f = external dso_local global %"class.std::map", align 8
@q = external dso_local global i64, align 8
@r = external dso_local global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", 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 i32, align 4
  %3 = alloca %"struct.std::pair", align 8
  %4 = alloca i64, align 8
  %5 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %6 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %7 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i64, align 8
  %19 = alloca i64, align 8
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %22 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %23 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %24 = getelementptr i8, ptr %23, i64 -24
  %25 = load i64, ptr %24, align 8
  %26 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %25
  %27 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %26, ptr noundef null)
  %28 = load ptr, ptr @_ZSt4cerr, align 8, !tbaa !5
  %29 = getelementptr i8, ptr %28, i64 -24
  %30 = load i64, ptr %29, align 8
  %31 = getelementptr inbounds i8, ptr @_ZSt4cerr, i64 %30
  %32 = call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %31, ptr noundef null)
  %33 = 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)
  %34 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %33, ptr noundef nonnull align 8 dereferenceable(8) @l)
  %35 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %34, ptr noundef nonnull align 8 dereferenceable(8) @k)
  %36 = load i64, ptr @l, align 8, !tbaa !8
  %37 = load i64, ptr @n, align 8, !tbaa !8
  %38 = sdiv i64 %36, %37
  store i64 %38, ptr @q, align 8, !tbaa !8
  %39 = load i64, ptr @l, align 8, !tbaa !8
  %40 = load i64, ptr @n, align 8, !tbaa !8
  %41 = srem i64 %39, %40
  store i64 %41, ptr @r, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !11
  br label %42

42:                                               ; preds = %61, %0
  %43 = load i32, ptr %2, align 4, !tbaa !11
  %44 = sext i32 %43 to i64
  %45 = load i64, ptr @n, align 8, !tbaa !8
  %46 = icmp slt i64 %44, %45
  br i1 %46, label %48, label %47

47:                                               ; preds = %42
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %64

48:                                               ; preds = %42
  %49 = load i32, ptr %2, align 4, !tbaa !11
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1001000 x i64], ptr @a, i64 0, i64 %50
  %52 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(8) %51)
  %53 = load i32, ptr %2, align 4, !tbaa !11
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [1001000 x i64], ptr @a, i64 0, i64 %54
  %56 = call { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertERKx(ptr noundef nonnull align 8 dereferenceable(48) @comp, ptr noundef nonnull align 8 dereferenceable(8) %55)
  %57 = getelementptr inbounds { ptr, i8 }, ptr %3, i32 0, i32 0
  %58 = extractvalue { ptr, i8 } %56, 0
  store ptr %58, ptr %57, align 8
  %59 = getelementptr inbounds { ptr, i8 }, ptr %3, i32 0, i32 1
  %60 = extractvalue { ptr, i8 } %56, 1
  store i8 %60, ptr %59, align 8
  br label %61

61:                                               ; preds = %48
  %62 = load i32, ptr %2, align 4, !tbaa !11
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %2, align 4, !tbaa !11
  br label %42, !llvm.loop !13

64:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #7
  store i64 0, ptr %4, align 8, !tbaa !8
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #7
  %65 = call ptr @_ZNKSt3setIxSt4lessIxESaIxEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #7
  %66 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %5, i32 0, i32 0
  store ptr %65, ptr %66, align 8
  br label %67

67:                                               ; preds = %77, %64
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #7
  %68 = call ptr @_ZNKSt3setIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #7
  %69 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %6, i32 0, i32 0
  store ptr %68, ptr %69, align 8
  %70 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef nonnull align 8 dereferenceable(8) %6) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #7
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #7
  br label %80

72:                                               ; preds = %67
  %73 = load i64, ptr %4, align 8, !tbaa !8
  %74 = add nsw i64 %73, 1
  store i64 %74, ptr %4, align 8, !tbaa !8
  %75 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %5) #7
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @f, ptr noundef nonnull align 8 dereferenceable(8) %75)
  store i64 %73, ptr %76, align 8, !tbaa !8
  br label %77

77:                                               ; preds = %72
  %78 = call ptr @_ZNSt23_Rb_tree_const_iteratorIxEppEi(ptr noundef nonnull align 8 dereferenceable(8) %5, i32 noundef 0) #7
  %79 = getelementptr inbounds %"struct.std::_Rb_tree_const_iterator", ptr %7, i32 0, i32 0
  store ptr %78, ptr %79, align 8
  br label %67, !llvm.loop !15

80:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #7
  store i32 0, ptr %8, align 4, !tbaa !11
  br label %81

81:                                               ; preds = %103, %80
  %82 = load i32, ptr %8, align 4, !tbaa !11
  %83 = sext i32 %82 to i64
  %84 = load i64, ptr @n, align 8, !tbaa !8
  %85 = icmp slt i64 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %81
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %106

87:                                               ; preds = %81
  %88 = load i32, ptr %8, align 4, !tbaa !11
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [1001000 x i64], ptr @a, i64 0, i64 %89
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @f, ptr noundef nonnull align 8 dereferenceable(8) %90)
  %92 = load i64, ptr %91, align 8, !tbaa !8
  %93 = load i32, ptr %8, align 4, !tbaa !11
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [1001000 x i64], ptr @a, i64 0, i64 %94
  store i64 %92, ptr %95, align 8, !tbaa !8
  %96 = load i32, ptr %8, align 4, !tbaa !11
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [1001000 x i64], ptr @a, i64 0, i64 %97
  %99 = load i64, ptr %98, align 8, !tbaa !8
  %100 = getelementptr inbounds [1001000 x i64], ptr @cont, i64 0, i64 %99
  %101 = load i64, ptr %100, align 8, !tbaa !8
  %102 = add nsw i64 %101, 1
  store i64 %102, ptr %100, align 8, !tbaa !8
  br label %103

103:                                              ; preds = %87
  %104 = load i32, ptr %8, align 4, !tbaa !11
  %105 = add nsw i32 %104, 1
  store i32 %105, ptr %8, align 4, !tbaa !11
  br label %81, !llvm.loop !16

106:                                              ; preds = %86
  %107 = load i64, ptr %4, align 8, !tbaa !8
  %108 = load i64, ptr @k, align 8, !tbaa !8
  %109 = add nsw i64 %108, 1
  %110 = call ptr @llvm.stacksave.p0()
  store ptr %110, ptr %9, align 8
  %111 = mul nuw i64 %107, %109
  %112 = alloca i64, i64 %111, align 16
  store i64 %107, ptr %10, align 8
  store i64 %109, ptr %11, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  store i32 0, ptr %12, align 4, !tbaa !11
  br label %113

113:                                              ; preds = %141, %106
  %114 = load i32, ptr %12, align 4, !tbaa !11
  %115 = sext i32 %114 to i64
  %116 = load i64, ptr %4, align 8, !tbaa !8
  %117 = icmp slt i64 %115, %116
  br i1 %117, label %119, label %118

118:                                              ; preds = %113
  store i32 11, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  br label %144

119:                                              ; preds = %113
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #7
  store i32 0, ptr %14, align 4, !tbaa !11
  br label %120

120:                                              ; preds = %137, %119
  %121 = load i32, ptr %14, align 4, !tbaa !11
  %122 = sext i32 %121 to i64
  %123 = load i64, ptr @k, align 8, !tbaa !8
  %124 = icmp sle i64 %122, %123
  br i1 %124, label %126, label %125

125:                                              ; preds = %120
  store i32 14, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #7
  br label %140

126:                                              ; preds = %120
  %127 = load i32, ptr %14, align 4, !tbaa !11
  %128 = icmp eq i32 %127, 0
  %129 = zext i1 %128 to i64
  %130 = load i32, ptr %12, align 4, !tbaa !11
  %131 = sext i32 %130 to i64
  %132 = mul nsw i64 %131, %109
  %133 = getelementptr inbounds i64, ptr %112, i64 %132
  %134 = load i32, ptr %14, align 4, !tbaa !11
  %135 = sext i32 %134 to i64
  %136 = getelementptr inbounds i64, ptr %133, i64 %135
  store i64 %129, ptr %136, align 8, !tbaa !8
  br label %137

137:                                              ; preds = %126
  %138 = load i32, ptr %14, align 4, !tbaa !11
  %139 = add nsw i32 %138, 1
  store i32 %139, ptr %14, align 4, !tbaa !11
  br label %120, !llvm.loop !17

140:                                              ; preds = %125
  br label %141

141:                                              ; preds = %140
  %142 = load i32, ptr %12, align 4, !tbaa !11
  %143 = add nsw i32 %142, 1
  store i32 %143, ptr %12, align 4, !tbaa !11
  br label %113, !llvm.loop !18

144:                                              ; preds = %118
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #7
  store i32 1, ptr %15, align 4, !tbaa !11
  br label %145

145:                                              ; preds = %196, %144
  %146 = load i32, ptr %15, align 4, !tbaa !11
  %147 = sext i32 %146 to i64
  %148 = load i64, ptr @k, align 8, !tbaa !8
  %149 = icmp sle i64 %147, %148
  br i1 %149, label %151, label %150

150:                                              ; preds = %145
  store i32 17, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #7
  br label %199

151:                                              ; preds = %145
  %152 = mul nsw i64 0, %109
  %153 = getelementptr inbounds i64, ptr %112, i64 %152
  %154 = load i32, ptr %15, align 4, !tbaa !11
  %155 = sub nsw i32 %154, 1
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds i64, ptr %153, i64 %156
  %158 = load i64, ptr %157, align 8, !tbaa !8
  %159 = load i64, ptr @cont, align 16, !tbaa !8
  %160 = mul nsw i64 %158, %159
  %161 = load i64, ptr @MOD, align 8, !tbaa !8
  %162 = srem i64 %160, %161
  %163 = mul nsw i64 0, %109
  %164 = getelementptr inbounds i64, ptr %112, i64 %163
  %165 = load i32, ptr %15, align 4, !tbaa !11
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds i64, ptr %164, i64 %166
  store i64 %162, ptr %167, align 8, !tbaa !8
  %168 = load i64, ptr @n, align 8, !tbaa !8
  %169 = load i32, ptr %15, align 4, !tbaa !11
  %170 = sext i32 %169 to i64
  %171 = mul nsw i64 %168, %170
  %172 = load i64, ptr @l, align 8, !tbaa !8
  %173 = icmp sle i64 %171, %172
  br i1 %173, label %174, label %195

174:                                              ; preds = %151
  %175 = load i64, ptr @ans, align 8, !tbaa !8
  %176 = mul nsw i64 0, %109
  %177 = getelementptr inbounds i64, ptr %112, i64 %176
  %178 = load i32, ptr %15, align 4, !tbaa !11
  %179 = sext i32 %178 to i64
  %180 = getelementptr inbounds i64, ptr %177, i64 %179
  %181 = load i64, ptr %180, align 8, !tbaa !8
  %182 = load i64, ptr @q, align 8, !tbaa !8
  %183 = load i32, ptr %15, align 4, !tbaa !11
  %184 = sext i32 %183 to i64
  %185 = sub nsw i64 %182, %184
  %186 = add nsw i64 %185, 1
  %187 = load i64, ptr @MOD, align 8, !tbaa !8
  %188 = srem i64 %186, %187
  %189 = mul nsw i64 %181, %188
  %190 = load i64, ptr @MOD, align 8, !tbaa !8
  %191 = srem i64 %189, %190
  %192 = add nsw i64 %175, %191
  %193 = load i64, ptr @MOD, align 8, !tbaa !8
  %194 = srem i64 %192, %193
  store i64 %194, ptr @ans, align 8, !tbaa !8
  br label %195

195:                                              ; preds = %174, %151
  br label %196

196:                                              ; preds = %195
  %197 = load i32, ptr %15, align 4, !tbaa !11
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %15, align 4, !tbaa !11
  br label %145, !llvm.loop !19

199:                                              ; preds = %150
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #7
  store i32 1, ptr %16, align 4, !tbaa !11
  br label %200

200:                                              ; preds = %278, %199
  %201 = load i32, ptr %16, align 4, !tbaa !11
  %202 = sext i32 %201 to i64
  %203 = load i64, ptr %4, align 8, !tbaa !8
  %204 = icmp slt i64 %202, %203
  br i1 %204, label %206, label %205

205:                                              ; preds = %200
  store i32 20, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #7
  br label %281

206:                                              ; preds = %200
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #7
  store i32 1, ptr %17, align 4, !tbaa !11
  br label %207

207:                                              ; preds = %274, %206
  %208 = load i32, ptr %17, align 4, !tbaa !11
  %209 = sext i32 %208 to i64
  %210 = load i64, ptr @k, align 8, !tbaa !8
  %211 = icmp sle i64 %209, %210
  br i1 %211, label %213, label %212

212:                                              ; preds = %207
  store i32 23, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #7
  br label %277

213:                                              ; preds = %207
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #7
  %214 = load i32, ptr %16, align 4, !tbaa !11
  %215 = sext i32 %214 to i64
  %216 = mul nsw i64 %215, %109
  %217 = getelementptr inbounds i64, ptr %112, i64 %216
  %218 = load i32, ptr %17, align 4, !tbaa !11
  %219 = sub nsw i32 %218, 1
  %220 = sext i32 %219 to i64
  %221 = getelementptr inbounds i64, ptr %217, i64 %220
  %222 = load i64, ptr %221, align 8, !tbaa !8
  %223 = load i32, ptr %16, align 4, !tbaa !11
  %224 = sext i32 %223 to i64
  %225 = getelementptr inbounds [1001000 x i64], ptr @cont, i64 0, i64 %224
  %226 = load i64, ptr %225, align 8, !tbaa !8
  %227 = mul nsw i64 %222, %226
  %228 = load i64, ptr @MOD, align 8, !tbaa !8
  %229 = srem i64 %227, %228
  store i64 %229, ptr %18, align 8, !tbaa !8
  %230 = load i32, ptr %16, align 4, !tbaa !11
  %231 = sub nsw i32 %230, 1
  %232 = sext i32 %231 to i64
  %233 = mul nsw i64 %232, %109
  %234 = getelementptr inbounds i64, ptr %112, i64 %233
  %235 = load i32, ptr %17, align 4, !tbaa !11
  %236 = sext i32 %235 to i64
  %237 = getelementptr inbounds i64, ptr %234, i64 %236
  %238 = load i64, ptr %237, align 8, !tbaa !8
  %239 = load i64, ptr %18, align 8, !tbaa !8
  %240 = add nsw i64 %238, %239
  %241 = load i64, ptr @MOD, align 8, !tbaa !8
  %242 = srem i64 %240, %241
  %243 = load i32, ptr %16, align 4, !tbaa !11
  %244 = sext i32 %243 to i64
  %245 = mul nsw i64 %244, %109
  %246 = getelementptr inbounds i64, ptr %112, i64 %245
  %247 = load i32, ptr %17, align 4, !tbaa !11
  %248 = sext i32 %247 to i64
  %249 = getelementptr inbounds i64, ptr %246, i64 %248
  store i64 %242, ptr %249, align 8, !tbaa !8
  %250 = load i32, ptr %17, align 4, !tbaa !11
  %251 = sext i32 %250 to i64
  %252 = load i64, ptr @n, align 8, !tbaa !8
  %253 = mul nsw i64 %251, %252
  %254 = load i64, ptr @l, align 8, !tbaa !8
  %255 = icmp sle i64 %253, %254
  br i1 %255, label %256, label %273

256:                                              ; preds = %213
  call void @llvm.lifetime.start.p0(i64 8, ptr %19) #7
  %257 = load i64, ptr %18, align 8, !tbaa !8
  %258 = load i64, ptr @q, align 8, !tbaa !8
  %259 = load i32, ptr %17, align 4, !tbaa !11
  %260 = sext i32 %259 to i64
  %261 = sub nsw i64 %258, %260
  %262 = add nsw i64 %261, 1
  %263 = load i64, ptr @MOD, align 8, !tbaa !8
  %264 = srem i64 %262, %263
  %265 = mul nsw i64 %257, %264
  %266 = load i64, ptr @MOD, align 8, !tbaa !8
  %267 = srem i64 %265, %266
  store i64 %267, ptr %19, align 8, !tbaa !8
  %268 = load i64, ptr @ans, align 8, !tbaa !8
  %269 = load i64, ptr %19, align 8, !tbaa !8
  %270 = add nsw i64 %268, %269
  %271 = load i64, ptr @MOD, align 8, !tbaa !8
  %272 = srem i64 %270, %271
  store i64 %272, ptr @ans, align 8, !tbaa !8
  call void @llvm.lifetime.end.p0(i64 8, ptr %19) #7
  br label %273

273:                                              ; preds = %256, %213
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #7
  br label %274

274:                                              ; preds = %273
  %275 = load i32, ptr %17, align 4, !tbaa !11
  %276 = add nsw i32 %275, 1
  store i32 %276, ptr %17, align 4, !tbaa !11
  br label %207, !llvm.loop !20

277:                                              ; preds = %212
  br label %278

278:                                              ; preds = %277
  %279 = load i32, ptr %16, align 4, !tbaa !11
  %280 = add nsw i32 %279, 1
  store i32 %280, ptr %16, align 4, !tbaa !11
  br label %200, !llvm.loop !21

281:                                              ; preds = %205
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #7
  store i32 0, ptr %20, align 4, !tbaa !11
  br label %282

282:                                              ; preds = %324, %281
  %283 = load i32, ptr %20, align 4, !tbaa !11
  %284 = sext i32 %283 to i64
  %285 = load i64, ptr @r, align 8, !tbaa !8
  %286 = icmp slt i64 %284, %285
  br i1 %286, label %288, label %287

287:                                              ; preds = %282
  store i32 26, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #7
  br label %327

288:                                              ; preds = %282
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #7
  store i32 1, ptr %21, align 4, !tbaa !11
  br label %289

289:                                              ; preds = %320, %288
  %290 = load i32, ptr %21, align 4, !tbaa !11
  %291 = sext i32 %290 to i64
  %292 = load i64, ptr @k, align 8, !tbaa !8
  %293 = icmp sle i64 %291, %292
  br i1 %293, label %295, label %294

294:                                              ; preds = %289
  store i32 29, ptr %13, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #7
  br label %323

295:                                              ; preds = %289
  %296 = load i32, ptr %21, align 4, !tbaa !11
  %297 = sub nsw i32 %296, 1
  %298 = sext i32 %297 to i64
  %299 = load i64, ptr @n, align 8, !tbaa !8
  %300 = mul nsw i64 %298, %299
  %301 = load i64, ptr @l, align 8, !tbaa !8
  %302 = icmp sle i64 %300, %301
  br i1 %302, label %303, label %319

303:                                              ; preds = %295
  %304 = load i64, ptr @ans, align 8, !tbaa !8
  %305 = load i32, ptr %20, align 4, !tbaa !11
  %306 = sext i32 %305 to i64
  %307 = getelementptr inbounds [1001000 x i64], ptr @a, i64 0, i64 %306
  %308 = load i64, ptr %307, align 8, !tbaa !8
  %309 = mul nsw i64 %308, %109
  %310 = getelementptr inbounds i64, ptr %112, i64 %309
  %311 = load i32, ptr %21, align 4, !tbaa !11
  %312 = sub nsw i32 %311, 1
  %313 = sext i32 %312 to i64
  %314 = getelementptr inbounds i64, ptr %310, i64 %313
  %315 = load i64, ptr %314, align 8, !tbaa !8
  %316 = add nsw i64 %304, %315
  %317 = load i64, ptr @MOD, align 8, !tbaa !8
  %318 = srem i64 %316, %317
  store i64 %318, ptr @ans, align 8, !tbaa !8
  br label %319

319:                                              ; preds = %303, %295
  br label %320

320:                                              ; preds = %319
  %321 = load i32, ptr %21, align 4, !tbaa !11
  %322 = add nsw i32 %321, 1
  store i32 %322, ptr %21, align 4, !tbaa !11
  br label %289, !llvm.loop !22

323:                                              ; preds = %294
  br label %324

324:                                              ; preds = %323
  %325 = load i32, ptr %20, align 4, !tbaa !11
  %326 = add nsw i32 %325, 1
  store i32 %326, ptr %20, align 4, !tbaa !11
  br label %282, !llvm.loop !23

327:                                              ; preds = %287
  %328 = load i64, ptr @ans, align 8, !tbaa !8
  %329 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %328)
  %330 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %329, i8 noundef signext 10)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %13, align 4
  %331 = load ptr, ptr %9, align 8
  call void @llvm.stackrestore.p0(ptr %331)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #7
  %332 = load i32, ptr %1, align 4
  ret i32 %332
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264), ptr noundef) #2 align 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: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertERKx(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) #3 align 2

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

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

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

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare ptr @llvm.stacksave.p0() #5

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

; 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

; Function Attrs: nocallback nofree nosync nounwind willreturn
declare void @llvm.stackrestore.p0(ptr) #5

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { nocallback nofree nosync nounwind willreturn }
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 = { 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 = !{!"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 = !{!"int", !10, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}
!17 = distinct !{!17, !14}
!18 = distinct !{!18, !14}
!19 = distinct !{!19, !14}
!20 = distinct !{!20, !14}
!21 = distinct !{!21, !14}
!22 = distinct !{!22, !14}
!23 = distinct !{!23, !14}


; 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::set" = type { %"class.std::_Rb_tree" }
%"class.std::_Rb_tree" = type { %"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, long long, std::_Identity<long long>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"struct.std::_Rb_tree_header" = type { %"struct.std::_Rb_tree_node_base", i64 }
%"struct.std::_Rb_tree_node_base" = type { i32, ptr, ptr, ptr }
%"class.std::map" = type { %"class.std::_Rb_tree.0" }
%"class.std::_Rb_tree.0" = type { %"struct.std::_Rb_tree<long long, std::pair<const long long, long long>, std::_Select1st<std::pair<const long long, long long>>, std::less<long long>>::_Rb_tree_impl" }
%"struct.std::_Rb_tree<long long, std::pair<const long long, long long>, std::_Select1st<std::pair<const long long, long long>>, std::less<long long>>::_Rb_tree_impl" = type { [8 x i8], %"struct.std::_Rb_tree_header" }
%"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" }
%"struct.std::_Rb_tree_const_iterator" = type { ptr }

@n = external dso_local global i64, align 8
@l = external dso_local global i64, align 8
@k = external dso_local global i64, align 8
@a = external dso_local global [1001000 x i64], align 16
@cont = external dso_local local_unnamed_addr global [1001000 x i64], align 16
@MOD = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local local_unnamed_addr global i64, align 8
@comp = external dso_local global %"class.std::set", align 8
@f = external dso_local global %"class.std::map", align 8
@q = external dso_local local_unnamed_addr global i64, align 8
@r = external dso_local local_unnamed_addr global i64, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cerr = external global %"class.std::basic_ostream", 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 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %2 = alloca %"struct.std::_Rb_tree_const_iterator", align 8
  %3 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %4 = load ptr, ptr @_ZSt3cin, align 8, !tbaa !5
  %5 = getelementptr i8, ptr %4, i64 -24
  %6 = load i64, ptr %5, align 8
  %7 = getelementptr inbounds i8, ptr @_ZSt3cin, i64 %6
  %8 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %7, ptr noundef null)
  %9 = load ptr, ptr @_ZSt4cerr, align 8, !tbaa !5
  %10 = getelementptr i8, ptr %9, i64 -24
  %11 = load i64, ptr %10, align 8
  %12 = getelementptr inbounds i8, ptr @_ZSt4cerr, i64 %11
  %13 = tail call noundef ptr @_ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo(ptr noundef nonnull align 8 dereferenceable(264) %12, ptr noundef null)
  %14 = 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)
  %15 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %14, ptr noundef nonnull align 8 dereferenceable(8) @l)
  %16 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERx(ptr noundef nonnull align 8 dereferenceable(16) %15, ptr noundef nonnull align 8 dereferenceable(8) @k)
  %17 = load i64, ptr @l, align 8, !tbaa !8
  %18 = load i64, ptr @n, align 8, !tbaa !8
  %19 = sdiv i64 %17, %18
  store i64 %19, ptr @q, align 8, !tbaa !8
  %20 = srem i64 %17, %18
  store i64 %20, ptr @r, align 8, !tbaa !8
  %21 = icmp sgt i64 %18, 0
  br i1 %21, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %0
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %1) #6
  %22 = tail call ptr @_ZNKSt3setIxSt4lessIxESaIxEE5beginEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #6
  store ptr %22, ptr %1, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %23 = tail call ptr @_ZNKSt3setIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #6
  store ptr %23, ptr %2, align 8
  %24 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  br i1 %24, label %.lr.ph84, label %._crit_edge85

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %0 ]
  %25 = getelementptr inbounds [1001000 x i64], ptr @a, i64 0, i64 %indvars.iv
  %26 = 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) %25)
  %27 = tail call { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertERKx(ptr noundef nonnull align 8 dereferenceable(48) @comp, ptr noundef nonnull align 8 dereferenceable(8) %25)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = load i64, ptr @n, align 8, !tbaa !8
  %29 = icmp sgt i64 %28, %indvars.iv.next
  br i1 %29, label %.lr.ph, label %._crit_edge, !llvm.loop !11

._crit_edge85:                                    ; preds = %.lr.ph84, %._crit_edge
  %.059.lcssa = phi i64 [ 0, %._crit_edge ], [ %32, %.lr.ph84 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %1) #6
  %30 = load i64, ptr @n, align 8, !tbaa !8
  %31 = icmp sgt i64 %30, 0
  br i1 %31, label %.lr.ph88, label %._crit_edge89

.lr.ph84:                                         ; preds = %._crit_edge, %.lr.ph84
  %.05982 = phi i64 [ %32, %.lr.ph84 ], [ 0, %._crit_edge ]
  %32 = add nuw nsw i64 %.05982, 1
  %33 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNKSt23_Rb_tree_const_iteratorIxEdeEv(ptr noundef nonnull align 8 dereferenceable(8) %1) #6
  %34 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @f, ptr noundef nonnull align 8 dereferenceable(8) %33)
  store i64 %.05982, ptr %34, align 8, !tbaa !8
  %35 = call ptr @_ZNSt23_Rb_tree_const_iteratorIxEppEi(ptr noundef nonnull align 8 dereferenceable(8) %1, i32 noundef 0) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #6
  %36 = call ptr @_ZNKSt3setIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48) @comp) #6
  store ptr %36, ptr %2, align 8
  %37 = call noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(ptr noundef nonnull align 8 dereferenceable(8) %1, ptr noundef nonnull align 8 dereferenceable(8) %2) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #6
  br i1 %37, label %.lr.ph84, label %._crit_edge85, !llvm.loop !13

._crit_edge89:                                    ; preds = %.lr.ph88, %._crit_edge85
  %.lcssa = phi i64 [ %30, %._crit_edge85 ], [ %48, %.lr.ph88 ]
  %38 = load i64, ptr @k, align 8, !tbaa !8
  %39 = add i64 %38, 1
  %40 = mul nuw i64 %39, %.059.lcssa
  %41 = alloca i64, i64 %40, align 16
  %.not124 = icmp eq i64 %.059.lcssa, 0
  br i1 %.not124, label %.preheader79, label %.preheader80.lr.ph

.preheader80.lr.ph:                               ; preds = %._crit_edge89
  %.not7491 = icmp slt i64 %38, 0
  br i1 %.not7491, label %.preheader76, label %.preheader80.preheader

.preheader80.preheader:                           ; preds = %.preheader80.lr.ph
  %min.iters.check = icmp ult i64 %39, 4
  %n.vec = and i64 %39, -4
  %cmp.n = icmp eq i64 %39, %n.vec
  br label %.preheader80

.lr.ph88:                                         ; preds = %._crit_edge85, %.lr.ph88
  %indvars.iv132 = phi i64 [ %indvars.iv.next133, %.lr.ph88 ], [ 0, %._crit_edge85 ]
  %42 = getelementptr inbounds [1001000 x i64], ptr @a, i64 0, i64 %indvars.iv132
  %43 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3mapIxxSt4lessIxESaISt4pairIKxxEEEixERS3_(ptr noundef nonnull align 8 dereferenceable(48) @f, ptr noundef nonnull align 8 dereferenceable(8) %42)
  %44 = load i64, ptr %43, align 8, !tbaa !8
  store i64 %44, ptr %42, align 8, !tbaa !8
  %45 = getelementptr inbounds [1001000 x i64], ptr @cont, i64 0, i64 %44
  %46 = load i64, ptr %45, align 8, !tbaa !8
  %47 = add nsw i64 %46, 1
  store i64 %47, ptr %45, align 8, !tbaa !8
  %indvars.iv.next133 = add nuw nsw i64 %indvars.iv132, 1
  %48 = load i64, ptr @n, align 8, !tbaa !8
  %49 = icmp sgt i64 %48, %indvars.iv.next133
  br i1 %49, label %.lr.ph88, label %._crit_edge89, !llvm.loop !14

.preheader80:                                     ; preds = %.preheader80.preheader, %._crit_edge94
  %indvars.iv138 = phi i64 [ %indvars.iv.next139, %._crit_edge94 ], [ 0, %.preheader80.preheader ]
  %50 = mul nuw nsw i64 %indvars.iv138, %39
  %51 = getelementptr inbounds i64, ptr %41, i64 %50
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.body

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader80
  %indvars.iv135.ph = phi i64 [ 0, %.preheader80 ], [ %n.vec, %middle.block ]
  br label %scalar.ph

vector.body:                                      ; preds = %.preheader80, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.preheader80 ]
  %vec.ind = phi <2 x i64> [ %vec.ind.next, %vector.body ], [ <i64 0, i64 1>, %.preheader80 ]
  %52 = icmp eq <2 x i64> %vec.ind, zeroinitializer
  %53 = icmp eq <2 x i64> %vec.ind, <i64 -2, i64 -2>
  %54 = zext <2 x i1> %52 to <2 x i64>
  %55 = zext <2 x i1> %53 to <2 x i64>
  %56 = getelementptr inbounds i64, ptr %51, i64 %index
  %57 = getelementptr inbounds i8, ptr %56, i64 16
  store <2 x i64> %54, ptr %56, align 8, !tbaa !8
  store <2 x i64> %55, ptr %57, align 8, !tbaa !8
  %index.next = add nuw i64 %index, 4
  %vec.ind.next = add <2 x i64> %vec.ind, <i64 4, i64 4>
  %58 = icmp eq i64 %index.next, %n.vec
  br i1 %58, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge94, label %scalar.ph.preheader

.preheader79:                                     ; preds = %._crit_edge94, %._crit_edge89
  %.not96 = icmp slt i64 %38, 1
  br i1 %.not96, label %.preheader78, label %.lr.ph98

.lr.ph98:                                         ; preds = %.preheader79
  %ans.promoted = load i64, ptr @ans, align 8, !tbaa !8
  %59 = load i64, ptr @cont, align 16, !tbaa !8
  %60 = load i64, ptr @MOD, align 8, !tbaa !8
  %61 = load i64, ptr @l, align 8, !tbaa !8
  %62 = load i64, ptr @q, align 8
  %load_initial183 = load i64, ptr %41, align 16
  br label %72

._crit_edge94:                                    ; preds = %scalar.ph, %middle.block
  %indvars.iv.next139 = add nuw nsw i64 %indvars.iv138, 1
  %exitcond141.not = icmp eq i64 %indvars.iv.next139, %.059.lcssa
  br i1 %exitcond141.not, label %.preheader79, label %.preheader80, !llvm.loop !18

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv135 = phi i64 [ %indvars.iv.next136, %scalar.ph ], [ %indvars.iv135.ph, %scalar.ph.preheader ]
  %63 = icmp eq i64 %indvars.iv135, 0
  %64 = zext i1 %63 to i64
  %65 = getelementptr inbounds i64, ptr %51, i64 %indvars.iv135
  store i64 %64, ptr %65, align 8, !tbaa !8
  %indvars.iv.next136 = add nuw nsw i64 %indvars.iv135, 1
  %exitcond = icmp eq i64 %indvars.iv135, %38
  br i1 %exitcond, label %._crit_edge94, label %scalar.ph, !llvm.loop !19

.preheader78:                                     ; preds = %85, %.preheader79
  %66 = icmp ugt i64 %.059.lcssa, 1
  br i1 %66, label %.preheader77.lr.ph, label %.preheader76

.preheader77.lr.ph:                               ; preds = %.preheader78
  %67 = load i64, ptr @MOD, align 8
  %68 = load i64, ptr @l, align 8
  %69 = load i64, ptr @q, align 8
  br i1 %.not96, label %.preheader76, label %.preheader77.preheader

.preheader77.preheader:                           ; preds = %.preheader77.lr.ph
  %ans.promoted104 = load i64, ptr @ans, align 8, !tbaa !8
  %70 = shl i64 %38, 3
  %71 = add i64 %70, 8
  br label %.preheader77

72:                                               ; preds = %.lr.ph98, %85
  %store_forwarded184 = phi i64 [ %load_initial183, %.lr.ph98 ], [ %76, %85 ]
  %indvars.iv145 = phi i64 [ 1, %.lr.ph98 ], [ %indvars.iv.next146, %85 ]
  %73 = phi i64 [ %ans.promoted, %.lr.ph98 ], [ %86, %85 ]
  %74 = getelementptr i64, ptr %41, i64 %indvars.iv145
  %75 = mul nsw i64 %59, %store_forwarded184
  %76 = srem i64 %75, %60
  store i64 %76, ptr %74, align 8, !tbaa !8
  %77 = mul nsw i64 %indvars.iv145, %.lcssa
  %.not73 = icmp sgt i64 %77, %61
  br i1 %.not73, label %85, label %78

78:                                               ; preds = %72
  %reass.sub = sub i64 %62, %indvars.iv145
  %79 = add i64 %reass.sub, 1
  %80 = srem i64 %79, %60
  %81 = mul nsw i64 %80, %76
  %82 = srem i64 %81, %60
  %83 = add nsw i64 %82, %73
  %84 = srem i64 %83, %60
  store i64 %84, ptr @ans, align 8, !tbaa !8
  br label %85

85:                                               ; preds = %72, %78
  %86 = phi i64 [ %73, %72 ], [ %84, %78 ]
  %indvars.iv.next146 = add nuw nsw i64 %indvars.iv145, 1
  %exitcond148 = icmp eq i64 %indvars.iv145, %38
  br i1 %exitcond148, label %.preheader78, label %72, !llvm.loop !20

.preheader77:                                     ; preds = %.preheader77.preheader, %._crit_edge103
  %indvar = phi i64 [ 0, %.preheader77.preheader ], [ %indvar.next, %._crit_edge103 ]
  %indvars.iv153 = phi i64 [ 1, %.preheader77.preheader ], [ %indvars.iv.next154, %._crit_edge103 ]
  %ans.promoted99108109 = phi i64 [ %ans.promoted104, %.preheader77.preheader ], [ %ans.promoted99105, %._crit_edge103 ]
  %87 = add i64 %indvar, 1
  %88 = mul i64 %71, %87
  %scevgep = getelementptr i8, ptr %41, i64 %88
  %89 = mul nuw nsw i64 %indvars.iv153, %39
  %90 = getelementptr inbounds i64, ptr %41, i64 %89
  %91 = getelementptr inbounds [1001000 x i64], ptr @cont, i64 0, i64 %indvars.iv153
  %92 = load i64, ptr %91, align 8, !tbaa !8
  %93 = add nsw i64 %indvars.iv153, -1
  %94 = mul nsw i64 %39, %93
  %95 = getelementptr inbounds i64, ptr %41, i64 %94
  %load_initial = load i64, ptr %scevgep, align 8
  br label %100

.preheader76:                                     ; preds = %._crit_edge103, %.preheader80.lr.ph, %.preheader77.lr.ph, %.preheader78
  %.not96172175 = phi i1 [ %.not96, %.preheader78 ], [ true, %.preheader77.lr.ph ], [ true, %.preheader80.lr.ph ], [ %.not96, %._crit_edge103 ]
  %96 = load i64, ptr @r, align 8, !tbaa !8
  %97 = icmp sgt i64 %96, 0
  %ans.promoted116 = load i64, ptr @ans, align 8, !tbaa !8
  br i1 %97, label %.preheader.lr.ph, label %._crit_edge123

.preheader.lr.ph:                                 ; preds = %.preheader76
  %98 = load i64, ptr @l, align 8
  %99 = load i64, ptr @MOD, align 8
  br i1 %.not96172175, label %._crit_edge123, label %.preheader

._crit_edge103:                                   ; preds = %117
  %indvars.iv.next154 = add nuw nsw i64 %indvars.iv153, 1
  %exitcond156.not = icmp eq i64 %indvars.iv.next154, %.059.lcssa
  %indvar.next = add i64 %indvar, 1
  br i1 %exitcond156.not, label %.preheader76, label %.preheader77, !llvm.loop !21

100:                                              ; preds = %.preheader77, %117
  %store_forwarded = phi i64 [ %load_initial, %.preheader77 ], [ %108, %117 ]
  %indvars.iv149 = phi i64 [ 1, %.preheader77 ], [ %indvars.iv.next150, %117 ]
  %ans.promoted99106 = phi i64 [ %ans.promoted99108109, %.preheader77 ], [ %ans.promoted99105, %117 ]
  %101 = phi i64 [ %ans.promoted99108109, %.preheader77 ], [ %118, %117 ]
  %102 = getelementptr i64, ptr %90, i64 %indvars.iv149
  %103 = mul nsw i64 %92, %store_forwarded
  %104 = srem i64 %103, %67
  %105 = getelementptr inbounds i64, ptr %95, i64 %indvars.iv149
  %106 = load i64, ptr %105, align 8, !tbaa !8
  %107 = add nsw i64 %106, %104
  %108 = srem i64 %107, %67
  store i64 %108, ptr %102, align 8, !tbaa !8
  %109 = mul nsw i64 %indvars.iv149, %.lcssa
  %.not72 = icmp sgt i64 %109, %68
  br i1 %.not72, label %117, label %110

110:                                              ; preds = %100
  %reass.sub125 = sub i64 %69, %indvars.iv149
  %111 = add i64 %reass.sub125, 1
  %112 = srem i64 %111, %67
  %113 = mul nsw i64 %112, %104
  %114 = srem i64 %113, %67
  %115 = add nsw i64 %101, %114
  %116 = srem i64 %115, %67
  store i64 %116, ptr @ans, align 8, !tbaa !8
  br label %117

117:                                              ; preds = %110, %100
  %ans.promoted99105 = phi i64 [ %116, %110 ], [ %ans.promoted99106, %100 ]
  %118 = phi i64 [ %116, %110 ], [ %101, %100 ]
  %indvars.iv.next150 = add nuw nsw i64 %indvars.iv149, 1
  %exitcond152 = icmp eq i64 %indvars.iv149, %38
  br i1 %exitcond152, label %._crit_edge103, label %100, !llvm.loop !22

.preheader:                                       ; preds = %.preheader.lr.ph, %._crit_edge115
  %indvars.iv164 = phi i64 [ %indvars.iv.next165, %._crit_edge115 ], [ 0, %.preheader.lr.ph ]
  %ans.promoted111120121 = phi i64 [ %ans.promoted111117, %._crit_edge115 ], [ %ans.promoted116, %.preheader.lr.ph ]
  %119 = getelementptr inbounds [1001000 x i64], ptr @a, i64 0, i64 %indvars.iv164
  br label %123

._crit_edge123:                                   ; preds = %._crit_edge115, %.preheader76, %.preheader.lr.ph
  %120 = phi i64 [ %ans.promoted116, %.preheader.lr.ph ], [ %ans.promoted116, %.preheader76 ], [ %ans.promoted111117, %._crit_edge115 ]
  %121 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %120)
  %122 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_c(ptr noundef nonnull align 8 dereferenceable(8) %121, i8 noundef signext 10)
  ret i32 0

._crit_edge115:                                   ; preds = %135
  %indvars.iv.next165 = add nuw nsw i64 %indvars.iv164, 1
  %exitcond167.not = icmp eq i64 %indvars.iv.next165, %96
  br i1 %exitcond167.not, label %._crit_edge123, label %.preheader, !llvm.loop !23

123:                                              ; preds = %.preheader, %135
  %indvars.iv160 = phi i64 [ 1, %.preheader ], [ %indvars.iv.next161, %135 ]
  %ans.promoted111118 = phi i64 [ %ans.promoted111120121, %.preheader ], [ %ans.promoted111117, %135 ]
  %124 = phi i64 [ %ans.promoted111120121, %.preheader ], [ %136, %135 ]
  %125 = add nsw i64 %indvars.iv160, -1
  %126 = mul nsw i64 %.lcssa, %125
  %.not70 = icmp sgt i64 %126, %98
  br i1 %.not70, label %135, label %127

127:                                              ; preds = %123
  %128 = load i64, ptr %119, align 8, !tbaa !8
  %129 = mul nsw i64 %128, %39
  %130 = getelementptr inbounds i64, ptr %41, i64 %129
  %131 = getelementptr inbounds i64, ptr %130, i64 %125
  %132 = load i64, ptr %131, align 8, !tbaa !8
  %133 = add nsw i64 %132, %124
  %134 = srem i64 %133, %99
  store i64 %134, ptr @ans, align 8, !tbaa !8
  br label %135

135:                                              ; preds = %123, %127
  %ans.promoted111117 = phi i64 [ %ans.promoted111118, %123 ], [ %134, %127 ]
  %136 = phi i64 [ %124, %123 ], [ %134, %127 ]
  %indvars.iv.next161 = add nuw nsw i64 %indvars.iv160, 1
  %exitcond163 = icmp eq i64 %indvars.iv160, %38
  br i1 %exitcond163, label %._crit_edge115, label %123, !llvm.loop !24
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #1

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

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

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

; Function Attrs: mustprogress uwtable
declare dso_local { ptr, i8 } @_ZNSt3setIxSt4lessIxESaIxEE6insertERKx(ptr noundef nonnull align 8 dereferenceable(48), ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZStneRKSt23_Rb_tree_const_iteratorIxES2_(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 @_ZNKSt3setIxSt4lessIxESaIxEE3endEv(ptr noundef nonnull align 8 dereferenceable(48)) local_unnamed_addr #2 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local ptr @_ZNSt23_Rb_tree_const_iteratorIxEppEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #2 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 #5

; 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 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 #6 = { 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 = !{!"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 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = distinct !{!15, !12, !16, !17}
!16 = !{!"llvm.loop.isvectorized", i32 1}
!17 = !{!"llvm.loop.unroll.runtime.disable"}
!18 = distinct !{!18, !12}
!19 = distinct !{!19, !12, !17, !16}
!20 = distinct !{!20, !12}
!21 = distinct !{!21, !12}
!22 = distinct !{!22, !12}
!23 = distinct !{!23, !12}
!24 = distinct !{!24, !12}


; Effective O3 passes: ADCEPass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass