; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/LTIME/LTIME28/Problem A (A)

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [5001 x i64], align 16
@dp = external dso_local global [5001 x [2 x [2 x i64]]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; 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: mustprogress uwtable
declare dso_local void @_Z6updateiiixiii(i32 noundef, i32 noundef, i32 noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5queryiiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %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
  store i32 0, ptr %1, align 4
  %9 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @t)
  br label %10

10:                                               ; preds = %203, %0
  %11 = load i32, ptr @t, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @t, align 4, !tbaa !5
  %13 = icmp ne i32 %11, 0
  br i1 %13, label %14, label %225

14:                                               ; preds = %10
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @n, ptr noundef @k)
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @d, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %47, %14
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = load i32, ptr @n, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %22, label %21

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

22:                                               ; preds = %17
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds i64, ptr @a, i64 %24
  %26 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %25)
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %28
  %30 = getelementptr inbounds [2 x [2 x i64]], ptr %29, i64 0, i64 1
  %31 = getelementptr inbounds [2 x i64], ptr %30, i64 0, i64 0
  store i64 0, ptr %31, align 16, !tbaa !9
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %33
  %35 = getelementptr inbounds [2 x [2 x i64]], ptr %34, i64 0, i64 0
  %36 = getelementptr inbounds [2 x i64], ptr %35, i64 0, i64 0
  store i64 0, ptr %36, align 16, !tbaa !9
  %37 = load i32, ptr %2, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %38
  %40 = getelementptr inbounds [2 x [2 x i64]], ptr %39, i64 0, i64 1
  %41 = getelementptr inbounds [2 x i64], ptr %40, i64 0, i64 1
  store i64 0, ptr %41, align 8, !tbaa !9
  %42 = load i32, ptr %2, align 4, !tbaa !5
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %43
  %45 = getelementptr inbounds [2 x [2 x i64]], ptr %44, i64 0, i64 0
  %46 = getelementptr inbounds [2 x i64], ptr %45, i64 0, i64 1
  store i64 0, ptr %46, align 8, !tbaa !9
  br label %47

47:                                               ; preds = %22
  %48 = load i32, ptr %2, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %2, align 4, !tbaa !5
  br label %17, !llvm.loop !11

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

51:                                               ; preds = %59, %50
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = load i32, ptr @k, align 4, !tbaa !5
  %54 = icmp sle i32 %52, %53
  br i1 %54, label %56, label %55

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

56:                                               ; preds = %51
  %57 = load i32, ptr %3, align 4, !tbaa !5
  %58 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z5buildiiii(i32 noundef %57, i32 noundef 1, i32 noundef 0, i32 noundef %58)
  br label %59

59:                                               ; preds = %56
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = add nsw i32 %60, 1
  store i32 %61, ptr %3, align 4, !tbaa !5
  br label %51, !llvm.loop !13

62:                                               ; preds = %55
  %63 = load i64, ptr @a, align 16, !tbaa !9
  store i64 %63, ptr @dp, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #5
  store i32 1, ptr %4, align 4, !tbaa !5
  br label %64

64:                                               ; preds = %87, %62
  %65 = load i32, ptr %4, align 4, !tbaa !5
  %66 = load i32, ptr @n, align 4, !tbaa !5
  %67 = icmp slt i32 %65, %66
  br i1 %67, label %69, label %68

68:                                               ; preds = %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #5
  br label %90

69:                                               ; preds = %64
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = sub nsw i32 %70, 1
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %72
  %74 = getelementptr inbounds [2 x [2 x i64]], ptr %73, i64 0, i64 0
  %75 = getelementptr inbounds [2 x i64], ptr %74, i64 0, i64 0
  %76 = load i64, ptr %75, align 16, !tbaa !9
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %78
  %80 = load i64, ptr %79, align 8, !tbaa !9
  %81 = add nsw i64 %76, %80
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %83
  %85 = getelementptr inbounds [2 x [2 x i64]], ptr %84, i64 0, i64 0
  %86 = getelementptr inbounds [2 x i64], ptr %85, i64 0, i64 0
  store i64 %81, ptr %86, align 16, !tbaa !9
  br label %87

87:                                               ; preds = %69
  %88 = load i32, ptr %4, align 4, !tbaa !5
  %89 = add nsw i32 %88, 1
  store i32 %89, ptr %4, align 4, !tbaa !5
  br label %64, !llvm.loop !14

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

91:                                               ; preds = %200, %90
  %92 = load i32, ptr %5, align 4, !tbaa !5
  %93 = load i32, ptr @k, align 4, !tbaa !5
  %94 = icmp sle i32 %92, %93
  br i1 %94, label %96, label %95

95:                                               ; preds = %91
  store i32 13, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %203

96:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %97 = load i32, ptr %5, align 4, !tbaa !5
  %98 = and i32 %97, 1
  store i32 %98, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  %99 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %99, ptr %8, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %196, %96
  %101 = load i32, ptr %8, align 4, !tbaa !5
  %102 = load i32, ptr @n, align 4, !tbaa !5
  %103 = icmp slt i32 %101, %102
  br i1 %103, label %105, label %104

104:                                              ; preds = %100
  store i32 16, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %199

105:                                              ; preds = %100
  %106 = load i32, ptr %8, align 4, !tbaa !5
  %107 = load i32, ptr @d, align 4, !tbaa !5
  %108 = sub nsw i32 %106, %107
  %109 = icmp sle i32 %108, 0
  br i1 %109, label %110, label %121

110:                                              ; preds = %105
  %111 = load i32, ptr %5, align 4, !tbaa !5
  %112 = load i32, ptr %8, align 4, !tbaa !5
  %113 = load i32, ptr %8, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %114
  %116 = load i64, ptr %115, align 8, !tbaa !9
  %117 = load i32, ptr @m, align 4, !tbaa !5
  %118 = sext i32 %117 to i64
  %119 = mul nsw i64 %116, %118
  %120 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z6updateiiixiii(i32 noundef %111, i32 noundef 0, i32 noundef %112, i64 noundef %119, i32 noundef 1, i32 noundef 0, i32 noundef %120)
  br label %144

121:                                              ; preds = %105
  %122 = load i32, ptr %5, align 4, !tbaa !5
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = load i32, ptr @d, align 4, !tbaa !5
  %125 = sub nsw i32 %123, %124
  %126 = load i32, ptr %8, align 4, !tbaa !5
  %127 = load i32, ptr %8, align 4, !tbaa !5
  %128 = sext i32 %127 to i64
  %129 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %128
  %130 = load i64, ptr %129, align 8, !tbaa !9
  %131 = load i32, ptr @m, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = mul nsw i64 %130, %132
  %134 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z6updateiiixiii(i32 noundef %122, i32 noundef %125, i32 noundef %126, i64 noundef %133, i32 noundef 1, i32 noundef 0, i32 noundef %134)
  %135 = load i32, ptr %5, align 4, !tbaa !5
  %136 = load i32, ptr %8, align 4, !tbaa !5
  %137 = load i32, ptr @d, align 4, !tbaa !5
  %138 = sub nsw i32 %136, %137
  %139 = load i32, ptr %8, align 4, !tbaa !5
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %140
  %142 = load i64, ptr %141, align 8, !tbaa !9
  %143 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z6updateiiixiii(i32 noundef %135, i32 noundef 0, i32 noundef %138, i64 noundef %142, i32 noundef 1, i32 noundef 0, i32 noundef %143)
  br label %144

144:                                              ; preds = %121, %110
  %145 = load i32, ptr %5, align 4, !tbaa !5
  %146 = load i32, ptr %8, align 4, !tbaa !5
  %147 = load i32, ptr @n, align 4, !tbaa !5
  %148 = call noundef i64 @_Z5queryiiiiii(i32 noundef %145, i32 noundef 0, i32 noundef %146, i32 noundef 1, i32 noundef 0, i32 noundef %147)
  %149 = load i32, ptr %8, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %150
  %152 = load i32, ptr %7, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [2 x [2 x i64]], ptr %151, i64 0, i64 %153
  %155 = getelementptr inbounds [2 x i64], ptr %154, i64 0, i64 0
  store i64 %148, ptr %155, align 16, !tbaa !9
  %156 = load i32, ptr %8, align 4, !tbaa !5
  %157 = sub nsw i32 %156, 1
  %158 = sext i32 %157 to i64
  %159 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %158
  %160 = load i32, ptr %7, align 4, !tbaa !5
  %161 = sub nsw i32 1, %160
  %162 = sext i32 %161 to i64
  %163 = getelementptr inbounds [2 x [2 x i64]], ptr %159, i64 0, i64 %162
  %164 = getelementptr inbounds [2 x i64], ptr %163, i64 0, i64 0
  %165 = load i32, ptr %8, align 4, !tbaa !5
  %166 = sub nsw i32 %165, 1
  %167 = sext i32 %166 to i64
  %168 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %167
  %169 = load i32, ptr %7, align 4, !tbaa !5
  %170 = sub nsw i32 1, %169
  %171 = sext i32 %170 to i64
  %172 = getelementptr inbounds [2 x [2 x i64]], ptr %168, i64 0, i64 %171
  %173 = getelementptr inbounds [2 x i64], ptr %172, i64 0, i64 1
  %174 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %164, ptr noundef nonnull align 8 dereferenceable(8) %173)
  %175 = load i64, ptr %174, align 8, !tbaa !9
  %176 = load i32, ptr %8, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %177
  %179 = load i32, ptr %7, align 4, !tbaa !5
  %180 = sext i32 %179 to i64
  %181 = getelementptr inbounds [2 x [2 x i64]], ptr %178, i64 0, i64 %180
  %182 = getelementptr inbounds [2 x i64], ptr %181, i64 0, i64 1
  store i64 %175, ptr %182, align 8, !tbaa !9
  %183 = load i32, ptr %5, align 4, !tbaa !5
  %184 = load i32, ptr %8, align 4, !tbaa !5
  %185 = load i32, ptr %8, align 4, !tbaa !5
  %186 = add nsw i32 %185, 1
  %187 = load i32, ptr %8, align 4, !tbaa !5
  %188 = sext i32 %187 to i64
  %189 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %188
  %190 = load i32, ptr %7, align 4, !tbaa !5
  %191 = sext i32 %190 to i64
  %192 = getelementptr inbounds [2 x [2 x i64]], ptr %189, i64 0, i64 %191
  %193 = getelementptr inbounds [2 x i64], ptr %192, i64 0, i64 1
  %194 = load i64, ptr %193, align 8, !tbaa !9
  %195 = load i32, ptr @n, align 4, !tbaa !5
  call void @_Z6updateiiixiii(i32 noundef %183, i32 noundef %184, i32 noundef %186, i64 noundef %194, i32 noundef 1, i32 noundef 0, i32 noundef %195)
  br label %196

196:                                              ; preds = %144
  %197 = load i32, ptr %8, align 4, !tbaa !5
  %198 = add nsw i32 %197, 1
  store i32 %198, ptr %8, align 4, !tbaa !5
  br label %100, !llvm.loop !15

199:                                              ; preds = %104
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %200

200:                                              ; preds = %199
  %201 = load i32, ptr %5, align 4, !tbaa !5
  %202 = add nsw i32 %201, 1
  store i32 %202, ptr %5, align 4, !tbaa !5
  br label %91, !llvm.loop !16

203:                                              ; preds = %95
  %204 = load i32, ptr @n, align 4, !tbaa !5
  %205 = sub nsw i32 %204, 1
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %206
  %208 = load i32, ptr @k, align 4, !tbaa !5
  %209 = srem i32 %208, 2
  %210 = sext i32 %209 to i64
  %211 = getelementptr inbounds [2 x [2 x i64]], ptr %207, i64 0, i64 %210
  %212 = getelementptr inbounds [2 x i64], ptr %211, i64 0, i64 0
  %213 = load i32, ptr @n, align 4, !tbaa !5
  %214 = sub nsw i32 %213, 1
  %215 = sext i32 %214 to i64
  %216 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %215
  %217 = load i32, ptr @k, align 4, !tbaa !5
  %218 = srem i32 %217, 2
  %219 = sext i32 %218 to i64
  %220 = getelementptr inbounds [2 x [2 x i64]], ptr %216, i64 0, i64 %219
  %221 = getelementptr inbounds [2 x i64], ptr %220, i64 0, i64 1
  %222 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %212, ptr noundef nonnull align 8 dereferenceable(8) %221)
  %223 = load i64, ptr %222, align 8, !tbaa !9
  %224 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %223)
  br label %10, !llvm.loop !17

225:                                              ; preds = %10
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #4

