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

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

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@g = external dso_local global [501 x [501 x i32]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8), ptr noundef) #0 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)) #1

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

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

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

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

19:                                               ; preds = %33, %18
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %21 = load i32, ptr @k, align 4, !tbaa !5
  %22 = icmp slt i32 %20, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  store i32 5, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #5
  br label %36

24:                                               ; preds = %19
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = add nsw i32 %25, 1
  store i32 %26, ptr %2, align 4, !tbaa !5
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %28
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [501 x i32], ptr %29, i64 0, i64 %31
  store i32 %26, ptr %32, align 4, !tbaa !5
  br label %33

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

36:                                               ; preds = %23
  br label %37

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

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

41:                                               ; preds = %66, %40
  %42 = load i32, ptr %6, align 4, !tbaa !5
  %43 = load i32, ptr @n, align 4, !tbaa !5
  %44 = icmp sle i32 %42, %43
  br i1 %44, label %46, label %45

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

46:                                               ; preds = %41
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %47 = load i32, ptr @k, align 4, !tbaa !5
  store i32 %47, ptr %7, align 4, !tbaa !5
  br label %48

48:                                               ; preds = %62, %46
  %49 = load i32, ptr %7, align 4, !tbaa !5
  %50 = load i32, ptr @n, align 4, !tbaa !5
  %51 = icmp sle i32 %49, %50
  br i1 %51, label %53, label %52

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

53:                                               ; preds = %48
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %2, align 4, !tbaa !5
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %57
  %59 = load i32, ptr %7, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [501 x i32], ptr %58, i64 0, i64 %60
  store i32 %55, ptr %61, align 4, !tbaa !5
  br label %62

62:                                               ; preds = %53
  %63 = load i32, ptr %7, align 4, !tbaa !5
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %7, align 4, !tbaa !5
  br label %48, !llvm.loop !12

65:                                               ; preds = %52
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %6, align 4, !tbaa !5
  br label %41, !llvm.loop !13

69:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #5
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %70

70:                                               ; preds = %86, %69
  %71 = load i32, ptr %9, align 4, !tbaa !5
  %72 = load i32, ptr @n, align 4, !tbaa !5
  %73 = icmp sle i32 %71, %72
  br i1 %73, label %75, label %74

74:                                               ; preds = %70
  store i32 14, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #5
  br label %89

75:                                               ; preds = %70
  %76 = load i32, ptr %9, align 4, !tbaa !5
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %77
  %79 = load i32, ptr @k, align 4, !tbaa !5
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds [501 x i32], ptr %78, i64 0, i64 %80
  %82 = load i32, ptr %81, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = load i64, ptr %8, align 8, !tbaa !14
  %85 = add nsw i64 %84, %83
  store i64 %85, ptr %8, align 8, !tbaa !14
  br label %86

86:                                               ; preds = %75
  %87 = load i32, ptr %9, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %9, align 4, !tbaa !5
  br label %70, !llvm.loop !16

89:                                               ; preds = %74
  %90 = load i64, ptr %8, align 8, !tbaa !14
  %91 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %90)
  %92 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %91, ptr noundef @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #5
  store i32 1, ptr %10, align 4, !tbaa !5
  br label %93

93:                                               ; preds = %118, %89
  %94 = load i32, ptr %10, align 4, !tbaa !5
  %95 = load i32, ptr @n, align 4, !tbaa !5
  %96 = icmp sle i32 %94, %95
  br i1 %96, label %98, label %97

97:                                               ; preds = %93
  store i32 17, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #5
  br label %121

98:                                               ; preds = %93
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  store i32 1, ptr %11, align 4, !tbaa !5
  br label %99

99:                                               ; preds = %113, %98
  %100 = load i32, ptr %11, align 4, !tbaa !5
  %101 = load i32, ptr @n, align 4, !tbaa !5
  %102 = icmp sle i32 %100, %101
  br i1 %102, label %104, label %103

103:                                              ; preds = %99
  store i32 20, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  br label %116

