; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/22 Beta Division 2/Problem B (B)

; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::basic_istream" = type { ptr, i64, %"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_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@grid = external dso_local global [25 x [25 x i32]], align 16
@mx = external dso_local global i32, align 4
@_Z1sB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %13 = 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)
  %14 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %13, ptr noundef nonnull align 4 dereferenceable(4) @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %44, %0
  %16 = load i32, ptr %2, align 4, !tbaa !5
  %17 = load i32, ptr @n, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %15
  store i32 2, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #7
  br label %47

20:                                               ; preds = %15
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11)
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #7
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %40, %20
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = load i32, ptr @m, align 4, !tbaa !5
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %27, label %26

26:                                               ; preds = %22
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #7
  br label %43

27:                                               ; preds = %22
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %29)
  %31 = load i8, ptr %30, align 1, !tbaa !9
  %32 = sext i8 %31 to i32
  %33 = sub nsw i32 %32, 48
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [25 x [25 x i32]], ptr @grid, i64 0, i64 %35
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [25 x i32], ptr %36, i64 0, i64 %38
  store i32 %33, ptr %39, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %27
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %4, align 4, !tbaa !5
  br label %22, !llvm.loop !10

43:                                               ; preds = %26
  br label %44

44:                                               ; preds = %43
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !12

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

48:                                               ; preds = %146, %47
  %49 = load i32, ptr %5, align 4, !tbaa !5
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = icmp sle i32 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #7
  br label %149

53:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %142, %53
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = load i32, ptr @m, align 4, !tbaa !5
  %57 = icmp sle i32 %55, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %54
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #7
  br label %145

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

60:                                               ; preds = %138, %59
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = load i32, ptr %5, align 4, !tbaa !5
  %64 = sub nsw i32 %62, %63
  %65 = icmp sle i32 %61, %64
  br i1 %65, label %67, label %66

66:                                               ; preds = %60
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  br label %141

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

68:                                               ; preds = %133, %67
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = load i32, ptr @m, align 4, !tbaa !5
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = sub nsw i32 %70, %71
  %73 = icmp sle i32 %69, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %68
  store i32 17, ptr %3, align 4
  br label %136

75:                                               ; preds = %68
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 1, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #7
  %76 = load i32, ptr %7, align 4, !tbaa !5
  store i32 %76, ptr %10, align 4, !tbaa !5
  br label %77

77:                                               ; preds = %111, %75
  %78 = load i32, ptr %10, align 4, !tbaa !5
  %79 = load i32, ptr %7, align 4, !tbaa !5
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = add nsw i32 %79, %80
  %82 = icmp slt i32 %78, %81
  br i1 %82, label %84, label %83

83:                                               ; preds = %77
  store i32 20, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #7
  br label %114

84:                                               ; preds = %77
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #7
  %85 = load i32, ptr %8, align 4, !tbaa !5
  store i32 %85, ptr %11, align 4, !tbaa !5
  br label %86

86:                                               ; preds = %106, %84
  %87 = load i32, ptr %11, align 4, !tbaa !5
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = load i32, ptr %6, align 4, !tbaa !5
  %90 = add nsw i32 %88, %89
  %91 = icmp slt i32 %87, %90
  br i1 %91, label %93, label %92

92:                                               ; preds = %86
  store i32 23, ptr %3, align 4
  br label %109

93:                                               ; preds = %86
  %94 = load i32, ptr %10, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [25 x [25 x i32]], ptr @grid, i64 0, i64 %95
  %97 = load i32, ptr %11, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [25 x i32], ptr %96, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = icmp eq i32 %100, 1
  br i1 %101, label %102, label %105

102:                                              ; preds = %93
  store i32 0, ptr %9, align 4, !tbaa !5
  %103 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %103, ptr %10, align 4, !tbaa !5
  %104 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %104, ptr %11, align 4, !tbaa !5
  store i32 23, ptr %3, align 4
  br label %109

105:                                              ; preds = %93
  br label %106

106:                                              ; preds = %105
  %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 %86, !llvm.loop !13

109:                                              ; preds = %102, %92
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #7
  br label %110

110:                                              ; preds = %109
  br label %111

111:                                              ; preds = %110
  %112 = load i32, ptr %10, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr %10, align 4, !tbaa !5
  br label %77, !llvm.loop !14

114:                                              ; preds = %83
  %115 = load i32, ptr %9, align 4, !tbaa !5
  %116 = icmp ne i32 %115, 0
  br i1 %116, label %117, label %129

117:                                              ; preds = %114
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #7
  %118 = load i32, ptr %5, align 4, !tbaa !5
  %119 = load i32, ptr %5, align 4, !tbaa !5
  %120 = add nsw i32 %118, %119
  %121 = load i32, ptr %6, align 4, !tbaa !5
  %122 = add nsw i32 %120, %121
  %123 = load i32, ptr %6, align 4, !tbaa !5
  %124 = add nsw i32 %122, %123
  store i32 %124, ptr %12, align 4, !tbaa !5
  %125 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mx, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %126 = load i32, ptr %125, align 4, !tbaa !5
  store i32 %126, ptr @mx, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #7
  %127 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %127, ptr %7, align 4, !tbaa !5
  %128 = load i32, ptr @n, align 4, !tbaa !5
  store i32 %128, ptr %8, align 4, !tbaa !5
  store i32 17, ptr %3, align 4
  br label %130

129:                                              ; preds = %114
  store i32 0, ptr %3, align 4
  br label %130

130:                                              ; preds = %129, %117
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  %131 = load i32, ptr %3, align 4
  switch i32 %131, label %136 [
    i32 0, label %132
  ]

132:                                              ; preds = %130
  br label %133

133:                                              ; preds = %132
  %134 = load i32, ptr %8, align 4, !tbaa !5
  %135 = add nsw i32 %134, 1
  store i32 %135, ptr %8, align 4, !tbaa !5
  br label %68, !llvm.loop !15

136:                                              ; preds = %130, %74
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  br label %137

137:                                              ; preds = %136
  br label %138

138:                                              ; preds = %137
  %139 = load i32, ptr %7, align 4, !tbaa !5
  %140 = add nsw i32 %139, 1
  store i32 %140, ptr %7, align 4, !tbaa !5
  br label %60, !llvm.loop !16

141:                                              ; preds = %66
  br label %142

142:                                              ; preds = %141
  %143 = load i32, ptr %6, align 4, !tbaa !5
  %144 = add nsw i32 %143, 1
  store i32 %144, ptr %6, align 4, !tbaa !5
  br label %54, !llvm.loop !17

145:                                              ; preds = %58
  br label %146

146:                                              ; preds = %145
  %147 = load i32, ptr %5, align 4, !tbaa !5
  %148 = add nsw i32 %147, 1
  store i32 %148, ptr %5, align 4, !tbaa !5
  br label %48, !llvm.loop !18

149:                                              ; preds = %52
  %150 = load i32, ptr @mx, align 4, !tbaa !5
  %151 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %150)
  %152 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %151, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) #3 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: 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)) #4

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #5 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)) #6

attributes #0 = { 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 #1 = { "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 = { 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 #4 = { 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 #5 = { 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 #6 = { 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 #7 = { 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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11}
!17 = distinct !{!17, !11}
!18 = distinct !{!18, !11}


; 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::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.std::basic_istream" = type { ptr, i64, %"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_ostream" = type { ptr, %"class.std::basic_ios" }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@grid = external dso_local local_unnamed_addr global [25 x [25 x i32]], align 16
@mx = external dso_local global i32, align 4
@_Z1sB5cxx11 = external dso_local global %"class.std::__cxx11::basic_string", align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %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) @m)
  %4 = load i32, ptr @n, align 4
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.lr.ph64, label %._crit_edge79

.preheader60:                                     ; preds = %._crit_edge
  %.not76 = icmp slt i32 %11, 1
  %6 = load i32, ptr @m, align 4
  %7 = icmp slt i32 %6, 1
  %or.cond122 = select i1 %.not76, i1 true, i1 %7
  br i1 %or.cond122, label %._crit_edge79, label %.preheader59

.lr.ph64:                                         ; preds = %0, %._crit_edge
  %indvars.iv83 = phi i64 [ %indvars.iv.next84, %._crit_edge ], [ 0, %0 ]
  %8 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11)
  %9 = load i32, ptr @m, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph64
  %indvars.iv.next84 = add nuw nsw i64 %indvars.iv83, 1
  %11 = load i32, ptr @n, align 4
  %12 = sext i32 %11 to i64
  %13 = icmp slt i64 %indvars.iv.next84, %12
  br i1 %13, label %.lr.ph64, label %.preheader60, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph64, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.lr.ph64 ]
  %14 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %indvars.iv)
  %15 = load i8, ptr %14, align 1, !tbaa !11
  %16 = sext i8 %15 to i32
  %17 = add nsw i32 %16, -48
  %18 = getelementptr inbounds [25 x [25 x i32]], ptr @grid, i64 0, i64 %indvars.iv83, i64 %indvars.iv
  store i32 %17, ptr %18, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = icmp slt i64 %indvars.iv.next, %20
  br i1 %21, label %.lr.ph, label %._crit_edge, !llvm.loop !12

.preheader59:                                     ; preds = %.preheader60, %._crit_edge75
  %.pre100101 = phi i32 [ %.pre100102, %._crit_edge75 ], [ %6, %.preheader60 ]
  %22 = phi i32 [ %40, %._crit_edge75 ], [ %11, %.preheader60 ]
  %23 = phi i32 [ %41, %._crit_edge75 ], [ %6, %.preheader60 ]
  %24 = phi i32 [ %42, %._crit_edge75 ], [ %6, %.preheader60 ]
  %indvars.iv97 = phi i64 [ %indvars.iv.next98, %._crit_edge75 ], [ 1, %.preheader60 ]
  %.not4773 = icmp slt i32 %24, 1
  %25 = sext i32 %22 to i64
  %26 = icmp sgt i64 %indvars.iv97, %25
  %or.cond = select i1 %.not4773, i1 true, i1 %26
  br i1 %or.cond, label %._crit_edge75, label %.preheader58.preheader

.preheader58.preheader:                           ; preds = %.preheader59
  %27 = trunc nuw nsw i64 %indvars.iv97 to i32
  %.pre107 = trunc nuw nsw i64 %indvars.iv97 to i32
  br label %.preheader58

._crit_edge79:                                    ; preds = %._crit_edge75, %0, %.preheader60
  %28 = load i32, ptr @mx, align 4, !tbaa !5
  %29 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %28)
  %30 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %29, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0

.preheader58:                                     ; preds = %.preheader58.preheader, %._crit_edge72
  %.pre100 = phi i32 [ %.pre100101, %.preheader58.preheader ], [ %.pre100104, %._crit_edge72 ]
  %31 = phi i32 [ %22, %.preheader58.preheader ], [ %52, %._crit_edge72 ]
  %32 = phi i32 [ %23, %.preheader58.preheader ], [ %53, %._crit_edge72 ]
  %33 = phi i32 [ %22, %.preheader58.preheader ], [ %54, %._crit_edge72 ]
  %34 = phi i32 [ %22, %.preheader58.preheader ], [ %55, %._crit_edge72 ]
  %indvars.iv94 = phi i64 [ 1, %.preheader58.preheader ], [ %indvars.iv.next95, %._crit_edge72 ]
  %indvars.iv92 = phi i32 [ 0, %.preheader58.preheader ], [ %indvars.iv.next93, %._crit_edge72 ]
  %35 = sext i32 %34 to i64
  %.not4870 = icmp sgt i64 %indvars.iv97, %35
  br i1 %.not4870, label %._crit_edge72, label %.preheader56.lr.ph

.preheader56.lr.ph:                               ; preds = %.preheader58
  %36 = add nuw nsw i64 %indvars.iv94, %indvars.iv97
  %37 = trunc nuw i64 %36 to i32
  %38 = shl i32 %37, 1
  %39 = trunc nuw nsw i64 %indvars.iv94 to i32
  br label %.preheader56

._crit_edge75:                                    ; preds = %._crit_edge72, %.preheader59
  %.pre100102 = phi i32 [ %.pre100101, %.preheader59 ], [ %.pre100104, %._crit_edge72 ]
  %40 = phi i32 [ %22, %.preheader59 ], [ %52, %._crit_edge72 ]
  %41 = phi i32 [ %23, %.preheader59 ], [ %53, %._crit_edge72 ]
  %42 = phi i32 [ %24, %.preheader59 ], [ %53, %._crit_edge72 ]
  %indvars.iv.next98 = add nuw nsw i64 %indvars.iv97, 1
  %43 = sext i32 %40 to i64
  %.not.not = icmp slt i64 %indvars.iv97, %43
  br i1 %.not.not, label %.preheader59, label %._crit_edge79, !llvm.loop !13

.preheader56:                                     ; preds = %.preheader56.lr.ph, %.loopexit57
  %.pre100105 = phi i32 [ %.pre100, %.preheader56.lr.ph ], [ %.pre100106, %.loopexit57 ]
  %44 = phi i32 [ %31, %.preheader56.lr.ph ], [ %72, %.loopexit57 ]
  %45 = phi i32 [ %33, %.preheader56.lr.ph ], [ %73, %.loopexit57 ]
  %46 = phi i32 [ %34, %.preheader56.lr.ph ], [ %73, %.loopexit57 ]
  %47 = phi i32 [ %.pre100, %.preheader56.lr.ph ], [ %74, %.loopexit57 ]
  %.04071 = phi i32 [ 0, %.preheader56.lr.ph ], [ %75, %.loopexit57 ]
  %.not4968 = icmp slt i32 %47, %39
  br i1 %.not4968, label %.loopexit57, label %.preheader55.lr.ph

.preheader55.lr.ph:                               ; preds = %.preheader56
  %48 = add nsw i32 %.04071, %27
  %49 = add i32 %indvars.iv92, %47
  %wide.trip.count = zext i32 %49 to i64
  %50 = add nsw i32 %46, 1
  %51 = icmp slt i32 %50, %48
  br label %.preheader55

._crit_edge72:                                    ; preds = %.loopexit57, %.preheader58
  %.pre100104 = phi i32 [ %.pre100, %.preheader58 ], [ %.pre100106, %.loopexit57 ]
  %52 = phi i32 [ %31, %.preheader58 ], [ %72, %.loopexit57 ]
  %53 = phi i32 [ %32, %.preheader58 ], [ %74, %.loopexit57 ]
  %54 = phi i32 [ %33, %.preheader58 ], [ %73, %.loopexit57 ]
  %55 = phi i32 [ %34, %.preheader58 ], [ %73, %.loopexit57 ]
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  %56 = sext i32 %53 to i64
  %.not47.not = icmp slt i64 %indvars.iv94, %56
  %indvars.iv.next93 = add nsw i32 %indvars.iv92, -1
  br i1 %.not47.not, label %.preheader58, label %._crit_edge75, !llvm.loop !15

.thread:                                          ; preds = %.loopexit.thread, %59
  %indvars.iv.next87 = add nuw nsw i64 %indvars.iv86, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next87, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit57, label %.preheader55, !llvm.loop !16

.preheader55:                                     ; preds = %.preheader55.lr.ph, %.thread
  %indvars.iv86 = phi i64 [ 0, %.preheader55.lr.ph ], [ %indvars.iv.next87, %.thread ]
  %57 = add nuw nsw i64 %indvars.iv86, %indvars.iv94
  br label %.preheader.outer

.preheader.outer:                                 ; preds = %.loopexit.thread, %.preheader55
  %.03567.ph = phi i32 [ %50, %.loopexit.thread ], [ %.04071, %.preheader55 ]
  %.not50 = phi i1 [ true, %.loopexit.thread ], [ false, %.preheader55 ]
  br label %.preheader

.preheader:                                       ; preds = %.preheader.outer, %.loopexit
  %.03567 = phi i32 [ %66, %.loopexit ], [ %.03567.ph, %.preheader.outer ]
  %58 = sext i32 %.03567 to i64
  br label %62

59:                                               ; preds = %.loopexit
  br i1 %.not50, label %.thread, label %68

60:                                               ; preds = %62
  %indvars.iv.next89 = add nuw nsw i64 %indvars.iv88, 1
  %61 = icmp ult i64 %indvars.iv.next89, %57
  br i1 %61, label %62, label %.loopexit, !llvm.loop !17

62:                                               ; preds = %.preheader, %60
  %indvars.iv88 = phi i64 [ %indvars.iv86, %.preheader ], [ %indvars.iv.next89, %60 ]
  %63 = getelementptr inbounds [25 x [25 x i32]], ptr @grid, i64 0, i64 %58, i64 %indvars.iv88
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = icmp eq i32 %64, 1
  br i1 %65, label %.loopexit.thread, label %60

.loopexit:                                        ; preds = %60
  %66 = add nsw i32 %.03567, 1
  %67 = icmp slt i32 %66, %48
  br i1 %67, label %.preheader, label %59, !llvm.loop !18

.loopexit.thread:                                 ; preds = %62
  br i1 %51, label %.preheader.outer, label %.thread, !llvm.loop !18

68:                                               ; preds = %59
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  store i32 %38, ptr %1, align 4, !tbaa !5
  %69 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mx, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %70 = load i32, ptr %69, align 4, !tbaa !5
  store i32 %70, ptr @mx, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %71 = load i32, ptr @n, align 4
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %.loopexit57

.loopexit57:                                      ; preds = %.thread, %.preheader56, %68
  %.pre-phi = phi i32 [ %27, %68 ], [ %.pre107, %.preheader56 ], [ %27, %.thread ]
  %.pre100106 = phi i32 [ %.pre, %68 ], [ %.pre100105, %.preheader56 ], [ %.pre100105, %.thread ]
  %72 = phi i32 [ %71, %68 ], [ %44, %.preheader56 ], [ %44, %.thread ]
  %73 = phi i32 [ %71, %68 ], [ %45, %.preheader56 ], [ %45, %.thread ]
  %74 = phi i32 [ %.pre, %68 ], [ %47, %.preheader56 ], [ %47, %.thread ]
  %.3 = phi i32 [ %71, %68 ], [ %.04071, %.preheader56 ], [ %.04071, %.thread ]
  %75 = add nsw i32 %.3, 1
  %76 = sub nsw i32 %73, %.pre-phi
  %.not48.not = icmp slt i32 %.3, %76
  br i1 %.not48.not, label %.preheader56, label %._crit_edge72, !llvm.loop !19
}

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 #1

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

declare noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE(ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32), i64 noundef) local_unnamed_addr #3 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: 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 #4

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) 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 #5 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)) #6

attributes #0 = { 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 #1 = { "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 = { 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 #4 = { 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 #5 = { 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 #6 = { 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 #7 = { 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10, !14}
!14 = !{!"llvm.loop.unswitch.partial.disable"}
!15 = distinct !{!15, !10, !14}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}


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