declare i32 @printf(ptr noundef, ...) #4

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 = { 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 #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #5 = { nounwind }

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

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

@t = external dso_local global i32, align 4
@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@d = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [5001 x i64], align 16
@dp = external dso_local global [5001 x [2 x [2 x i64]]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z5buildiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z6updateiiixiii(i32 noundef, i32 noundef, i32 noundef, i64 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z5queryiiiiii(i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @t)
  %2 = load i32, ptr @t, align 4, !tbaa !5
  %3 = add nsw i32 %2, -1
  store i32 %3, ptr @t, align 4, !tbaa !5
  %.not72 = icmp eq i32 %2, 0
  br i1 %.not72, label %._crit_edge75, label %.lr.ph74

.lr.ph74:                                         ; preds = %0, %._crit_edge71
  %4 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @n, ptr noundef nonnull @k)
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @d, ptr noundef nonnull @m)
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %.preheader56

.preheader56:                                     ; preds = %.lr.ph, %.lr.ph74
  %8 = phi i32 [ %6, %.lr.ph74 ], [ %13, %.lr.ph ]
  %9 = load i32, ptr @k, align 4, !tbaa !5
  %.not5458 = icmp slt i32 %9, 1
  br i1 %.not5458, label %._crit_edge, label %.lr.ph60

.lr.ph:                                           ; preds = %.lr.ph74, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph74 ]
  %10 = getelementptr inbounds i64, ptr @a, i64 %indvars.iv
  %11 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %10)
  %12 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(32) %12, i8 0, i64 32, i1 false)
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = sext i32 %13 to i64
  %15 = icmp slt i64 %indvars.iv.next, %14
  br i1 %15, label %.lr.ph, label %.preheader56, !llvm.loop !9

._crit_edge.loopexit:                             ; preds = %.lr.ph60
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader56
  %16 = phi i32 [ %25, %._crit_edge.loopexit ], [ %9, %.preheader56 ]
  %17 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %8, %.preheader56 ]
  %18 = load i64, ptr @a, align 16, !tbaa !11
  store i64 %18, ptr @dp, align 16, !tbaa !11
  %19 = icmp sgt i32 %17, 1
  br i1 %19, label %.lr.ph63.preheader, label %.preheader

.lr.ph63.preheader:                               ; preds = %._crit_edge
  %wide.trip.count = zext nneg i32 %17 to i64
  %20 = add nsw i64 %wide.trip.count, -1
  %21 = add nsw i64 %wide.trip.count, -2
  %xtraiter = and i64 %20, 3
  %22 = icmp ult i64 %21, 3
  br i1 %22, label %.preheader.loopexit.unr-lcssa, label %.lr.ph63.preheader.new

.lr.ph63.preheader.new:                           ; preds = %.lr.ph63.preheader
  %unroll_iter = and i64 %20, -4
  br label %.lr.ph63

.lr.ph60:                                         ; preds = %.preheader56, %.lr.ph60
  %.05059 = phi i32 [ %24, %.lr.ph60 ], [ 1, %.preheader56 ]
  %23 = load i32, ptr @n, align 4, !tbaa !5
  tail call void @_Z5buildiiii(i32 noundef %.05059, i32 noundef 1, i32 noundef 0, i32 noundef %23)
  %24 = add nuw nsw i32 %.05059, 1
  %25 = load i32, ptr @k, align 4, !tbaa !5
  %.not54.not = icmp slt i32 %.05059, %25
  br i1 %.not54.not, label %.lr.ph60, label %._crit_edge.loopexit, !llvm.loop !13

.preheader.loopexit.unr-lcssa:                    ; preds = %.lr.ph63, %.lr.ph63.preheader
  %.unr = phi i64 [ %18, %.lr.ph63.preheader ], [ %46, %.lr.ph63 ]
  %indvars.iv78.unr = phi i64 [ 1, %.lr.ph63.preheader ], [ %indvars.iv.next79.3, %.lr.ph63 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.lr.ph63.epil

.lr.ph63.epil:                                    ; preds = %.preheader.loopexit.unr-lcssa, %.lr.ph63.epil
  %26 = phi i64 [ %29, %.lr.ph63.epil ], [ %.unr, %.preheader.loopexit.unr-lcssa ]
  %indvars.iv78.epil = phi i64 [ %indvars.iv.next79.epil, %.lr.ph63.epil ], [ %indvars.iv78.unr, %.preheader.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph63.epil ], [ 0, %.preheader.loopexit.unr-lcssa ]
  %27 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %indvars.iv78.epil
  %28 = load i64, ptr %27, align 8, !tbaa !11
  %29 = add nsw i64 %28, %26
  %30 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv78.epil
  store i64 %29, ptr %30, align 16, !tbaa !11
  %indvars.iv.next79.epil = add nuw nsw i64 %indvars.iv78.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader, label %.lr.ph63.epil, !llvm.loop !14

.preheader:                                       ; preds = %.preheader.loopexit.unr-lcssa, %.lr.ph63.epil, %._crit_edge
  %.not5568 = icmp slt i32 %16, 1
  br i1 %.not5568, label %._crit_edge71, label %.lr.ph70

.lr.ph63:                                         ; preds = %.lr.ph63, %.lr.ph63.preheader.new
  %31 = phi i64 [ %18, %.lr.ph63.preheader.new ], [ %46, %.lr.ph63 ]
  %indvars.iv78 = phi i64 [ 1, %.lr.ph63.preheader.new ], [ %indvars.iv.next79.3, %.lr.ph63 ]
  %niter = phi i64 [ 0, %.lr.ph63.preheader.new ], [ %niter.next.3, %.lr.ph63 ]
  %32 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %indvars.iv78
  %33 = load i64, ptr %32, align 8, !tbaa !11
  %34 = add nsw i64 %33, %31
  %35 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv78
  store i64 %34, ptr %35, align 16, !tbaa !11
  %indvars.iv.next79 = add nuw nsw i64 %indvars.iv78, 1
  %36 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %indvars.iv.next79
  %37 = load i64, ptr %36, align 8, !tbaa !11
  %38 = add nsw i64 %37, %34
  %39 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv.next79
  store i64 %38, ptr %39, align 16, !tbaa !11
  %indvars.iv.next79.1 = add nuw nsw i64 %indvars.iv78, 2
  %40 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %indvars.iv.next79.1
  %41 = load i64, ptr %40, align 8, !tbaa !11
  %42 = add nsw i64 %41, %38
  %43 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv.next79.1
  store i64 %42, ptr %43, align 16, !tbaa !11
  %indvars.iv.next79.2 = add nuw nsw i64 %indvars.iv78, 3
  %44 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %indvars.iv.next79.2
  %45 = load i64, ptr %44, align 8, !tbaa !11
  %46 = add nsw i64 %45, %42
  %47 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv.next79.2
  store i64 %46, ptr %47, align 16, !tbaa !11
  %indvars.iv.next79.3 = add nuw nsw i64 %indvars.iv78, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader.loopexit.unr-lcssa, label %.lr.ph63, !llvm.loop !16

._crit_edge71:                                    ; preds = %._crit_edge67, %.preheader
  %48 = phi i32 [ %17, %.preheader ], [ %67, %._crit_edge67 ]
  %.lcssa = phi i32 [ %16, %.preheader ], [ %66, %._crit_edge67 ]
  %49 = add nsw i32 %48, -1
  %50 = sext i32 %49 to i64
  %51 = srem i32 %.lcssa, 2
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %50, i64 %52
  %54 = getelementptr inbounds i8, ptr %53, i64 8
  %55 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %53, ptr noundef nonnull align 8 dereferenceable(8) %54)
  %56 = load i64, ptr %55, align 8, !tbaa !11
  %57 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %56)
  %58 = load i32, ptr @t, align 4, !tbaa !5
  %59 = add nsw i32 %58, -1
  store i32 %59, ptr @t, align 4, !tbaa !5
  %.not = icmp eq i32 %58, 0
  br i1 %.not, label %._crit_edge75, label %.lr.ph74, !llvm.loop !17

.lr.ph70:                                         ; preds = %.preheader, %._crit_edge67
  %60 = phi i32 [ %66, %._crit_edge67 ], [ %16, %.preheader ]
  %61 = phi i32 [ %67, %._crit_edge67 ], [ %17, %.preheader ]
  %indvars.iv81 = phi i64 [ %indvars.iv.next82, %._crit_edge67 ], [ 1, %.preheader ]
  %indvars87 = trunc i64 %indvars.iv81 to i32
  %62 = icmp sgt i32 %61, %indvars87
  br i1 %62, label %.lr.ph66, label %._crit_edge67

.lr.ph66:                                         ; preds = %.lr.ph70
  %63 = and i64 %indvars.iv81, 1
  %64 = and i64 %indvars.iv81, 1
  %65 = xor i64 %63, 1
  br label %68

