; LLVM IR from tangjz/acm-icpc :: codeforces/complete (946D)

; 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
@f = external dso_local global [501 x i32], align 16
@g = external dso_local global [501 x i32], align 16
@tot = external dso_local global i32, align 4
@seq = external dso_local global [501 x i32], align 16
@buf = external dso_local global [501 x i8], 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 [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)
  br label %12

12:                                               ; preds = %141, %0
  %13 = load i32, ptr @n, align 4, !tbaa !5
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr @n, align 4, !tbaa !5
  %15 = icmp ne i32 %13, 0
  br i1 %15, label %16, label %142

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

18:                                               ; preds = %37, %16
  %19 = load i32, ptr %2, align 4, !tbaa !5
  %20 = load i32, ptr @m, align 4, !tbaa !5
  %21 = icmp slt i32 %19, %20
  br i1 %21, label %23, label %22

22:                                               ; preds = %18
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  br label %40

23:                                               ; preds = %18
  %24 = load i32, ptr %2, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [501 x i8], ptr @buf, i64 0, i64 %25
  %27 = load i8, ptr %26, align 1, !tbaa !9
  %28 = sext i8 %27 to i32
  %29 = icmp eq i32 %28, 49
  br i1 %29, label %30, label %36

30:                                               ; preds = %23
  %31 = load i32, ptr %2, align 4, !tbaa !5
  %32 = load i32, ptr @tot, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr @tot, align 4, !tbaa !5
  %34 = sext i32 %32 to i64
  %35 = getelementptr inbounds [501 x i32], ptr @seq, i64 0, i64 %34
  store i32 %31, ptr %35, align 4, !tbaa !5
  br label %36

36:                                               ; preds = %30, %23
  br label %37

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

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

41:                                               ; preds = %84, %40
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = load i32, ptr @tot, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br i1 %44, label %46, label %45

45:                                               ; preds = %41
  store i32 7, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  br label %87

46:                                               ; preds = %41
  %47 = load i32, ptr %3, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [501 x i32], ptr @g, i64 0, i64 %48
  store i32 1061109567, ptr %49, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %50 = load i32, ptr @tot, align 4, !tbaa !5
  %51 = sub nsw i32 %50, 1
  %52 = load i32, ptr %3, align 4, !tbaa !5
  %53 = sub nsw i32 %51, %52
  store i32 %53, ptr %6, align 4, !tbaa !5
  br label %54

54:                                               ; preds = %78, %46
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = load i32, ptr @tot, align 4, !tbaa !5
  %57 = icmp slt i32 %55, %56
  br i1 %57, label %59, label %58

58:                                               ; preds = %54
  store i32 10, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %83

59:                                               ; preds = %54
  %60 = load i32, ptr %3, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [501 x i32], ptr @g, i64 0, i64 %61
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %63 = load i32, ptr %6, align 4, !tbaa !5
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [501 x i32], ptr @seq, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !5
  %67 = load i32, ptr %5, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [501 x i32], ptr @seq, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = sub nsw i32 %66, %70
  %72 = add nsw i32 %71, 1
  store i32 %72, ptr %7, align 4, !tbaa !5
  %73 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %62, ptr noundef nonnull align 4 dereferenceable(4) %7)
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = load i32, ptr %3, align 4, !tbaa !5
  %76 = sext i32 %75 to i64
  %77 = getelementptr inbounds [501 x i32], ptr @g, i64 0, i64 %76
  store i32 %74, ptr %77, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %78

78:                                               ; preds = %59
  %79 = load i32, ptr %5, align 4, !tbaa !5
  %80 = add nsw i32 %79, 1
  store i32 %80, ptr %5, align 4, !tbaa !5
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %6, align 4, !tbaa !5
  br label %54, !llvm.loop !12

83:                                               ; preds = %58
  br label %84

84:                                               ; preds = %83
  %85 = load i32, ptr %3, align 4, !tbaa !5
  %86 = add nsw i32 %85, 1
  store i32 %86, ptr %3, align 4, !tbaa !5
  br label %41, !llvm.loop !13

