; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/AIM Tech Division 1/Problem B/B.ll (Z5solvei)

; 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"

@inf = external dso_local global i64, align 8
@n = external dso_local global i32, align 4
@a = external dso_local global i64, align 8
@b = external dso_local global i64, align 8
@ans = external dso_local global i64, align 8
@arr = external dso_local global [1001000 x i32], align 16
@dp = external dso_local global [1001000 x [3 x i64]], align 16

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

15:                                               ; preds = %41, %1
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp sle i32 %16, %17
  br i1 %18, label %20, label %19

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

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

21:                                               ; preds = %37, %20
  %22 = load i32, ptr %6, align 4, !tbaa !5
  %23 = icmp sle i32 %22, 1
  br i1 %23, label %25, label %24

24:                                               ; preds = %21
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %40

25:                                               ; preds = %21
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [1001000 x i32], ptr @arr, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = add nsw i32 %29, %30
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = srem i32 %31, %32
  %34 = icmp eq i32 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %25
  store i8 1, ptr %3, align 1, !tbaa !9
  br label %36

36:                                               ; preds = %35, %25
  br label %37

37:                                               ; preds = %36
  %38 = load i32, ptr %6, align 4, !tbaa !5
  %39 = add nsw i32 %38, 1
  store i32 %39, ptr %6, align 4, !tbaa !5
  br label %21, !llvm.loop !11

40:                                               ; preds = %24
  br label %41

41:                                               ; preds = %40
  %42 = load i32, ptr %4, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %4, align 4, !tbaa !5
  br label %15, !llvm.loop !13

44:                                               ; preds = %19
  %45 = load i8, ptr %3, align 1, !tbaa !9, !range !14, !noundef !15
  %46 = trunc i8 %45 to i1
  br i1 %46, label %48, label %47

47:                                               ; preds = %44
  store i32 1, ptr %5, align 4
  br label %249

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

49:                                               ; preds = %63, %48
  %50 = load i32, ptr %7, align 4, !tbaa !5
  %51 = icmp sle i32 %50, 1
  br i1 %51, label %53, label %52

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

53:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %54 = load i32, ptr getelementptr inbounds ([1001000 x i32], ptr @arr, i64 0, i64 1), align 4, !tbaa !5
  %55 = load i32, ptr %7, align 4, !tbaa !5
  %56 = add nsw i32 %54, %55
  store i32 %56, ptr %8, align 4, !tbaa !5
  %57 = load i32, ptr %8, align 4, !tbaa !5
  %58 = load i32, ptr %2, align 4, !tbaa !5
  %59 = srem i32 %57, %58
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %53
  store i8 1, ptr %3, align 1, !tbaa !9
  br label %62

62:                                               ; preds = %61, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %7, align 4, !tbaa !5
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %7, align 4, !tbaa !5
  br label %49, !llvm.loop !16

66:                                               ; preds = %52
  %67 = load i8, ptr %3, align 1, !tbaa !9, !range !14, !noundef !15
  %68 = trunc i8 %67 to i1
  br i1 %68, label %70, label %69

69:                                               ; preds = %66
  store i32 1, ptr %5, align 4
  br label %249

70:                                               ; preds = %66
  %71 = load i32, ptr getelementptr inbounds ([1001000 x i32], ptr @arr, i64 0, i64 1), align 4, !tbaa !5
  %72 = load i32, ptr %2, align 4, !tbaa !5
  %73 = srem i32 %71, %72
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %76

75:                                               ; preds = %70
  br label %78

76:                                               ; preds = %70
  %77 = load i64, ptr @b, align 8, !tbaa !17
  br label %78

78:                                               ; preds = %76, %75
  %79 = phi i64 [ 0, %75 ], [ %77, %76 ]
  store i64 %79, ptr getelementptr inbounds ([1001000 x [3 x i64]], ptr @dp, i64 0, i64 1), align 8, !tbaa !17
  %80 = load i64, ptr @inf, align 8, !tbaa !17
  store i64 %80, ptr getelementptr inbounds ([3 x i64], ptr getelementptr inbounds ([1001000 x [3 x i64]], ptr @dp, i64 0, i64 1), i64 0, i64 1), align 8, !tbaa !17
  %81 = load i64, ptr getelementptr inbounds ([1001000 x [3 x i64]], ptr @dp, i64 0, i64 1), align 8, !tbaa !17
  store i64 %81, ptr getelementptr inbounds ([3 x i64], ptr getelementptr inbounds ([1001000 x [3 x i64]], ptr @dp, i64 0, i64 1), i64 0, i64 2), align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 2, ptr %9, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %229, %78
  %83 = load i32, ptr %9, align 4, !tbaa !5
  %84 = load i32, ptr @n, align 4, !tbaa !5
  %85 = icmp sle i32 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %232

87:                                               ; preds = %82
  %88 = load i64, ptr @inf, align 8, !tbaa !17
  %89 = load i32, ptr %9, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %90
  %92 = getelementptr inbounds [3 x i64], ptr %91, i64 0, i64 2
  store i64 %88, ptr %92, align 8, !tbaa !17
  %93 = load i32, ptr %9, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %94
  %96 = getelementptr inbounds [3 x i64], ptr %95, i64 0, i64 1
  store i64 %88, ptr %96, align 8, !tbaa !17
  %97 = load i32, ptr %9, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %98
  %100 = getelementptr inbounds [3 x i64], ptr %99, i64 0, i64 0
  store i64 %88, ptr %100, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 -1, ptr %10, align 4, !tbaa !5
  br label %101

101:                                              ; preds = %201, %87
  %102 = load i32, ptr %10, align 4, !tbaa !5
  %103 = icmp sle i32 %102, 1
  br i1 %103, label %105, label %104

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

105:                                              ; preds = %101
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %106 = load i32, ptr %9, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [1001000 x i32], ptr @arr, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = load i32, ptr %10, align 4, !tbaa !5
  %111 = add nsw i32 %109, %110
  store i32 %111, ptr %11, align 4, !tbaa !5
  %112 = load i32, ptr %11, align 4, !tbaa !5
  %113 = load i32, ptr %2, align 4, !tbaa !5
  %114 = srem i32 %112, %113
  %115 = icmp eq i32 %114, 0
  br i1 %115, label %116, label %200

116:                                              ; preds = %105
  %117 = load i32, ptr %10, align 4, !tbaa !5
  %118 = icmp eq i32 %117, 0
  br i1 %118, label %119, label %156

119:                                              ; preds = %116
  %120 = load i32, ptr %9, align 4, !tbaa !5
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %121
  %123 = getelementptr inbounds [3 x i64], ptr %122, i64 0, i64 0
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = sub nsw i32 %124, 1
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %126
  %128 = getelementptr inbounds [3 x i64], ptr %127, i64 0, i64 0
  %129 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %123, ptr noundef nonnull align 8 dereferenceable(8) %128)
  %130 = load i64, ptr %129, align 8, !tbaa !17
  %131 = load i32, ptr %9, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %132
  %134 = getelementptr inbounds [3 x i64], ptr %133, i64 0, i64 0
  store i64 %130, ptr %134, align 8, !tbaa !17
  %135 = load i32, ptr %9, align 4, !tbaa !5
  %136 = sext i32 %135 to i64
  %137 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %136
  %138 = getelementptr inbounds [3 x i64], ptr %137, i64 0, i64 2
  %139 = load i32, ptr %9, align 4, !tbaa !5
  %140 = sub nsw i32 %139, 1
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %141
  %143 = getelementptr inbounds [3 x i64], ptr %142, i64 0, i64 1
  %144 = load i32, ptr %9, align 4, !tbaa !5
  %145 = sub nsw i32 %144, 1
  %146 = sext i32 %145 to i64
  %147 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %146
  %148 = getelementptr inbounds [3 x i64], ptr %147, i64 0, i64 2
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %143, ptr noundef nonnull align 8 dereferenceable(8) %148)
  %150 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %138, ptr noundef nonnull align 8 dereferenceable(8) %149)
  %151 = load i64, ptr %150, align 8, !tbaa !17
  %152 = load i32, ptr %9, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %153
  %155 = getelementptr inbounds [3 x i64], ptr %154, i64 0, i64 2
  store i64 %151, ptr %155, align 8, !tbaa !17
  br label %199

