; LLVM IR from tangjz/acm-icpc :: codeforces/complete (548B)

; 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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@mat = external dso_local global [501 x [501 x i32]], align 16
@cnt = external dso_local global [501 x i32], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

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

12:                                               ; preds = %61, %0
  %13 = load i32, ptr %2, 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 %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %64

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

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

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

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %25
  %27 = getelementptr inbounds [501 x i32], ptr %26, i64 0, i64 0
  %28 = load i32, ptr %5, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds i32, ptr %27, i64 %29
  %31 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %30)
  %32 = load i32, ptr %2, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %33
  %35 = load i32, ptr %5, align 4, !tbaa !5
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [501 x i32], ptr %34, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = icmp ne i32 %38, 0
  br i1 %39, label %40, label %43

40:                                               ; preds = %23
  %41 = load i32, ptr %4, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %4, align 4, !tbaa !5
  br label %44

43:                                               ; preds = %23
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %43, %40
  %45 = load i32, ptr %2, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = load i32, ptr %4, align 4, !tbaa !5
  %50 = icmp slt i32 %48, %49
  br i1 %50, label %51, label %56

51:                                               ; preds = %44
  %52 = load i32, ptr %4, align 4, !tbaa !5
  %53 = load i32, ptr %2, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %54
  store i32 %52, ptr %55, align 4, !tbaa !5
  br label %56

56:                                               ; preds = %51, %44
  br label %57

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

60:                                               ; preds = %22
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %61

61:                                               ; preds = %60
  %62 = load i32, ptr %2, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %2, align 4, !tbaa !5
  br label %12, !llvm.loop !11

64:                                               ; preds = %16
  br label %65

65:                                               ; preds = %138, %64
  %66 = load i32, ptr @q, align 4, !tbaa !5
  %67 = add nsw i32 %66, -1
  store i32 %67, ptr @q, align 4, !tbaa !5
  %68 = icmp ne i32 %66, 0
  br i1 %68, label %69, label %141

69:                                               ; preds = %65
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 0, ptr %8, align 4, !tbaa !5
  %70 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.2, ptr noundef %6, ptr noundef %7)
  %71 = load i32, ptr %6, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %72
  %74 = load i32, ptr %7, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [501 x i32], ptr %73, i64 0, i64 %75
  %77 = load i32, ptr %76, align 4, !tbaa !5
  %78 = xor i32 %77, 1
  store i32 %78, ptr %76, align 4, !tbaa !5
  %79 = load i32, ptr %6, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %80
  store i32 0, ptr %81, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %82

82:                                               ; preds = %113, %69
  %83 = load i32, ptr %9, align 4, !tbaa !5
  %84 = load i32, ptr @m, align 4, !tbaa !5
  %85 = icmp sle i32 %83, %84
  br i1 %85, label %87, label %86

86:                                               ; preds = %82
  store i32 10, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  br label %116

87:                                               ; preds = %82
  %88 = load i32, ptr %6, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %89
  %91 = load i32, ptr %9, align 4, !tbaa !5
  %92 = sext i32 %91 to i64
  %93 = getelementptr inbounds [501 x i32], ptr %90, i64 0, i64 %92
  %94 = load i32, ptr %93, align 4, !tbaa !5
  %95 = icmp ne i32 %94, 0
  br i1 %95, label %96, label %99

96:                                               ; preds = %87
  %97 = load i32, ptr %8, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %8, align 4, !tbaa !5
  br label %100

99:                                               ; preds = %87
  store i32 0, ptr %8, align 4, !tbaa !5
  br label %100

100:                                              ; preds = %99, %96
  %101 = load i32, ptr %6, align 4, !tbaa !5
  %102 = sext i32 %101 to i64
  %103 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %102
  %104 = load i32, ptr %103, align 4, !tbaa !5
  %105 = load i32, ptr %8, align 4, !tbaa !5
  %106 = icmp slt i32 %104, %105
  br i1 %106, label %107, label %112

107:                                              ; preds = %100
  %108 = load i32, ptr %8, align 4, !tbaa !5
  %109 = load i32, ptr %6, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %110
  store i32 %108, ptr %111, align 4, !tbaa !5
  br label %112

112:                                              ; preds = %107, %100
  br label %113

113:                                              ; preds = %112
  %114 = load i32, ptr %9, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %9, align 4, !tbaa !5
  br label %82, !llvm.loop !12

116:                                              ; preds = %86
  store i32 0, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %117

117:                                              ; preds = %135, %116
  %118 = load i32, ptr %10, align 4, !tbaa !5
  %119 = load i32, ptr @n, align 4, !tbaa !5
  %120 = icmp sle i32 %118, %119
  br i1 %120, label %122, label %121

121:                                              ; preds = %117
  store i32 13, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %138

122:                                              ; preds = %117
  %123 = load i32, ptr %8, align 4, !tbaa !5
  %124 = load i32, ptr %10, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = icmp slt i32 %123, %127
  br i1 %128, label %129, label %134

129:                                              ; preds = %122
  %130 = load i32, ptr %10, align 4, !tbaa !5
  %131 = sext i32 %130 to i64
  %132 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %131
  %133 = load i32, ptr %132, align 4, !tbaa !5
  store i32 %133, ptr %8, align 4, !tbaa !5
  br label %134

134:                                              ; preds = %129, %122
  br label %135

135:                                              ; preds = %134
  %136 = load i32, ptr %10, align 4, !tbaa !5
  %137 = add nsw i32 %136, 1
  store i32 %137, ptr %10, align 4, !tbaa !5
  br label %117, !llvm.loop !13

138:                                              ; preds = %121
  %139 = load i32, ptr %8, align 4, !tbaa !5
  %140 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %139)
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %65, !llvm.loop !14

141:                                              ; preds = %65
  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 i32 @printf(ptr noundef, ...) #1

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


; 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"

@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@q = external dso_local global i32, align 4
@mat = external dso_local global [501 x [501 x i32]], align 16
@cnt = external dso_local local_unnamed_addr global [501 x i32], align 16
@.str = external hidden unnamed_addr constant [7 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: mustprogress nofree norecurse nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull @n, ptr noundef nonnull @m, ptr noundef nonnull @q)
  %4 = load i32, ptr @n, align 4, !tbaa !5
  %.not43 = icmp slt i32 %4, 1
  %5 = load i32, ptr @m, align 4
  %6 = icmp slt i32 %5, 1
  %or.cond = select i1 %.not43, i1 true, i1 %6
  br i1 %or.cond, label %.preheader38, label %.preheader39

.preheader39:                                     ; preds = %0, %._crit_edge
  %7 = phi i32 [ %13, %._crit_edge ], [ %4, %0 ]
  %8 = phi i32 [ %14, %._crit_edge ], [ %5, %0 ]
  %indvars.iv60 = phi i64 [ %indvars.iv.next61, %._crit_edge ], [ 1, %0 ]
  %.not3640 = icmp slt i32 %8, 1
  br i1 %.not3640, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader39
  %9 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %indvars.iv60
  %10 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %indvars.iv60
  br label %16

.preheader38:                                     ; preds = %._crit_edge, %0
  %11 = load i32, ptr @q, align 4, !tbaa !5
  %12 = add nsw i32 %11, -1
  store i32 %12, ptr @q, align 4, !tbaa !5
  %.not3255 = icmp eq i32 %11, 0
  br i1 %.not3255, label %._crit_edge57, label %.lr.ph56

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

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %.preheader39
  %13 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %7, %.preheader39 ]
  %14 = phi i32 [ %26, %._crit_edge.loopexit ], [ %8, %.preheader39 ]
  %indvars.iv.next61 = add nuw nsw i64 %indvars.iv60, 1
  %15 = sext i32 %13 to i64
  %.not.not = icmp slt i64 %indvars.iv60, %15
  br i1 %.not.not, label %.preheader39, label %.preheader38, !llvm.loop !9

16:                                               ; preds = %.lr.ph, %25
  %indvars.iv = phi i64 [ 1, %.lr.ph ], [ %indvars.iv.next, %25 ]
  %.02841 = phi i32 [ 0, %.lr.ph ], [ %.129, %25 ]
  %17 = getelementptr inbounds i32, ptr %9, i64 %indvars.iv
  %18 = tail call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %17)
  %19 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %indvars.iv60, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %.not37 = icmp eq i32 %20, 0
  %21 = add nsw i32 %.02841, 1
  %.129 = select i1 %.not37, i32 0, i32 %21
  %22 = load i32, ptr %10, align 4, !tbaa !5
  %23 = icmp slt i32 %22, %.129
  br i1 %23, label %24, label %25

