; LLVM IR from andreimaximov/algorithms :: codeforces/the-bakery (main)

; 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::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@A = external dso_local global [35005 x i32], align 16
@DP = external dso_local global [35005 x [55 x i32]], align 16
@P = external dso_local global [35005 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

; 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
declare dso_local noundef i32 @_Z3rmqii(i32 noundef, i32 noundef) #1

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5clearv() #2

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #1 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #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 i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %8 = call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %9 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %10 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %9, ptr noundef nonnull align 4 dereferenceable(4) @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #6
  store i32 1, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %21, %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = icmp sle i32 %12, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #6
  br label %24

16:                                               ; preds = %11
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %18
  %20 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %19)
  br label %21

21:                                               ; preds = %16
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !9

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

25:                                               ; preds = %67, %24
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = load i32, ptr @n, align 4, !tbaa !5
  %28 = icmp sle i32 %26, %27
  br i1 %28, label %30, label %29

29:                                               ; preds = %25
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  br label %70

30:                                               ; preds = %25
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %35
  %37 = load i32, ptr %36, align 4, !tbaa !5
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %47

39:                                               ; preds = %30
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sub nsw i32 %40, 1
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %42
  %44 = getelementptr inbounds [55 x i32], ptr %43, i64 0, i64 1
  %45 = load i32, ptr %44, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  br label %54

47:                                               ; preds = %30
  %48 = load i32, ptr %3, align 4, !tbaa !5
  %49 = sub nsw i32 %48, 1
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %50
  %52 = getelementptr inbounds [55 x i32], ptr %51, i64 0, i64 1
  %53 = load i32, ptr %52, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %47, %39
  %55 = phi i32 [ %46, %39 ], [ %53, %47 ]
  %56 = load i32, ptr %3, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %57
  %59 = getelementptr inbounds [55 x i32], ptr %58, i64 0, i64 1
  store i32 %55, ptr %59, align 4, !tbaa !5
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = load i32, ptr %3, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %65
  store i32 %60, ptr %66, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %54
  %68 = load i32, ptr %3, align 4, !tbaa !5
  %69 = add nsw i32 %68, 1
  store i32 %69, ptr %3, align 4, !tbaa !5
  br label %25, !llvm.loop !11

70:                                               ; preds = %29
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 2, ptr %4, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %169, %70
  %72 = load i32, ptr %4, align 4, !tbaa !5
  %73 = load i32, ptr @k, align 4, !tbaa !5
  %74 = icmp sle i32 %72, %73
  br i1 %74, label %76, label %75

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

76:                                               ; preds = %71
  call void @_Z5clearv()
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = load i32, ptr %4, align 4, !tbaa !5
  %79 = sext i32 %78 to i64
  %80 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %79
  %81 = load i32, ptr %4, align 4, !tbaa !5
  %82 = sext i32 %81 to i64
  %83 = getelementptr inbounds [55 x i32], ptr %80, i64 0, i64 %82
  store i32 %77, ptr %83, align 4, !tbaa !5
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %86
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %89
  store i32 %84, ptr %90, align 4, !tbaa !5
  %91 = load i32, ptr %4, align 4, !tbaa !5
  %92 = sub nsw i32 %91, 1
  %93 = load i32, ptr %4, align 4, !tbaa !5
  %94 = sub nsw i32 %93, 1
  %95 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z6updateiii(i32 noundef %92, i32 noundef %94, i32 noundef %95)
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %96 = load i32, ptr %4, align 4, !tbaa !5
  %97 = add nsw i32 %96, 1
  store i32 %97, ptr %6, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %165, %76
  %99 = load i32, ptr %6, align 4, !tbaa !5
  %100 = load i32, ptr @n, align 4, !tbaa !5
  %101 = icmp sle i32 %99, %100
  br i1 %101, label %103, label %102

102:                                              ; preds = %98
  store i32 11, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %168

103:                                              ; preds = %98
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  %104 = load i32, ptr %6, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = sext i32 %107 to i64
  %109 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %108
  %110 = load i32, ptr %109, align 4, !tbaa !5
  %111 = icmp eq i32 %110, 0
  br i1 %111, label %112, label %115

112:                                              ; preds = %103
  %113 = load i32, ptr %4, align 4, !tbaa !5
  %114 = sub nsw i32 %113, 1
  br label %123

115:                                              ; preds = %103
  %116 = load i32, ptr %6, align 4, !tbaa !5
  %117 = sext i32 %116 to i64
  %118 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %117
  %119 = load i32, ptr %118, align 4, !tbaa !5
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %120
  %122 = load i32, ptr %121, align 4, !tbaa !5
  br label %123

123:                                              ; preds = %115, %112
  %124 = phi i32 [ %114, %112 ], [ %122, %115 ]
  store i32 %124, ptr %7, align 4, !tbaa !5
  %125 = load i32, ptr %7, align 4, !tbaa !5
  %126 = load i32, ptr %6, align 4, !tbaa !5
  %127 = sub nsw i32 %126, 1
  %128 = icmp slt i32 %125, %127
  br i1 %128, label %129, label %133

129:                                              ; preds = %123
  %130 = load i32, ptr %7, align 4, !tbaa !5
  %131 = load i32, ptr %6, align 4, !tbaa !5
  %132 = sub nsw i32 %131, 2
  call void @_Z6updateiii(i32 noundef %130, i32 noundef %132, i32 noundef 1)
  br label %133

133:                                              ; preds = %129, %123
  %134 = load i32, ptr %6, align 4, !tbaa !5
  %135 = sub nsw i32 %134, 1
  %136 = load i32, ptr %6, align 4, !tbaa !5
  %137 = sub nsw i32 %136, 1
  %138 = load i32, ptr %6, align 4, !tbaa !5
  %139 = sub nsw i32 %138, 1
  %140 = sext i32 %139 to i64
  %141 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %140
  %142 = load i32, ptr %4, align 4, !tbaa !5
  %143 = sub nsw i32 %142, 1
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [55 x i32], ptr %141, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = add nsw i32 %146, 1
  call void @_Z6updateiii(i32 noundef %135, i32 noundef %137, i32 noundef %147)
  %148 = load i32, ptr %4, align 4, !tbaa !5
  %149 = sub nsw i32 %148, 1
  %150 = load i32, ptr %6, align 4, !tbaa !5
  %151 = call noundef i32 @_Z3rmqii(i32 noundef %149, i32 noundef %150)
  %152 = load i32, ptr %6, align 4, !tbaa !5
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %153
  %155 = load i32, ptr %4, align 4, !tbaa !5
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [55 x i32], ptr %154, i64 0, i64 %156
  store i32 %151, ptr %157, align 4, !tbaa !5
  %158 = load i32, ptr %6, align 4, !tbaa !5
  %159 = load i32, ptr %6, align 4, !tbaa !5
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %160
  %162 = load i32, ptr %161, align 4, !tbaa !5
  %163 = sext i32 %162 to i64
  %164 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %163
  store i32 %158, ptr %164, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #6
  br label %165

165:                                              ; preds = %133
  %166 = load i32, ptr %6, align 4, !tbaa !5
  %167 = add nsw i32 %166, 1
  store i32 %167, ptr %6, align 4, !tbaa !5
  br label %98, !llvm.loop !12

168:                                              ; preds = %102
  br label %169

169:                                              ; preds = %168
  %170 = load i32, ptr %4, align 4, !tbaa !5
  %171 = add nsw i32 %170, 1
  store i32 %171, ptr %4, align 4, !tbaa !5
  br label %71, !llvm.loop !13

172:                                              ; preds = %75
  %173 = load i32, ptr @n, align 4, !tbaa !5
  %174 = sext i32 %173 to i64
  %175 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %174
  %176 = load i32, ptr @k, align 4, !tbaa !5
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [55 x i32], ptr %175, i64 0, i64 %177
  %179 = load i32, ptr %178, align 4, !tbaa !5
  %180 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %179)
  %181 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %180, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) #5

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #5

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 = { 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 = { inlinehint 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !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"

%"class.std::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }
%"class.std::basic_istream" = type { ptr, i64, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@A = external dso_local global [35005 x i32], align 16
@DP = external dso_local local_unnamed_addr global [35005 x [55 x i32]], align 16
@P = external dso_local local_unnamed_addr global [35005 x i32], align 16
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5clearv() local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #0 align 2

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(ptr noundef nonnull align 8 dereferenceable(8)) #2

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = tail call noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext false)
  %2 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) @n)
  %3 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %2, ptr noundef nonnull align 4 dereferenceable(4) @k)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not52 = icmp slt i32 %4, 1
  br i1 %.not52, label %.preheader, label %.lr.ph

.preheader50:                                     ; preds = %.lr.ph
  %.not4754 = icmp slt i32 %8, 1
  br i1 %.not4754, label %.preheader, label %.lr.ph56.preheader

.lr.ph56.preheader:                               ; preds = %.preheader50
  %5 = add nuw i32 %8, 1
  %wide.trip.count = zext i32 %5 to i64
  br label %.lr.ph56

.lr.ph:                                           ; preds = %0, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 1, %0 ]
  %6 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %indvars.iv
  %7 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %8 = load i32, ptr @n, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %.not.not = icmp slt i64 %indvars.iv, %9
  br i1 %.not.not, label %.lr.ph, label %.preheader50, !llvm.loop !9

.preheader:                                       ; preds = %.lr.ph56, %0, %.preheader50
  %.lcssa5180 = phi i32 [ %8, %.preheader50 ], [ %4, %0 ], [ %8, %.lr.ph56 ]
  %10 = load i32, ptr @k, align 4, !tbaa !5
  %.not4860 = icmp slt i32 %10, 2
  br i1 %.not4860, label %.preheader.._crit_edge_crit_edge, label %.lr.ph62

.preheader.._crit_edge_crit_edge:                 ; preds = %.preheader
  %.pre = sext i32 %10 to i64
  br label %._crit_edge

.lr.ph56:                                         ; preds = %.lr.ph56.preheader, %.lr.ph56
  %indvars.iv67 = phi i64 [ 1, %.lr.ph56.preheader ], [ %indvars.iv.next68, %.lr.ph56 ]
  %11 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %indvars.iv67
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = icmp eq i32 %15, 0
  %17 = add nsw i64 %indvars.iv67, -1
  %18 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %17, i64 1
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = zext i1 %16 to i32
  %21 = add nsw i32 %19, %20
  %22 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %indvars.iv67, i64 1
  store i32 %21, ptr %22, align 4, !tbaa !5
  %23 = trunc nuw nsw i64 %indvars.iv67 to i32
  store i32 %23, ptr %14, align 4, !tbaa !5
  %indvars.iv.next68 = add nuw nsw i64 %indvars.iv67, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next68, %wide.trip.count
  br i1 %exitcond.not, label %.preheader, label %.lr.ph56, !llvm.loop !11

.loopexit:                                        ; preds = %57, %.lr.ph62
  %24 = phi i32 [ %40, %.lr.ph62 ], [ %68, %57 ]
  %25 = load i32, ptr @k, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %.not48.not = icmp slt i64 %indvars.iv75, %26
  %indvars.iv.next71 = add nuw i32 %indvars.iv70, 1
  br i1 %.not48.not, label %.lr.ph62, label %._crit_edge, !llvm.loop !12

._crit_edge:                                      ; preds = %.loopexit, %.preheader.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.preheader.._crit_edge_crit_edge ], [ %26, %.loopexit ]
  %27 = phi i32 [ %.lcssa5180, %.preheader.._crit_edge_crit_edge ], [ %24, %.loopexit ]
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %28, i64 %.pre-phi
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %30)
  %32 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %31, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.lr.ph62:                                         ; preds = %.preheader, %.loopexit
  %indvars.iv75 = phi i64 [ %indvars.iv.next76, %.loopexit ], [ 2, %.preheader ]
  %indvars.iv70 = phi i32 [ %indvars.iv.next71, %.loopexit ], [ 3, %.preheader ]
  %indvars77 = trunc i64 %indvars.iv75 to i32
  tail call void @_Z5clearv()
  %33 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %indvars.iv75, i64 %indvars.iv75
  store i32 %indvars77, ptr %33, align 4, !tbaa !5
  %34 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %indvars.iv75
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %36
  store i32 %indvars77, ptr %37, align 4, !tbaa !5
  %38 = add nsw i64 %indvars.iv75, -1
  %39 = add nsw i32 %indvars77, -1
  tail call void @_Z6updateiii(i32 noundef %39, i32 noundef %39, i32 noundef %indvars77)
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %40 = load i32, ptr @n, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %.not4957.not = icmp slt i64 %indvars.iv75, %41
  br i1 %.not4957.not, label %.lr.ph59, label %.loopexit

.lr.ph59:                                         ; preds = %.lr.ph62
  %42 = sext i32 %indvars.iv70 to i64
  %43 = trunc nuw nsw i64 %38 to i32
  br label %44

44:                                               ; preds = %.lr.ph59, %57
  %indvars.iv72 = phi i64 [ %42, %.lr.ph59 ], [ %indvars.iv.next73, %57 ]
  %45 = getelementptr inbounds [35005 x i32], ptr @A, i64 0, i64 %indvars.iv72
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = icmp eq i32 %49, 0
  %. = select i1 %50, i32 %43, i32 %49
  %51 = add nsw i64 %indvars.iv72, -1
  %52 = sext i32 %. to i64
  %53 = icmp sgt i64 %51, %52
  br i1 %53, label %54, label %57

54:                                               ; preds = %44
  %55 = trunc i64 %indvars.iv72 to i32
  %56 = add nsw i32 %55, -2
  tail call void @_Z6updateiii(i32 noundef %., i32 noundef %56, i32 noundef 1)
  br label %57

57:                                               ; preds = %54, %44
  %58 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %51, i64 %38
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = add nsw i32 %59, 1
  %61 = trunc nuw nsw i64 %51 to i32
  tail call void @_Z6updateiii(i32 noundef %61, i32 noundef %61, i32 noundef %60)
  %62 = trunc nsw i64 %indvars.iv72 to i32
  %63 = tail call noundef i32 @_Z3rmqii(i32 noundef %43, i32 noundef %62)
  %64 = getelementptr inbounds [35005 x [55 x i32]], ptr @DP, i64 0, i64 %indvars.iv72, i64 %indvars.iv75
  store i32 %63, ptr %64, align 4, !tbaa !5
  %65 = load i32, ptr %45, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [35005 x i32], ptr @P, i64 0, i64 %66
  store i32 %62, ptr %67, align 4, !tbaa !5
  %indvars.iv.next73 = add nuw nsw i64 %indvars.iv72, 1
  %68 = load i32, ptr @n, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %.not49.not = icmp slt i64 %indvars.iv72, %69
  br i1 %.not49.not, label %44, label %.loopexit, !llvm.loop !13
}

declare noundef zeroext i1 @_ZNSt8ios_base15sync_with_stdioEb(i1 noundef zeroext) local_unnamed_addr #4

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #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 = { 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 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" }

!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}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}


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