156:                                              ; preds = %116
  %157 = load i32, ptr %9, align 4, !tbaa !5
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %158
  %160 = getelementptr inbounds [3 x i64], ptr %159, i64 0, i64 0
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %161 = load i32, ptr %9, align 4, !tbaa !5
  %162 = sub nsw i32 %161, 1
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %163
  %165 = getelementptr inbounds [3 x i64], ptr %164, i64 0, i64 0
  %166 = load i64, ptr %165, align 8, !tbaa !17
  %167 = load i64, ptr @b, align 8, !tbaa !17
  %168 = add nsw i64 %166, %167
  store i64 %168, ptr %12, align 8, !tbaa !17
  %169 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %160, ptr noundef nonnull align 8 dereferenceable(8) %12)
  %170 = load i64, ptr %169, align 8, !tbaa !17
  %171 = load i32, ptr %9, align 4, !tbaa !5
  %172 = sext i32 %171 to i64
  %173 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %172
  %174 = getelementptr inbounds [3 x i64], ptr %173, i64 0, i64 0
  store i64 %170, ptr %174, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  %175 = load i32, ptr %9, align 4, !tbaa !5
  %176 = sext i32 %175 to i64
  %177 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %176
  %178 = getelementptr inbounds [3 x i64], ptr %177, i64 0, i64 2
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #3
  %179 = load i32, ptr %9, align 4, !tbaa !5
  %180 = sub nsw i32 %179, 1
  %181 = sext i32 %180 to i64
  %182 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %181
  %183 = getelementptr inbounds [3 x i64], ptr %182, i64 0, i64 1
  %184 = load i32, ptr %9, align 4, !tbaa !5
  %185 = sub nsw i32 %184, 1
  %186 = sext i32 %185 to i64
  %187 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %186
  %188 = getelementptr inbounds [3 x i64], ptr %187, i64 0, i64 2
  %189 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %183, ptr noundef nonnull align 8 dereferenceable(8) %188)
  %190 = load i64, ptr %189, align 8, !tbaa !17
  %191 = load i64, ptr @b, align 8, !tbaa !17
  %192 = add nsw i64 %190, %191
  store i64 %192, ptr %13, align 8, !tbaa !17
  %193 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %178, ptr noundef nonnull align 8 dereferenceable(8) %13)
  %194 = load i64, ptr %193, align 8, !tbaa !17
  %195 = load i32, ptr %9, align 4, !tbaa !5
  %196 = sext i32 %195 to i64
  %197 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %196
  %198 = getelementptr inbounds [3 x i64], ptr %197, i64 0, i64 2
  store i64 %194, ptr %198, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  br label %199

199:                                              ; preds = %156, %119
  br label %200

200:                                              ; preds = %199, %105
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %201

201:                                              ; preds = %200
  %202 = load i32, ptr %10, align 4, !tbaa !5
  %203 = add nsw i32 %202, 1
  store i32 %203, ptr %10, align 4, !tbaa !5
  br label %101, !llvm.loop !19

204:                                              ; preds = %104
  %205 = load i32, ptr %9, align 4, !tbaa !5
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %206
  %208 = getelementptr inbounds [3 x i64], ptr %207, i64 0, i64 1
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #3
  %209 = load i32, ptr %9, align 4, !tbaa !5
  %210 = sub nsw i32 %209, 1
  %211 = sext i32 %210 to i64
  %212 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %211
  %213 = getelementptr inbounds [3 x i64], ptr %212, i64 0, i64 0
  %214 = load i32, ptr %9, align 4, !tbaa !5
  %215 = sub nsw i32 %214, 1
  %216 = sext i32 %215 to i64
  %217 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %216
  %218 = getelementptr inbounds [3 x i64], ptr %217, i64 0, i64 1
  %219 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %213, ptr noundef nonnull align 8 dereferenceable(8) %218)
  %220 = load i64, ptr %219, align 8, !tbaa !17
  %221 = load i64, ptr @a, align 8, !tbaa !17
  %222 = add nsw i64 %220, %221
  store i64 %222, ptr %14, align 8, !tbaa !17
  %223 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %208, ptr noundef nonnull align 8 dereferenceable(8) %14)
  %224 = load i64, ptr %223, align 8, !tbaa !17
  %225 = load i32, ptr %9, align 4, !tbaa !5
  %226 = sext i32 %225 to i64
  %227 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %226
  %228 = getelementptr inbounds [3 x i64], ptr %227, i64 0, i64 1
  store i64 %224, ptr %228, align 8, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #3
  br label %229

229:                                              ; preds = %204
  %230 = load i32, ptr %9, align 4, !tbaa !5
  %231 = add nsw i32 %230, 1
  store i32 %231, ptr %9, align 4, !tbaa !5
  br label %82, !llvm.loop !20

232:                                              ; preds = %86
  %233 = load i32, ptr @n, align 4, !tbaa !5
  %234 = sext i32 %233 to i64
  %235 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %234
  %236 = getelementptr inbounds [3 x i64], ptr %235, i64 0, i64 0
  %237 = load i32, ptr @n, align 4, !tbaa !5
  %238 = sext i32 %237 to i64
  %239 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %238
  %240 = getelementptr inbounds [3 x i64], ptr %239, i64 0, i64 1
  %241 = load i32, ptr @n, align 4, !tbaa !5
  %242 = sext i32 %241 to i64
  %243 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %242
  %244 = getelementptr inbounds [3 x i64], ptr %243, i64 0, i64 2
  %245 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %240, ptr noundef nonnull align 8 dereferenceable(8) %244)
  %246 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %236, ptr noundef nonnull align 8 dereferenceable(8) %245)
  %247 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %246)
  %248 = load i64, ptr %247, align 8, !tbaa !17
  store i64 %248, ptr @ans, align 8, !tbaa !17
  store i32 1, ptr %5, align 4
  br label %249

249:                                              ; preds = %232, %69, %47
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  ret void
}

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

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

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

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

@inf = external dso_local local_unnamed_addr global i64, align 8
@n = external dso_local local_unnamed_addr global i32, align 4
@a = external dso_local local_unnamed_addr global i64, align 8
@b = external dso_local local_unnamed_addr global i64, align 8
@ans = external dso_local global i64, align 8
@arr = external dso_local local_unnamed_addr global [1001000 x i32], align 16
@dp = external dso_local global [1001000 x [3 x i64]], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z5solvei(i32 noundef %0) local_unnamed_addr #0 {
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = load i32, ptr @n, align 4, !tbaa !5
  %.not56 = icmp slt i32 %5, 1
  br i1 %.not56, label %._crit_edge.thread, label %.preheader53.preheader

.preheader53.preheader:                           ; preds = %1
  %6 = add nuw i32 %5, 1
  %wide.trip.count = zext i32 %6 to i64
  br label %.preheader53

.preheader53:                                     ; preds = %.preheader53.preheader, %.preheader53
  %indvars.iv = phi i64 [ 1, %.preheader53.preheader ], [ %indvars.iv.next, %.preheader53 ]
  %.058 = phi i8 [ 0, %.preheader53.preheader ], [ %spec.select.2, %.preheader53 ]
  %7 = getelementptr inbounds [1001000 x i32], ptr @arr, i64 0, i64 %indvars.iv
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = add nsw i32 %8, -1
  %10 = srem i32 %9, %0
  %11 = icmp eq i32 %10, 0
  %12 = srem i32 %8, %0
  %13 = icmp eq i32 %12, 0
  %14 = add nsw i32 %8, 1
  %15 = srem i32 %14, %0
  %16 = icmp eq i32 %15, 0
  %17 = select i1 %16, i1 true, i1 %13
  %18 = select i1 %17, i1 true, i1 %11
  %spec.select.2 = select i1 %18, i8 1, i8 %.058
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.preheader53, !llvm.loop !9

._crit_edge:                                      ; preds = %.preheader53
  %19 = trunc nuw i8 %spec.select.2 to i1
  br i1 %19, label %20, label %._crit_edge.thread

20:                                               ; preds = %._crit_edge
  %21 = load i32, ptr getelementptr inbounds (i8, ptr @arr, i64 4), align 4, !tbaa !5
  %22 = srem i32 %21, %0
  %23 = icmp eq i32 %22, 0
  %24 = load i64, ptr @b, align 8
  %25 = select i1 %23, i64 0, i64 %24
  store i64 %25, ptr getelementptr inbounds (i8, ptr @dp, i64 24), align 8, !tbaa !11
  %26 = load i64, ptr @inf, align 8, !tbaa !11
  store i64 %26, ptr getelementptr inbounds (i8, ptr @dp, i64 32), align 16, !tbaa !11
  store i64 %25, ptr getelementptr inbounds (i8, ptr @dp, i64 40), align 8, !tbaa !11
  %.not5162 = icmp eq i32 %5, 1
  br i1 %.not5162, label %.._crit_edge65_crit_edge, label %.lr.ph

.._crit_edge65_crit_edge:                         ; preds = %20
  %.pre74 = zext nneg i32 %5 to i64
  br label %._crit_edge65

._crit_edge65:                                    ; preds = %86, %.._crit_edge65_crit_edge
  %.pre-phi = phi i64 [ %.pre74, %.._crit_edge65_crit_edge ], [ %94, %86 ]
  %27 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %.pre-phi
  %28 = getelementptr inbounds i8, ptr %27, i64 8
  %29 = getelementptr inbounds i8, ptr %27, i64 16
  %30 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %28, ptr noundef nonnull align 8 dereferenceable(8) %29)
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %27, ptr noundef nonnull align 8 dereferenceable(8) %30)
  %32 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) @ans, ptr noundef nonnull align 8 dereferenceable(8) %31)
  %33 = load i64, ptr %32, align 8, !tbaa !11
  store i64 %33, ptr @ans, align 8, !tbaa !11
  br label %._crit_edge.thread

.lr.ph:                                           ; preds = %20, %86
  %indvars.iv70 = phi i64 [ %indvars.iv.next71, %86 ], [ 2, %20 ]
  %34 = load i64, ptr @inf, align 8, !tbaa !11
  %35 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %indvars.iv70
  %36 = getelementptr inbounds i8, ptr %35, i64 16
  store i64 %34, ptr %36, align 8, !tbaa !11
  %37 = getelementptr inbounds i8, ptr %35, i64 8
  store i64 %34, ptr %37, align 8, !tbaa !11
  store i64 %34, ptr %35, align 8, !tbaa !11
  %38 = getelementptr inbounds [1001000 x i32], ptr @arr, i64 0, i64 %indvars.iv70
  %39 = add nsw i64 %indvars.iv70, -1
  %40 = getelementptr inbounds [1001000 x [3 x i64]], ptr @dp, i64 0, i64 %39
  %41 = getelementptr inbounds i8, ptr %40, i64 8
  %42 = getelementptr inbounds i8, ptr %40, i64 16
  %43 = load i32, ptr %38, align 4, !tbaa !5
  %44 = add nsw i32 %43, -1
  %45 = srem i32 %44, %0
  %46 = icmp eq i32 %45, 0
  br i1 %46, label %47, label %59

