; LLVM IR from VastoLorde95/Competitive-Programming :: Codeforces/194 Division 1/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::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
@g = external dso_local global [1001 x [1001 x i32]], align 16
@r = external dso_local global [1001 x i32], align 16
@c = external dso_local global [1001 x i32], align 16
@u = external dso_local global [1001 x i32], align 16
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@cnt = external dso_local global i32, align 4
@v = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @n, ptr noundef @m)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %11

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

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

16:                                               ; preds = %11
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef @x, ptr noundef @y)
  %18 = load i32, ptr @x, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %19
  %21 = load i32, ptr @y, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [1001 x i32], ptr %20, i64 0, i64 %22
  store i32 1, ptr %23, align 4, !tbaa !5
  br label %24

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

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

28:                                               ; preds = %57, %27
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = load i32, ptr @n, align 4, !tbaa !5
  %31 = icmp slt i32 %29, %30
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  br label %60

33:                                               ; preds = %28
  store i32 0, ptr @v, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #5
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %34

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

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

39:                                               ; preds = %34
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %41
  %43 = load i32, ptr %5, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds [1001 x i32], ptr %42, i64 0, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !5
  %47 = load i32, ptr @v, align 4, !tbaa !5
  %48 = or i32 %47, %46
  store i32 %48, ptr @v, align 4, !tbaa !5
  br label %49

49:                                               ; preds = %39
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %5, align 4, !tbaa !5
  br label %34, !llvm.loop !11

52:                                               ; preds = %38
  %53 = load i32, ptr @v, align 4, !tbaa !5
  %54 = load i32, ptr %3, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %55
  store i32 %53, ptr %56, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %52
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = add nsw i32 %58, 1
  store i32 %59, ptr %3, align 4, !tbaa !5
  br label %28, !llvm.loop !12

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

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

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

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

67:                                               ; preds = %82, %66
  %68 = load i32, ptr %7, align 4, !tbaa !5
  %69 = load i32, ptr @n, align 4, !tbaa !5
  %70 = icmp sle i32 %68, %69
  br i1 %70, label %72, label %71

71:                                               ; preds = %67
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %85

72:                                               ; preds = %67
  %73 = load i32, ptr %7, align 4, !tbaa !5
  %74 = sext i32 %73 to i64
  %75 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %74
  %76 = load i32, ptr %6, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [1001 x i32], ptr %75, i64 0, i64 %77
  %79 = load i32, ptr %78, align 4, !tbaa !5
  %80 = load i32, ptr @v, align 4, !tbaa !5
  %81 = or i32 %80, %79
  store i32 %81, ptr @v, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %72
  %83 = load i32, ptr %7, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %7, align 4, !tbaa !5
  br label %67, !llvm.loop !13

85:                                               ; preds = %71
  %86 = load i32, ptr @v, align 4, !tbaa !5
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %88
  store i32 %86, ptr %89, align 4, !tbaa !5
  br label %90

90:                                               ; preds = %85
  %91 = load i32, ptr %6, align 4, !tbaa !5
  %92 = add nsw i32 %91, 1
  store i32 %92, ptr %6, align 4, !tbaa !5
  br label %61, !llvm.loop !14

93:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #5
  store i32 2, ptr %8, align 4, !tbaa !5
  br label %94

94:                                               ; preds = %112, %93
  %95 = load i32, ptr %8, align 4, !tbaa !5
  %96 = load i32, ptr @n, align 4, !tbaa !5
  %97 = icmp slt i32 %95, %96
  br i1 %97, label %99, label %98

98:                                               ; preds = %94
  store i32 17, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #5
  br label %115

99:                                               ; preds = %94
  %100 = load i32, ptr %8, align 4, !tbaa !5
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %101
  %103 = load i32, ptr %102, align 4, !tbaa !5
  %104 = icmp ne i32 %103, 0
  br i1 %104, label %111, label %105

105:                                              ; preds = %99
  %106 = load i32, ptr %8, align 4, !tbaa !5
  %107 = sext i32 %106 to i64
  %108 = getelementptr inbounds [1001 x i32], ptr @u, i64 0, i64 %107
  store i32 1, ptr %108, align 4, !tbaa !5
  %109 = load i32, ptr @cnt, align 4, !tbaa !5
  %110 = add nsw i32 %109, 1
  store i32 %110, ptr @cnt, align 4, !tbaa !5
  br label %111

111:                                              ; preds = %105, %99
  br label %112

112:                                              ; preds = %111
  %113 = load i32, ptr %8, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %8, align 4, !tbaa !5
  br label %94, !llvm.loop !15

115:                                              ; preds = %98
  %116 = load i32, ptr @n, align 4, !tbaa !5
  %117 = icmp sgt i32 %116, 3
  br i1 %117, label %118, label %161

118:                                              ; preds = %115
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 2, ptr %9, align 4, !tbaa !5
  br label %119

119:                                              ; preds = %134, %118
  %120 = load i32, ptr %9, align 4, !tbaa !5
  %121 = load i32, ptr @n, align 4, !tbaa !5
  %122 = icmp slt i32 %120, %121
  br i1 %122, label %124, label %123

123:                                              ; preds = %119
  store i32 20, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %137

124:                                              ; preds = %119
  %125 = load i32, ptr %9, align 4, !tbaa !5
  %126 = sext i32 %125 to i64
  %127 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %126
  %128 = load i32, ptr %127, align 4, !tbaa !5
  %129 = icmp ne i32 %128, 0
  br i1 %129, label %133, label %130

130:                                              ; preds = %124
  %131 = load i32, ptr @cnt, align 4, !tbaa !5
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr @cnt, align 4, !tbaa !5
  br label %133

133:                                              ; preds = %130, %124
  br label %134

134:                                              ; preds = %133
  %135 = load i32, ptr %9, align 4, !tbaa !5
  %136 = add nsw i32 %135, 1
  store i32 %136, ptr %9, align 4, !tbaa !5
  br label %119, !llvm.loop !16

137:                                              ; preds = %123
  %138 = load i32, ptr @n, align 4, !tbaa !5
  %139 = srem i32 %138, 2
  %140 = icmp eq i32 %139, 1
  br i1 %140, label %141, label %160

141:                                              ; preds = %137
  %142 = load i32, ptr @n, align 4, !tbaa !5
  %143 = add nsw i32 %142, 1
  %144 = sdiv i32 %143, 2
  %145 = sext i32 %144 to i64
  %146 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %145
  %147 = load i32, ptr %146, align 4, !tbaa !5
  %148 = icmp eq i32 %147, 0
  br i1 %148, label %149, label %160

149:                                              ; preds = %141
  %150 = load i32, ptr @n, align 4, !tbaa !5
  %151 = add nsw i32 %150, 1
  %152 = sdiv i32 %151, 2
  %153 = sext i32 %152 to i64
  %154 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %153
  %155 = load i32, ptr %154, align 4, !tbaa !5
  %156 = icmp eq i32 %155, 0
  br i1 %156, label %157, label %160

157:                                              ; preds = %149
  %158 = load i32, ptr @cnt, align 4, !tbaa !5
  %159 = add nsw i32 %158, -1
  store i32 %159, ptr @cnt, align 4, !tbaa !5
  br label %160

160:                                              ; preds = %157, %149, %141, %137
  br label %161

161:                                              ; preds = %160, %115
  %162 = load i32, ptr @cnt, align 4, !tbaa !5
  %163 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %162)
  %164 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %163, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

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

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress 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 = { 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
@g = external dso_local local_unnamed_addr global [1001 x [1001 x i32]], align 16
@r = external dso_local local_unnamed_addr global [1001 x i32], align 16
@c = external dso_local local_unnamed_addr global [1001 x i32], align 16
@u = external dso_local local_unnamed_addr global [1001 x i32], align 16
@x = external dso_local global i32, align 4
@y = external dso_local global i32, align 4
@cnt = external dso_local local_unnamed_addr global i32, align 4
@v = external dso_local local_unnamed_addr global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@_ZSt4cout = external global %"class.std::basic_ostream", align 8

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m)
  %2 = load i32, ptr @m, align 4, !tbaa !5
  %3 = icmp sgt i32 %2, 0
  br i1 %3, label %.lr.ph, label %.preheader37

.preheader37:                                     ; preds = %.lr.ph, %0
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %5 = icmp sgt i32 %4, 2
  br i1 %5, label %.lr.ph41.preheader, label %.preheader35.thread

.lr.ph41.preheader:                               ; preds = %.preheader37
  %6 = add nuw i32 %4, 1
  %wide.trip.count69 = zext nneg i32 %4 to i64
  %wide.trip.count = zext i32 %6 to i64
  %7 = zext nneg i32 %4 to i64
  %min.iters.check = icmp ult i32 %4, 8
  %n.vec = and i64 %7, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  %cmp.n = icmp eq i64 %n.vec, %7
  br label %.lr.ph41

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.02838 = phi i32 [ %14, %.lr.ph ], [ 0, %0 ]
  %8 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @x, ptr noundef nonnull @y)
  %9 = load i32, ptr @x, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = load i32, ptr @y, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %10, i64 %12
  store i32 1, ptr %13, align 4, !tbaa !5
  %14 = add nuw nsw i32 %.02838, 1
  %15 = load i32, ptr @m, align 4, !tbaa !5
  %16 = icmp slt i32 %14, %15
  br i1 %16, label %.lr.ph, label %.preheader37, !llvm.loop !9

.preheader36:                                     ; preds = %._crit_edge
  store i32 %.lcssa100, ptr @v, align 4, !tbaa !5
  br i1 %5, label %.lr.ph51.preheader, label %.preheader35.thread

.lr.ph51.preheader:                               ; preds = %.preheader36
  %17 = add nuw i32 %4, 1
  %wide.trip.count79 = zext nneg i32 %4 to i64
  %wide.trip.count74 = zext i32 %17 to i64
  %18 = zext nneg i32 %4 to i64
  %min.iters.check105 = icmp ult i32 %4, 8
  %n.vec108 = and i64 %18, 2147483640
  %ind.end109 = or disjoint i64 %n.vec108, 1
  %cmp.n118 = icmp eq i64 %n.vec108, %18
  br label %.lr.ph51

.lr.ph41:                                         ; preds = %.lr.ph41.preheader, %._crit_edge
  %indvars.iv66 = phi i64 [ 2, %.lr.ph41.preheader ], [ %indvars.iv.next67, %._crit_edge ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.body

scalar.ph.preheader:                              ; preds = %middle.block, %.lr.ph41
  %indvars.iv.ph = phi i64 [ 1, %.lr.ph41 ], [ %ind.end, %middle.block ]
  %.ph124 = phi i32 [ 0, %.lr.ph41 ], [ %24, %middle.block ]
  br label %scalar.ph

vector.body:                                      ; preds = %.lr.ph41, %vector.body
  %index = phi i64 [ %index.next, %vector.body ], [ 0, %.lr.ph41 ]
  %vec.phi = phi <4 x i32> [ %21, %vector.body ], [ zeroinitializer, %.lr.ph41 ]
  %vec.phi101 = phi <4 x i32> [ %22, %vector.body ], [ zeroinitializer, %.lr.ph41 ]
  %offset.idx = or disjoint i64 %index, 1
  %19 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %indvars.iv66, i64 %offset.idx
  %20 = getelementptr inbounds i8, ptr %19, i64 16
  %wide.load = load <4 x i32>, ptr %19, align 4, !tbaa !5
  %wide.load102 = load <4 x i32>, ptr %20, align 4, !tbaa !5
  %21 = or <4 x i32> %vec.phi, %wide.load
  %22 = or <4 x i32> %vec.phi101, %wide.load102
  %index.next = add nuw i64 %index, 8
  %23 = icmp eq i64 %index.next, %n.vec
  br i1 %23, label %middle.block, label %vector.body, !llvm.loop !11

middle.block:                                     ; preds = %vector.body
  %bin.rdx = or <4 x i32> %22, %21
  %24 = tail call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %bin.rdx)
  br i1 %cmp.n, label %._crit_edge, label %scalar.ph.preheader

