; LLVM IR from upupming/algorithm :: CCCC-GPLT/L2-013. 红色警报  (main)

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

@e = external dso_local global [510 x [510 x i32]], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8countcntv() #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 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)
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %12

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

16:                                               ; preds = %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %34

17:                                               ; preds = %12
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2, ptr noundef %3)
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %20
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds [510 x i32], ptr %21, i64 0, i64 %23
  store i32 1, ptr %24, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %26
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [510 x i32], ptr %27, i64 0, i64 %29
  store i32 1, ptr %30, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %17
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %5, align 4, !tbaa !5
  br label %12, !llvm.loop !9

34:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %35 = call noundef i32 @_Z8countcntv()
  store i32 %35, ptr %6, align 4, !tbaa !5
  %36 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef @k)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %96, %34
  %38 = load i32, ptr %7, align 4, !tbaa !5
  %39 = load i32, ptr @k, align 4, !tbaa !5
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %42, label %41

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

42:                                               ; preds = %37
  %43 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %72, %42
  %45 = load i32, ptr %9, align 4, !tbaa !5
  %46 = load i32, ptr @n, align 4, !tbaa !5
  %47 = icmp slt i32 %45, %46
  br i1 %47, label %49, label %48

48:                                               ; preds = %44
  store i32 8, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %75

49:                                               ; preds = %44
  %50 = load i32, ptr %4, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %51
  %53 = load i32, ptr %9, align 4, !tbaa !5
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds [510 x i32], ptr %52, i64 0, i64 %54
  %56 = load i32, ptr %55, align 4, !tbaa !5
  %57 = icmp eq i32 %56, 1
  br i1 %57, label %58, label %71

58:                                               ; preds = %49
  %59 = load i32, ptr %4, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %60
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds [510 x i32], ptr %61, i64 0, i64 %63
  store i32 0, ptr %64, align 4, !tbaa !5
  %65 = load i32, ptr %9, align 4, !tbaa !5
  %66 = sext i32 %65 to i64
  %67 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %66
  %68 = load i32, ptr %4, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [510 x i32], ptr %67, i64 0, i64 %69
  store i32 0, ptr %70, align 4, !tbaa !5
  br label %71

71:                                               ; preds = %58, %49
  br label %72

72:                                               ; preds = %71
  %73 = load i32, ptr %9, align 4, !tbaa !5
  %74 = add nsw i32 %73, 1
  store i32 %74, ptr %9, align 4, !tbaa !5
  br label %44, !llvm.loop !11

75:                                               ; preds = %48
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %76 = call noundef i32 @_Z8countcntv()
  store i32 %76, ptr %10, align 4, !tbaa !5
  %77 = load i32, ptr %10, align 4, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = add nsw i32 %78, 1
  %80 = icmp sgt i32 %77, %79
  br i1 %80, label %81, label %84

81:                                               ; preds = %75
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %82)
  br label %87

84:                                               ; preds = %75
  %85 = load i32, ptr %4, align 4, !tbaa !5
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, i32 noundef %85)
  br label %87

87:                                               ; preds = %84, %81
  %88 = load i32, ptr %10, align 4, !tbaa !5
  store i32 %88, ptr %6, align 4, !tbaa !5
  %89 = load i32, ptr %7, align 4, !tbaa !5
  %90 = load i32, ptr @n, align 4, !tbaa !5
  %91 = sub nsw i32 %90, 1
  %92 = icmp eq i32 %89, %91
  br i1 %92, label %93, label %95

93:                                               ; preds = %87
  %94 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  br label %95

95:                                               ; preds = %93, %87
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  br label %96

96:                                               ; preds = %95
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %7, align 4, !tbaa !5
  br label %37, !llvm.loop !12

99:                                               ; preds = %41
  store i32 0, ptr %1, align 4
  store i32 1, ptr %8, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  %100 = load i32, ptr %1, align 4
  ret i32 %100
}

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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}


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

@e = external dso_local local_unnamed_addr global [510 x [510 x i32]], align 16
@n = external dso_local global i32, align 4
@m = external dso_local global i32, align 4
@k = external dso_local global i32, align 4
@.str = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [12 x i8], align 1

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z8countcntv() local_unnamed_addr #1

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

._crit_edge:                                      ; preds = %.lr.ph, %0
  %7 = call noundef i32 @_Z8countcntv()
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull @k)
  %9 = load i32, ptr @k, align 4, !tbaa !5
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph25, label %._crit_edge26

.lr.ph:                                           ; preds = %0, %.lr.ph
  %.01617 = phi i32 [ %18, %.lr.ph ], [ 0, %0 ]
  %11 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1, ptr noundef nonnull %2)
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = load i32, ptr %1, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %13, i64 %15
  store i32 1, ptr %16, align 4, !tbaa !5
  %17 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %15, i64 %13
  store i32 1, ptr %17, align 4, !tbaa !5
  %18 = add nuw nsw i32 %.01617, 1
  %19 = load i32, ptr @m, align 4, !tbaa !5
  %20 = icmp slt i32 %18, %19
  br i1 %20, label %.lr.ph, label %._crit_edge, !llvm.loop !9

._crit_edge26:                                    ; preds = %55, %._crit_edge
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 0

.lr.ph25:                                         ; preds = %._crit_edge, %55
  %.01423 = phi i32 [ %56, %55 ], [ 0, %._crit_edge ]
  %.01522 = phi i32 [ %32, %55 ], [ %7, %._crit_edge ]
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %22 = load i32, ptr @n, align 4, !tbaa !5
  %23 = icmp sgt i32 %22, 0
  br i1 %23, label %.lr.ph20, label %._crit_edge21

.lr.ph20:                                         ; preds = %.lr.ph25
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %wide.trip.count = zext nneg i32 %22 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %26 = icmp eq i32 %22, 1
  br i1 %26, label %._crit_edge21.loopexit.unr-lcssa, label %.lr.ph20.new

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

._crit_edge21.loopexit.unr-lcssa:                 ; preds = %52, %.lr.ph20
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph20 ], [ %indvars.iv.next.1, %52 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge21, label %.epil.preheader

.epil.preheader:                                  ; preds = %._crit_edge21.loopexit.unr-lcssa
  %27 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %25, i64 %indvars.iv.unr
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = icmp eq i32 %28, 1
  br i1 %29, label %30, label %._crit_edge21

30:                                               ; preds = %.epil.preheader
  store i32 0, ptr %27, align 4, !tbaa !5
  %31 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %indvars.iv.unr, i64 %25
  store i32 0, ptr %31, align 4, !tbaa !5
  br label %._crit_edge21

._crit_edge21:                                    ; preds = %._crit_edge21.loopexit.unr-lcssa, %30, %.epil.preheader, %.lr.ph25
  %32 = call noundef i32 @_Z8countcntv()
  %33 = add nsw i32 %.01522, 1
  %34 = icmp sgt i32 %32, %33
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %.str.2..str.3 = select i1 %34, ptr @.str.2, ptr @.str.3
  %36 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) %.str.2..str.3, i32 noundef %35)
  %37 = load i32, ptr @n, align 4, !tbaa !5
  %38 = add nsw i32 %37, -1
  %39 = icmp eq i32 %.01423, %38
  br i1 %39, label %53, label %55

40:                                               ; preds = %52, %.lr.ph20.new
  %indvars.iv = phi i64 [ 0, %.lr.ph20.new ], [ %indvars.iv.next.1, %52 ]
  %niter = phi i64 [ 0, %.lr.ph20.new ], [ %niter.next.1, %52 ]
  %41 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %25, i64 %indvars.iv
  %42 = load i32, ptr %41, align 8, !tbaa !5
  %43 = icmp eq i32 %42, 1
  br i1 %43, label %44, label %46

44:                                               ; preds = %40
  store i32 0, ptr %41, align 8, !tbaa !5
  %45 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %indvars.iv, i64 %25
  store i32 0, ptr %45, align 4, !tbaa !5
  br label %46

46:                                               ; preds = %40, %44
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %47 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %25, i64 %indvars.iv.next
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = icmp eq i32 %48, 1
  br i1 %49, label %50, label %52

50:                                               ; preds = %46
  store i32 0, ptr %47, align 4, !tbaa !5
  %51 = getelementptr inbounds [510 x [510 x i32]], ptr @e, i64 0, i64 %indvars.iv.next, i64 %25
  store i32 0, ptr %51, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %50, %46
  %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 %._crit_edge21.loopexit.unr-lcssa, label %40, !llvm.loop !11

53:                                               ; preds = %._crit_edge21
  %54 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %55

55:                                               ; preds = %53, %._crit_edge21
  %56 = add nuw nsw i32 %.01423, 1
  %57 = load i32, ptr @k, align 4, !tbaa !5
  %58 = icmp slt i32 %56, %57
  br i1 %58, label %.lr.ph25, label %._crit_edge26, !llvm.loop !12
}

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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" }
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 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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