; LLVM IR from lzyrapx/Competitive-Programming :: ACdream/1115（打表&数学推导）.ll (Z5checkx)

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z5checkx(i64 noundef %0) #0 {
  %2 = alloca i1, align 1
  %3 = alloca i64, align 8
  store i64 %0, ptr %3, align 8, !tbaa !5
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = add nsw i64 %4, 2
  store i64 %5, ptr %3, align 8, !tbaa !5
  br label %6

6:                                                ; preds = %10, %1
  %7 = load i64, ptr %3, align 8, !tbaa !5
  %8 = srem i64 %7, 3
  %9 = icmp eq i64 %8, 0
  br i1 %9, label %10, label %13

10:                                               ; preds = %6
  %11 = load i64, ptr %3, align 8, !tbaa !5
  %12 = sdiv i64 %11, 3
  store i64 %12, ptr %3, align 8, !tbaa !5
  br label %6, !llvm.loop !9

13:                                               ; preds = %6
  br label %14

14:                                               ; preds = %18, %13
  %15 = load i64, ptr %3, align 8, !tbaa !5
  %16 = srem i64 %15, 5
  %17 = icmp eq i64 %16, 0
  br i1 %17, label %18, label %21

18:                                               ; preds = %14
  %19 = load i64, ptr %3, align 8, !tbaa !5
  %20 = sdiv i64 %19, 5
  store i64 %20, ptr %3, align 8, !tbaa !5
  br label %14, !llvm.loop !11

21:                                               ; preds = %14
  %22 = load i64, ptr %3, align 8, !tbaa !5
  %23 = icmp eq i64 %22, 1
  br i1 %23, label %24, label %25

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

25:                                               ; preds = %21
  store i1 false, ptr %2, align 1
  br label %26

26:                                               ; preds = %25, %24
  %27 = load i1, ptr %2, align 1
  ret i1 %27
}

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

!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 = !{!"long long", !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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef zeroext i1 @_Z5checkx(i64 noundef %0) local_unnamed_addr #0 {
  %2 = add nsw i64 %0, 2
  %3 = srem i64 %2, 3
  %4 = icmp eq i64 %3, 0
  br i1 %4, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %.lr.ph, %1
  %.0.lcssa = phi i64 [ %2, %1 ], [ %7, %.lr.ph ]
  %5 = srem i64 %.0.lcssa, 5
  %6 = icmp eq i64 %5, 0
  br i1 %6, label %.lr.ph9, label %._crit_edge

.lr.ph:                                           ; preds = %1, %.lr.ph
  %.07 = phi i64 [ %7, %.lr.ph ], [ %2, %1 ]
  %7 = sdiv i64 %.07, 3
  %8 = srem i64 %7, 3
  %9 = icmp eq i64 %8, 0
  br i1 %9, label %.lr.ph, label %.preheader, !llvm.loop !5

.lr.ph9:                                          ; preds = %.preheader, %.lr.ph9
  %.18 = phi i64 [ %10, %.lr.ph9 ], [ %.0.lcssa, %.preheader ]
  %10 = sdiv i64 %.18, 5
  %11 = srem i64 %10, 5
  %12 = icmp eq i64 %11, 0
  br i1 %12, label %.lr.ph9, label %._crit_edge, !llvm.loop !7

._crit_edge:                                      ; preds = %.lr.ph9, %.preheader
  %.1.lcssa = phi i64 [ %.0.lcssa, %.preheader ], [ %10, %.lr.ph9 ]
  %13 = icmp eq i64 %.1.lcssa, 1
  ret i1 %13
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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)"}
!5 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = distinct !{!7, !6}


; Effective O3 passes: GVNPass,GlobalOptPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass