; LLVM IR from tangjz/acm-icpc :: hdu (6118)

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [501 x i64], align 16
@b = external dso_local global [501 x i64], align 16
@c = external dso_local global [501 x i64], align 16
@d = external dso_local global [501 x i64], align 16
@dis = external dso_local global [501 x [501 x i64]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN4MCMF5solveEiPxS0_PA501_x(i32 noundef, ptr noundef, ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i64, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  br label %13

13:                                               ; preds = %186, %0
  %14 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  %15 = icmp eq i32 %14, 2
  br i1 %15, label %16, label %190

16:                                               ; preds = %13
  call void @llvm.memset.p0.i64(ptr align 16 @dis, i8 63, i64 2008008, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %42, %16
  %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) #6
  br label %45

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 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds i64, ptr @b, i64 %27
  %29 = load i32, ptr %2, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i64, ptr @c, i64 %30
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds i64, ptr @d, i64 %33
  %35 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %25, ptr noundef %28, ptr noundef %31, ptr noundef %34)
  %36 = load i32, ptr %2, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %37
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [501 x i64], ptr %38, i64 0, i64 %40
  store i64 0, ptr %41, align 8, !tbaa !9
  br label %42

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

45:                                               ; preds = %21
  br label %46

46:                                               ; preds = %50, %45
  %47 = load i32, ptr @m, align 4, !tbaa !5
  %48 = add nsw i32 %47, -1
  store i32 %48, ptr @m, align 4, !tbaa !5
  %49 = icmp ne i32 %47, 0
  br i1 %49, label %50, label %84

50:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  %51 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %3, ptr noundef %4, ptr noundef %5)
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = add nsw i32 %52, -1
  store i32 %53, ptr %3, align 4, !tbaa !5
  %54 = load i32, ptr %4, align 4, !tbaa !5
  %55 = add nsw i32 %54, -1
  store i32 %55, ptr %4, align 4, !tbaa !5
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %57
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [501 x i64], ptr %58, i64 0, i64 %60
  %62 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %61, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = load i32, ptr %3, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %65
  %67 = load i32, ptr %4, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [501 x i64], ptr %66, i64 0, i64 %68
  store i64 %63, ptr %69, align 8, !tbaa !9
  %70 = load i32, ptr %4, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %71
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [501 x i64], ptr %72, i64 0, i64 %74
  %76 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %75, ptr noundef nonnull align 8 dereferenceable(8) %5)
  %77 = load i64, ptr %76, align 8, !tbaa !9
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %79
  %81 = load i32, ptr %3, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [501 x i64], ptr %80, i64 0, i64 %82
  store i64 %77, ptr %83, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %46, !llvm.loop !13

84:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %140, %84
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = load i32, ptr @n, align 4, !tbaa !5
  %88 = icmp slt i32 %86, %87
  br i1 %88, label %90, label %89

89:                                               ; preds = %85
  store i32 9, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %143

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

91:                                               ; preds = %136, %90
  %92 = load i32, ptr %8, align 4, !tbaa !5
  %93 = load i32, ptr @n, align 4, !tbaa !5
  %94 = icmp slt i32 %92, %93
  br i1 %94, label %96, label %95

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

96:                                               ; preds = %91
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %132, %96
  %98 = load i32, ptr %9, align 4, !tbaa !5
  %99 = load i32, ptr @n, align 4, !tbaa !5
  %100 = icmp slt i32 %98, %99
  br i1 %100, label %102, label %101

101:                                              ; preds = %97
  store i32 15, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %135

102:                                              ; preds = %97
  %103 = load i32, ptr %8, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %104
  %106 = load i32, ptr %9, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [501 x i64], ptr %105, i64 0, i64 %107
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #6
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %110
  %112 = load i32, ptr %6, align 4, !tbaa !5
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [501 x i64], ptr %111, i64 0, i64 %113
  %115 = load i64, ptr %114, align 8, !tbaa !9
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %117
  %119 = load i32, ptr %9, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [501 x i64], ptr %118, i64 0, i64 %120
  %122 = load i64, ptr %121, align 8, !tbaa !9
  %123 = add nsw i64 %115, %122
  store i64 %123, ptr %10, align 8, !tbaa !9
  %124 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %108, ptr noundef nonnull align 8 dereferenceable(8) %10)
  %125 = load i64, ptr %124, align 8, !tbaa !9
  %126 = load i32, ptr %8, align 4, !tbaa !5
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %127
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [501 x i64], ptr %128, i64 0, i64 %130
  store i64 %125, ptr %131, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #6
  br label %132

132:                                              ; preds = %102
  %133 = load i32, ptr %9, align 4, !tbaa !5
  %134 = add nsw i32 %133, 1
  store i32 %134, ptr %9, align 4, !tbaa !5
  br label %97, !llvm.loop !14

135:                                              ; preds = %101
  br label %136

136:                                              ; preds = %135
  %137 = load i32, ptr %8, align 4, !tbaa !5
  %138 = add nsw i32 %137, 1
  store i32 %138, ptr %8, align 4, !tbaa !5
  br label %91, !llvm.loop !15

139:                                              ; preds = %95
  br label %140

140:                                              ; preds = %139
  %141 = load i32, ptr %6, align 4, !tbaa !5
  %142 = add nsw i32 %141, 1
  store i32 %142, ptr %6, align 4, !tbaa !5
  br label %85, !llvm.loop !16

143:                                              ; preds = %89
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %144

144:                                              ; preds = %183, %143
  %145 = load i32, ptr %11, align 4, !tbaa !5
  %146 = load i32, ptr @n, align 4, !tbaa !5
  %147 = icmp slt i32 %145, %146
  br i1 %147, label %149, label %148

148:                                              ; preds = %144
  store i32 18, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %186

149:                                              ; preds = %144
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %150

150:                                              ; preds = %179, %149
  %151 = load i32, ptr %12, align 4, !tbaa !5
  %152 = load i32, ptr @n, align 4, !tbaa !5
  %153 = icmp slt i32 %151, %152
  br i1 %153, label %155, label %154

154:                                              ; preds = %150
  store i32 21, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %182

155:                                              ; preds = %150
  %156 = load i32, ptr %12, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [501 x i64], ptr @c, i64 0, i64 %157
  %159 = load i64, ptr %158, align 8, !tbaa !9
  %160 = load i32, ptr %11, align 4, !tbaa !5
  %161 = sext i32 %160 to i64
  %162 = getelementptr inbounds [501 x i64], ptr @a, i64 0, i64 %161
  %163 = load i64, ptr %162, align 8, !tbaa !9
  %164 = sub nsw i64 %159, %163
  %165 = load i32, ptr %11, align 4, !tbaa !5
  %166 = sext i32 %165 to i64
  %167 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %166
  %168 = load i32, ptr %12, align 4, !tbaa !5
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [501 x i64], ptr %167, i64 0, i64 %169
  %171 = load i64, ptr %170, align 8, !tbaa !9
  %172 = sub nsw i64 %164, %171
  %173 = load i32, ptr %11, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %174
  %176 = load i32, ptr %12, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [501 x i64], ptr %175, i64 0, i64 %177
  store i64 %172, ptr %178, align 8, !tbaa !9
  br label %179

179:                                              ; preds = %155
  %180 = load i32, ptr %12, align 4, !tbaa !5
  %181 = add nsw i32 %180, 1
  store i32 %181, ptr %12, align 4, !tbaa !5
  br label %150, !llvm.loop !17

182:                                              ; preds = %154
  br label %183

183:                                              ; preds = %182
  %184 = load i32, ptr %11, align 4, !tbaa !5
  %185 = add nsw i32 %184, 1
  store i32 %185, ptr %11, align 4, !tbaa !5
  br label %144, !llvm.loop !18

186:                                              ; preds = %148
  %187 = load i32, ptr @n, align 4, !tbaa !5
  %188 = call noundef i64 @_ZN4MCMF5solveEiPxS0_PA501_x(i32 noundef %187, ptr noundef @b, ptr noundef @d, ptr noundef @dis)
  %189 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i64 noundef %188)
  br label %13, !llvm.loop !19

190:                                              ; preds = %13
  ret i32 0
}

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

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

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


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@a = external dso_local global [501 x i64], align 16
@b = external dso_local global [501 x i64], align 16
@c = external dso_local global [501 x i64], align 16
@d = external dso_local global [501 x i64], align 16
@dis = external dso_local global [501 x [501 x i64]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [7 x i8], align 1

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

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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_ZN4MCMF5solveEiPxS0_PA501_x(i32 noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #4 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %6 = icmp eq i32 %5, 2
  br i1 %6, label %.lr.ph59, label %._crit_edge60

.lr.ph59:                                         ; preds = %0, %._crit_edge57.split.us
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(2008008) @dis, i8 63, i64 2008008, i1 false)
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %.preheader44

.preheader44:                                     ; preds = %.lr.ph, %.lr.ph59
  %9 = phi i32 [ %7, %.lr.ph59 ], [ %18, %.lr.ph ]
  %10 = load i32, ptr @m, align 4, !tbaa !5
  %11 = add nsw i32 %10, -1
  store i32 %11, ptr @m, align 4, !tbaa !5
  %.not46 = icmp eq i32 %10, 0
  br i1 %.not46, label %.preheader43, label %.lr.ph47

.lr.ph:                                           ; preds = %.lr.ph59, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph59 ]
  %12 = getelementptr inbounds i64, ptr @a, i64 %indvars.iv
  %13 = getelementptr inbounds i64, ptr @b, i64 %indvars.iv
  %14 = getelementptr inbounds i64, ptr @c, i64 %indvars.iv
  %15 = getelementptr inbounds i64, ptr @d, i64 %indvars.iv
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %12, ptr noundef nonnull %13, ptr noundef nonnull %14, ptr noundef nonnull %15)
  %17 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %indvars.iv, i64 %indvars.iv
  store i64 0, ptr %17, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr @n, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = icmp slt i64 %indvars.iv.next, %19
  br i1 %20, label %.lr.ph, label %.preheader44, !llvm.loop !11

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

.preheader43:                                     ; preds = %.preheader43.loopexit, %.preheader44
  %21 = phi i32 [ %.pre, %.preheader43.loopexit ], [ %9, %.preheader44 ]
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %.preheader41, label %._crit_edge57.split.us

.lr.ph47:                                         ; preds = %.preheader44, %.lr.ph47
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #6
  %23 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = add nsw i32 %24, -1
  store i32 %25, ptr %1, align 4, !tbaa !5
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = add nsw i32 %26, -1
  store i32 %27, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %25 to i64
  %29 = sext i32 %27 to i64
  %30 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %28, i64 %29
  %31 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %30, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %32 = load i64, ptr %31, align 8, !tbaa !9
  %33 = load i32, ptr %1, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = load i32, ptr %2, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %34, i64 %36
  store i64 %32, ptr %37, align 8, !tbaa !9
  %38 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %36, i64 %34
  %39 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %38, ptr noundef nonnull align 8 dereferenceable(8) %3)
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = load i32, ptr %1, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %42, i64 %44
  store i64 %40, ptr %45, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #6
  %46 = load i32, ptr @m, align 4, !tbaa !5
  %47 = add nsw i32 %46, -1
  store i32 %47, ptr @m, align 4, !tbaa !5
  %.not = icmp eq i32 %46, 0
  br i1 %.not, label %.preheader43.loopexit, label %.lr.ph47, !llvm.loop !13

.preheader42:                                     ; preds = %._crit_edge51
  %48 = icmp sgt i32 %72, 0
  br i1 %48, label %.preheader40.us.preheader, label %._crit_edge57.split.us

.preheader40.us.preheader:                        ; preds = %.preheader42
  %wide.trip.count80 = zext nneg i32 %72 to i64
  %min.iters.check = icmp ult i32 %72, 4
  %n.vec = and i64 %wide.trip.count80, 2147483644
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count80
  br label %.preheader40.us

.preheader40.us:                                  ; preds = %.preheader40.us.preheader, %._crit_edge55.us
  %indvars.iv77 = phi i64 [ 0, %.preheader40.us.preheader ], [ %indvars.iv.next78, %._crit_edge55.us ]
  %49 = getelementptr inbounds [501 x i64], ptr @a, i64 0, i64 %indvars.iv77
  %50 = load i64, ptr %49, align 8, !tbaa !9
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.preheader40.us
  %broadcast.splatinsert = insertelement <2 x i64> poison, i64 %50, i64 0
  %broadcast.splat = shufflevector <2 x i64> %broadcast.splatinsert, <2 x i64> poison, <2 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %51 = getelementptr inbounds [501 x i64], ptr @c, i64 0, i64 %index
  %52 = getelementptr inbounds i8, ptr %51, i64 16
  %wide.load = load <2 x i64>, ptr %51, align 16, !tbaa !9
  %wide.load93 = load <2 x i64>, ptr %52, align 16, !tbaa !9
  %53 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %indvars.iv77, i64 %index
  %54 = getelementptr inbounds i8, ptr %53, i64 16
  %wide.load94 = load <2 x i64>, ptr %53, align 8, !tbaa !9
  %wide.load95 = load <2 x i64>, ptr %54, align 8, !tbaa !9
  %55 = add <2 x i64> %broadcast.splat, %wide.load94
  %56 = add <2 x i64> %broadcast.splat, %wide.load95
  %57 = sub <2 x i64> %wide.load, %55
  %58 = sub <2 x i64> %wide.load93, %56
  store <2 x i64> %57, ptr %53, align 8, !tbaa !9
  store <2 x i64> %58, ptr %54, align 8, !tbaa !9
  %index.next = add nuw i64 %index, 4
  %59 = icmp eq i64 %index.next, %n.vec
  br i1 %59, label %middle.block, label %vector.body, !llvm.loop !14

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

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

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv74 = phi i64 [ %indvars.iv.next75, %scalar.ph ], [ %indvars.iv74.ph, %scalar.ph.preheader ]
  %60 = getelementptr inbounds [501 x i64], ptr @c, i64 0, i64 %indvars.iv74
  %61 = load i64, ptr %60, align 8, !tbaa !9
  %62 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %indvars.iv77, i64 %indvars.iv74
  %63 = load i64, ptr %62, align 8, !tbaa !9
  %64 = add i64 %50, %63
  %65 = sub i64 %61, %64
  store i64 %65, ptr %62, align 8, !tbaa !9
  %indvars.iv.next75 = add nuw nsw i64 %indvars.iv74, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next75, %wide.trip.count80
  br i1 %exitcond.not, label %._crit_edge55.us, label %scalar.ph, !llvm.loop !17

._crit_edge55.us:                                 ; preds = %scalar.ph, %middle.block
  %indvars.iv.next78 = add nuw nsw i64 %indvars.iv77, 1
  %exitcond81.not = icmp eq i64 %indvars.iv.next78, %wide.trip.count80
  br i1 %exitcond81.not, label %._crit_edge57.split.us, label %.preheader40.us, !llvm.loop !18

.preheader41:                                     ; preds = %.preheader43, %._crit_edge51
  %66 = phi i32 [ %72, %._crit_edge51 ], [ %21, %.preheader43 ]
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %._crit_edge51 ], [ 0, %.preheader43 ]
  %67 = icmp sgt i32 %66, 0
  br i1 %67, label %.preheader, label %._crit_edge51

.preheader:                                       ; preds = %.preheader41, %._crit_edge
  %68 = phi i32 [ %75, %._crit_edge ], [ %66, %.preheader41 ]
  %69 = phi i32 [ %76, %._crit_edge ], [ %66, %.preheader41 ]
  %indvars.iv68 = phi i64 [ %indvars.iv.next69, %._crit_edge ], [ 0, %.preheader41 ]
  %70 = icmp sgt i32 %69, 0
  br i1 %70, label %.lr.ph49, label %.preheader.._crit_edge_crit_edge

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre82 = sext i32 %69 to i64
  br label %._crit_edge

.lr.ph49:                                         ; preds = %.preheader
  %71 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %indvars.iv68, i64 %indvars.iv71
  br label %78

._crit_edge51:                                    ; preds = %._crit_edge, %.preheader41
  %72 = phi i32 [ %66, %.preheader41 ], [ %75, %._crit_edge ]
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %73 = sext i32 %72 to i64
  %74 = icmp slt i64 %indvars.iv.next72, %73
  br i1 %74, label %.preheader41, label %.preheader42, !llvm.loop !19

._crit_edge:                                      ; preds = %78, %.preheader.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre82, %.preheader.._crit_edge_crit_edge ], [ %87, %78 ]
  %75 = phi i32 [ %68, %.preheader.._crit_edge_crit_edge ], [ %86, %78 ]
  %76 = phi i32 [ %69, %.preheader.._crit_edge_crit_edge ], [ %86, %78 ]
  %indvars.iv.next69 = add nuw nsw i64 %indvars.iv68, 1
  %77 = icmp slt i64 %indvars.iv.next69, %.pre-phi
  br i1 %77, label %.preheader, label %._crit_edge51, !llvm.loop !21

78:                                               ; preds = %.lr.ph49, %78
  %indvars.iv65 = phi i64 [ 0, %.lr.ph49 ], [ %indvars.iv.next66, %78 ]
  %79 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %indvars.iv68, i64 %indvars.iv65
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #6
  %80 = load i64, ptr %71, align 8, !tbaa !9
  %81 = getelementptr inbounds [501 x [501 x i64]], ptr @dis, i64 0, i64 %indvars.iv71, i64 %indvars.iv65
  %82 = load i64, ptr %81, align 8, !tbaa !9
  %83 = add nsw i64 %82, %80
  store i64 %83, ptr %4, align 8, !tbaa !9
  %84 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZSt3minIxERKT_S2_S2_(ptr noundef nonnull align 8 dereferenceable(8) %79, ptr noundef nonnull align 8 dereferenceable(8) %4)
  %85 = load i64, ptr %84, align 8, !tbaa !9
  store i64 %85, ptr %79, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #6
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %86 = load i32, ptr @n, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = icmp slt i64 %indvars.iv.next66, %87
  br i1 %88, label %78, label %._crit_edge, !llvm.loop !22

._crit_edge57.split.us:                           ; preds = %._crit_edge55.us, %.preheader43, %.preheader42
  %.lcssa84 = phi i32 [ %72, %.preheader42 ], [ %21, %.preheader43 ], [ %72, %._crit_edge55.us ]
  %89 = call noundef i64 @_ZN4MCMF5solveEiPxS0_PA501_x(i32 noundef %.lcssa84, ptr noundef nonnull @b, ptr noundef nonnull @d, ptr noundef nonnull @dis)
  %90 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i64 noundef %89)
  %91 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %92 = icmp eq i32 %91, 2
  br i1 %92, label %.lr.ph59, label %._crit_edge60, !llvm.loop !23

._crit_edge60:                                    ; preds = %._crit_edge57.split.us, %0
  ret i32 0
}

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

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

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


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