87:                                               ; preds = %45
  %88 = load i32, ptr @tot, align 4, !tbaa !5
  %89 = sext i32 %88 to i64
  %90 = getelementptr inbounds [501 x i32], ptr @g, i64 0, i64 %89
  store i32 0, ptr %90, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %91 = load i32, ptr @q, align 4, !tbaa !5
  store i32 %91, ptr %8, align 4, !tbaa !5
  br label %92

92:                                               ; preds = %138, %87
  %93 = load i32, ptr %8, align 4, !tbaa !5
  %94 = icmp sge i32 %93, 0
  br i1 %94, label %96, label %95

95:                                               ; preds = %92
  store i32 13, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %141

96:                                               ; preds = %92
  %97 = load i32, ptr @g, align 16, !tbaa !5
  %98 = load i32, ptr %8, align 4, !tbaa !5
  %99 = sext i32 %98 to i64
  %100 = getelementptr inbounds [501 x i32], ptr @f, i64 0, i64 %99
  %101 = load i32, ptr %100, align 4, !tbaa !5
  %102 = add nsw i32 %101, %97
  store i32 %102, ptr %100, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 1, ptr %9, align 4, !tbaa !5
  br label %103

103:                                              ; preds = %134, %96
  %104 = load i32, ptr %9, align 4, !tbaa !5
  %105 = load i32, ptr @tot, align 4, !tbaa !5
  %106 = icmp sle i32 %104, %105
  br i1 %106, label %107, label %111

107:                                              ; preds = %103
  %108 = load i32, ptr %9, align 4, !tbaa !5
  %109 = load i32, ptr %8, align 4, !tbaa !5
  %110 = icmp sle i32 %108, %109
  br label %111

111:                                              ; preds = %107, %103
  %112 = phi i1 [ false, %103 ], [ %110, %107 ]
  br i1 %112, label %114, label %113

113:                                              ; preds = %111
  store i32 16, ptr %4, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %137

114:                                              ; preds = %111
  %115 = load i32, ptr %8, align 4, !tbaa !5
  %116 = sext i32 %115 to i64
  %117 = getelementptr inbounds [501 x i32], ptr @f, i64 0, i64 %116
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %118 = load i32, ptr %8, align 4, !tbaa !5
  %119 = load i32, ptr %9, align 4, !tbaa !5
  %120 = sub nsw i32 %118, %119
  %121 = sext i32 %120 to i64
  %122 = getelementptr inbounds [501 x i32], ptr @f, i64 0, i64 %121
  %123 = load i32, ptr %122, align 4, !tbaa !5
  %124 = load i32, ptr %9, align 4, !tbaa !5
  %125 = sext i32 %124 to i64
  %126 = getelementptr inbounds [501 x i32], ptr @g, i64 0, i64 %125
  %127 = load i32, ptr %126, align 4, !tbaa !5
  %128 = add nsw i32 %123, %127
  store i32 %128, ptr %10, align 4, !tbaa !5
  %129 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %117, ptr noundef nonnull align 4 dereferenceable(4) %10)
  %130 = load i32, ptr %129, align 4, !tbaa !5
  %131 = load i32, ptr %8, align 4, !tbaa !5
  %132 = sext i32 %131 to i64
  %133 = getelementptr inbounds [501 x i32], ptr @f, i64 0, i64 %132
  store i32 %130, ptr %133, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %134

134:                                              ; preds = %114
  %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 %103, !llvm.loop !14

137:                                              ; preds = %113
  br label %138

138:                                              ; preds = %137
  %139 = load i32, ptr %8, align 4, !tbaa !5
  %140 = add nsw i32 %139, -1
  store i32 %140, ptr %8, align 4, !tbaa !5
  br label %92, !llvm.loop !15

141:                                              ; preds = %95
  br label %12, !llvm.loop !16

142:                                              ; preds = %12
  %143 = load i32, ptr @q, align 4, !tbaa !5
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [501 x i32], ptr @f, i64 0, i64 %144
  %146 = load i32, ptr %145, align 4, !tbaa !5
  %147 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %146)
  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

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

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 = { inlinehint mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}
!14 = distinct !{!14, !11}
!15 = distinct !{!15, !11}
!16 = distinct !{!16, !11}


; 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
@f = external dso_local global [501 x i32], align 16
@g = external dso_local global [501 x i32], align 16
@tot = external dso_local local_unnamed_addr global i32, align 4
@seq = external dso_local local_unnamed_addr global [501 x i32], align 16
@buf = external dso_local global [501 x i8], 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 [4 x i8], align 1

; Function Attrs: mustprogress 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
  %5 = add nsw i32 %4, -1
  store i32 %5, ptr @n, align 4, !tbaa !5
  %.not47 = icmp eq i32 %4, 0
  br i1 %.not47, label %._crit_edge50, label %.lr.ph49

.loopexit:                                        ; preds = %._crit_edge43, %._crit_edge39
  %6 = load i32, ptr @n, align 4, !tbaa !5
  %7 = add nsw i32 %6, -1
  store i32 %7, ptr @n, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge50, label %.lr.ph49, !llvm.loop !9

.lr.ph49:                                         ; preds = %0, %.loopexit
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @buf)
  store i32 0, ptr @tot, align 4, !tbaa !5
  %9 = load i32, ptr @m, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph.preheader, label %.preheader.._crit_edge39_crit_edge

.lr.ph.preheader:                                 ; preds = %.lr.ph49
  %wide.trip.count = zext nneg i32 %9 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %11 = icmp eq i32 %9, 1
  br i1 %11, label %.preheader.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 2147483646
  br label %.lr.ph

.preheader.unr-lcssa:                             ; preds = %40, %.lr.ph.preheader
  %.lcssa83.ph = phi i32 [ poison, %.lr.ph.preheader ], [ %41, %40 ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.1, %40 ]
  %.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %41, %40 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader.unr-lcssa
  %12 = getelementptr inbounds [501 x i8], ptr @buf, i64 0, i64 %indvars.iv.unr
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = icmp eq i8 %13, 49
  br i1 %14, label %15, label %.preheader

15:                                               ; preds = %.lr.ph.epil
  %16 = add nsw i32 %.unr, 1
  store i32 %16, ptr @tot, align 4, !tbaa !5
  %17 = sext i32 %.unr to i64
  %18 = getelementptr inbounds [501 x i32], ptr @seq, i64 0, i64 %17
  %19 = trunc nuw nsw i64 %indvars.iv.unr to i32
  store i32 %19, ptr %18, align 4, !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.lr.ph.epil, %15, %.preheader.unr-lcssa
  %.lcssa83 = phi i32 [ %.lcssa83.ph, %.preheader.unr-lcssa ], [ %.unr, %.lr.ph.epil ], [ %16, %15 ]
  %20 = icmp sgt i32 %.lcssa83, 0
  br i1 %20, label %.lr.ph38, label %.preheader.._crit_edge39_crit_edge

.preheader.._crit_edge39_crit_edge:               ; preds = %.lr.ph49, %.preheader
  %21 = phi i32 [ %.lcssa83, %.preheader ], [ 0, %.lr.ph49 ]
  %.pre71 = sext i32 %21 to i64
  br label %._crit_edge39

.lr.ph:                                           ; preds = %40, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %40 ]
  %22 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %41, %40 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %40 ]
  %23 = getelementptr inbounds [501 x i8], ptr @buf, i64 0, i64 %indvars.iv
  %24 = load i8, ptr %23, align 2, !tbaa !11
  %25 = icmp eq i8 %24, 49
  br i1 %25, label %26, label %.lr.ph.1

26:                                               ; preds = %.lr.ph
  %27 = add nsw i32 %22, 1
  store i32 %27, ptr @tot, align 4, !tbaa !5
  %28 = sext i32 %22 to i64
  %29 = getelementptr inbounds [501 x i32], ptr @seq, i64 0, i64 %28
  %30 = trunc nuw nsw i64 %indvars.iv to i32
  store i32 %30, ptr %29, align 4, !tbaa !5
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %.lr.ph, %26
  %31 = phi i32 [ %22, %.lr.ph ], [ %27, %26 ]
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %32 = getelementptr inbounds [501 x i8], ptr @buf, i64 0, i64 %indvars.iv.next
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = icmp eq i8 %33, 49
  br i1 %34, label %35, label %40

35:                                               ; preds = %.lr.ph.1
  %36 = add nsw i32 %31, 1
  store i32 %36, ptr @tot, align 4, !tbaa !5
  %37 = sext i32 %31 to i64
  %38 = getelementptr inbounds [501 x i32], ptr @seq, i64 0, i64 %37
  %39 = trunc nuw nsw i64 %indvars.iv.next to i32
  store i32 %39, ptr %38, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %35, %.lr.ph.1
  %41 = phi i32 [ %31, %.lr.ph.1 ], [ %36, %35 ]
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 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.unr-lcssa, label %.lr.ph, !llvm.loop !12

._crit_edge39:                                    ; preds = %._crit_edge, %.preheader.._crit_edge39_crit_edge
  %.pre-phi72 = phi i64 [ %.pre71, %.preheader.._crit_edge39_crit_edge ], [ %.pre-phi, %._crit_edge ]
  %.lcssa = phi i32 [ %21, %.preheader.._crit_edge39_crit_edge ], [ %54, %._crit_edge ]
  %42 = getelementptr inbounds [501 x i32], ptr @g, i64 0, i64 %.pre-phi72
  store i32 0, ptr %42, align 4, !tbaa !5
  %43 = load i32, ptr @q, align 4, !tbaa !5
  %44 = icmp sgt i32 %43, -1
  br i1 %44, label %.lr.ph46.preheader, label %.loopexit

.lr.ph46.preheader:                               ; preds = %._crit_edge39
  %45 = zext nneg i32 %43 to i64
  br label %.lr.ph46

.lr.ph38:                                         ; preds = %.preheader, %._crit_edge
  %46 = phi i32 [ %54, %._crit_edge ], [ %.lcssa83, %.preheader ]
  %indvars.iv62 = phi i64 [ %indvars.iv.next63, %._crit_edge ], [ 0, %.preheader ]
  %indvars.iv53 = phi i32 [ %indvars.iv.next54, %._crit_edge ], [ -1, %.preheader ]
  %47 = getelementptr inbounds [501 x i32], ptr @g, i64 0, i64 %indvars.iv62
  store i32 1061109567, ptr %47, align 4, !tbaa !5
  %48 = trunc nuw nsw i64 %indvars.iv62 to i32
  %49 = xor i32 %48, -1
  %50 = add i32 %46, %49
  %51 = icmp slt i32 %50, %46
  br i1 %51, label %.lr.ph36.preheader, label %.lr.ph38.._crit_edge_crit_edge

.lr.ph38.._crit_edge_crit_edge:                   ; preds = %.lr.ph38
  %.pre = sext i32 %46 to i64
  br label %._crit_edge

.lr.ph36.preheader:                               ; preds = %.lr.ph38
  %52 = add i32 %46, %indvars.iv53
  %53 = sext i32 %52 to i64
  br label %.lr.ph36

._crit_edge:                                      ; preds = %.lr.ph36, %.lr.ph38.._crit_edge_crit_edge
  %.pre-phi = phi i64 [ %.pre, %.lr.ph38.._crit_edge_crit_edge ], [ %65, %.lr.ph36 ]
  %54 = phi i32 [ %46, %.lr.ph38.._crit_edge_crit_edge ], [ %64, %.lr.ph36 ]
  %indvars.iv.next63 = add nuw nsw i64 %indvars.iv62, 1
  %55 = icmp slt i64 %indvars.iv.next63, %.pre-phi
  %indvars.iv.next54 = add nsw i32 %indvars.iv53, -1
  br i1 %55, label %.lr.ph38, label %._crit_edge39, !llvm.loop !13

