; LLVM IR from upupming/algorithm :: kick-start/2021/RoundA/C. Rabbit House.ll (Z5solvev)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<P, std::allocator<P>>::_Vector_impl" }
%"struct.std::_Vector_base<P, std::allocator<P>>::_Vector_impl" = type { %"struct.std::_Vector_base<P, std::allocator<P>>::_Vector_impl_data" }
%"struct.std::_Vector_base<P, std::allocator<P>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.P = type { i32, i32, i32 }

@g = external dso_local global [310 x [310 x i32]], align 16
@r = external dso_local global i32, align 4
@c = external dso_local global i32, align 4
@v = external dso_local global [310 x [310 x i32]], align 16
@maxV = external dso_local global i32, align 4
@dx = external dso_local global [4 x i32], align 16
@dy = external dso_local global [4 x i32], align 16
@q = external dso_local global %"class.std::priority_queue", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5validii(i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5solvev() #1 {
  %1 = alloca i64, align 8
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca %struct.P, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.P, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.P, align 4
  %14 = load i32, ptr @maxV, align 4, !tbaa !5
  %15 = icmp eq i32 %14, 0
  br i1 %15, label %16, label %17

16:                                               ; preds = %0
  store i64 0, ptr %1, align 8
  br label %173

17:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store i64 0, ptr %2, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %46, %17
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = load i32, ptr @r, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  store i32 2, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %49

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

24:                                               ; preds = %42, %23
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = load i32, ptr @c, align 4, !tbaa !5
  %27 = icmp slt i32 %25, %26
  br i1 %27, label %29, label %28

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

29:                                               ; preds = %24
  call void @llvm.lifetime.start.p0(i64 12, ptr %6) #4
  %30 = getelementptr inbounds %struct.P, ptr %6, i32 0, i32 0
  %31 = load i32, ptr %3, align 4, !tbaa !5
  store i32 %31, ptr %30, align 4, !tbaa !11
  %32 = getelementptr inbounds %struct.P, ptr %6, i32 0, i32 1
  %33 = load i32, ptr %5, align 4, !tbaa !5
  store i32 %33, ptr %32, align 4, !tbaa !13
  %34 = getelementptr inbounds %struct.P, ptr %6, i32 0, i32 2
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %36
  %38 = load i32, ptr %5, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [310 x i32], ptr %37, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !5
  store i32 %41, ptr %34, align 4, !tbaa !14
  call void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(12) %6)
  call void @llvm.lifetime.end.p0(i64 12, ptr %6) #4
  br label %42

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

45:                                               ; preds = %28
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %3, align 4, !tbaa !5
  br label %18, !llvm.loop !17

49:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %50

50:                                               ; preds = %169, %167, %49
  %51 = call noundef i64 @_ZNKSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %52 = icmp ne i64 %51, 0
  br i1 %52, label %53, label %170

53:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 12, ptr %8) #4
  %54 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %8, ptr align 4 %54, i64 12, i1 false), !tbaa.struct !18
  call void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %55 = getelementptr inbounds %struct.P, ptr %8, i32 0, i32 0
  %56 = load i32, ptr %55, align 4, !tbaa !11
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [310 x [310 x i32]], ptr @v, i64 0, i64 %57
  %59 = getelementptr inbounds %struct.P, ptr %8, i32 0, i32 1
  %60 = load i32, ptr %59, align 4, !tbaa !13
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [310 x i32], ptr %58, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp ne i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %53
  store i32 8, ptr %4, align 4
  br label %167, !llvm.loop !19

66:                                               ; preds = %53
  %67 = getelementptr inbounds %struct.P, ptr %8, i32 0, i32 0
  %68 = load i32, ptr %67, align 4, !tbaa !11
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [310 x [310 x i32]], ptr @v, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.P, ptr %8, i32 0, i32 1
  %72 = load i32, ptr %71, align 4, !tbaa !13
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [310 x i32], ptr %70, i64 0, i64 %73
  store i32 1, ptr %74, align 4, !tbaa !5
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %7, align 4, !tbaa !5
  %77 = load i32, ptr @r, align 4, !tbaa !5
  %78 = load i32, ptr @c, align 4, !tbaa !5
  %79 = mul nsw i32 %77, %78
  %80 = icmp eq i32 %76, %79
  br i1 %80, label %81, label %83

81:                                               ; preds = %66
  %82 = load i64, ptr %2, align 8, !tbaa !9
  store i64 %82, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %167

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

84:                                               ; preds = %163, %83
  %85 = load i32, ptr %9, align 4, !tbaa !5
  %86 = icmp slt i32 %85, 4
  br i1 %86, label %88, label %87

87:                                               ; preds = %84
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %166

88:                                               ; preds = %84
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %89 = getelementptr inbounds %struct.P, ptr %8, i32 0, i32 0
  %90 = load i32, ptr %89, align 4, !tbaa !11
  %91 = load i32, ptr %9, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [4 x i32], ptr @dx, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = add nsw i32 %90, %94
  store i32 %95, ptr %10, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %96 = getelementptr inbounds %struct.P, ptr %8, i32 0, i32 1
  %97 = load i32, ptr %96, align 4, !tbaa !13
  %98 = load i32, ptr %9, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [4 x i32], ptr @dy, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = add nsw i32 %97, %101
  store i32 %102, ptr %11, align 4, !tbaa !5
  %103 = load i32, ptr %10, align 4, !tbaa !5
  %104 = load i32, ptr %11, align 4, !tbaa !5
  %105 = call noundef zeroext i1 @_Z5validii(i32 noundef %103, i32 noundef %104)
  br i1 %105, label %107, label %106

106:                                              ; preds = %88
  store i32 12, ptr %4, align 4
  br label %160

107:                                              ; preds = %88
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %108 = getelementptr inbounds %struct.P, ptr %8, i32 0, i32 0
  %109 = load i32, ptr %108, align 4, !tbaa !11
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %110
  %112 = getelementptr inbounds %struct.P, ptr %8, i32 0, i32 1
  %113 = load i32, ptr %112, align 4, !tbaa !13
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [310 x i32], ptr %111, i64 0, i64 %114
  %116 = load i32, ptr %115, align 4, !tbaa !5
  %117 = sub nsw i32 %116, 1
  store i32 %117, ptr %12, align 4, !tbaa !5
  %118 = load i32, ptr %10, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %119
  %121 = load i32, ptr %11, align 4, !tbaa !5
  %122 = sext i32 %121 to i64
  %123 = getelementptr inbounds [310 x i32], ptr %120, i64 0, i64 %122
  %124 = load i32, ptr %123, align 4, !tbaa !5
  %125 = load i32, ptr %12, align 4, !tbaa !5
  %126 = icmp slt i32 %124, %125
  br i1 %126, label %127, label %147

127:                                              ; preds = %107
  %128 = load i32, ptr %12, align 4, !tbaa !5
  %129 = load i32, ptr %10, align 4, !tbaa !5
  %130 = sext i32 %129 to i64
  %131 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %130
  %132 = load i32, ptr %11, align 4, !tbaa !5
  %133 = sext i32 %132 to i64
  %134 = getelementptr inbounds [310 x i32], ptr %131, i64 0, i64 %133
  %135 = load i32, ptr %134, align 4, !tbaa !5
  %136 = sub nsw i32 %128, %135
  %137 = sext i32 %136 to i64
  %138 = load i64, ptr %2, align 8, !tbaa !9
  %139 = add nsw i64 %138, %137
  store i64 %139, ptr %2, align 8, !tbaa !9
  %140 = load i32, ptr %12, align 4, !tbaa !5
  %141 = load i32, ptr %10, align 4, !tbaa !5
  %142 = sext i32 %141 to i64
  %143 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %142
  %144 = load i32, ptr %11, align 4, !tbaa !5
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [310 x i32], ptr %143, i64 0, i64 %145
  store i32 %140, ptr %146, align 4, !tbaa !5
  br label %147

147:                                              ; preds = %127, %107
  call void @llvm.lifetime.start.p0(i64 12, ptr %13) #4
  %148 = getelementptr inbounds %struct.P, ptr %13, i32 0, i32 0
  %149 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %149, ptr %148, align 4, !tbaa !11
  %150 = getelementptr inbounds %struct.P, ptr %13, i32 0, i32 1
  %151 = load i32, ptr %11, align 4, !tbaa !5
  store i32 %151, ptr %150, align 4, !tbaa !13
  %152 = getelementptr inbounds %struct.P, ptr %13, i32 0, i32 2
  %153 = load i32, ptr %10, align 4, !tbaa !5
  %154 = sext i32 %153 to i64
  %155 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %154
  %156 = load i32, ptr %11, align 4, !tbaa !5
  %157 = sext i32 %156 to i64
  %158 = getelementptr inbounds [310 x i32], ptr %155, i64 0, i64 %157
  %159 = load i32, ptr %158, align 4, !tbaa !5
  store i32 %159, ptr %152, align 4, !tbaa !14
  call void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(12) %13)
  call void @llvm.lifetime.end.p0(i64 12, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  store i32 0, ptr %4, align 4
  br label %160

160:                                              ; preds = %147, %106
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  %161 = load i32, ptr %4, align 4
  switch i32 %161, label %175 [
    i32 0, label %162
    i32 12, label %163
  ]

162:                                              ; preds = %160
  br label %163

163:                                              ; preds = %162, %160
  %164 = load i32, ptr %9, align 4, !tbaa !5
  %165 = add nsw i32 %164, 1
  store i32 %165, ptr %9, align 4, !tbaa !5
  br label %84, !llvm.loop !20

166:                                              ; preds = %87
  store i32 0, ptr %4, align 4
  br label %167

167:                                              ; preds = %166, %81, %65
  call void @llvm.lifetime.end.p0(i64 12, ptr %8) #4
  %168 = load i32, ptr %4, align 4
  switch i32 %168, label %172 [
    i32 0, label %169
    i32 8, label %50
  ]

169:                                              ; preds = %167
  br label %50, !llvm.loop !19

170:                                              ; preds = %50
  %171 = load i64, ptr %2, align 8, !tbaa !9
  store i64 %171, ptr %1, align 8
  store i32 1, ptr %4, align 4
  br label %172

172:                                              ; preds = %170, %167
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  br label %173

173:                                              ; preds = %172, %16
  %174 = load i64, ptr %1, align 8
  ret i64 %174

175:                                              ; preds = %160
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(12)) #1 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) #0 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) #1 align 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 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ZTS1P", !6, i64 0, !6, i64 4, !6, i64 8}
!13 = !{!12, !6, i64 4}
!14 = !{!12, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5}
!19 = distinct !{!19, !16}
!20 = distinct !{!20, !16}


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

%"class.std::priority_queue" = type <{ %"class.std::vector", [8 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<P, std::allocator<P>>::_Vector_impl" }
%"struct.std::_Vector_base<P, std::allocator<P>>::_Vector_impl" = type { %"struct.std::_Vector_base<P, std::allocator<P>>::_Vector_impl_data" }
%"struct.std::_Vector_base<P, std::allocator<P>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.P = type { i32, i32, i32 }

@g = external dso_local local_unnamed_addr global [310 x [310 x i32]], align 16
@r = external dso_local local_unnamed_addr global i32, align 4
@c = external dso_local local_unnamed_addr global i32, align 4
@v = external dso_local local_unnamed_addr global [310 x [310 x i32]], align 16
@maxV = external dso_local local_unnamed_addr global i32, align 4
@dx = external dso_local local_unnamed_addr global [4 x i32], align 16
@dy = external dso_local local_unnamed_addr global [4 x i32], align 16
@q = external dso_local global %"class.std::priority_queue", align 8

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z5validii(i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i64 @_Z5solvev() local_unnamed_addr #1 {
  %1 = alloca %struct.P, align 4
  %2 = alloca %struct.P, align 4
  %3 = load i32, ptr @maxV, align 4, !tbaa !5
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %.thread, label %.preheader60

.preheader60:                                     ; preds = %0
  %5 = load i32, ptr @r, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.preheader59.lr.ph, label %.preheader58

.preheader59.lr.ph:                               ; preds = %.preheader60
  %7 = getelementptr inbounds i8, ptr %1, i64 4
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load i32, ptr @c, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.preheader59, label %.preheader58

.preheader59:                                     ; preds = %.preheader59.lr.ph, %._crit_edge
  %11 = phi i32 [ %18, %._crit_edge ], [ %5, %.preheader59.lr.ph ]
  %12 = phi i32 [ %19, %._crit_edge ], [ %9, %.preheader59.lr.ph ]
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %._crit_edge ], [ 0, %.preheader59.lr.ph ]
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader59
  %14 = trunc nuw nsw i64 %indvars.iv73 to i32
  br label %22

.preheader58:                                     ; preds = %._crit_edge, %.preheader59.lr.ph, %.preheader60
  %15 = call noundef i64 @_ZNKSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %.not65 = icmp eq i64 %15, 0
  br i1 %.not65, label %.thread, label %.lr.ph68

.lr.ph68:                                         ; preds = %.preheader58
  %16 = getelementptr inbounds i8, ptr %2, i64 4
  %17 = getelementptr inbounds i8, ptr %2, i64 8
  br label %29

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader59
  %18 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %11, %.preheader59 ]
  %19 = phi i32 [ %26, %._crit_edge.loopexit ], [ %12, %.preheader59 ]
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %20 = sext i32 %18 to i64
  %21 = icmp slt i64 %indvars.iv.next74, %20
  br i1 %21, label %.preheader59, label %.preheader58, !llvm.loop !9

22:                                               ; preds = %.lr.ph, %22
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %22 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %1) #3
  store i32 %14, ptr %1, align 4, !tbaa !12
  %23 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %23, ptr %7, align 4, !tbaa !14
  %24 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %indvars.iv73, i64 %indvars.iv
  %25 = load i32, ptr %24, align 4, !tbaa !5
  store i32 %25, ptr %8, align 4, !tbaa !15
  call void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(12) %1)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %1) #3
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @c, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %22, label %._crit_edge.loopexit, !llvm.loop !16

29:                                               ; preds = %.lr.ph68, %.loopexit
  %.03967 = phi i64 [ 0, %.lr.ph68 ], [ %.4, %.loopexit ]
  %.04766 = phi i32 [ 0, %.lr.ph68 ], [ %.148, %.loopexit ]
  %30 = call noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %.sroa.0.0.copyload = load i32, ptr %30, align 4, !tbaa !5
  %.sroa.7.0..sroa_idx = getelementptr inbounds i8, ptr %30, i64 4
  %.sroa.7.0.copyload = load i32, ptr %.sroa.7.0..sroa_idx, align 4, !tbaa !5
  call void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %31 = sext i32 %.sroa.0.0.copyload to i64
  %32 = sext i32 %.sroa.7.0.copyload to i64
  %33 = getelementptr inbounds [310 x [310 x i32]], ptr @v, i64 0, i64 %31, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %.not53 = icmp eq i32 %34, 0
  br i1 %.not53, label %35, label %.loopexit, !llvm.loop !17

35:                                               ; preds = %29
  store i32 1, ptr %33, align 4, !tbaa !5
  %36 = add nsw i32 %.04766, 1
  %37 = load i32, ptr @r, align 4, !tbaa !5
  %38 = load i32, ptr @c, align 4, !tbaa !5
  %39 = mul nsw i32 %38, %37
  %40 = icmp eq i32 %36, %39
  br i1 %40, label %.thread, label %.preheader

.preheader:                                       ; preds = %35
  %41 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %31, i64 %32
  %42 = load i32, ptr @dx, align 16, !tbaa !5
  %43 = add nsw i32 %42, %.sroa.0.0.copyload
  %44 = load i32, ptr @dy, align 16, !tbaa !5
  %45 = add nsw i32 %44, %.sroa.7.0.copyload
  %46 = call noundef zeroext i1 @_Z5validii(i32 noundef %43, i32 noundef %45)
  br i1 %46, label %47, label %61

47:                                               ; preds = %.preheader
  %48 = load i32, ptr %41, align 4, !tbaa !5
  %49 = add nsw i32 %48, -1
  %50 = sext i32 %43 to i64
  %51 = sext i32 %45 to i64
  %52 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %50, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = icmp slt i32 %53, %49
  br i1 %54, label %55, label %59

55:                                               ; preds = %47
  %56 = sub nsw i32 %49, %53
  %57 = sext i32 %56 to i64
  %58 = add nsw i64 %.03967, %57
  store i32 %49, ptr %52, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %55, %47
  %60 = phi i32 [ %49, %55 ], [ %53, %47 ]
  %.241 = phi i64 [ %58, %55 ], [ %.03967, %47 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #3
  store i32 %43, ptr %2, align 4, !tbaa !12
  store i32 %45, ptr %16, align 4, !tbaa !14
  store i32 %60, ptr %17, align 4, !tbaa !15
  call void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(12) %2)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #3
  br label %61

61:                                               ; preds = %.preheader, %59
  %.342 = phi i64 [ %.241, %59 ], [ %.03967, %.preheader ]
  %62 = load i32, ptr getelementptr inbounds (i8, ptr @dx, i64 4), align 4, !tbaa !5
  %63 = add nsw i32 %62, %.sroa.0.0.copyload
  %64 = load i32, ptr getelementptr inbounds (i8, ptr @dy, i64 4), align 4, !tbaa !5
  %65 = add nsw i32 %64, %.sroa.7.0.copyload
  %66 = call noundef zeroext i1 @_Z5validii(i32 noundef %63, i32 noundef %65)
  br i1 %66, label %67, label %81

67:                                               ; preds = %61
  %68 = load i32, ptr %41, align 4, !tbaa !5
  %69 = add nsw i32 %68, -1
  %70 = sext i32 %63 to i64
  %71 = sext i32 %65 to i64
  %72 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %70, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = icmp slt i32 %73, %69
  br i1 %74, label %75, label %79

75:                                               ; preds = %67
  %76 = sub nsw i32 %69, %73
  %77 = sext i32 %76 to i64
  %78 = add nsw i64 %.342, %77
  store i32 %69, ptr %72, align 4, !tbaa !5
  br label %79

79:                                               ; preds = %75, %67
  %80 = phi i32 [ %69, %75 ], [ %73, %67 ]
  %.241.1 = phi i64 [ %78, %75 ], [ %.342, %67 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #3
  store i32 %63, ptr %2, align 4, !tbaa !12
  store i32 %65, ptr %16, align 4, !tbaa !14
  store i32 %80, ptr %17, align 4, !tbaa !15
  call void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(12) %2)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #3
  br label %81

81:                                               ; preds = %79, %61
  %.342.1 = phi i64 [ %.241.1, %79 ], [ %.342, %61 ]
  %82 = load i32, ptr getelementptr inbounds (i8, ptr @dx, i64 8), align 8, !tbaa !5
  %83 = add nsw i32 %82, %.sroa.0.0.copyload
  %84 = load i32, ptr getelementptr inbounds (i8, ptr @dy, i64 8), align 8, !tbaa !5
  %85 = add nsw i32 %84, %.sroa.7.0.copyload
  %86 = call noundef zeroext i1 @_Z5validii(i32 noundef %83, i32 noundef %85)
  br i1 %86, label %87, label %101

87:                                               ; preds = %81
  %88 = load i32, ptr %41, align 4, !tbaa !5
  %89 = add nsw i32 %88, -1
  %90 = sext i32 %83 to i64
  %91 = sext i32 %85 to i64
  %92 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %90, i64 %91
  %93 = load i32, ptr %92, align 4, !tbaa !5
  %94 = icmp slt i32 %93, %89
  br i1 %94, label %95, label %99

95:                                               ; preds = %87
  %96 = sub nsw i32 %89, %93
  %97 = sext i32 %96 to i64
  %98 = add nsw i64 %.342.1, %97
  store i32 %89, ptr %92, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %95, %87
  %100 = phi i32 [ %89, %95 ], [ %93, %87 ]
  %.241.2 = phi i64 [ %98, %95 ], [ %.342.1, %87 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #3
  store i32 %83, ptr %2, align 4, !tbaa !12
  store i32 %85, ptr %16, align 4, !tbaa !14
  store i32 %100, ptr %17, align 4, !tbaa !15
  call void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(12) %2)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #3
  br label %101

101:                                              ; preds = %99, %81
  %.342.2 = phi i64 [ %.241.2, %99 ], [ %.342.1, %81 ]
  %102 = load i32, ptr getelementptr inbounds (i8, ptr @dx, i64 12), align 4, !tbaa !5
  %103 = add nsw i32 %102, %.sroa.0.0.copyload
  %104 = load i32, ptr getelementptr inbounds (i8, ptr @dy, i64 12), align 4, !tbaa !5
  %105 = add nsw i32 %104, %.sroa.7.0.copyload
  %106 = call noundef zeroext i1 @_Z5validii(i32 noundef %103, i32 noundef %105)
  br i1 %106, label %107, label %.loopexit

107:                                              ; preds = %101
  %108 = load i32, ptr %41, align 4, !tbaa !5
  %109 = add nsw i32 %108, -1
  %110 = sext i32 %103 to i64
  %111 = sext i32 %105 to i64
  %112 = getelementptr inbounds [310 x [310 x i32]], ptr @g, i64 0, i64 %110, i64 %111
  %113 = load i32, ptr %112, align 4, !tbaa !5
  %114 = icmp slt i32 %113, %109
  br i1 %114, label %115, label %119

115:                                              ; preds = %107
  %116 = sub nsw i32 %109, %113
  %117 = sext i32 %116 to i64
  %118 = add nsw i64 %.342.2, %117
  store i32 %109, ptr %112, align 4, !tbaa !5
  br label %119

119:                                              ; preds = %115, %107
  %120 = phi i32 [ %109, %115 ], [ %113, %107 ]
  %.241.3 = phi i64 [ %118, %115 ], [ %.342.2, %107 ]
  call void @llvm.lifetime.start.p0(i64 12, ptr nonnull %2) #3
  store i32 %103, ptr %2, align 4, !tbaa !12
  store i32 %105, ptr %16, align 4, !tbaa !14
  store i32 %120, ptr %17, align 4, !tbaa !15
  call void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25) @q, ptr noundef nonnull align 4 dereferenceable(12) %2)
  call void @llvm.lifetime.end.p0(i64 12, ptr nonnull %2) #3
  br label %.loopexit

.loopexit:                                        ; preds = %101, %119, %29
  %.148 = phi i32 [ %.04766, %29 ], [ %36, %119 ], [ %36, %101 ]
  %.4 = phi i64 [ %.03967, %29 ], [ %.241.3, %119 ], [ %.342.2, %101 ]
  %121 = call noundef i64 @_ZNKSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4sizeEv(ptr noundef nonnull align 8 dereferenceable(25) @q)
  %.not = icmp eq i64 %121, 0
  br i1 %.not, label %.thread, label %29

.thread:                                          ; preds = %.loopexit, %35, %.preheader58, %0
  %.3 = phi i64 [ 0, %0 ], [ 0, %.preheader58 ], [ %.4, %.loopexit ], [ %.03967, %35 ]
  ret i64 %.3
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE4pushEOS0_(ptr noundef nonnull align 8 dereferenceable(25), ptr noundef nonnull align 4 dereferenceable(12)) local_unnamed_addr #1 align 2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(12) ptr @_ZNKSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE3topEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNSt14priority_queueI1PSt6vectorIS0_SaIS0_EESt4lessIS0_EE3popEv(ptr noundef nonnull align 8 dereferenceable(25)) local_unnamed_addr #1 align 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 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unswitch.partial.disable"}
!12 = !{!13, !6, i64 0}
!13 = !{!"_ZTS1P", !6, i64 0, !6, i64 4, !6, i64 8}
!14 = !{!13, !6, i64 4}
!15 = !{!13, !6, i64 8}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}


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