47:                                               ; preds = %.lr.ph
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %48 = load i64, ptr %40, align 8, !tbaa !11
  %49 = load i64, ptr @b, align 8, !tbaa !11
  %50 = add nsw i64 %49, %48
  store i64 %50, ptr %2, align 8, !tbaa !11
  %51 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %35, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %52 = load i64, ptr %51, align 8, !tbaa !11
  store i64 %52, ptr %35, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %53 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef nonnull align 8 dereferenceable(8) %42)
  %54 = load i64, ptr %53, align 8, !tbaa !11
  %55 = load i64, ptr @b, align 8, !tbaa !11
  %56 = add nsw i64 %55, %54
  store i64 %56, ptr %3, align 8, !tbaa !11
  %57 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %58 = load i64, ptr %57, align 8, !tbaa !11
  store i64 %58, ptr %36, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  %.pre = load i32, ptr %38, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %47, %.lr.ph
  %60 = phi i32 [ %.pre, %47 ], [ %43, %.lr.ph ]
  %61 = srem i32 %60, %0
  %62 = icmp eq i32 %61, 0
  br i1 %62, label %63, label %69

63:                                               ; preds = %59
  %64 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %35, ptr noundef nonnull align 8 dereferenceable(8) %40)
  %65 = load i64, ptr %64, align 8, !tbaa !11
  store i64 %65, ptr %35, align 8, !tbaa !11
  %66 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef nonnull align 8 dereferenceable(8) %42)
  %67 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef nonnull align 8 dereferenceable(8) %66)
  %68 = load i64, ptr %67, align 8, !tbaa !11
  store i64 %68, ptr %36, align 8, !tbaa !11
  %.pre73 = load i32, ptr %38, align 4, !tbaa !5
  br label %69

69:                                               ; preds = %63, %59
  %70 = phi i32 [ %.pre73, %63 ], [ %60, %59 ]
  %71 = add nsw i32 %70, 1
  %72 = srem i32 %71, %0
  %73 = icmp eq i32 %72, 0
  br i1 %73, label %74, label %86

74:                                               ; preds = %69
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #3
  %75 = load i64, ptr %40, align 8, !tbaa !11
  %76 = load i64, ptr @b, align 8, !tbaa !11
  %77 = add nsw i64 %76, %75
  store i64 %77, ptr %2, align 8, !tbaa !11
  %78 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %35, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %79 = load i64, ptr %78, align 8, !tbaa !11
  store i64 %79, ptr %35, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %80 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %41, ptr noundef nonnull align 8 dereferenceable(8) %42)
  %81 = load i64, ptr %80, align 8, !tbaa !11
  %82 = load i64, ptr @b, align 8, !tbaa !11
  %83 = add nsw i64 %82, %81
  store i64 %83, ptr %3, align 8, !tbaa !11
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %36, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %85 = load i64, ptr %84, align 8, !tbaa !11
  store i64 %85, ptr %36, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  br label %86

86:                                               ; preds = %74, %69
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #3
  %87 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %40, ptr noundef nonnull align 8 dereferenceable(8) %41)
  %88 = load i64, ptr %87, align 8, !tbaa !11
  %89 = load i64, ptr @a, align 8, !tbaa !11
  %90 = add nsw i64 %89, %88
  store i64 %90, ptr %4, align 8, !tbaa !11
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %37, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %92 = load i64, ptr %91, align 8, !tbaa !11
  store i64 %92, ptr %37, align 8, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #3
  %indvars.iv.next71 = add nuw nsw i64 %indvars.iv70, 1
  %93 = load i32, ptr @n, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %.not51.not = icmp slt i64 %indvars.iv70, %94
  br i1 %.not51.not, label %.lr.ph, label %._crit_edge65, !llvm.loop !13

._crit_edge.thread:                               ; preds = %1, %._crit_edge, %._crit_edge65
  ret void
}

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

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

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

attributes #0 = { 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 #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !12, i64 0}
!12 = !{!"long long", !7, i64 0}
!13 = distinct !{!13, !10}


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