.lr.ph36:                                         ; preds = %.lr.ph36.preheader, %.lr.ph36
  %indvars.iv57 = phi i64 [ 0, %.lr.ph36.preheader ], [ %indvars.iv.next58, %.lr.ph36 ]
  %indvars.iv55 = phi i64 [ %53, %.lr.ph36.preheader ], [ %indvars.iv.next56, %.lr.ph36 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %56 = getelementptr inbounds [501 x i32], ptr @seq, i64 0, i64 %indvars.iv55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = getelementptr inbounds [501 x i32], ptr @seq, i64 0, i64 %indvars.iv57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = add i32 %57, 1
  %61 = sub i32 %60, %59
  store i32 %61, ptr %1, align 4, !tbaa !5
  %62 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %47, ptr noundef nonnull align 4 dereferenceable(4) %1)
  %63 = load i32, ptr %62, align 4, !tbaa !5
  store i32 %63, ptr %47, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %indvars.iv.next58 = add nuw nsw i64 %indvars.iv57, 1
  %indvars.iv.next56 = add nsw i64 %indvars.iv55, 1
  %64 = load i32, ptr @tot, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = icmp slt i64 %indvars.iv.next56, %65
  br i1 %66, label %.lr.ph36, label %._crit_edge, !llvm.loop !14

.lr.ph46:                                         ; preds = %.lr.ph46.preheader, %._crit_edge43
  %67 = phi i32 [ %.lcssa, %.lr.ph46.preheader ], [ %75, %._crit_edge43 ]
  %indvars.iv68 = phi i64 [ %45, %.lr.ph46.preheader ], [ %indvars.iv.next69, %._crit_edge43 ]
  %68 = load i32, ptr @g, align 16, !tbaa !5
  %69 = getelementptr inbounds [501 x i32], ptr @f, i64 0, i64 %indvars.iv68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = add nsw i32 %70, %68
  store i32 %71, ptr %69, align 4, !tbaa !5
  %72 = icmp sgt i32 %67, 0
  %73 = icmp ne i64 %indvars.iv68, 0
  %74 = and i1 %73, %72
  br i1 %74, label %.lr.ph42, label %._crit_edge43

._crit_edge43:                                    ; preds = %.lr.ph42, %.lr.ph46
  %75 = phi i32 [ %67, %.lr.ph46 ], [ %84, %.lr.ph42 ]
  %indvars.iv.next69 = add nsw i64 %indvars.iv68, -1
  br i1 %73, label %.lr.ph46, label %.loopexit, !llvm.loop !15

.lr.ph42:                                         ; preds = %.lr.ph46, %.lr.ph42
  %indvars.iv65 = phi i64 [ %indvars.iv.next66, %.lr.ph42 ], [ 1, %.lr.ph46 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %76 = sub nsw i64 %indvars.iv68, %indvars.iv65
  %77 = getelementptr inbounds [501 x i32], ptr @f, i64 0, i64 %76
  %78 = load i32, ptr %77, align 4, !tbaa !5
  %79 = getelementptr inbounds [501 x i32], ptr @g, i64 0, i64 %indvars.iv65
  %80 = load i32, ptr %79, align 4, !tbaa !5
  %81 = add nsw i32 %80, %78
  store i32 %81, ptr %2, align 4, !tbaa !5
  %82 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4) %69, ptr noundef nonnull align 4 dereferenceable(4) %2)
  %83 = load i32, ptr %82, align 4, !tbaa !5
  store i32 %83, ptr %69, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  %indvars.iv.next66 = add nuw nsw i64 %indvars.iv65, 1
  %84 = load i32, ptr @tot, align 4, !tbaa !5
  %85 = sext i32 %84 to i64
  %86 = icmp slt i64 %indvars.iv65, %85
  %87 = icmp slt i64 %indvars.iv65, %indvars.iv68
  %88 = and i1 %87, %86
  br i1 %88, label %.lr.ph42, label %._crit_edge43, !llvm.loop !16

._crit_edge50:                                    ; preds = %.loopexit, %0
  %89 = load i32, ptr @q, align 4, !tbaa !5
  %90 = sext i32 %89 to i64
  %91 = getelementptr inbounds [501 x i32], ptr @f, i64 0, i64 %90
  %92 = load i32, ptr %91, align 4, !tbaa !5
  %93 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %92)
  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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3minIiERKT_S2_S2_(ptr noundef nonnull align 4 dereferenceable(4), ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #3

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

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

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

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !10}
!15 = distinct !{!15, !10}
!16 = distinct !{!16, !10}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass