; LLVM IR from VastoLorde95/Competitive-Programming :: Codejam/2017/Qualification/D/D.ll (Z4initv)

; 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_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 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@bg = external dso_local global [110 x [110 x i32]], align 16
@g = external dso_local global [110 x [110 x i32]], align 16
@ans = external dso_local global i32, align 4
@row = external dso_local global { [2 x i64] }, align 8
@col = external dso_local global { [2 x i64] }, align 8
@d1 = external dso_local global { [4 x i64] }, align 8
@d2 = external dso_local global { [4 x i64] }, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4initv() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, 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 %1) #4
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %12

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

16:                                               ; preds = %12
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  br label %37

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

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

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

23:                                               ; preds = %18
  %24 = load i32, ptr %1, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %25
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [110 x i32], ptr %26, i64 0, i64 %28
  store i32 0, ptr %29, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %23
  %31 = load i32, ptr %3, align 4, !tbaa !5
  %32 = add nsw i32 %31, 1
  store i32 %32, ptr %3, align 4, !tbaa !5
  br label %18, !llvm.loop !9

33:                                               ; preds = %22
  br label %34

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

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

38:                                               ; preds = %78, %37
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = load i32, ptr @m, align 4, !tbaa !5
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %43, label %42

42:                                               ; preds = %38
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  br label %81

43:                                               ; preds = %38
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %44 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 1 dereferenceable(1) %5)
  %45 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %44, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %46 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %45, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %47 = load i8, ptr %5, align 1, !tbaa !12
  %48 = sext i8 %47 to i32
  %49 = icmp eq i32 %48, 43
  br i1 %49, label %50, label %51

50:                                               ; preds = %43
  br label %57

51:                                               ; preds = %43
  %52 = load i8, ptr %5, align 1, !tbaa !12
  %53 = sext i8 %52 to i32
  %54 = icmp eq i32 %53, 120
  %55 = zext i1 %54 to i64
  %56 = select i1 %54, i32 2, i32 3
  br label %57

57:                                               ; preds = %51, %50
  %58 = phi i32 [ 1, %50 ], [ %56, %51 ]
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %60
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [110 x i32], ptr %61, i64 0, i64 %63
  store i32 %58, ptr %64, align 4, !tbaa !5
  %65 = load i32, ptr %6, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %66
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [110 x i32], ptr %67, i64 0, i64 %69
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [110 x [110 x i32]], ptr @bg, i64 0, i64 %73
  %75 = load i32, ptr %7, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [110 x i32], ptr %74, i64 0, i64 %76
  store i32 %71, ptr %77, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  br label %78

78:                                               ; preds = %57
  %79 = load i32, ptr %4, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %4, align 4, !tbaa !5
  br label %38, !llvm.loop !13

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

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

86:                                               ; preds = %82
  store i32 11, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %135

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

88:                                               ; preds = %128, %87
  %89 = load i32, ptr %9, align 4, !tbaa !5
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = icmp sle i32 %89, %90
  br i1 %91, label %93, label %92

92:                                               ; preds = %88
  store i32 14, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %131

93:                                               ; preds = %88
  %94 = load i32, ptr %8, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %95
  %97 = load i32, ptr %9, align 4, !tbaa !5
  %98 = sext i32 %97 to i64
  %99 = getelementptr inbounds [110 x i32], ptr %96, i64 0, i64 %98
  %100 = load i32, ptr %99, align 4, !tbaa !5
  %101 = icmp sle i32 1, %100
  br i1 %101, label %102, label %114

102:                                              ; preds = %93
  %103 = load i32, ptr %8, align 4, !tbaa !5
  %104 = sext i32 %103 to i64
  %105 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %104
  %106 = load i32, ptr %9, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [110 x i32], ptr %105, i64 0, i64 %107
  %109 = load i32, ptr %108, align 4, !tbaa !5
  %110 = icmp sle i32 %109, 2
  br i1 %110, label %111, label %114

111:                                              ; preds = %102
  %112 = load i32, ptr @ans, align 4, !tbaa !5
  %113 = add nsw i32 %112, 1
  store i32 %113, ptr @ans, align 4, !tbaa !5
  br label %127

114:                                              ; preds = %102, %93
  %115 = load i32, ptr %8, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %116
  %118 = load i32, ptr %9, align 4, !tbaa !5
  %119 = sext i32 %118 to i64
  %120 = getelementptr inbounds [110 x i32], ptr %117, i64 0, i64 %119
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = icmp eq i32 %121, 3
  br i1 %122, label %123, label %126

123:                                              ; preds = %114
  %124 = load i32, ptr @ans, align 4, !tbaa !5
  %125 = add nsw i32 %124, 2
  store i32 %125, ptr @ans, align 4, !tbaa !5
  br label %126

126:                                              ; preds = %123, %114
  br label %127

127:                                              ; preds = %126, %111
  br label %128

128:                                              ; preds = %127
  %129 = load i32, ptr %9, align 4, !tbaa !5
  %130 = add nsw i32 %129, 1
  store i32 %130, ptr %9, align 4, !tbaa !5
  br label %88, !llvm.loop !14

131:                                              ; preds = %92
  br label %132

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

135:                                              ; preds = %86
  %136 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm110EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @row) #4
  %137 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm110EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @col) #4
  %138 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6bitsetILm220EE5resetEv(ptr noundef nonnull align 8 dereferenceable(32) @d1) #4
  %139 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6bitsetILm220EE5resetEv(ptr noundef nonnull align 8 dereferenceable(32) @d2) #4
  ret void
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm110EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16)) #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6bitsetILm220EE5resetEv(ptr noundef nonnull align 8 dereferenceable(32)) #3 align 2

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 = { "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 = { 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}


; 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_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 }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@bg = external dso_local local_unnamed_addr global [110 x [110 x i32]], align 16
@g = external dso_local local_unnamed_addr global [110 x [110 x i32]], align 16
@ans = external dso_local local_unnamed_addr global i32, align 4
@row = external dso_local global { [2 x i64] }, align 8
@col = external dso_local global { [2 x i64] }, align 8
@d1 = external dso_local global { [4 x i64] }, align 8
@d2 = external dso_local global { [4 x i64] }, align 8
@_ZSt3cin = external global %"class.std::basic_istream", align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4initv() local_unnamed_addr #0 {
  %1 = alloca i8, align 1
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = 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)
  %5 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %4, ptr noundef nonnull align 4 dereferenceable(4) @m)
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %.not31 = icmp slt i32 %6, 1
  br i1 %.not31, label %.preheader27, label %.preheader28.preheader

.preheader28.preheader:                           ; preds = %0
  %7 = zext nneg i32 %6 to i64
  %8 = shl nuw nsw i64 %7, 2
  %xtraiter = and i64 %7, 7
  %9 = icmp ult i32 %6, 8
  br i1 %9, label %.preheader27.loopexit.unr-lcssa, label %.preheader28.preheader.new

.preheader28.preheader.new:                       ; preds = %.preheader28.preheader
  %unroll_iter = and i64 %7, 2147483640
  br label %.preheader28

.preheader28:                                     ; preds = %.preheader28, %.preheader28.preheader.new
  %indvar = phi i64 [ 0, %.preheader28.preheader.new ], [ %indvar.next.7, %.preheader28 ]
  %niter = phi i64 [ 0, %.preheader28.preheader.new ], [ %niter.next.7, %.preheader28 ]
  %10 = mul nuw nsw i64 %indvar, 440
  %gep = getelementptr i8, ptr getelementptr inbounds (i8, ptr @g, i64 444), i64 %10
  tail call void @llvm.memset.p0.i64(ptr align 4 %gep, i8 0, i64 %8, i1 false), !tbaa !5
  %11 = mul nuw i64 %indvar, 440
  %gep64 = getelementptr i8, ptr getelementptr (i8, ptr getelementptr inbounds (i8, ptr @g, i64 444), i64 440), i64 %11
  tail call void @llvm.memset.p0.i64(ptr align 4 %gep64, i8 0, i64 %8, i1 false), !tbaa !5
  %12 = mul nuw i64 %indvar, 440
  %gep65 = getelementptr i8, ptr getelementptr (i8, ptr getelementptr inbounds (i8, ptr @g, i64 444), i64 880), i64 %12
  tail call void @llvm.memset.p0.i64(ptr align 4 %gep65, i8 0, i64 %8, i1 false), !tbaa !5
  %13 = mul nuw i64 %indvar, 440
  %gep66 = getelementptr i8, ptr getelementptr (i8, ptr getelementptr inbounds (i8, ptr @g, i64 444), i64 1320), i64 %13
  tail call void @llvm.memset.p0.i64(ptr align 4 %gep66, i8 0, i64 %8, i1 false), !tbaa !5
  %14 = mul nuw i64 %indvar, 440
  %gep67 = getelementptr i8, ptr getelementptr (i8, ptr getelementptr inbounds (i8, ptr @g, i64 444), i64 1760), i64 %14
  tail call void @llvm.memset.p0.i64(ptr align 4 %gep67, i8 0, i64 %8, i1 false), !tbaa !5
  %15 = mul nuw i64 %indvar, 440
  %gep68 = getelementptr i8, ptr getelementptr (i8, ptr getelementptr inbounds (i8, ptr @g, i64 444), i64 2200), i64 %15
  tail call void @llvm.memset.p0.i64(ptr align 4 %gep68, i8 0, i64 %8, i1 false), !tbaa !5
  %16 = mul nuw i64 %indvar, 440
  %gep69 = getelementptr i8, ptr getelementptr (i8, ptr getelementptr inbounds (i8, ptr @g, i64 444), i64 2640), i64 %16
  tail call void @llvm.memset.p0.i64(ptr align 4 %gep69, i8 0, i64 %8, i1 false), !tbaa !5
  %17 = mul nuw i64 %indvar, 440
  %gep70 = getelementptr i8, ptr getelementptr (i8, ptr getelementptr inbounds (i8, ptr @g, i64 444), i64 3080), i64 %17
  tail call void @llvm.memset.p0.i64(ptr align 4 %gep70, i8 0, i64 %8, i1 false), !tbaa !5
  %indvar.next.7 = add nuw nsw i64 %indvar, 8
  %niter.next.7 = add i64 %niter, 8
  %niter.ncmp.7 = icmp eq i64 %niter.next.7, %unroll_iter
  br i1 %niter.ncmp.7, label %.preheader27.loopexit.unr-lcssa, label %.preheader28, !llvm.loop !9

.preheader27.loopexit.unr-lcssa:                  ; preds = %.preheader28, %.preheader28.preheader
  %indvar.unr = phi i64 [ 0, %.preheader28.preheader ], [ %indvar.next.7, %.preheader28 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader27, label %.preheader28.epil

.preheader28.epil:                                ; preds = %.preheader27.loopexit.unr-lcssa, %.preheader28.epil
  %indvar.epil = phi i64 [ %indvar.next.epil, %.preheader28.epil ], [ %indvar.unr, %.preheader27.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.preheader28.epil ], [ 0, %.preheader27.loopexit.unr-lcssa ]
  %18 = mul nuw nsw i64 %indvar.epil, 440
  %gep.epil = getelementptr i8, ptr getelementptr inbounds (i8, ptr @g, i64 444), i64 %18
  tail call void @llvm.memset.p0.i64(ptr align 4 %gep.epil, i8 0, i64 %8, i1 false), !tbaa !5
  %indvar.next.epil = add nuw nsw i64 %indvar.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader27, label %.preheader28.epil, !llvm.loop !11

.preheader27:                                     ; preds = %.preheader27.loopexit.unr-lcssa, %.preheader28.epil, %0
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %._crit_edge34

._crit_edge34.loopexit:                           ; preds = %.lr.ph
  %.pre = load i32, ptr @n, align 4, !tbaa !5
  br label %._crit_edge34

._crit_edge34:                                    ; preds = %._crit_edge34.loopexit, %.preheader27
  %21 = phi i32 [ %.pre, %._crit_edge34.loopexit ], [ %6, %.preheader27 ]
  store i32 0, ptr @ans, align 4, !tbaa !5
  %.not2444 = icmp slt i32 %21, 1
  br i1 %.not2444, label %._crit_edge47, label %.preheader.preheader

.preheader.preheader:                             ; preds = %._crit_edge34
  %22 = add nuw i32 %21, 1
  %wide.trip.count55 = zext i32 %22 to i64
  %23 = zext nneg i32 %21 to i64
  %xtraiter58 = and i64 %23, 1
  %24 = icmp eq i32 %22, 2
  %unroll_iter62 = and i64 %23, 2147483646
  %lcmp.mod60.not = icmp eq i64 %xtraiter58, 0
  br label %.preheader

.lr.ph:                                           ; preds = %.preheader27, %.lr.ph
  %.01933 = phi i32 [ %39, %.lr.ph ], [ 0, %.preheader27 ]
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #5
  %25 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZStrsIcSt11char_traitsIcEERSt13basic_istreamIT_T0_ES6_RS3_(ptr noundef nonnull align 8 dereferenceable(16) @_ZSt3cin, ptr noundef nonnull align 1 dereferenceable(1) %1)
  %26 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %25, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %27 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSirsERi(ptr noundef nonnull align 8 dereferenceable(16) %26, ptr noundef nonnull align 4 dereferenceable(4) %3)
  %28 = load i8, ptr %1, align 1, !tbaa !13
  %29 = icmp eq i8 %28, 43
  %30 = icmp eq i8 %28, 120
  %31 = select i1 %30, i32 2, i32 3
  %32 = select i1 %29, i32 1, i32 %31
  %33 = load i32, ptr %2, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %34, i64 %36
  store i32 %32, ptr %37, align 4, !tbaa !5
  %38 = getelementptr inbounds [110 x [110 x i32]], ptr @bg, i64 0, i64 %34, i64 %36
  store i32 %32, ptr %38, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %1) #5
  %39 = add nuw nsw i32 %.01933, 1
  %40 = load i32, ptr @m, align 4, !tbaa !5
  %41 = icmp slt i32 %39, %40
  br i1 %41, label %.lr.ph, label %._crit_edge34.loopexit, !llvm.loop !14

.preheader:                                       ; preds = %.preheader.preheader, %._crit_edge38
  %indvars.iv52 = phi i64 [ 1, %.preheader.preheader ], [ %indvars.iv.next53, %._crit_edge38 ]
  %ans.promoted4345 = phi i32 [ 0, %.preheader.preheader ], [ %ans.promoted40.lcssa, %._crit_edge38 ]
  br i1 %24, label %._crit_edge38.unr-lcssa, label %.preheader.new

._crit_edge47:                                    ; preds = %._crit_edge38, %._crit_edge34
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm110EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @row) #5
  %43 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm110EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16) @col) #5
  %44 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6bitsetILm220EE5resetEv(ptr noundef nonnull align 8 dereferenceable(32) @d1) #5
  %45 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6bitsetILm220EE5resetEv(ptr noundef nonnull align 8 dereferenceable(32) @d2) #5
  ret void

._crit_edge38.unr-lcssa:                          ; preds = %67, %.preheader
  %ans.promoted40.lcssa.ph = phi i32 [ poison, %.preheader ], [ %ans.promoted40.1, %67 ]
  %indvars.iv.unr = phi i64 [ 1, %.preheader ], [ %indvars.iv.next.1, %67 ]
  %ans.promoted41.unr = phi i32 [ %ans.promoted4345, %.preheader ], [ %ans.promoted40.1, %67 ]
  %.unr = phi i32 [ %ans.promoted4345, %.preheader ], [ %68, %67 ]
  br i1 %lcmp.mod60.not, label %._crit_edge38, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge38.unr-lcssa
  %46 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %indvars.iv52, i64 %indvars.iv.unr
  %47 = load i32, ptr %46, align 4, !tbaa !5
  %48 = add i32 %47, -1
  %or.cond.epil = icmp ult i32 %48, 2
  br i1 %or.cond.epil, label %.sink.split.epil, label %49

49:                                               ; preds = %.epil.preheader
  %50 = icmp eq i32 %47, 3
  br i1 %50, label %.sink.split.epil, label %._crit_edge38

.sink.split.epil:                                 ; preds = %49, %.epil.preheader
  %.sink57.epil = phi i32 [ 1, %.epil.preheader ], [ 2, %49 ]
  %51 = add nsw i32 %.unr, %.sink57.epil
  store i32 %51, ptr @ans, align 4, !tbaa !5
  br label %._crit_edge38

._crit_edge38:                                    ; preds = %49, %.sink.split.epil, %._crit_edge38.unr-lcssa
  %ans.promoted40.lcssa = phi i32 [ %ans.promoted40.lcssa.ph, %._crit_edge38.unr-lcssa ], [ %ans.promoted41.unr, %49 ], [ %51, %.sink.split.epil ]
  %indvars.iv.next53 = add nuw nsw i64 %indvars.iv52, 1
  %exitcond56.not = icmp eq i64 %indvars.iv.next53, %wide.trip.count55
  br i1 %exitcond56.not, label %._crit_edge47, label %.preheader, !llvm.loop !15

.preheader.new:                                   ; preds = %.preheader, %67
  %indvars.iv = phi i64 [ %indvars.iv.next.1, %67 ], [ 1, %.preheader ]
  %ans.promoted41 = phi i32 [ %ans.promoted40.1, %67 ], [ %ans.promoted4345, %.preheader ]
  %52 = phi i32 [ %68, %67 ], [ %ans.promoted4345, %.preheader ]
  %niter63 = phi i64 [ %niter63.next.1, %67 ], [ 0, %.preheader ]
  %53 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %indvars.iv52, i64 %indvars.iv
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = add i32 %54, -1
  %or.cond = icmp ult i32 %55, 2
  br i1 %or.cond, label %.sink.split, label %56

56:                                               ; preds = %.preheader.new
  %57 = icmp eq i32 %54, 3
  br i1 %57, label %.sink.split, label %59

.sink.split:                                      ; preds = %56, %.preheader.new
  %.sink57 = phi i32 [ 1, %.preheader.new ], [ 2, %56 ]
  %58 = add nsw i32 %52, %.sink57
  store i32 %58, ptr @ans, align 4, !tbaa !5
  br label %59

59:                                               ; preds = %.sink.split, %56
  %ans.promoted40 = phi i32 [ %ans.promoted41, %56 ], [ %58, %.sink.split ]
  %60 = phi i32 [ %52, %56 ], [ %58, %.sink.split ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %61 = getelementptr inbounds [110 x [110 x i32]], ptr @g, i64 0, i64 %indvars.iv52, i64 %indvars.iv.next
  %62 = load i32, ptr %61, align 4, !tbaa !5
  %63 = add i32 %62, -1
  %or.cond.1 = icmp ult i32 %63, 2
  br i1 %or.cond.1, label %.sink.split.1, label %64

64:                                               ; preds = %59
  %65 = icmp eq i32 %62, 3
  br i1 %65, label %.sink.split.1, label %67

.sink.split.1:                                    ; preds = %64, %59
  %.sink57.1 = phi i32 [ 1, %59 ], [ 2, %64 ]
  %66 = add nsw i32 %60, %.sink57.1
  store i32 %66, ptr @ans, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %.sink.split.1, %64
  %ans.promoted40.1 = phi i32 [ %ans.promoted40, %64 ], [ %66, %.sink.split.1 ]
  %68 = phi i32 [ %60, %64 ], [ %66, %.sink.split.1 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter63.next.1 = add i64 %niter63, 2
  %niter63.ncmp.1 = icmp eq i64 %niter63.next.1, %unroll_iter62
  br i1 %niter63.ncmp.1, label %._crit_edge38.unr-lcssa, label %.preheader.new, !llvm.loop !16
}

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

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6bitsetILm110EE5resetEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt6bitsetILm220EE5resetEv(ptr noundef nonnull align 8 dereferenceable(32)) local_unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


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