; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/243 Division 2/Problem D (D)

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

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

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@a = external dso_local global [100 x [100 x i32]], align 16
@b = external dso_local global [100 x i32], align 16
@mn = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

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

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

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

15:                                               ; preds = %38, %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) #6
  br label %41

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

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

25:                                               ; preds = %21
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  br label %37

26:                                               ; preds = %21
  %27 = load i32, ptr %2, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [100 x [100 x i32]], ptr @a, i64 0, i64 %28
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [100 x i32], ptr %29, i64 0, i64 %31
  %33 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %32)
  br label %34

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

37:                                               ; preds = %25
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %2, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %2, align 4, !tbaa !5
  br label %15, !llvm.loop !11

41:                                               ; preds = %19
  %42 = load i32, ptr @n, align 4, !tbaa !5
  %43 = load i32, ptr @k, align 4, !tbaa !5
  %44 = icmp sgt i32 %42, %43
  br i1 %44, label %45, label %60

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

46:                                               ; preds = %56, %45
  %47 = load i32, ptr %5, align 4, !tbaa !5
  %48 = load i32, ptr @n, align 4, !tbaa !5
  %49 = icmp slt i32 %47, %48
  br i1 %49, label %51, label %50

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

51:                                               ; preds = %46
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  %52 = load i32, ptr %5, align 4, !tbaa !5
  %53 = call noundef i32 @_Z4calci(i32 noundef %52)
  store i32 %53, ptr %6, align 4, !tbaa !5
  %54 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mn, ptr noundef nonnull align 4 dereferenceable(4) %6)
  %55 = load i32, ptr %54, align 4, !tbaa !5
  store i32 %55, ptr @mn, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %56

56:                                               ; preds = %51
  %57 = load i32, ptr %5, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %5, align 4, !tbaa !5
  br label %46, !llvm.loop !12

59:                                               ; preds = %50
  br label %143

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

61:                                               ; preds = %139, %60
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = load i32, ptr @n, align 4, !tbaa !5
  %64 = shl i32 1, %63
  %65 = icmp slt i32 %62, %64
  br i1 %65, label %67, label %66

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

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

68:                                               ; preds = %88, %67
  %69 = load i32, ptr %8, align 4, !tbaa !5
  %70 = load i32, ptr @n, align 4, !tbaa !5
  %71 = icmp slt i32 %69, %70
  br i1 %71, label %73, label %72

72:                                               ; preds = %68
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #6
  br label %91

73:                                               ; preds = %68
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = load i32, ptr %8, align 4, !tbaa !5
  %76 = shl i32 1, %75
  %77 = and i32 %74, %76
  %78 = icmp sgt i32 %77, 0
  br i1 %78, label %79, label %83

79:                                               ; preds = %73
  %80 = load i32, ptr %8, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100 x i32], ptr @b, i64 0, i64 %81
  store i32 1, ptr %82, align 4, !tbaa !5
  br label %87

83:                                               ; preds = %73
  %84 = load i32, ptr %8, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = getelementptr inbounds [100 x i32], ptr @b, i64 0, i64 %85
  store i32 0, ptr %86, align 4, !tbaa !5
  br label %87

87:                                               ; preds = %83, %79
  br label %88

88:                                               ; preds = %87
  %89 = load i32, ptr %8, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %8, align 4, !tbaa !5
  br label %68, !llvm.loop !13

91:                                               ; preds = %72
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  store i32 0, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %133, %91
  %93 = load i32, ptr %10, align 4, !tbaa !5
  %94 = load i32, ptr @m, align 4, !tbaa !5
  %95 = icmp slt i32 %93, %94
  br i1 %95, label %97, label %96

96:                                               ; preds = %92
  store i32 17, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %136

97:                                               ; preds = %92
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  store i32 0, ptr %11, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  store i32 0, ptr %13, align 4, !tbaa !5
  br label %98

98:                                               ; preds = %123, %97
  %99 = load i32, ptr %13, align 4, !tbaa !5
  %100 = load i32, ptr @n, align 4, !tbaa !5
  %101 = icmp slt i32 %99, %100
  br i1 %101, label %103, label %102

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

103:                                              ; preds = %98
  %104 = load i32, ptr %13, align 4, !tbaa !5
  %105 = sext i32 %104 to i64
  %106 = getelementptr inbounds [100 x i32], ptr @b, i64 0, i64 %105
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %108 = load i32, ptr %13, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [100 x [100 x i32]], ptr @a, i64 0, i64 %109
  %111 = load i32, ptr %10, align 4, !tbaa !5
  %112 = sext i32 %111 to i64
  %113 = getelementptr inbounds [100 x i32], ptr %110, i64 0, i64 %112
  %114 = load i32, ptr %113, align 4, !tbaa !5
  %115 = icmp eq i32 %107, %114
  br i1 %115, label %116, label %119

116:                                              ; preds = %103
  %117 = load i32, ptr %11, align 4, !tbaa !5
  %118 = add nsw i32 %117, 1
  store i32 %118, ptr %11, align 4, !tbaa !5
  br label %122

119:                                              ; preds = %103
  %120 = load i32, ptr %12, align 4, !tbaa !5
  %121 = add nsw i32 %120, 1
  store i32 %121, ptr %12, align 4, !tbaa !5
  br label %122

122:                                              ; preds = %119, %116
  br label %123

123:                                              ; preds = %122
  %124 = load i32, ptr %13, align 4, !tbaa !5
  %125 = add nsw i32 %124, 1
  store i32 %125, ptr %13, align 4, !tbaa !5
  br label %98, !llvm.loop !14

126:                                              ; preds = %102
  %127 = load i32, ptr @n, align 4, !tbaa !5
  %128 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %11, ptr noundef nonnull align 4 dereferenceable(4) %12)
  %129 = load i32, ptr %128, align 4, !tbaa !5
  %130 = sub nsw i32 %127, %129
  %131 = load i32, ptr %9, align 4, !tbaa !5
  %132 = add nsw i32 %131, %130
  store i32 %132, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  br label %133

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

136:                                              ; preds = %96
  %137 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mn, ptr noundef nonnull align 4 dereferenceable(4) %9)
  %138 = load i32, ptr %137, align 4, !tbaa !5
  store i32 %138, ptr @mn, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  br label %139

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

142:                                              ; preds = %66
  br label %143

143:                                              ; preds = %142, %59
  %144 = load i32, ptr @mn, align 4, !tbaa !5
  %145 = load i32, ptr @k, align 4, !tbaa !5
  %146 = icmp sle i32 %144, %145
  br i1 %146, label %147, label %151

147:                                              ; preds = %143
  %148 = load i32, ptr @mn, align 4, !tbaa !5
  %149 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %148)
  %150 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %149, ptr noundef @.str.2)
  br label %154

151:                                              ; preds = %143
  %152 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef -1)
  %153 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %152, ptr noundef @.str.2)
  br label %154

154:                                              ; preds = %151, %147
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) #2

; 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) #5

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
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" }
attributes #6 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!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::basic_ostream" = type { ptr, %"class.std::basic_ios" }
%"class.std::basic_ios" = type { %"class.std::ios_base", ptr, i8, i8, ptr, ptr, ptr, ptr }
%"class.std::ios_base" = type { ptr, i64, i64, i32, i32, i32, ptr, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, ptr, %"class.std::locale" }
%"struct.std::ios_base::_Words" = type { ptr, i64 }
%"class.std::locale" = type { ptr }

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@a = external dso_local global [100 x [100 x i32]], align 16
@b = external dso_local local_unnamed_addr global [100 x i32], align 16
@mn = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

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

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

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #3 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @k)
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  %8 = load i32, ptr @m, align 4
  %9 = icmp sgt i32 %8, 0
  %or.cond = select i1 %7, i1 %9, i1 false
  br i1 %or.cond, label %.preheader37, label %._crit_edge41

.preheader37:                                     ; preds = %0, %._crit_edge
  %10 = phi i32 [ %17, %._crit_edge ], [ %6, %0 ]
  %11 = phi i32 [ %18, %._crit_edge ], [ %8, %0 ]
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %._crit_edge ], [ 0, %0 ]
  %12 = icmp sgt i32 %11, 0
  br i1 %12, label %.lr.ph, label %._crit_edge

._crit_edge41:                                    ; preds = %._crit_edge, %0
  %13 = phi i32 [ %6, %0 ], [ %17, %._crit_edge ]
  %14 = load i32, ptr @k, align 4, !tbaa !5
  %15 = icmp sgt i32 %13, %14
  br i1 %15, label %.preheader, label %.preheader35

.preheader35:                                     ; preds = %._crit_edge41
  %.not58 = icmp eq i32 %13, 31
  br i1 %.not58, label %.loopexit, label %.preheader34

.preheader:                                       ; preds = %._crit_edge41
  %16 = icmp sgt i32 %13, 0
  br i1 %16, label %.lr.ph57, label %.loopexit

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader37
  %17 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %10, %.preheader37 ]
  %18 = phi i32 [ %23, %._crit_edge.loopexit ], [ %11, %.preheader37 ]
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %19 = sext i32 %17 to i64
  %20 = icmp slt i64 %indvars.iv.next63, %19
  br i1 %20, label %.preheader37, label %._crit_edge41, !llvm.loop !9

.lr.ph:                                           ; preds = %.preheader37, %.lr.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %.preheader37 ]
  %21 = getelementptr inbounds [100 x [100 x i32]], ptr @a, i64 0, i64 %indvars.iv62, i64 %indvars.iv
  %22 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %21)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr @m, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next, %24
  br i1 %25, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !12

.lr.ph57:                                         ; preds = %.preheader, %.lr.ph57
  %.02756 = phi i32 [ %29, %.lr.ph57 ], [ 0, %.preheader ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #7
  %26 = call noundef i32 @_Z4calci(i32 noundef %.02756)
  store i32 %26, ptr %1, align 4, !tbaa !5
  %27 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mn, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %28 = load i32, ptr %27, align 4, !tbaa !5
  store i32 %28, ptr @mn, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #7
  %29 = add nuw nsw i32 %.02756, 1
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %.lr.ph57, label %.loopexit, !llvm.loop !13

.preheader34:                                     ; preds = %.preheader35, %._crit_edge54
  %32 = phi i32 [ %49, %._crit_edge54 ], [ %13, %.preheader35 ]
  %.02655 = phi i32 [ %48, %._crit_edge54 ], [ 0, %.preheader35 ]
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.lr.ph43.preheader, label %._crit_edge44

.lr.ph43.preheader:                               ; preds = %.preheader34
  %wide.trip.count = zext nneg i32 %32 to i64
  %min.iters.check = icmp ult i32 %32, 8
  br i1 %min.iters.check, label %.lr.ph43.preheader83, label %vector.ph

.lr.ph43.preheader83:                             ; preds = %middle.block, %.lr.ph43.preheader
  %indvars.iv65.ph = phi i64 [ 0, %.lr.ph43.preheader ], [ %n.vec, %middle.block ]
  br label %.lr.ph43

vector.ph:                                        ; preds = %.lr.ph43.preheader
  %n.vec = and i64 %wide.trip.count, 2147483640
  %broadcast.splatinsert = insertelement <4 x i32> poison, i32 %.02655, i64 0
  %broadcast.splat = shufflevector <4 x i32> %broadcast.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.ind = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %step.add = add <4 x i32> %vec.ind, <i32 4, i32 4, i32 4, i32 4>
  %34 = lshr <4 x i32> %broadcast.splat, %vec.ind
  %35 = lshr <4 x i32> %broadcast.splat, %step.add
  %36 = and <4 x i32> %34, <i32 1, i32 1, i32 1, i32 1>
  %37 = and <4 x i32> %35, <i32 1, i32 1, i32 1, i32 1>
  %38 = getelementptr inbounds [100 x i32], ptr @b, i64 0, i64 %index
  %39 = getelementptr inbounds i8, ptr %38, i64 16
  store <4 x i32> %36, ptr %38, align 16
  store <4 x i32> %37, ptr %39, align 16
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %40 = icmp eq i64 %index.next, %n.vec
  br i1 %40, label %middle.block, label %vector.body, !llvm.loop !14

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %n.vec, %wide.trip.count
  br i1 %cmp.n, label %._crit_edge44, label %.lr.ph43.preheader83

._crit_edge44:                                    ; preds = %.lr.ph43, %middle.block, %.preheader34
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #7
  store i32 0, ptr %2, align 4, !tbaa !5
  %41 = load i32, ptr @m, align 4, !tbaa !5
  %42 = icmp sgt i32 %41, 0
  br i1 %42, label %.lr.ph53, label %._crit_edge54

.lr.ph43:                                         ; preds = %.lr.ph43.preheader83, %.lr.ph43
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %.lr.ph43 ], [ %indvars.iv65.ph, %.lr.ph43.preheader83 ]
  %43 = trunc nuw nsw i64 %indvars.iv65 to i32
  %44 = lshr i32 %.02655, %43
  %spec.select = and i32 %44, 1
  %45 = getelementptr inbounds [100 x i32], ptr @b, i64 0, i64 %indvars.iv65
  store i32 %spec.select, ptr %45, align 4
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next66, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge44, label %.lr.ph43, !llvm.loop !17

._crit_edge54:                                    ; preds = %._crit_edge49, %._crit_edge44
  %46 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) @mn, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %47 = load i32, ptr %46, align 4, !tbaa !5
  store i32 %47, ptr @mn, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #7
  %48 = add nuw nsw i32 %.02655, 1
  %49 = load i32, ptr @n, align 4, !tbaa !5
  %50 = shl nuw i32 1, %49
  %51 = icmp slt i32 %48, %50
  br i1 %51, label %.preheader34, label %.loopexit, !llvm.loop !18

.lr.ph53:                                         ; preds = %._crit_edge44, %._crit_edge49
  %indvars.iv73 = phi i64 [ %indvars.iv.next74, %._crit_edge49 ], [ 0, %._crit_edge44 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #7
  store i32 0, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #7
  store i32 0, ptr %4, align 4, !tbaa !5
  %52 = load i32, ptr @n, align 4, !tbaa !5
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %.lr.ph48, label %._crit_edge49

.lr.ph48:                                         ; preds = %.lr.ph53
  %wide.trip.count71 = zext nneg i32 %52 to i64
  %xtraiter = and i64 %wide.trip.count71, 1
  %54 = icmp eq i32 %52, 1
  br i1 %54, label %._crit_edge49.loopexit.unr-lcssa, label %.lr.ph48.new

.lr.ph48.new:                                     ; preds = %.lr.ph48
  %unroll_iter = and i64 %wide.trip.count71, 2147483646
  br label %72

._crit_edge49.loopexit.unr-lcssa:                 ; preds = %96, %.lr.ph48
  %indvars.iv68.unr = phi i64 [ 0, %.lr.ph48 ], [ %indvars.iv.next69.1, %96 ]
  %.unr = phi i32 [ 0, %.lr.ph48 ], [ %98, %96 ]
  %.unr86 = phi i32 [ 0, %.lr.ph48 ], [ %97, %96 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge49, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge49.loopexit.unr-lcssa
  %55 = getelementptr inbounds [100 x i32], ptr @b, i64 0, i64 %indvars.iv68.unr
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = getelementptr inbounds [100 x [100 x i32]], ptr @a, i64 0, i64 %indvars.iv68.unr, i64 %indvars.iv73
  %58 = load i32, ptr %57, align 4, !tbaa !5
  %59 = icmp eq i32 %56, %58
  br i1 %59, label %62, label %60

60:                                               ; preds = %.epil.preheader
  %61 = add nsw i32 %.unr, 1
  store i32 %61, ptr %4, align 4, !tbaa !5
  br label %._crit_edge49

62:                                               ; preds = %.epil.preheader
  %63 = add nsw i32 %.unr86, 1
  store i32 %63, ptr %3, align 4, !tbaa !5
  br label %._crit_edge49

._crit_edge49:                                    ; preds = %._crit_edge49.loopexit.unr-lcssa, %62, %60, %.lr.ph53
  %64 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3maxIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %3, ptr noundef nonnull align 4 dereferenceable(4) %4)
  %65 = load i32, ptr %64, align 4, !tbaa !5
  %66 = sub i32 %52, %65
  %67 = load i32, ptr %2, align 4, !tbaa !5
  %68 = add nsw i32 %66, %67
  store i32 %68, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #7
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #7
  %indvars.iv.next74 = add nuw nsw i64 %indvars.iv73, 1
  %69 = load i32, ptr @m, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = icmp slt i64 %indvars.iv.next74, %70
  br i1 %71, label %.lr.ph53, label %._crit_edge54, !llvm.loop !19

72:                                               ; preds = %96, %.lr.ph48.new
  %indvars.iv68 = phi i64 [ 0, %.lr.ph48.new ], [ %indvars.iv.next69.1, %96 ]
  %73 = phi i32 [ 0, %.lr.ph48.new ], [ %98, %96 ]
  %74 = phi i32 [ 0, %.lr.ph48.new ], [ %97, %96 ]
  %niter = phi i64 [ 0, %.lr.ph48.new ], [ %niter.next.1, %96 ]
  %75 = getelementptr inbounds [100 x i32], ptr @b, i64 0, i64 %indvars.iv68
  %76 = load i32, ptr %75, align 8, !tbaa !5
  %77 = getelementptr inbounds [100 x [100 x i32]], ptr @a, i64 0, i64 %indvars.iv68, i64 %indvars.iv73
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = icmp eq i32 %76, %78
  br i1 %79, label %80, label %82

80:                                               ; preds = %72
  %81 = add nsw i32 %74, 1
  store i32 %81, ptr %3, align 4, !tbaa !5
  br label %84

82:                                               ; preds = %72
  %83 = add nsw i32 %73, 1
  store i32 %83, ptr %4, align 4, !tbaa !5
  br label %84

84:                                               ; preds = %80, %82
  %85 = phi i32 [ %81, %80 ], [ %74, %82 ]
  %86 = phi i32 [ %73, %80 ], [ %83, %82 ]
  %indvars.iv.next69 = or disjoint i64 %indvars.iv68, 1
  %87 = getelementptr inbounds [100 x i32], ptr @b, i64 0, i64 %indvars.iv.next69
  %88 = load i32, ptr %87, align 4, !tbaa !5
  %89 = getelementptr inbounds [100 x [100 x i32]], ptr @a, i64 0, i64 %indvars.iv.next69, i64 %indvars.iv73
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = icmp eq i32 %88, %90
  br i1 %91, label %94, label %92

92:                                               ; preds = %84
  %93 = add nsw i32 %86, 1
  store i32 %93, ptr %4, align 4, !tbaa !5
  br label %96

94:                                               ; preds = %84
  %95 = add nsw i32 %85, 1
  store i32 %95, ptr %3, align 4, !tbaa !5
  br label %96

96:                                               ; preds = %94, %92
  %97 = phi i32 [ %95, %94 ], [ %85, %92 ]
  %98 = phi i32 [ %86, %94 ], [ %93, %92 ]
  %indvars.iv.next69.1 = add nuw nsw i64 %indvars.iv68, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge49.loopexit.unr-lcssa, label %72, !llvm.loop !20

.loopexit:                                        ; preds = %._crit_edge54, %.lr.ph57, %.preheader35, %.preheader
  %99 = load i32, ptr @mn, align 4, !tbaa !5
  %100 = load i32, ptr @k, align 4, !tbaa !5
  %.not33 = icmp sgt i32 %99, %100
  %. = select i1 %.not33, i32 -1, i32 %99
  %101 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %.)
  %102 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(ptr noundef nonnull align 8 dereferenceable(8) %101, ptr noundef nonnull @.str.2)
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #4

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #2

; 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

declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8), i32 noundef) local_unnamed_addr #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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #3 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nofree nounwind "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 = { 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 #6 = { "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, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unswitch.partial.disable"}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10, !15, !16}
!15 = !{!"llvm.loop.isvectorized", i32 1}
!16 = !{!"llvm.loop.unroll.runtime.disable"}
!17 = distinct !{!17, !10, !16, !15}
!18 = distinct !{!18, !10}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}


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