._crit_edge:                                      ; preds = %scalar.ph, %middle.block
  %.lcssa100 = phi i32 [ %24, %middle.block ], [ %29, %scalar.ph ]
  %25 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %indvars.iv66
  store i32 %.lcssa100, ptr %25, align 4, !tbaa !5
  %indvars.iv.next67 = add nuw nsw i64 %indvars.iv66, 1
  %exitcond70.not = icmp eq i64 %indvars.iv.next67, %wide.trip.count69
  br i1 %exitcond70.not, label %.preheader36, label %.lr.ph41, !llvm.loop !14

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %26 = phi i32 [ %29, %scalar.ph ], [ %.ph124, %scalar.ph.preheader ]
  %27 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %indvars.iv66, i64 %indvars.iv
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = or i32 %26, %28
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %scalar.ph, !llvm.loop !15

.preheader35.thread:                              ; preds = %.preheader36, %.preheader37
  %cnt.promoted92 = load i32, ptr @cnt, align 4, !tbaa !5
  br label %._crit_edge61.thread

.preheader35:                                     ; preds = %._crit_edge52
  store i32 %.lcssa99, ptr @v, align 4, !tbaa !5
  %cnt.promoted = load i32, ptr @cnt, align 4, !tbaa !5
  br i1 %5, label %.lr.ph60.preheader, label %._crit_edge61.thread

.lr.ph60.preheader:                               ; preds = %.preheader35
  %30 = add nsw i64 %18, -2
  %31 = add nsw i64 %18, -3
  %xtraiter = and i64 %18, 1
  %32 = icmp eq i64 %31, 0
  br i1 %32, label %._crit_edge61.unr-lcssa, label %.lr.ph60.preheader.new

.lr.ph60.preheader.new:                           ; preds = %.lr.ph60.preheader
  %unroll_iter = and i64 %30, -2
  br label %.lr.ph60

.lr.ph51:                                         ; preds = %.lr.ph51.preheader, %._crit_edge52
  %indvars.iv76 = phi i64 [ 2, %.lr.ph51.preheader ], [ %indvars.iv.next77, %._crit_edge52 ]
  br i1 %min.iters.check105, label %scalar.ph104.preheader, label %vector.body111

scalar.ph104.preheader:                           ; preds = %middle.block103, %.lr.ph51
  %indvars.iv71.ph = phi i64 [ 1, %.lr.ph51 ], [ %ind.end109, %middle.block103 ]
  %.ph = phi i32 [ 0, %.lr.ph51 ], [ %67, %middle.block103 ]
  br label %scalar.ph104

vector.body111:                                   ; preds = %.lr.ph51, %vector.body111
  %index112 = phi i64 [ %index.next116, %vector.body111 ], [ 0, %.lr.ph51 ]
  %vec.phi113 = phi <4 x i32> [ %64, %vector.body111 ], [ zeroinitializer, %.lr.ph51 ]
  %vec.phi114 = phi <4 x i32> [ %65, %vector.body111 ], [ zeroinitializer, %.lr.ph51 ]
  %offset.idx115 = or disjoint i64 %index112, 1
  %33 = or disjoint i64 %index112, 2
  %34 = or disjoint i64 %index112, 3
  %35 = or disjoint i64 %index112, 4
  %36 = or disjoint i64 %index112, 5
  %37 = or disjoint i64 %index112, 6
  %38 = or disjoint i64 %index112, 7
  %39 = add i64 %index112, 8
  %40 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %offset.idx115, i64 %indvars.iv76
  %41 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %33, i64 %indvars.iv76
  %42 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %34, i64 %indvars.iv76
  %43 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %35, i64 %indvars.iv76
  %44 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %36, i64 %indvars.iv76
  %45 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %37, i64 %indvars.iv76
  %46 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %38, i64 %indvars.iv76
  %47 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %39, i64 %indvars.iv76
  %48 = load i32, ptr %40, align 4, !tbaa !5
  %49 = load i32, ptr %41, align 4, !tbaa !5
  %50 = load i32, ptr %42, align 4, !tbaa !5
  %51 = load i32, ptr %43, align 4, !tbaa !5
  %52 = insertelement <4 x i32> poison, i32 %48, i64 0
  %53 = insertelement <4 x i32> %52, i32 %49, i64 1
  %54 = insertelement <4 x i32> %53, i32 %50, i64 2
  %55 = insertelement <4 x i32> %54, i32 %51, i64 3
  %56 = load i32, ptr %44, align 4, !tbaa !5
  %57 = load i32, ptr %45, align 4, !tbaa !5
  %58 = load i32, ptr %46, align 4, !tbaa !5
  %59 = load i32, ptr %47, align 4, !tbaa !5
  %60 = insertelement <4 x i32> poison, i32 %56, i64 0
  %61 = insertelement <4 x i32> %60, i32 %57, i64 1
  %62 = insertelement <4 x i32> %61, i32 %58, i64 2
  %63 = insertelement <4 x i32> %62, i32 %59, i64 3
  %64 = or <4 x i32> %vec.phi113, %55
  %65 = or <4 x i32> %vec.phi114, %63
  %index.next116 = add nuw i64 %index112, 8
  %66 = icmp eq i64 %index.next116, %n.vec108
  br i1 %66, label %middle.block103, label %vector.body111, !llvm.loop !16

middle.block103:                                  ; preds = %vector.body111
  %bin.rdx117 = or <4 x i32> %65, %64
  %67 = tail call i32 @llvm.vector.reduce.or.v4i32(<4 x i32> %bin.rdx117)
  br i1 %cmp.n118, label %._crit_edge52, label %scalar.ph104.preheader

._crit_edge52:                                    ; preds = %scalar.ph104, %middle.block103
  %.lcssa99 = phi i32 [ %67, %middle.block103 ], [ %72, %scalar.ph104 ]
  %68 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %indvars.iv76
  store i32 %.lcssa99, ptr %68, align 4, !tbaa !5
  %indvars.iv.next77 = add nuw nsw i64 %indvars.iv76, 1
  %exitcond80.not = icmp eq i64 %indvars.iv.next77, %wide.trip.count79
  br i1 %exitcond80.not, label %.preheader35, label %.lr.ph51, !llvm.loop !17

scalar.ph104:                                     ; preds = %scalar.ph104.preheader, %scalar.ph104
  %indvars.iv71 = phi i64 [ %indvars.iv.next72, %scalar.ph104 ], [ %indvars.iv71.ph, %scalar.ph104.preheader ]
  %69 = phi i32 [ %72, %scalar.ph104 ], [ %.ph, %scalar.ph104.preheader ]
  %70 = getelementptr inbounds [1001 x [1001 x i32]], ptr @g, i64 0, i64 %indvars.iv71, i64 %indvars.iv76
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = or i32 %69, %71
  %indvars.iv.next72 = add nuw nsw i64 %indvars.iv71, 1
  %exitcond75.not = icmp eq i64 %indvars.iv.next72, %wide.trip.count74
  br i1 %exitcond75.not, label %._crit_edge52, label %scalar.ph104, !llvm.loop !18

