; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/1993.ll (Z4Find5state)

; 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.state = type { [4 x %class.face], %class.face }
%class.face = type { i8, i32 }

@P = external dso_local global [6 x %class.state], align 16

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

7:                                                ; preds = %29, %1
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = icmp slt i32 %8, 6
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  store i32 2, ptr %4, align 4
  br label %32

11:                                               ; preds = %7
  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 = %23, %11
  %13 = load i32, ptr %5, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 4
  br i1 %14, label %16, label %15

15:                                               ; preds = %12
  store i32 5, ptr %4, align 4
  br label %26

16:                                               ; preds = %12
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %17 = load i32, ptr %3, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [6 x %class.state], ptr @P, i64 0, i64 %18
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %6, ptr align 8 %0, i64 40, i1 false), !tbaa.struct !9
  %20 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) %19, ptr noundef byval(%class.state) align 8 %6)
  br i1 %20, label %21, label %22

21:                                               ; preds = %16
  store i1 true, ptr %2, align 1
  store i32 1, ptr %4, align 4
  br label %26

22:                                               ; preds = %16
  br label %23

23:                                               ; preds = %22
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = add nsw i32 %24, 1
  store i32 %25, ptr %5, align 4, !tbaa !5
  br label %12, !llvm.loop !11

26:                                               ; preds = %21, %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  %27 = load i32, ptr %4, align 4
  switch i32 %27, label %32 [
    i32 5, label %28
  ]

28:                                               ; preds = %26
  br label %29

29:                                               ; preds = %28
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %3, align 4, !tbaa !5
  br label %7, !llvm.loop !13

32:                                               ; preds = %26, %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  %33 = load i32, ptr %4, align 4
  switch i32 %33, label %37 [
    i32 2, label %34
    i32 1, label %35
  ]

34:                                               ; preds = %32
  store i1 false, ptr %2, align 1
  br label %35

35:                                               ; preds = %34, %32
  %36 = load i1, ptr %2, align 1
  ret i1 %36

37:                                               ; preds = %32
  unreachable
}

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40)) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40), ptr noundef byval(%class.state) align 8) #2 align 2

; 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

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

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{i64 0, i64 32, !10, i64 32, i64 1, !10, i64 36, i64 4, !5}
!10 = !{!7, !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}


; 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.state = type { [4 x %class.face], %class.face }
%class.face = type { i8, i32 }

@P = external dso_local global [6 x %class.state], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_Z4Find5state(ptr noundef nonnull byval(%class.state) align 8 %0) local_unnamed_addr #0 {
.preheader:
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %1 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) @P, ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %1, label %.loopexit.loopexit, label %2

2:                                                ; preds = %.preheader
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %3 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) @P, ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %3, label %.loopexit.loopexit, label %4

4:                                                ; preds = %2
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %5 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) @P, ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %5, label %.loopexit.loopexit, label %6

6:                                                ; preds = %4
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %7 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) @P, ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %7, label %.loopexit.loopexit, label %.preheader.1

.preheader.1:                                     ; preds = %6
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %8 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 40), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %8, label %.loopexit.loopexit, label %9

9:                                                ; preds = %.preheader.1
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %10 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 40), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %10, label %.loopexit.loopexit, label %11

11:                                               ; preds = %9
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %12 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 40), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %12, label %.loopexit.loopexit, label %13

13:                                               ; preds = %11
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %14 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 40), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %14, label %.loopexit.loopexit, label %.preheader.2

.preheader.2:                                     ; preds = %13
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %15 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 80), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %15, label %.loopexit.loopexit, label %16

16:                                               ; preds = %.preheader.2
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %17 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 80), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %17, label %.loopexit.loopexit, label %18

18:                                               ; preds = %16
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %19 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 80), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %19, label %.loopexit.loopexit, label %20

20:                                               ; preds = %18
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %21 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 80), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %21, label %.loopexit.loopexit, label %.preheader.3

.preheader.3:                                     ; preds = %20
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %22 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 120), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %22, label %.loopexit.loopexit, label %23

23:                                               ; preds = %.preheader.3
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %24 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 120), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %24, label %.loopexit.loopexit, label %25

25:                                               ; preds = %23
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %26 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 120), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %26, label %.loopexit.loopexit, label %27

27:                                               ; preds = %25
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %28 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 120), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %28, label %.loopexit.loopexit, label %.preheader.4

.preheader.4:                                     ; preds = %27
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %29 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 160), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %29, label %.loopexit.loopexit, label %30

30:                                               ; preds = %.preheader.4
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %31 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 160), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %31, label %.loopexit.loopexit, label %32

32:                                               ; preds = %30
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %33 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 160), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %33, label %.loopexit.loopexit, label %34

34:                                               ; preds = %32
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %35 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 160), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %35, label %.loopexit.loopexit, label %.preheader.5

.preheader.5:                                     ; preds = %34
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %36 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 200), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %36, label %.loopexit.loopexit, label %37

37:                                               ; preds = %.preheader.5
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %38 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 200), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %38, label %.loopexit.loopexit, label %39

39:                                               ; preds = %37
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %40 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 200), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %40, label %.loopexit.loopexit, label %41

41:                                               ; preds = %39
  call void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40) %0)
  %42 = call noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40) getelementptr inbounds (i8, ptr @P, i64 200), ptr noundef nonnull byval(%class.state) align 8 %0)
  br i1 %42, label %.loopexit.loopexit, label %.loopexit

.loopexit.loopexit:                               ; preds = %41, %39, %37, %.preheader.5, %34, %32, %30, %.preheader.4, %27, %25, %23, %.preheader.3, %20, %18, %16, %.preheader.2, %13, %11, %9, %.preheader.1, %6, %4, %2, %.preheader
  br label %.loopexit

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN5state6rotateEv(ptr noundef nonnull align 4 dereferenceable(40)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN5state7CompareES_(ptr noundef nonnull align 4 dereferenceable(40), ptr noundef byval(%class.state) align 8) local_unnamed_addr #1 align 2

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

!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,DSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass