; LLVM IR from upupming/algorithm :: acwing/算法竞赛进阶指南/0x29-总结与练习/194. 涂满它！.ll (Z7idaStarii)

; 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 i32, align 4
@v = external dso_local global [10 x [10 x i32]], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z9cntColorsv() #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4filli(i32 noundef) #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z7idaStarii(i32 noundef %0, i32 noundef %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [10 x [10 x i32]], align 16
  %9 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %10 = call noundef i32 @_Z9cntColorsv()
  store i32 %10, ptr %6, align 4, !tbaa !5
  %11 = load i32, ptr %4, align 4, !tbaa !5
  %12 = load i32, ptr @e, align 4, !tbaa !5
  %13 = icmp eq i32 %11, %12
  br i1 %13, label %14, label %17

14:                                               ; preds = %2
  %15 = load i32, ptr %6, align 4, !tbaa !5
  %16 = icmp eq i32 %15, 0
  store i1 %16, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %54

17:                                               ; preds = %2
  %18 = load i32, ptr %4, align 4, !tbaa !5
  %19 = load i32, ptr %6, align 4, !tbaa !5
  %20 = add nsw i32 %18, %19
  %21 = load i32, ptr @e, align 4, !tbaa !5
  %22 = icmp sgt i32 %20, %21
  br i1 %22, label %23, label %24

23:                                               ; preds = %17
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %54

24:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 400, ptr %8) #4
  %25 = getelementptr inbounds [10 x [10 x i32]], ptr %8, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %25, ptr align 16 @v, i64 400, i1 false)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  store i32 0, ptr %9, align 4, !tbaa !5
  br label %26

26:                                               ; preds = %47, %24
  %27 = load i32, ptr %9, align 4, !tbaa !5
  %28 = icmp slt i32 %27, 6
  br i1 %28, label %30, label %29

29:                                               ; preds = %26
  store i32 2, ptr %7, align 4
  br label %50

30:                                               ; preds = %26
  %31 = load i32, ptr %9, align 4, !tbaa !5
  %32 = load i32, ptr %5, align 4, !tbaa !5
  %33 = icmp eq i32 %31, %32
  br i1 %33, label %34, label %35

34:                                               ; preds = %30
  br label %47

35:                                               ; preds = %30
  %36 = load i32, ptr %9, align 4, !tbaa !5
  %37 = call noundef i32 @_Z4filli(i32 noundef %36)
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %45

39:                                               ; preds = %35
  %40 = load i32, ptr %4, align 4, !tbaa !5
  %41 = add nsw i32 %40, 1
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = call noundef zeroext i1 @_Z7idaStarii(i32 noundef %41, i32 noundef %42)
  br i1 %43, label %44, label %45

44:                                               ; preds = %39
  store i1 true, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %50

45:                                               ; preds = %39, %35
  %46 = getelementptr inbounds [10 x [10 x i32]], ptr %8, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 @v, ptr align 16 %46, i64 400, i1 false)
  br label %47

47:                                               ; preds = %45, %34
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %9, align 4, !tbaa !5
  br label %26, !llvm.loop !9

50:                                               ; preds = %44, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  %51 = load i32, ptr %7, align 4
  switch i32 %51, label %53 [
    i32 2, label %52
  ]

52:                                               ; preds = %50
  store i1 false, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %53

53:                                               ; preds = %52, %50
  call void @llvm.lifetime.end.p0(i64 400, ptr %8) #4
  br label %54

54:                                               ; preds = %53, %23, %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %55 = load i1, ptr %3, align 1
  ret i1 %55
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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


; 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 i32, align 4
@v = external dso_local local_unnamed_addr global [10 x [10 x i32]], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z9cntColorsv() local_unnamed_addr #0

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

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

; Function Attrs: mustprogress uwtable
declare dso_local noundef i32 @_Z4filli(i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z7idaStarii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = alloca [10 x [10 x i32]], align 16
  %4 = tail call noundef i32 @_Z9cntColorsv()
  %5 = load i32, ptr @e, align 4, !tbaa !5
  %6 = icmp eq i32 %5, %0
  br i1 %6, label %7, label %9

7:                                                ; preds = %2
  %8 = icmp eq i32 %4, 0
  br label %45

9:                                                ; preds = %2
  %10 = add nsw i32 %4, %0
  %11 = icmp sgt i32 %10, %5
  br i1 %11, label %45, label %12

12:                                               ; preds = %9
  call void @llvm.lifetime.start.p0(i64 400, ptr nonnull %3)
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) %3, ptr noundef nonnull align 16 dereferenceable(400) @v, i64 400, i1 false)
  %13 = add nsw i32 %0, 1
  %14 = icmp eq i32 %1, 0
  br i1 %14, label %.thread, label %15

15:                                               ; preds = %12
  %16 = tail call noundef i32 @_Z4filli(i32 noundef 0)
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %19, label %17

17:                                               ; preds = %15
  %18 = tail call noundef zeroext i1 @_Z7idaStarii(i32 noundef %13, i32 noundef 0)
  br i1 %18, label %.critedge, label %19

19:                                               ; preds = %15, %17
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) @v, ptr noundef nonnull align 16 dereferenceable(400) %3, i64 400, i1 false)
  %20 = icmp eq i32 %1, 1
  br i1 %20, label %.thread18, label %.thread

.thread:                                          ; preds = %12, %19
  %21 = tail call noundef i32 @_Z4filli(i32 noundef 1)
  %.not.1 = icmp eq i32 %21, 0
  br i1 %.not.1, label %24, label %22

22:                                               ; preds = %.thread
  %23 = tail call noundef zeroext i1 @_Z7idaStarii(i32 noundef %13, i32 noundef 1)
  br i1 %23, label %.critedge, label %24

24:                                               ; preds = %.thread, %22
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) @v, ptr noundef nonnull align 16 dereferenceable(400) %3, i64 400, i1 false)
  %25 = icmp eq i32 %1, 2
  br i1 %25, label %.thread19, label %.thread18

.thread18:                                        ; preds = %19, %24
  %26 = tail call noundef i32 @_Z4filli(i32 noundef 2)
  %.not.2 = icmp eq i32 %26, 0
  br i1 %.not.2, label %29, label %27

27:                                               ; preds = %.thread18
  %28 = tail call noundef zeroext i1 @_Z7idaStarii(i32 noundef %13, i32 noundef 2)
  br i1 %28, label %.critedge, label %29

29:                                               ; preds = %.thread18, %27
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) @v, ptr noundef nonnull align 16 dereferenceable(400) %3, i64 400, i1 false)
  %30 = icmp eq i32 %1, 3
  br i1 %30, label %.thread20, label %.thread19

.thread19:                                        ; preds = %24, %29
  %31 = tail call noundef i32 @_Z4filli(i32 noundef 3)
  %.not.3 = icmp eq i32 %31, 0
  br i1 %.not.3, label %34, label %32

32:                                               ; preds = %.thread19
  %33 = tail call noundef zeroext i1 @_Z7idaStarii(i32 noundef %13, i32 noundef 3)
  br i1 %33, label %.critedge, label %34

34:                                               ; preds = %.thread19, %32
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) @v, ptr noundef nonnull align 16 dereferenceable(400) %3, i64 400, i1 false)
  %35 = icmp eq i32 %1, 4
  br i1 %35, label %.thread21, label %.thread20

.thread20:                                        ; preds = %29, %34
  %36 = tail call noundef i32 @_Z4filli(i32 noundef 4)
  %.not.4 = icmp eq i32 %36, 0
  br i1 %.not.4, label %39, label %37

37:                                               ; preds = %.thread20
  %38 = tail call noundef zeroext i1 @_Z7idaStarii(i32 noundef %13, i32 noundef 4)
  br i1 %38, label %.critedge, label %39

39:                                               ; preds = %.thread20, %37
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) @v, ptr noundef nonnull align 16 dereferenceable(400) %3, i64 400, i1 false)
  %40 = icmp eq i32 %1, 5
  br i1 %40, label %.critedge, label %.thread21

.thread21:                                        ; preds = %34, %39
  %41 = tail call noundef i32 @_Z4filli(i32 noundef 5)
  %.not.5 = icmp eq i32 %41, 0
  br i1 %.not.5, label %44, label %42

42:                                               ; preds = %.thread21
  %43 = tail call noundef zeroext i1 @_Z7idaStarii(i32 noundef %13, i32 noundef 5)
  br i1 %43, label %.critedge, label %44

44:                                               ; preds = %42, %.thread21
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(400) @v, ptr noundef nonnull align 16 dereferenceable(400) %3, i64 400, i1 false)
  br label %.critedge

.critedge:                                        ; preds = %39, %44, %42, %37, %32, %27, %22, %17
  %.lcssa = phi i1 [ true, %17 ], [ true, %22 ], [ true, %27 ], [ true, %32 ], [ true, %37 ], [ true, %42 ], [ false, %44 ], [ false, %39 ]
  call void @llvm.lifetime.end.p0(i64 400, ptr nonnull %3)
  br label %45

45:                                               ; preds = %9, %.critedge, %7
  %.2 = phi i1 [ %8, %7 ], [ %.lcssa, %.critedge ], [ false, %9 ]
  ret i1 %.2
}

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

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

!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"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,SROAPass,SimplifyCFGPass,TailCallElimPass