; LLVM IR from lzyrapx/Competitive-Programming :: 百度之星/2020/第一场/D.ll (Z5solveiiiii)

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

@a = external dso_local global [1234 x [1234 x i32]], align 16
@cost = external dso_local global [4 x [25 x [25 x [25 x i32]]]], align 16

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5solveiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %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 i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  %19 = alloca i32, align 4
  %20 = alloca i32, align 4
  %21 = alloca i32, align 4
  %22 = alloca i32, align 4
  %23 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store i32 %4, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  store i32 0, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 1, ptr %15, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #4
  %24 = load i32, ptr %6, align 4, !tbaa !5
  %25 = sub nsw i32 %24, 3
  store i32 %25, ptr %16, align 4, !tbaa !5
  %26 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %15, ptr noundef nonnull align 4 dereferenceable(4) %16)
  %27 = load i32, ptr %26, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  store i32 %27, ptr %14, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %94, %5
  %29 = load i32, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %17) #4
  %30 = load i32, ptr %6, align 4, !tbaa !5
  %31 = add nsw i32 %30, 3
  store i32 %31, ptr %17, align 4, !tbaa !5
  %32 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %17, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %33 = load i32, ptr %32, align 4, !tbaa !5
  %34 = icmp sle i32 %29, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %17) #4
  br i1 %34, label %36, label %35

35:                                               ; preds = %28
  store i32 2, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %97

36:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %20) #4
  %37 = load i32, ptr %7, align 4, !tbaa !5
  %38 = sub nsw i32 %37, 3
  store i32 %38, ptr %20, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %21) #4
  store i32 1, ptr %21, align 4, !tbaa !5
  %39 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %20, ptr noundef nonnull align 4 dereferenceable(4) %21)
  %40 = load i32, ptr %39, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %21) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %20) #4
  store i32 %40, ptr %19, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %90, %36
  %42 = load i32, ptr %19, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %22) #4
  %43 = load i32, ptr %7, align 4, !tbaa !5
  %44 = add nsw i32 %43, 3
  store i32 %44, ptr %22, align 4, !tbaa !5
  %45 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %22, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = icmp sle i32 %42, %46
  call void @llvm.lifetime.end.p0(i64 4, ptr %22) #4
  br i1 %47, label %49, label %48

48:                                               ; preds = %41
  store i32 5, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #4
  br label %93

49:                                               ; preds = %41
  %50 = load i32, ptr %14, align 4, !tbaa !5
  %51 = load i32, ptr %6, align 4, !tbaa !5
  %52 = sub nsw i32 %50, %51
  %53 = call i32 @llvm.abs.i32(i32 %52, i1 true)
  %54 = load i32, ptr %19, align 4, !tbaa !5
  %55 = load i32, ptr %7, align 4, !tbaa !5
  %56 = sub nsw i32 %54, %55
  %57 = call i32 @llvm.abs.i32(i32 %56, i1 true)
  %58 = add nsw i32 %53, %57
  %59 = icmp sgt i32 %58, 3
  br i1 %59, label %60, label %61

60:                                               ; preds = %49
  br label %90

61:                                               ; preds = %49
  %62 = load i32, ptr %14, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [1234 x [1234 x i32]], ptr @a, i64 0, i64 %63
  %65 = load i32, ptr %19, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [1234 x i32], ptr %64, i64 0, i64 %66
  %68 = load i32, ptr %67, align 4, !tbaa !5
  %69 = icmp eq i32 %68, 3
  br i1 %69, label %70, label %73

70:                                               ; preds = %61
  %71 = load i32, ptr %11, align 4, !tbaa !5
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %11, align 4, !tbaa !5
  br label %89

73:                                               ; preds = %61
  %74 = load i32, ptr %14, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [1234 x [1234 x i32]], ptr @a, i64 0, i64 %75
  %77 = load i32, ptr %19, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [1234 x i32], ptr %76, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = icmp eq i32 %80, 2
  br i1 %81, label %82, label %85

82:                                               ; preds = %73
  %83 = load i32, ptr %12, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %12, align 4, !tbaa !5
  br label %88

85:                                               ; preds = %73
  %86 = load i32, ptr %13, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %13, align 4, !tbaa !5
  br label %88

88:                                               ; preds = %85, %82
  br label %89

89:                                               ; preds = %88, %70
  br label %90

90:                                               ; preds = %89, %60
  %91 = load i32, ptr %19, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %19, align 4, !tbaa !5
  br label %41, !llvm.loop !9

93:                                               ; preds = %48
  br label %94

94:                                               ; preds = %93
  %95 = load i32, ptr %14, align 4, !tbaa !5
  %96 = add nsw i32 %95, 1
  store i32 %96, ptr %14, align 4, !tbaa !5
  br label %28, !llvm.loop !11

97:                                               ; preds = %35
  %98 = load i32, ptr %6, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [1234 x [1234 x i32]], ptr @a, i64 0, i64 %99
  %101 = load i32, ptr %7, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [1234 x i32], ptr %100, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = icmp eq i32 %104, 3
  br i1 %105, label %106, label %109

106:                                              ; preds = %97
  %107 = load i32, ptr %11, align 4, !tbaa !5
  %108 = add nsw i32 %107, -1
  store i32 %108, ptr %11, align 4, !tbaa !5
  br label %125

109:                                              ; preds = %97
  %110 = load i32, ptr %6, align 4, !tbaa !5
  %111 = sext i32 %110 to i64
  %112 = getelementptr inbounds [1234 x [1234 x i32]], ptr @a, i64 0, i64 %111
  %113 = load i32, ptr %7, align 4, !tbaa !5
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [1234 x i32], ptr %112, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = icmp eq i32 %116, 2
  br i1 %117, label %118, label %121

118:                                              ; preds = %109
  %119 = load i32, ptr %12, align 4, !tbaa !5
  %120 = add nsw i32 %119, -1
  store i32 %120, ptr %12, align 4, !tbaa !5
  br label %124

121:                                              ; preds = %109
  %122 = load i32, ptr %13, align 4, !tbaa !5
  %123 = add nsw i32 %122, -1
  store i32 %123, ptr %13, align 4, !tbaa !5
  br label %124

124:                                              ; preds = %121, %118
  br label %125

125:                                              ; preds = %124, %106
  call void @llvm.lifetime.start.p0(i64 4, ptr %23) #4
  %126 = load i32, ptr %6, align 4, !tbaa !5
  %127 = load i32, ptr %9, align 4, !tbaa !5
  %128 = sub nsw i32 %126, %127
  %129 = call i32 @llvm.abs.i32(i32 %128, i1 true)
  %130 = load i32, ptr %7, align 4, !tbaa !5
  %131 = load i32, ptr %10, align 4, !tbaa !5
  %132 = sub nsw i32 %130, %131
  %133 = call i32 @llvm.abs.i32(i32 %132, i1 true)
  %134 = add nsw i32 %129, %133
  %135 = add nsw i32 %134, 1
  %136 = sdiv i32 %135, 2
  %137 = load i32, ptr %6, align 4, !tbaa !5
  %138 = sext i32 %137 to i64
  %139 = getelementptr inbounds [1234 x [1234 x i32]], ptr @a, i64 0, i64 %138
  %140 = load i32, ptr %7, align 4, !tbaa !5
  %141 = sext i32 %140 to i64
  %142 = getelementptr inbounds [1234 x i32], ptr %139, i64 0, i64 %141
  %143 = load i32, ptr %142, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [4 x [25 x [25 x [25 x i32]]]], ptr @cost, i64 0, i64 %144
  %146 = load i32, ptr %11, align 4, !tbaa !5
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [25 x [25 x [25 x i32]]], ptr %145, i64 0, i64 %147
  %149 = load i32, ptr %12, align 4, !tbaa !5
  %150 = sext i32 %149 to i64
  %151 = getelementptr inbounds [25 x [25 x i32]], ptr %148, i64 0, i64 %150
  %152 = load i32, ptr %13, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [25 x i32], ptr %151, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = add nsw i32 %136, %155
  store i32 %156, ptr %23, align 4, !tbaa !5
  %157 = load i32, ptr %23, align 4, !tbaa !5
  store i32 1, ptr %18, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %23) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  ret i32 %157
}

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

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

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

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


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

@a = external dso_local local_unnamed_addr global [1234 x [1234 x i32]], align 16
@cost = external dso_local local_unnamed_addr global [4 x [25 x [25 x [25 x i32]]]], align 16

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_Z5solveiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %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 i32, align 4
  store i32 %2, ptr %6, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #4
  store i32 1, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %8) #4
  %13 = add nsw i32 %0, -3
  store i32 %13, ptr %8, align 4, !tbaa !5
  %14 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8)
  %15 = load i32, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #4
  %16 = add nsw i32 %0, 3
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  store i32 %16, ptr %9, align 4, !tbaa !5
  %17 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %18 = load i32, ptr %17, align 4, !tbaa !5
  %.not56 = icmp sgt i32 %15, %18
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  br i1 %.not56, label %._crit_edge63, label %.lr.ph62

.lr.ph62:                                         ; preds = %5
  %19 = add nsw i32 %1, -3
  %20 = add nsw i32 %1, 3
  %21 = sext i32 %15 to i64
  br label %24

._crit_edge63:                                    ; preds = %._crit_edge, %5
  %.042.lcssa = phi i32 [ 0, %5 ], [ %.143.lcssa, %._crit_edge ]
  %.038.lcssa = phi i32 [ 0, %5 ], [ %.139.lcssa, %._crit_edge ]
  %.0.lcssa = phi i32 [ 0, %5 ], [ %.1.lcssa, %._crit_edge ]
  %.pre-phi = sext i32 %0 to i64
  %.pre-phi72 = sext i32 %1 to i64
  %22 = getelementptr inbounds [1234 x [1234 x i32]], ptr @a, i64 0, i64 %.pre-phi, i64 %.pre-phi72
  %23 = load i32, ptr %22, align 4, !tbaa !5
  switch i32 %23, label %59 [
    i32 3, label %55
    i32 2, label %57
  ]

24:                                               ; preds = %.lr.ph62, %._crit_edge
  %indvars.iv68 = phi i64 [ %21, %.lr.ph62 ], [ %indvars.iv.next69, %._crit_edge ]
  %.060 = phi i32 [ 0, %.lr.ph62 ], [ %.1.lcssa, %._crit_edge ]
  %.03858 = phi i32 [ 0, %.lr.ph62 ], [ %.139.lcssa, %._crit_edge ]
  %.04257 = phi i32 [ 0, %.lr.ph62 ], [ %.143.lcssa, %._crit_edge ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %10) #4
  store i32 %19, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %11) #4
  store i32 1, ptr %11, align 4, !tbaa !5
  %25 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %10, ptr noundef nonnull align 4 dereferenceable(4) %11)
  %26 = load i32, ptr %25, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %10) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #4
  store i32 %20, ptr %12, align 4, !tbaa !5
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %.not4849 = icmp sgt i32 %26, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #4
  br i1 %.not4849, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %24
  %29 = trunc i64 %indvars.iv68 to i32
  %30 = sub i32 %29, %0
  %31 = call i32 @llvm.abs.i32(i32 %30, i1 true)
  %32 = sext i32 %26 to i64
  br label %36

._crit_edge:                                      ; preds = %51, %24
  %.143.lcssa = phi i32 [ %.04257, %24 ], [ %.244, %51 ]
  %.139.lcssa = phi i32 [ %.03858, %24 ], [ %.240, %51 ]
  %.1.lcssa = phi i32 [ %.060, %24 ], [ %.2, %51 ]
  %indvars.iv.next69 = add nsw i64 %indvars.iv68, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %9) #4
  store i32 %16, ptr %9, align 4, !tbaa !5
  %33 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %9, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %.not.not = icmp slt i64 %indvars.iv68, %35
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %9) #4
  br i1 %.not.not, label %24, label %._crit_edge63, !llvm.loop !9

36:                                               ; preds = %.lr.ph, %51
  %indvars.iv = phi i64 [ %32, %.lr.ph ], [ %indvars.iv.next, %51 ]
  %.153 = phi i32 [ %.060, %.lr.ph ], [ %.2, %51 ]
  %.13951 = phi i32 [ %.03858, %.lr.ph ], [ %.240, %51 ]
  %.14350 = phi i32 [ %.04257, %.lr.ph ], [ %.244, %51 ]
  %37 = trunc i64 %indvars.iv to i32
  %38 = sub i32 %37, %1
  %39 = call i32 @llvm.abs.i32(i32 %38, i1 true)
  %40 = add nuw nsw i32 %39, %31
  %41 = icmp ugt i32 %40, 3
  br i1 %41, label %51, label %42

42:                                               ; preds = %36
  %43 = getelementptr inbounds [1234 x [1234 x i32]], ptr @a, i64 0, i64 %indvars.iv68, i64 %indvars.iv
  %44 = load i32, ptr %43, align 4, !tbaa !5
  switch i32 %44, label %49 [
    i32 3, label %45
    i32 2, label %47
  ]

45:                                               ; preds = %42
  %46 = add nsw i32 %.153, 1
  br label %51

47:                                               ; preds = %42
  %48 = add nsw i32 %.14350, 1
  br label %51

49:                                               ; preds = %42
  %50 = add nsw i32 %.13951, 1
  br label %51

51:                                               ; preds = %45, %49, %47, %36
  %.244 = phi i32 [ %.14350, %36 ], [ %.14350, %45 ], [ %48, %47 ], [ %.14350, %49 ]
  %.240 = phi i32 [ %.13951, %36 ], [ %.13951, %45 ], [ %.13951, %47 ], [ %50, %49 ]
  %.2 = phi i32 [ %.153, %36 ], [ %46, %45 ], [ %.153, %47 ], [ %.153, %49 ]
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %12) #4
  store i32 %20, ptr %12, align 4, !tbaa !5
  %52 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %12, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %.not48.not = icmp slt i64 %indvars.iv, %54
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %12) #4
  br i1 %.not48.not, label %36, label %._crit_edge, !llvm.loop !11

55:                                               ; preds = %._crit_edge63
  %56 = add nsw i32 %.0.lcssa, -1
  br label %61

57:                                               ; preds = %._crit_edge63
  %58 = add nsw i32 %.042.lcssa, -1
  br label %61

59:                                               ; preds = %._crit_edge63
  %60 = add nsw i32 %.038.lcssa, -1
  br label %61

61:                                               ; preds = %57, %59, %55
  %.345 = phi i32 [ %.042.lcssa, %55 ], [ %58, %57 ], [ %.042.lcssa, %59 ]
  %.341 = phi i32 [ %.038.lcssa, %55 ], [ %.038.lcssa, %57 ], [ %60, %59 ]
  %.3 = phi i32 [ %56, %55 ], [ %.0.lcssa, %57 ], [ %.0.lcssa, %59 ]
  %62 = sub nsw i32 %0, %3
  %63 = call i32 @llvm.abs.i32(i32 %62, i1 true)
  %64 = sub nsw i32 %1, %4
  %65 = call i32 @llvm.abs.i32(i32 %64, i1 true)
  %66 = add nuw nsw i32 %63, 1
  %67 = add nuw nsw i32 %66, %65
  %68 = lshr i32 %67, 1
  %69 = sext i32 %23 to i64
  %70 = sext i32 %.3 to i64
  %71 = sext i32 %.345 to i64
  %72 = sext i32 %.341 to i64
  %73 = getelementptr inbounds [4 x [25 x [25 x [25 x i32]]]], ptr @cost, i64 0, i64 %69, i64 %70, i64 %71, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = add nsw i32 %74, %68
  ret i32 %75
}

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

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

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.abs.i32(i32, i1 immarg) #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #4 = { nounwind }

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

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


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