; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/168 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 [52 x [52 x i32]], align 16
@visited = external dso_local global [52 x [52 x i32]], align 16
@cntt = 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
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #1 {
  %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
  store i32 0, ptr %1, align 4
  %10 = 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)
  %11 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %10, 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 %12

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

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

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

17:                                               ; preds = %28, %16
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = icmp sle i32 %18, 51
  br i1 %19, label %21, label %20

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

21:                                               ; preds = %17
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [52 x [52 x i32]], ptr @grid, i64 0, i64 %23
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [52 x i32], ptr %24, i64 0, i64 %26
  store i32 -1, ptr %27, align 4, !tbaa !5
  br label %28

28:                                               ; preds = %21
  %29 = load i32, ptr %4, align 4, !tbaa !5
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %4, align 4, !tbaa !5
  br label %17, !llvm.loop !9

31:                                               ; preds = %20
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = add nsw i32 %33, 1
  store i32 %34, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !11

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

36:                                               ; preds = %77, %35
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr @n, align 4, !tbaa !5
  %39 = icmp sle i32 %37, %38
  br i1 %39, label %41, label %40

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

41:                                               ; preds = %36
  %42 = 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 %6) #7
  store i32 1, ptr %6, align 4, !tbaa !5
  br label %43

43:                                               ; preds = %73, %41
  %44 = load i32, ptr %6, align 4, !tbaa !5
  %45 = load i32, ptr @m, align 4, !tbaa !5
  %46 = icmp sle i32 %44, %45
  br i1 %46, label %48, label %47

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

48:                                               ; preds = %43
  %49 = load i32, ptr %6, align 4, !tbaa !5
  %50 = sub nsw i32 %49, 1
  %51 = sext i32 %50 to i64
  %52 = call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %51)
  %53 = load i8, ptr %52, align 1, !tbaa !12
  %54 = sext i8 %53 to i32
  %55 = icmp eq i32 %54, 66
  br i1 %55, label %56, label %65

56:                                               ; preds = %48
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [52 x [52 x i32]], ptr @grid, i64 0, i64 %58
  %60 = load i32, ptr %6, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [52 x i32], ptr %59, i64 0, i64 %61
  store i32 1, ptr %62, align 4, !tbaa !5
  %63 = load i32, ptr @cntt, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr @cntt, align 4, !tbaa !5
  br label %72

65:                                               ; preds = %48
  %66 = load i32, ptr %5, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [52 x [52 x i32]], ptr @grid, i64 0, i64 %67
  %69 = load i32, ptr %6, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [52 x i32], ptr %68, i64 0, i64 %70
  store i32 0, ptr %71, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %65, %56
  br label %73

73:                                               ; preds = %72
  %74 = load i32, ptr %6, align 4, !tbaa !5
  %75 = add nsw i32 %74, 1
  store i32 %75, ptr %6, align 4, !tbaa !5
  br label %43, !llvm.loop !13

76:                                               ; preds = %47
  br label %77

77:                                               ; preds = %76
  %78 = load i32, ptr %5, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  store i32 %79, ptr %5, align 4, !tbaa !5
  br label %36, !llvm.loop !14

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

81:                                               ; preds = %148, %80
  %82 = load i32, ptr %7, align 4, !tbaa !5
  %83 = load i32, ptr @n, align 4, !tbaa !5
  %84 = icmp sle i32 %82, %83
  br i1 %84, label %86, label %85

85:                                               ; preds = %81
  store i32 14, ptr %3, align 4
  br label %151

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

87:                                               ; preds = %142, %86
  %88 = load i32, ptr %8, align 4, !tbaa !5
  %89 = load i32, ptr @m, align 4, !tbaa !5
  %90 = icmp sle i32 %88, %89
  br i1 %90, label %92, label %91

91:                                               ; preds = %87
  store i32 17, ptr %3, align 4
  br label %145

92:                                               ; preds = %87
  %93 = load i32, ptr %7, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [52 x [52 x i32]], ptr @grid, i64 0, i64 %94
  %96 = load i32, ptr %8, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [52 x i32], ptr %95, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = icmp eq i32 %99, 1
  br i1 %100, label %101, label %141

101:                                              ; preds = %92
  call void @llvm.memset.p0.i64(ptr align 16 @visited, i8 0, i64 10816, i1 false)
  %102 = load i32, ptr %7, align 4, !tbaa !5
  %103 = sext i32 %102 to i64
  %104 = getelementptr inbounds [52 x [52 x i32]], ptr @visited, i64 0, i64 %103
  %105 = load i32, ptr %8, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [52 x i32], ptr %104, i64 0, i64 %106
  store i32 1, ptr %107, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #7
  store i32 1, ptr %9, align 4, !tbaa !5
  %108 = load i32, ptr %7, align 4, !tbaa !5
  %109 = sub nsw i32 %108, 1
  %110 = load i32, ptr %8, align 4, !tbaa !5
  %111 = call noundef i32 @_Z5go_upiiii(i32 noundef %109, i32 noundef %110, i32 noundef 0, i32 noundef 0)
  %112 = load i32, ptr %9, align 4, !tbaa !5
  %113 = add nsw i32 %112, %111
  store i32 %113, ptr %9, align 4, !tbaa !5
  %114 = load i32, ptr %7, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  %116 = load i32, ptr %8, align 4, !tbaa !5
  %117 = call noundef i32 @_Z7go_downiiii(i32 noundef %115, i32 noundef %116, i32 noundef 0, i32 noundef 0)
  %118 = load i32, ptr %9, align 4, !tbaa !5
  %119 = add nsw i32 %118, %117
  store i32 %119, ptr %9, align 4, !tbaa !5
  %120 = load i32, ptr %7, align 4, !tbaa !5
  %121 = load i32, ptr %8, align 4, !tbaa !5
  %122 = sub nsw i32 %121, 1
  %123 = call noundef i32 @_Z7go_leftiiii(i32 noundef %120, i32 noundef %122, i32 noundef 0, i32 noundef 0)
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = add nsw i32 %124, %123
  store i32 %125, ptr %9, align 4, !tbaa !5
  %126 = load i32, ptr %7, align 4, !tbaa !5
  %127 = load i32, ptr %8, align 4, !tbaa !5
  %128 = add nsw i32 %127, 1
  %129 = call noundef i32 @_Z8go_rightiiii(i32 noundef %126, i32 noundef %128, i32 noundef 0, i32 noundef 0)
  %130 = load i32, ptr %9, align 4, !tbaa !5
  %131 = add nsw i32 %130, %129
  store i32 %131, ptr %9, align 4, !tbaa !5
  %132 = load i32, ptr %9, align 4, !tbaa !5
  %133 = load i32, ptr @cntt, align 4, !tbaa !5
  %134 = icmp ne i32 %132, %133
  br i1 %134, label %135, label %137

135:                                              ; preds = %101
  %136 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %3, align 4
  br label %138

137:                                              ; preds = %101
  store i32 0, ptr %3, align 4
  br label %138

138:                                              ; preds = %137, %135
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #7
  %139 = load i32, ptr %3, align 4
  switch i32 %139, label %145 [
    i32 0, label %140
  ]

140:                                              ; preds = %138
  br label %141

141:                                              ; preds = %140, %92
  br label %142

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

145:                                              ; preds = %138, %91
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #7
  %146 = load i32, ptr %3, align 4
  switch i32 %146, label %151 [
    i32 17, label %147
  ]

147:                                              ; preds = %145
  br label %148

148:                                              ; preds = %147
  %149 = load i32, ptr %7, align 4, !tbaa !5
  %150 = add nsw i32 %149, 1
  store i32 %150, ptr %7, align 4, !tbaa !5
  br label %81, !llvm.loop !16

151:                                              ; preds = %145, %85
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #7
  %152 = load i32, ptr %3, align 4
  switch i32 %152, label %157 [
    i32 14, label %153
    i32 1, label %155
  ]

153:                                              ; preds = %151
  %154 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef @.str.2)
  store i32 0, ptr %1, align 4
  br label %155

155:                                              ; preds = %153, %151
  %156 = load i32, ptr %1, align 4
  ret i32 %156

157:                                              ; preds = %151
  unreachable
}

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

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

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

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)) #2

; 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) #4 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #6

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 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 #2 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = distinct !{!11, !10}
!12 = !{!7, !7, i64 0}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !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::__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 [52 x [52 x i32]], align 16
@visited = external dso_local local_unnamed_addr global [52 x [52 x i32]], align 16
@cntt = external dso_local local_unnamed_addr 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
@.str = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #1 {
.preheader60:
  %0 = 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)
  %1 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull align 4 dereferenceable(4) @m)
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(10816) @grid, i8 -1, i64 10816, i1 false), !tbaa !5
  %2 = load i32, ptr @n, align 4, !tbaa !5
  %.not66 = icmp slt i32 %2, 1
  br i1 %.not66, label %._crit_edge75, label %.lr.ph68

.preheader59:                                     ; preds = %._crit_edge
  %.not5073 = icmp slt i32 %7, 1
  %3 = load i32, ptr @m, align 4
  %4 = icmp slt i32 %3, 1
  %or.cond = select i1 %.not5073, i1 true, i1 %4
  br i1 %or.cond, label %._crit_edge75, label %.preheader

.lr.ph68:                                         ; preds = %.preheader60, %._crit_edge
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %._crit_edge ], [ 1, %.preheader60 ]
  %5 = 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)
  %6 = load i32, ptr @m, align 4, !tbaa !5
  %.not5364 = icmp slt i32 %6, 1
  br i1 %.not5364, label %._crit_edge, label %.lr.ph

._crit_edge:                                      ; preds = %16, %.lr.ph68
  %indvars.iv.next81 = add nuw nsw i64 %indvars.iv80, 1
  %7 = load i32, ptr @n, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %.not.not = icmp slt i64 %indvars.iv80, %8
  br i1 %.not.not, label %.lr.ph68, label %.preheader59, !llvm.loop !9

.lr.ph:                                           ; preds = %.lr.ph68, %16
  %indvars.iv = phi i64 [ %indvars.iv.next, %16 ], [ 1, %.lr.ph68 ]
  %9 = add nsw i64 %indvars.iv, -1
  %10 = tail call noundef nonnull align 1 dereferenceable(1) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm(ptr noundef nonnull align 8 dereferenceable(32) @_Z1sB5cxx11, i64 noundef %9)
  %11 = load i8, ptr %10, align 1, !tbaa !11
  %12 = icmp eq i8 %11, 66
  br i1 %12, label %13, label %16

13:                                               ; preds = %.lr.ph
  %14 = load i32, ptr @cntt, align 4, !tbaa !5
  %15 = add nsw i32 %14, 1
  store i32 %15, ptr @cntt, align 4, !tbaa !5
  br label %16

16:                                               ; preds = %.lr.ph, %13
  %.sink = phi i32 [ 1, %13 ], [ 0, %.lr.ph ]
  %17 = getelementptr inbounds [52 x [52 x i32]], ptr @grid, i64 0, i64 %indvars.iv80, i64 %indvars.iv
  store i32 %.sink, ptr %17, align 4
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %18 = load i32, ptr @m, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %.not53.not = icmp slt i64 %indvars.iv, %19
  br i1 %.not53.not, label %.lr.ph, label %._crit_edge, !llvm.loop !12

.preheader:                                       ; preds = %.preheader59, %._crit_edge72
  %20 = phi i32 [ %50, %._crit_edge72 ], [ %7, %.preheader59 ]
  %21 = phi i32 [ %51, %._crit_edge72 ], [ %3, %.preheader59 ]
  %22 = phi i32 [ %52, %._crit_edge72 ], [ %3, %.preheader59 ]
  %indvars.iv86 = phi i64 [ %.pre91, %._crit_edge72 ], [ 1, %.preheader59 ]
  %.not5169 = icmp slt i32 %22, 1
  %.pre91 = add nuw nsw i64 %indvars.iv86, 1
  br i1 %.not5169, label %._crit_edge72, label %.lr.ph71

.lr.ph71:                                         ; preds = %.preheader
  %23 = trunc i64 %indvars.iv86 to i32
  %24 = add i32 %23, -1
  %25 = trunc nuw i64 %.pre91 to i32
  %26 = trunc nuw nsw i64 %indvars.iv86 to i32
  br label %27

