; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/6202（魔方大模拟）.ll (Z5checkv)

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

@a = external dso_local global [73 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5checkv() #0 {
  %1 = alloca i1, align 1
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #2
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %6

6:                                                ; preds = %43, %0
  %7 = load i32, ptr %2, align 4, !tbaa !5
  %8 = icmp slt i32 %7, 8
  br i1 %8, label %10, label %9

9:                                                ; preds = %6
  store i32 2, ptr %3, align 4
  br label %46

10:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %11 = load i32, ptr %2, align 4, !tbaa !5
  %12 = mul nsw i32 %11, 9
  %13 = add nsw i32 %12, 1
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [73 x i32], ptr @a, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !5
  store i32 %16, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  store i32 1, ptr %5, align 4, !tbaa !5
  br label %17

17:                                               ; preds = %34, %10
  %18 = load i32, ptr %5, align 4, !tbaa !5
  %19 = icmp slt i32 %18, 9
  br i1 %19, label %21, label %20

20:                                               ; preds = %17
  store i32 5, ptr %3, align 4
  br label %37

21:                                               ; preds = %17
  %22 = load i32, ptr %2, align 4, !tbaa !5
  %23 = mul nsw i32 %22, 9
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = add nsw i32 %23, %24
  %26 = add nsw i32 %25, 1
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [73 x i32], ptr @a, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = icmp ne i32 %29, %30
  br i1 %31, label %32, label %33

32:                                               ; preds = %21
  store i1 false, ptr %1, align 1
  store i32 1, ptr %3, align 4
  br label %37

33:                                               ; preds = %21
  br label %34

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

37:                                               ; preds = %32, %20
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  %38 = load i32, ptr %3, align 4
  switch i32 %38, label %40 [
    i32 5, label %39
  ]

39:                                               ; preds = %37
  store i32 0, ptr %3, align 4
  br label %40

40:                                               ; preds = %39, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %41 = load i32, ptr %3, align 4
  switch i32 %41, label %46 [
    i32 0, label %42
  ]

42:                                               ; preds = %40
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = add nsw i32 %44, 1
  store i32 %45, ptr %2, align 4, !tbaa !5
  br label %6, !llvm.loop !11

46:                                               ; preds = %40, %9
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #2
  %47 = load i32, ptr %3, align 4
  switch i32 %47, label %51 [
    i32 2, label %48
    i32 1, label %49
  ]

48:                                               ; preds = %46
  store i1 true, ptr %1, align 1
  br label %49

49:                                               ; preds = %48, %46
  %50 = load i1, ptr %1, align 1
  ret i1 %50

51:                                               ; preds = %46
  unreachable
}

; 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

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


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

@a = external dso_local local_unnamed_addr global [73 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) uwtable
define dso_local noundef zeroext i1 @_Z5checkv() local_unnamed_addr #0 {
  %1 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 4), align 4
  %2 = load <8 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 8), align 8
  %3 = shufflevector <4 x i32> %1, <4 x i32> poison, <8 x i32> zeroinitializer
  %4 = icmp eq <8 x i32> %2, %3
  %5 = freeze <8 x i1> %4
  %6 = bitcast <8 x i1> %5 to i8
  %7 = icmp eq i8 %6, -1
  br i1 %7, label %8, label %.loopexit.loopexit

8:                                                ; preds = %0
  %9 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 40), align 8
  %10 = load <8 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 44), align 4
  %11 = shufflevector <4 x i32> %9, <4 x i32> poison, <8 x i32> zeroinitializer
  %12 = icmp eq <8 x i32> %10, %11
  %13 = freeze <8 x i1> %12
  %14 = bitcast <8 x i1> %13 to i8
  %15 = icmp eq i8 %14, -1
  br i1 %15, label %16, label %.loopexit.loopexit

16:                                               ; preds = %8
  %17 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 76), align 4
  %18 = load <8 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 80), align 16
  %19 = shufflevector <4 x i32> %17, <4 x i32> poison, <8 x i32> zeroinitializer
  %20 = icmp eq <8 x i32> %18, %19
  %21 = freeze <8 x i1> %20
  %22 = bitcast <8 x i1> %21 to i8
  %23 = icmp eq i8 %22, -1
  br i1 %23, label %24, label %.loopexit.loopexit

24:                                               ; preds = %16
  %25 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 112), align 16
  %26 = load <8 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 116), align 4
  %27 = shufflevector <4 x i32> %25, <4 x i32> poison, <8 x i32> zeroinitializer
  %28 = icmp eq <8 x i32> %26, %27
  %29 = freeze <8 x i1> %28
  %30 = bitcast <8 x i1> %29 to i8
  %31 = icmp eq i8 %30, -1
  br i1 %31, label %32, label %.loopexit.loopexit

32:                                               ; preds = %24
  %33 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 148), align 4
  %34 = load <8 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 152), align 8
  %35 = shufflevector <4 x i32> %33, <4 x i32> poison, <8 x i32> zeroinitializer
  %36 = icmp eq <8 x i32> %34, %35
  %37 = freeze <8 x i1> %36
  %38 = bitcast <8 x i1> %37 to i8
  %39 = icmp eq i8 %38, -1
  br i1 %39, label %40, label %.loopexit.loopexit

40:                                               ; preds = %32
  %41 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 184), align 8
  %42 = load <8 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 188), align 4
  %43 = shufflevector <4 x i32> %41, <4 x i32> poison, <8 x i32> zeroinitializer
  %44 = icmp eq <8 x i32> %42, %43
  %45 = freeze <8 x i1> %44
  %46 = bitcast <8 x i1> %45 to i8
  %47 = icmp eq i8 %46, -1
  br i1 %47, label %48, label %.loopexit.loopexit

48:                                               ; preds = %40
  %49 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 220), align 4
  %50 = load <8 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 224), align 16
  %51 = shufflevector <4 x i32> %49, <4 x i32> poison, <8 x i32> zeroinitializer
  %52 = icmp eq <8 x i32> %50, %51
  %53 = freeze <8 x i1> %52
  %54 = bitcast <8 x i1> %53 to i8
  %55 = icmp eq i8 %54, -1
  br i1 %55, label %56, label %.loopexit.loopexit

56:                                               ; preds = %48
  %57 = load <4 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 256), align 16
  %58 = load <8 x i32>, ptr getelementptr inbounds (i8, ptr @a, i64 260), align 4
  %59 = shufflevector <4 x i32> %57, <4 x i32> poison, <8 x i32> zeroinitializer
  %60 = icmp eq <8 x i32> %58, %59
  %61 = freeze <8 x i1> %60
  %62 = bitcast <8 x i1> %61 to i8
  %63 = icmp eq i8 %62, -1
  br i1 %63, label %.loopexit, label %.loopexit.loopexit

.loopexit.loopexit:                               ; preds = %56, %48, %40, %32, %24, %16, %8, %0
  br label %.loopexit

.loopexit:                                        ; preds = %56, %.loopexit.loopexit
  %64 = phi i1 [ false, %.loopexit.loopexit ], [ true, %56 ]
  ret i1 %64
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: none, inaccessiblemem: none) 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" }

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalDCEPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,VectorCombinePass