24:                                               ; preds = %16
  store i32 %.129, ptr %10, align 4, !tbaa !5
  br label %25

25:                                               ; preds = %16, %24
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @m, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %.not36.not = icmp slt i64 %indvars.iv, %27
  br i1 %.not36.not, label %16, label %._crit_edge.loopexit, !llvm.loop !12

.lr.ph56:                                         ; preds = %.preheader38, %._crit_edge54
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %28 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.2, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %30, i64 %32
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = xor i32 %34, 1
  store i32 %35, ptr %33, align 4, !tbaa !5
  %36 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %30
  store i32 0, ptr %36, align 4, !tbaa !5
  %37 = load i32, ptr @m, align 4, !tbaa !5
  %.not3345 = icmp slt i32 %37, 1
  br i1 %.not3345, label %.preheader, label %.lr.ph49

.lr.ph49:                                         ; preds = %.lr.ph56
  %38 = zext nneg i32 %37 to i64
  %xtraiter = and i64 %38, 1
  %39 = icmp eq i32 %37, 1
  br i1 %39, label %.preheader.loopexit.unr-lcssa, label %.lr.ph49.new

.lr.ph49.new:                                     ; preds = %.lr.ph49
  %unroll_iter = and i64 %38, 2147483646
  br label %54

.preheader.loopexit.unr-lcssa:                    ; preds = %68, %.lr.ph49
  %indvars.iv63.unr = phi i64 [ 1, %.lr.ph49 ], [ %indvars.iv.next64.1, %68 ]
  %.unr = phi i32 [ 0, %.lr.ph49 ], [ %69, %68 ]
  %.02646.unr = phi i32 [ 0, %.lr.ph49 ], [ %.1.1, %68 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.epil.preheader

.epil.preheader:                                  ; preds = %.preheader.loopexit.unr-lcssa
  %40 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %30, i64 %indvars.iv63.unr
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %.not35.epil = icmp eq i32 %41, 0
  %42 = add nsw i32 %.02646.unr, 1
  %.1.epil = select i1 %.not35.epil, i32 0, i32 %42
  %43 = icmp slt i32 %.unr, %.1.epil
  br i1 %43, label %44, label %.preheader

44:                                               ; preds = %.epil.preheader
  store i32 %.1.epil, ptr %36, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader.loopexit.unr-lcssa, %44, %.epil.preheader, %.lr.ph56
  %45 = load i32, ptr @n, align 4, !tbaa !5
  %.not3450 = icmp slt i32 %45, 1
  br i1 %.not3450, label %._crit_edge54, label %.lr.ph53.preheader

.lr.ph53.preheader:                               ; preds = %.preheader
  %46 = add nuw i32 %45, 1
  %wide.trip.count69 = zext i32 %46 to i64
  %47 = zext nneg i32 %45 to i64
  %min.iters.check = icmp ult i32 %45, 8
  br i1 %min.iters.check, label %.lr.ph53.preheader74, label %vector.ph

.lr.ph53.preheader74:                             ; preds = %middle.block, %.lr.ph53.preheader
  %indvars.iv66.ph = phi i64 [ 1, %.lr.ph53.preheader ], [ %ind.end, %middle.block ]
  %.251.ph = phi i32 [ 0, %.lr.ph53.preheader ], [ %53, %middle.block ]
  br label %.lr.ph53

vector.ph:                                        ; preds = %.lr.ph53.preheader
  %n.vec = and i64 %47, 2147483640
  %ind.end = or disjoint i64 %n.vec, 1
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %vec.phi = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %50, %vector.body ]
  %vec.phi72 = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ %51, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %48 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %offset.idx
  %49 = getelementptr inbounds i8, ptr %48, i64 16
  %wide.load = load <4 x i32>, ptr %48, align 4, !tbaa !5
  %wide.load73 = load <4 x i32>, ptr %49, align 4, !tbaa !5
  %50 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %vec.phi, <4 x i32> %wide.load)
  %51 = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %vec.phi72, <4 x i32> %wide.load73)
  %index.next = add nuw i64 %index, 8
  %52 = icmp eq i64 %index.next, %n.vec
  br i1 %52, label %middle.block, label %vector.body, !llvm.loop !13