._crit_edge67.loopexit:                           ; preds = %85
  %.pre88 = load i32, ptr @k, align 4, !tbaa !5
  br label %._crit_edge67

._crit_edge67:                                    ; preds = %._crit_edge67.loopexit, %.lr.ph70
  %66 = phi i32 [ %.pre88, %._crit_edge67.loopexit ], [ %60, %.lr.ph70 ]
  %67 = phi i32 [ %96, %._crit_edge67.loopexit ], [ %61, %.lr.ph70 ]
  %indvars.iv.next82 = add nuw nsw i64 %indvars.iv81, 1
  %.not55.not = icmp sgt i32 %66, %indvars87
  br i1 %.not55.not, label %.lr.ph70, label %._crit_edge71, !llvm.loop !18

68:                                               ; preds = %.lr.ph66, %85
  %indvars.iv83 = phi i64 [ %indvars.iv81, %.lr.ph66 ], [ %indvars.iv.next84, %85 ]
  %69 = phi i32 [ %61, %.lr.ph66 ], [ %96, %85 ]
  %70 = load i32, ptr @d, align 4, !tbaa !5
  %71 = trunc nuw nsw i64 %indvars.iv83 to i32
  %72 = sub nsw i32 %71, %70
  %73 = icmp slt i32 %72, 1
  %74 = getelementptr inbounds [5001 x i64], ptr @a, i64 0, i64 %indvars.iv83
  %75 = load i64, ptr %74, align 8, !tbaa !11
  %76 = load i32, ptr @m, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = mul nsw i64 %75, %77
  br i1 %73, label %79, label %80

79:                                               ; preds = %68
  tail call void @_Z6updateiiixiii(i32 noundef %indvars87, i32 noundef 0, i32 noundef %71, i64 noundef %78, i32 noundef 1, i32 noundef 0, i32 noundef %69)
  br label %85

80:                                               ; preds = %68
  tail call void @_Z6updateiiixiii(i32 noundef %indvars87, i32 noundef %72, i32 noundef %71, i64 noundef %78, i32 noundef 1, i32 noundef 0, i32 noundef %69)
  %81 = load i32, ptr @d, align 4, !tbaa !5
  %82 = sub nsw i32 %71, %81
  %83 = load i64, ptr %74, align 8, !tbaa !11
  %84 = load i32, ptr @n, align 4, !tbaa !5
  tail call void @_Z6updateiiixiii(i32 noundef %indvars87, i32 noundef 0, i32 noundef %82, i64 noundef %83, i32 noundef 1, i32 noundef 0, i32 noundef %84)
  br label %85

85:                                               ; preds = %80, %79
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = tail call noundef i64 @_Z5queryiiiiii(i32 noundef %indvars87, i32 noundef 0, i32 noundef %71, i32 noundef 1, i32 noundef 0, i32 noundef %86)
  %88 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %indvars.iv83, i64 %64
  store i64 %87, ptr %88, align 16, !tbaa !11
  %89 = add nsw i64 %indvars.iv83, -1
  %90 = getelementptr inbounds [5001 x [2 x [2 x i64]]], ptr @dp, i64 0, i64 %89, i64 %65
  %91 = getelementptr inbounds i8, ptr %90, i64 8
  %92 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3maxIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %90, ptr noundef nonnull align 8 dereferenceable(8) %91)
  %93 = load i64, ptr %92, align 8, !tbaa !11
  %94 = getelementptr inbounds i8, ptr %88, i64 8
  store i64 %93, ptr %94, align 8, !tbaa !11
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %indvars = trunc i64 %indvars.iv.next84 to i32
  %95 = load i32, ptr @n, align 4, !tbaa !5
  tail call void @_Z6updateiiixiii(i32 noundef %indvars87, i32 noundef %71, i32 noundef %indvars, i64 noundef %93, i32 noundef 1, i32 noundef 0, i32 noundef %95)
  %96 = load i32, ptr @n, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = icmp slt i64 %indvars.iv.next84, %97
  br i1 %98, label %68, label %._crit_edge67.loopexit, !llvm.loop !19

._crit_edge75:                                    ; preds = %._crit_edge71, %0
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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

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 = { 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 #2 = { 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 #3 = { nofree nounwind "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 nounwind willreturn memory(argmem: write) }

!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}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.unroll.disable"}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


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