._crit_edge61.unr-lcssa:                          ; preds = %91, %.lr.ph60.preheader
  %.lcssa120.ph = phi i32 [ poison, %.lr.ph60.preheader ], [ %92, %91 ]
  %indvars.iv81.unr = phi i64 [ 2, %.lr.ph60.preheader ], [ %indvars.iv.next82.1, %91 ]
  %.unr = phi i32 [ %cnt.promoted, %.lr.ph60.preheader ], [ %92, %91 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge61, label %.lr.ph60.epil

.lr.ph60.epil:                                    ; preds = %._crit_edge61.unr-lcssa
  %73 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %indvars.iv81.unr
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %.not31.epil = icmp eq i32 %74, 0
  br i1 %.not31.epil, label %75, label %._crit_edge61

75:                                               ; preds = %.lr.ph60.epil
  %76 = getelementptr inbounds [1001 x i32], ptr @u, i64 0, i64 %indvars.iv81.unr
  store i32 1, ptr %76, align 4, !tbaa !5
  %77 = add nsw i32 %.unr, 1
  store i32 %77, ptr @cnt, align 4, !tbaa !5
  br label %._crit_edge61

._crit_edge61:                                    ; preds = %.lr.ph60.epil, %75, %._crit_edge61.unr-lcssa
  %.lcssa120 = phi i32 [ %.lcssa120.ph, %._crit_edge61.unr-lcssa ], [ %.unr, %.lr.ph60.epil ], [ %77, %75 ]
  %.not97 = icmp eq i32 %4, 3
  br i1 %.not97, label %._crit_edge61.thread, label %.preheader

.preheader:                                       ; preds = %._crit_edge61
  %xtraiter129 = and i64 %18, 1
  %78 = icmp eq i64 %31, 0
  br i1 %78, label %.unr-lcssa, label %.preheader.new

.preheader.new:                                   ; preds = %.preheader
  %unroll_iter133 = and i64 %30, -2
  br label %98

.lr.ph60:                                         ; preds = %91, %.lr.ph60.preheader.new
  %indvars.iv81 = phi i64 [ 2, %.lr.ph60.preheader.new ], [ %indvars.iv.next82.1, %91 ]
  %79 = phi i32 [ %cnt.promoted, %.lr.ph60.preheader.new ], [ %92, %91 ]
  %niter = phi i64 [ 0, %.lr.ph60.preheader.new ], [ %niter.next.1, %91 ]
  %80 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %indvars.iv81
  %81 = load i32, ptr %80, align 8, !tbaa !5
  %.not31 = icmp eq i32 %81, 0
  br i1 %.not31, label %82, label %.lr.ph60.1

82:                                               ; preds = %.lr.ph60
  %83 = getelementptr inbounds [1001 x i32], ptr @u, i64 0, i64 %indvars.iv81
  store i32 1, ptr %83, align 8, !tbaa !5
  %84 = add nsw i32 %79, 1
  store i32 %84, ptr @cnt, align 4, !tbaa !5
  br label %.lr.ph60.1

.lr.ph60.1:                                       ; preds = %.lr.ph60, %82
  %85 = phi i32 [ %79, %.lr.ph60 ], [ %84, %82 ]
  %indvars.iv.next82 = or disjoint i64 %indvars.iv81, 1
  %86 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %indvars.iv.next82
  %87 = load i32, ptr %86, align 4, !tbaa !5
  %.not31.1 = icmp eq i32 %87, 0
  br i1 %.not31.1, label %88, label %91

88:                                               ; preds = %.lr.ph60.1
  %89 = getelementptr inbounds [1001 x i32], ptr @u, i64 0, i64 %indvars.iv.next82
  store i32 1, ptr %89, align 4, !tbaa !5
  %90 = add nsw i32 %85, 1
  store i32 %90, ptr @cnt, align 4, !tbaa !5
  br label %91

91:                                               ; preds = %88, %.lr.ph60.1
  %92 = phi i32 [ %85, %.lr.ph60.1 ], [ %90, %88 ]
  %indvars.iv.next82.1 = add nuw nsw i64 %indvars.iv81, 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_edge61.unr-lcssa, label %.lr.ph60, !llvm.loop !19

.unr-lcssa:                                       ; preds = %110, %.preheader
  %.lcssa.ph = phi i32 [ poison, %.preheader ], [ %111, %110 ]
  %indvars.iv86.unr = phi i64 [ 2, %.preheader ], [ %indvars.iv.next87.1, %110 ]
  %.unr130 = phi i32 [ %.lcssa120, %.preheader ], [ %111, %110 ]
  %lcmp.mod131.not = icmp eq i64 %xtraiter129, 0
  br i1 %lcmp.mod131.not, label %.epilog-lcssa, label %.epil.preheader

.epil.preheader:                                  ; preds = %.unr-lcssa
  %93 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %indvars.iv86.unr
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %.not.epil = icmp eq i32 %94, 0
  br i1 %.not.epil, label %95, label %.epilog-lcssa

95:                                               ; preds = %.epil.preheader
  %96 = add nsw i32 %.unr130, 1
  store i32 %96, ptr @cnt, align 4, !tbaa !5
  br label %.epilog-lcssa

.epilog-lcssa:                                    ; preds = %.epil.preheader, %95, %.unr-lcssa
  %.lcssa = phi i32 [ %.lcssa.ph, %.unr-lcssa ], [ %.unr130, %.epil.preheader ], [ %96, %95 ]
  %97 = and i32 %4, 1
  %.not34 = icmp eq i32 %97, 0
  br i1 %.not34, label %._crit_edge61.thread, label %112

98:                                               ; preds = %110, %.preheader.new
  %indvars.iv86 = phi i64 [ 2, %.preheader.new ], [ %indvars.iv.next87.1, %110 ]
  %99 = phi i32 [ %.lcssa120, %.preheader.new ], [ %111, %110 ]
  %niter134 = phi i64 [ 0, %.preheader.new ], [ %niter134.next.1, %110 ]
  %100 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %indvars.iv86
  %101 = load i32, ptr %100, align 8, !tbaa !5
  %.not = icmp eq i32 %101, 0
  br i1 %.not, label %102, label %104

102:                                              ; preds = %98
  %103 = add nsw i32 %99, 1
  store i32 %103, ptr @cnt, align 4, !tbaa !5
  br label %104

104:                                              ; preds = %98, %102
  %105 = phi i32 [ %99, %98 ], [ %103, %102 ]
  %indvars.iv.next87 = or disjoint i64 %indvars.iv86, 1
  %106 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %indvars.iv.next87
  %107 = load i32, ptr %106, align 4, !tbaa !5
  %.not.1 = icmp eq i32 %107, 0
  br i1 %.not.1, label %108, label %110

108:                                              ; preds = %104
  %109 = add nsw i32 %105, 1
  store i32 %109, ptr @cnt, align 4, !tbaa !5
  br label %110

110:                                              ; preds = %108, %104
  %111 = phi i32 [ %105, %104 ], [ %109, %108 ]
  %indvars.iv.next87.1 = add nuw nsw i64 %indvars.iv86, 2
  %niter134.next.1 = add i64 %niter134, 2
  %niter134.ncmp.1 = icmp eq i64 %niter134.next.1, %unroll_iter133
  br i1 %niter134.ncmp.1, label %.unr-lcssa, label %98, !llvm.loop !20

112:                                              ; preds = %.epilog-lcssa
  %113 = add nuw nsw i32 %4, 1
  %114 = lshr exact i32 %113, 1
  %115 = zext nneg i32 %114 to i64
  %116 = getelementptr inbounds [1001 x i32], ptr @r, i64 0, i64 %115
  %117 = load i32, ptr %116, align 4, !tbaa !5
  %118 = icmp eq i32 %117, 0
  br i1 %118, label %119, label %._crit_edge61.thread

119:                                              ; preds = %112
  %120 = getelementptr inbounds [1001 x i32], ptr @c, i64 0, i64 %115
  %121 = load i32, ptr %120, align 4, !tbaa !5
  %122 = icmp eq i32 %121, 0
  br i1 %122, label %123, label %._crit_edge61.thread

123:                                              ; preds = %119
  %124 = add nsw i32 %.lcssa, -1
  store i32 %124, ptr @cnt, align 4, !tbaa !5
  br label %._crit_edge61.thread

._crit_edge61.thread:                             ; preds = %.preheader35, %.preheader35.thread, %.epilog-lcssa, %112, %119, %123, %._crit_edge61
  %125 = phi i32 [ %.lcssa, %.epilog-lcssa ], [ %.lcssa, %112 ], [ %.lcssa, %119 ], [ %124, %123 ], [ %.lcssa120, %._crit_edge61 ], [ %cnt.promoted92, %.preheader35.thread ], [ %cnt.promoted, %.preheader35 ]
  %126 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEi(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i32 noundef %125)
  %127 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %126, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  ret i32 0
}

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

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

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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.or.v4i32(<4 x i32>) #5

attributes #0 = { mustprogress norecurse uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { 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 #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 uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { inlinehint mustprogress 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 nosync nounwind speculatable willreturn memory(none) }

!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, !13}
!12 = !{!"llvm.loop.isvectorized", i32 1}
!13 = !{!"llvm.loop.unroll.runtime.disable"}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10, !13, !12}
!16 = distinct !{!16, !10, !12, !13}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10, !13, !12}
!19 = distinct !{!19, !10}
!20 = distinct !{!20, !10}


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