middle.block:                                     ; preds = %vector.body
  %rdx.minmax = call <4 x i32> @llvm.smax.v4i32(<4 x i32> %50, <4 x i32> %51)
  %53 = call i32 @llvm.vector.reduce.smax.v4i32(<4 x i32> %rdx.minmax)
  %cmp.n = icmp eq i64 %n.vec, %47
  br i1 %cmp.n, label %._crit_edge54, label %.lr.ph53.preheader74

54:                                               ; preds = %68, %.lr.ph49.new
  %indvars.iv63 = phi i64 [ 1, %.lr.ph49.new ], [ %indvars.iv.next64.1, %68 ]
  %55 = phi i32 [ 0, %.lr.ph49.new ], [ %69, %68 ]
  %.02646 = phi i32 [ 0, %.lr.ph49.new ], [ %.1.1, %68 ]
  %niter = phi i64 [ 0, %.lr.ph49.new ], [ %niter.next.1, %68 ]
  %56 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %30, i64 %indvars.iv63
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %.not35 = icmp eq i32 %57, 0
  %58 = add nsw i32 %.02646, 1
  %.1 = select i1 %.not35, i32 0, i32 %58
  %59 = icmp slt i32 %55, %.1
  br i1 %59, label %60, label %61

60:                                               ; preds = %54
  store i32 %.1, ptr %36, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %54, %60
  %62 = phi i32 [ %55, %54 ], [ %.1, %60 ]
  %indvars.iv.next64 = add nuw nsw i64 %indvars.iv63, 1
  %63 = getelementptr inbounds [501 x [501 x i32]], ptr @mat, i64 0, i64 %30, i64 %indvars.iv.next64
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %.not35.1 = icmp eq i32 %64, 0
  %65 = add nsw i32 %.1, 1
  %.1.1 = select i1 %.not35.1, i32 0, i32 %65
  %66 = icmp slt i32 %62, %.1.1
  br i1 %66, label %67, label %68

67:                                               ; preds = %61
  store i32 %.1.1, ptr %36, align 4, !tbaa !5
  br label %68

68:                                               ; preds = %67, %61
  %69 = phi i32 [ %62, %61 ], [ %.1.1, %67 ]
  %indvars.iv.next64.1 = add nuw nsw i64 %indvars.iv63, 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 %.preheader.loopexit.unr-lcssa, label %54, !llvm.loop !16

._crit_edge54:                                    ; preds = %.lr.ph53, %middle.block, %.preheader
  %.2.lcssa = phi i32 [ 0, %.preheader ], [ %53, %middle.block ], [ %spec.select, %.lr.ph53 ]
  %70 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, i32 noundef %.2.lcssa)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %71 = load i32, ptr @q, align 4, !tbaa !5
  %72 = add nsw i32 %71, -1
  store i32 %72, ptr @q, align 4, !tbaa !5
  %.not32 = icmp eq i32 %71, 0
  br i1 %.not32, label %._crit_edge57, label %.lr.ph56, !llvm.loop !17

.lr.ph53:                                         ; preds = %.lr.ph53.preheader74, %.lr.ph53
  %indvars.iv66 = phi i64 [ %indvars.iv.next67, %.lr.ph53 ], [ %indvars.iv66.ph, %.lr.ph53.preheader74 ]
  %.251 = phi i32 [ %spec.select, %.lr.ph53 ], [ %.251.ph, %.lr.ph53.preheader74 ]
  %73 = getelementptr inbounds [501 x i32], ptr @cnt, i64 0, i64 %indvars.iv66
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %spec.select = call i32 @llvm.smax.i32(i32 %.251, i32 %74)
  %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 %._crit_edge54, label %.lr.ph53, !llvm.loop !18

._crit_edge57:                                    ; preds = %._crit_edge54, %.preheader38
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) 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

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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.smax.i32(i32, i32) #3

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare <4 x i32> @llvm.smax.v4i32(<4 x i32>, <4 x i32>) #3

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

attributes #0 = { mustprogress nofree norecurse 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 #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
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, !11}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!"llvm.loop.unswitch.partial.disable"}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10, !14, !15}
!14 = !{!"llvm.loop.isvectorized", i32 1}
!15 = !{!"llvm.loop.unroll.runtime.disable"}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !10, !15, !14}


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