104:                                              ; preds = %99
  %105 = load i32, ptr %10, align 4, !tbaa !5
  %106 = sext i32 %105 to i64
  %107 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %106
  %108 = load i32, ptr %11, align 4, !tbaa !5
  %109 = sext i32 %108 to i64
  %110 = getelementptr inbounds [501 x i32], ptr %107, i64 0, i64 %109
  %111 = load i32, ptr %110, align 4, !tbaa !5
  %112 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %111)
  br label %113

113:                                              ; preds = %104
  %114 = load i32, ptr %11, align 4, !tbaa !5
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %11, align 4, !tbaa !5
  br label %99, !llvm.loop !17

116:                                              ; preds = %103
  %117 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %118

118:                                              ; preds = %116
  %119 = load i32, ptr %10, align 4, !tbaa !5
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %10, align 4, !tbaa !5
  br label %93, !llvm.loop !18

121:                                              ; preds = %97
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  %122 = load i32, ptr %1, align 4
  ret i32 %122
}

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

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

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

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8), i64 noundef) #0 align 2

declare i32 @printf(ptr noundef, ...) #3

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 = { 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 #2 = { 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 #3 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!15, !15, i64 0}
!15 = !{!"long long", !7, i64 0}
!16 = distinct !{!16, !10}
!17 = distinct !{!17, !10}
!18 = distinct !{!18, !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 }

@_ZSt4cout = external global %"class.std::basic_ostream", align 8
@n = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@g = external dso_local local_unnamed_addr global [501 x [501 x i32]], align 16
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [2 x i8], align 1

; 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 #0 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)) #1

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

.preheader41.lr.ph:                               ; preds = %0
  %3 = load i32, ptr @k, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 1
  br i1 %4, label %.preheader41.us.preheader, label %.lr.ph56

.preheader41.us.preheader:                        ; preds = %.preheader41.lr.ph
  %5 = add nuw i32 %2, 1
  %wide.trip.count78 = zext i32 %5 to i64
  %wide.trip.count = zext nneg i32 %3 to i64
  %6 = add nsw i64 %wide.trip.count, -1
  %min.iters.check = icmp ult i32 %3, 9
  %n.vec = and i64 %6, -8
  %ind.end = or disjoint i64 %n.vec, 1
  %.cast = trunc nsw i64 %n.vec to i32
  %cmp.n = icmp eq i64 %6, %n.vec
  br label %.preheader41.us

.preheader41.us:                                  ; preds = %.preheader41.us.preheader, %._crit_edge.us
  %indvars.iv75 = phi i64 [ 1, %.preheader41.us.preheader ], [ %indvars.iv.next76, %._crit_edge.us ]
  %.03345.us = phi i32 [ 0, %.preheader41.us.preheader ], [ %.lcssa108, %._crit_edge.us ]
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.ph

vector.ph:                                        ; preds = %.preheader41.us
  %ind.end109 = add i32 %.03345.us, %.cast
  %.splatinsert = insertelement <4 x i32> poison, i32 %.03345.us, i64 0
  %.splat = shufflevector <4 x i32> %.splatinsert, <4 x i32> poison, <4 x i32> zeroinitializer
  %induction = add <4 x i32> %.splat, <i32 0, i32 1, i32 2, i32 3>
  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> [ %induction, %vector.ph ], [ %vec.ind.next, %vector.body ]
  %offset.idx = or disjoint i64 %index, 1
  %7 = add nsw <4 x i32> %vec.ind, <i32 1, i32 1, i32 1, i32 1>
  %8 = add <4 x i32> %vec.ind, <i32 5, i32 5, i32 5, i32 5>
  %9 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv75, i64 %offset.idx
  %10 = getelementptr inbounds i8, ptr %9, i64 16
  store <4 x i32> %7, ptr %9, align 4, !tbaa !5
  store <4 x i32> %8, ptr %10, align 4, !tbaa !5
  %index.next = add nuw i64 %index, 8
  %vec.ind.next = add <4 x i32> %vec.ind, <i32 8, i32 8, i32 8, i32 8>
  %11 = icmp eq i64 %index.next, %n.vec
  br i1 %11, label %middle.block, label %vector.body, !llvm.loop !9

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %.preheader41.us
  %indvars.iv.ph = phi i64 [ 1, %.preheader41.us ], [ %ind.end, %middle.block ]
  %.142.us.ph = phi i32 [ %.03345.us, %.preheader41.us ], [ %ind.end109, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %indvars.iv = phi i64 [ %indvars.iv.next, %scalar.ph ], [ %indvars.iv.ph, %scalar.ph.preheader ]
  %.142.us = phi i32 [ %12, %scalar.ph ], [ %.142.us.ph, %scalar.ph.preheader ]
  %12 = add nsw i32 %.142.us, 1
  %13 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv75, i64 %indvars.iv
  store i32 %12, ptr %13, align 4, !tbaa !5
  %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.us, label %scalar.ph, !llvm.loop !13

._crit_edge.us:                                   ; preds = %scalar.ph, %middle.block
  %.lcssa108 = phi i32 [ %ind.end109, %middle.block ], [ %12, %scalar.ph ]
  %indvars.iv.next76 = add nuw nsw i64 %indvars.iv75, 1
  %exitcond79.not = icmp eq i64 %indvars.iv.next76, %wide.trip.count78
  br i1 %exitcond79.not, label %.preheader40, label %.preheader41.us, !llvm.loop !14

.preheader40:                                     ; preds = %._crit_edge.us
  br i1 %.not44, label %._crit_edge61, label %.lr.ph56

.lr.ph56:                                         ; preds = %.preheader41.lr.ph, %.preheader40
  %.033.lcssa103 = phi i32 [ %.lcssa108, %.preheader40 ], [ 0, %.preheader41.lr.ph ]
  %14 = load i32, ptr @k, align 4, !tbaa !5
  %.not3850 = icmp sgt i32 %14, %2
  br i1 %.not3850, label %.lr.ph60, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.lr.ph56
  %15 = sext i32 %14 to i64
  %16 = add nuw i32 %2, 1
  %wide.trip.count87 = zext i32 %16 to i64
  %17 = sub i32 %2, %14
  %18 = zext i32 %17 to i64
  %19 = add nuw nsw i64 %18, 1
  %min.iters.check114 = icmp ult i32 %17, 7
  %n.vec117 = and i64 %19, 8589934584
  %ind.end118 = add nsw i64 %n.vec117, %15
  %.cast120 = trunc i64 %n.vec117 to i32
  %cmp.n134 = icmp eq i64 %19, %n.vec117
  br label %.lr.ph

.preheader39:                                     ; preds = %._crit_edge
  br i1 %.not44, label %._crit_edge61, label %.lr.ph60

.lr.ph60:                                         ; preds = %.lr.ph56, %.preheader39
  %20 = load i32, ptr @k, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = zext nneg i32 %2 to i64
  %xtraiter = and i64 %22, 3
  %23 = icmp ult i32 %2, 4
  br i1 %23, label %._crit_edge61.loopexit.unr-lcssa, label %.lr.ph60.new

.lr.ph60.new:                                     ; preds = %.lr.ph60
  %unroll_iter = and i64 %22, 2147483644
  br label %38

.lr.ph:                                           ; preds = %.lr.ph.preheader, %._crit_edge
  %indvars.iv84 = phi i64 [ 1, %.lr.ph.preheader ], [ %indvars.iv.next85, %._crit_edge ]
  %.254 = phi i32 [ %.033.lcssa103, %.lr.ph.preheader ], [ %.lcssa107, %._crit_edge ]
  br i1 %min.iters.check114, label %scalar.ph113.preheader, label %vector.ph115

scalar.ph113.preheader:                           ; preds = %middle.block112, %.lr.ph
  %indvars.iv80.ph = phi i64 [ %15, %.lr.ph ], [ %ind.end118, %middle.block112 ]
  %.351.ph = phi i32 [ %.254, %.lr.ph ], [ %ind.end121, %middle.block112 ]
  br label %scalar.ph113

vector.ph115:                                     ; preds = %.lr.ph
  %ind.end121 = add i32 %.254, %.cast120
  %.splatinsert125 = insertelement <4 x i32> poison, i32 %.254, i64 0
  %.splat126 = shufflevector <4 x i32> %.splatinsert125, <4 x i32> poison, <4 x i32> zeroinitializer
  %induction127 = add <4 x i32> %.splat126, <i32 0, i32 1, i32 2, i32 3>
  br label %vector.body123

vector.body123:                                   ; preds = %vector.body123, %vector.ph115
  %index124 = phi i64 [ 0, %vector.ph115 ], [ %index.next133, %vector.body123 ]
  %vec.ind128 = phi <4 x i32> [ %induction127, %vector.ph115 ], [ %vec.ind.next131, %vector.body123 ]
  %offset.idx132 = add i64 %index124, %15
  %24 = add nsw <4 x i32> %vec.ind128, <i32 1, i32 1, i32 1, i32 1>
  %25 = add <4 x i32> %vec.ind128, <i32 5, i32 5, i32 5, i32 5>
  %26 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv84, i64 %offset.idx132
  %27 = getelementptr inbounds i8, ptr %26, i64 16
  store <4 x i32> %24, ptr %26, align 4, !tbaa !5
  store <4 x i32> %25, ptr %27, align 4, !tbaa !5
  %index.next133 = add nuw i64 %index124, 8
  %vec.ind.next131 = add <4 x i32> %vec.ind128, <i32 8, i32 8, i32 8, i32 8>
  %28 = icmp eq i64 %index.next133, %n.vec117
  br i1 %28, label %middle.block112, label %vector.body123, !llvm.loop !15

middle.block112:                                  ; preds = %vector.body123
  br i1 %cmp.n134, label %._crit_edge, label %scalar.ph113.preheader

._crit_edge:                                      ; preds = %scalar.ph113, %middle.block112
  %.lcssa107 = phi i32 [ %ind.end121, %middle.block112 ], [ %29, %scalar.ph113 ]
  %indvars.iv.next85 = add nuw nsw i64 %indvars.iv84, 1
  %exitcond88.not = icmp eq i64 %indvars.iv.next85, %wide.trip.count87
  br i1 %exitcond88.not, label %.preheader39, label %.lr.ph, !llvm.loop !16

scalar.ph113:                                     ; preds = %scalar.ph113.preheader, %scalar.ph113
  %indvars.iv80 = phi i64 [ %indvars.iv.next81, %scalar.ph113 ], [ %indvars.iv80.ph, %scalar.ph113.preheader ]
  %.351 = phi i32 [ %29, %scalar.ph113 ], [ %.351.ph, %scalar.ph113.preheader ]
  %29 = add nsw i32 %.351, 1
  %30 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv84, i64 %indvars.iv80
  store i32 %29, ptr %30, align 4, !tbaa !5
  %indvars.iv.next81 = add nsw i64 %indvars.iv80, 1
  %lftr.wideiv = trunc i64 %indvars.iv.next81 to i32
  %exitcond83.not = icmp eq i32 %16, %lftr.wideiv
  br i1 %exitcond83.not, label %._crit_edge, label %scalar.ph113, !llvm.loop !17

._crit_edge61.loopexit.unr-lcssa:                 ; preds = %38, %.lr.ph60
  %.lcssa.ph = phi i64 [ poison, %.lr.ph60 ], [ %54, %38 ]
  %indvars.iv89.unr = phi i64 [ 1, %.lr.ph60 ], [ %indvars.iv.next90.3, %38 ]
  %.02858.unr = phi i64 [ 0, %.lr.ph60 ], [ %54, %38 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge61, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge61.loopexit.unr-lcssa, %.epil.preheader
  %indvars.iv89.epil = phi i64 [ %indvars.iv.next90.epil, %.epil.preheader ], [ %indvars.iv89.unr, %._crit_edge61.loopexit.unr-lcssa ]
  %.02858.epil = phi i64 [ %34, %.epil.preheader ], [ %.02858.unr, %._crit_edge61.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.epil.preheader ], [ 0, %._crit_edge61.loopexit.unr-lcssa ]
  %31 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv89.epil, i64 %21
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = add nsw i64 %.02858.epil, %33
  %indvars.iv.next90.epil = add nuw nsw i64 %indvars.iv89.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %._crit_edge61, label %.epil.preheader, !llvm.loop !18

._crit_edge61:                                    ; preds = %._crit_edge61.loopexit.unr-lcssa, %.epil.preheader, %0, %.preheader40, %.preheader39
  %.028.lcssa = phi i64 [ 0, %.preheader39 ], [ 0, %.preheader40 ], [ 0, %0 ], [ %.lcssa.ph, %._crit_edge61.loopexit.unr-lcssa ], [ %34, %.epil.preheader ]
  %35 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEx(ptr noundef nonnull align 8 dereferenceable(8) @_ZSt4cout, i64 noundef %.028.lcssa)
  %36 = tail call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSolsEPFRSoS_E(ptr noundef nonnull align 8 dereferenceable(8) %35, ptr noundef nonnull @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_)
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %.not3667 = icmp slt i32 %37, 1
  br i1 %.not3667, label %._crit_edge69, label %.preheader

38:                                               ; preds = %38, %.lr.ph60.new
  %indvars.iv89 = phi i64 [ 1, %.lr.ph60.new ], [ %indvars.iv.next90.3, %38 ]
  %.02858 = phi i64 [ 0, %.lr.ph60.new ], [ %54, %38 ]
  %niter = phi i64 [ 0, %.lr.ph60.new ], [ %niter.next.3, %38 ]
  %39 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv89, i64 %21
  %40 = load i32, ptr %39, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = add nsw i64 %.02858, %41
  %indvars.iv.next90 = add nuw nsw i64 %indvars.iv89, 1
  %43 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv.next90, i64 %21
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = add nsw i64 %42, %45
  %indvars.iv.next90.1 = add nuw nsw i64 %indvars.iv89, 2
  %47 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv.next90.1, i64 %21
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = add nsw i64 %46, %49
  %indvars.iv.next90.2 = add nuw nsw i64 %indvars.iv89, 3
  %51 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv.next90.2, i64 %21
  %52 = load i32, ptr %51, align 4, !tbaa !5
  %53 = sext i32 %52 to i64
  %54 = add nsw i64 %50, %53
  %indvars.iv.next90.3 = add nuw nsw i64 %indvars.iv89, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %._crit_edge61.loopexit.unr-lcssa, label %38, !llvm.loop !20

.preheader:                                       ; preds = %._crit_edge61, %._crit_edge66
  %55 = phi i32 [ %57, %._crit_edge66 ], [ %37, %._crit_edge61 ]
  %indvars.iv97 = phi i64 [ %indvars.iv.next98, %._crit_edge66 ], [ 1, %._crit_edge61 ]
  %.not3763 = icmp slt i32 %55, 1
  br i1 %.not3763, label %._crit_edge66, label %.lr.ph65

._crit_edge69:                                    ; preds = %._crit_edge66, %._crit_edge61
  ret i32 0

._crit_edge66:                                    ; preds = %.lr.ph65, %.preheader
  %56 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %indvars.iv.next98 = add nuw nsw i64 %indvars.iv97, 1
  %57 = load i32, ptr @n, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %.not36.not = icmp slt i64 %indvars.iv97, %58
  br i1 %.not36.not, label %.preheader, label %._crit_edge69, !llvm.loop !21

.lr.ph65:                                         ; preds = %.preheader, %.lr.ph65
  %indvars.iv94 = phi i64 [ %indvars.iv.next95, %.lr.ph65 ], [ 1, %.preheader ]
  %59 = getelementptr inbounds [501 x [501 x i32]], ptr @g, i64 0, i64 %indvars.iv97, i64 %indvars.iv94
  %60 = load i32, ptr %59, align 4, !tbaa !5
  %61 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %60)
  %indvars.iv.next95 = add nuw nsw i64 %indvars.iv94, 1
  %62 = load i32, ptr @n, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %.not37.not = icmp slt i64 %indvars.iv94, %63
  br i1 %.not37.not, label %.lr.ph65, label %._crit_edge66, !llvm.loop !22
}

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

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

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

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

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


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