27:                                               ; preds = %.lr.ph71, %.critedge
  %28 = phi i32 [ %21, %.lr.ph71 ], [ %48, %.critedge ]
  %indvars.iv83 = phi i64 [ 1, %.lr.ph71 ], [ %indvars.iv.next84.pre-phi, %.critedge ]
  %29 = getelementptr inbounds [52 x [52 x i32]], ptr @grid, i64 0, i64 %indvars.iv86, i64 %indvars.iv83
  %30 = load i32, ptr %29, align 4, !tbaa !5
  %31 = icmp eq i32 %30, 1
  br i1 %31, label %32, label %..critedge_crit_edge90

..critedge_crit_edge90:                           ; preds = %27
  %.pre92 = add nuw nsw i64 %indvars.iv83, 1
  br label %.critedge

32:                                               ; preds = %27
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(10816) @visited, i8 0, i64 10816, i1 false)
  %33 = getelementptr inbounds [52 x [52 x i32]], ptr @visited, i64 0, i64 %indvars.iv86, i64 %indvars.iv83
  store i32 1, ptr %33, align 4, !tbaa !5
  %34 = trunc nuw nsw i64 %indvars.iv83 to i32
  %35 = tail call noundef i32 @_Z5go_upiiii(i32 noundef %24, i32 noundef %34, i32 noundef 0, i32 noundef 0)
  %36 = add nsw i32 %35, 1
  %37 = tail call noundef i32 @_Z7go_downiiii(i32 noundef %25, i32 noundef %34, i32 noundef 0, i32 noundef 0)
  %38 = add nsw i32 %36, %37
  %39 = trunc i64 %indvars.iv83 to i32
  %40 = add i32 %39, -1
  %41 = tail call noundef i32 @_Z7go_leftiiii(i32 noundef %26, i32 noundef %40, i32 noundef 0, i32 noundef 0)
  %42 = add nsw i32 %38, %41
  %43 = add nuw nsw i64 %indvars.iv83, 1
  %44 = trunc nuw i64 %43 to i32
  %45 = tail call noundef i32 @_Z8go_rightiiii(i32 noundef %26, i32 noundef %44, i32 noundef 0, i32 noundef 0)
  %46 = add nsw i32 %42, %45
  %47 = load i32, ptr @cntt, align 4, !tbaa !5
  %.not52 = icmp eq i32 %46, %47
  br i1 %.not52, label %..critedge_crit_edge, label %._crit_edge75

..critedge_crit_edge:                             ; preds = %32
  %.pre = load i32, ptr @m, align 4, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %..critedge_crit_edge90, %..critedge_crit_edge
  %indvars.iv.next84.pre-phi = phi i64 [ %.pre92, %..critedge_crit_edge90 ], [ %43, %..critedge_crit_edge ]
  %48 = phi i32 [ %28, %..critedge_crit_edge90 ], [ %.pre, %..critedge_crit_edge ]
  %49 = sext i32 %48 to i64
  %.not51.not = icmp slt i64 %indvars.iv83, %49
  br i1 %.not51.not, label %27, label %._crit_edge72.loopexit, !llvm.loop !13

._crit_edge72.loopexit:                           ; preds = %.critedge
  %.pre89 = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge72

._crit_edge72:                                    ; preds = %.preheader, %._crit_edge72.loopexit
  %50 = phi i32 [ %.pre89, %._crit_edge72.loopexit ], [ %20, %.preheader ]
  %51 = phi i32 [ %48, %._crit_edge72.loopexit ], [ %21, %.preheader ]
  %52 = phi i32 [ %48, %._crit_edge72.loopexit ], [ %22, %.preheader ]
  %53 = sext i32 %50 to i64
  %.not50.not = icmp slt i64 %indvars.iv86, %53
  br i1 %.not50.not, label %.preheader, label %._crit_edge75, !llvm.loop !14

._crit_edge75:                                    ; preds = %._crit_edge72, %32, %.preheader59, %.preheader60
  %.str.sink = phi ptr [ @.str.2, %.preheader60 ], [ @.str.2, %.preheader59 ], [ @.str, %32 ], [ @.str.2, %._crit_edge72 ]
  %54 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, ptr noundef nonnull %.str.sink)
  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)) local_unnamed_addr #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 #2

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

; Function Attrs: inlinehint mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) local_unnamed_addr #5

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 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 #2 = { "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 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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" }

!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 = distinct !{!14, !10, !15}
!15 = !{!"llvm.loop.unswitch.partial.disable"}


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