; LLVM IR from DionysiosB/CodeForces :: 0001-0099/49B-Sum.ll (Z5checklll)

; 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 @_Z5checklll(i64 noundef %0, i64 noundef %1, i64 noundef %2) #0 {
  %4 = alloca i1, align 1
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  store i64 %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !5
  store i64 %2, ptr %7, align 8, !tbaa !5
  br label %8

8:                                                ; preds = %17, %3
  %9 = load i64, ptr %5, align 8, !tbaa !5
  %10 = icmp sgt i64 %9, 0
  br i1 %10, label %11, label %20

11:                                               ; preds = %8
  %12 = load i64, ptr %5, align 8, !tbaa !5
  %13 = srem i64 %12, 10
  %14 = load i64, ptr %7, align 8, !tbaa !5
  %15 = icmp sge i64 %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  store i1 false, ptr %4, align 1
  br label %34

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

20:                                               ; preds = %8
  br label %21

21:                                               ; preds = %30, %20
  %22 = load i64, ptr %6, align 8, !tbaa !5
  %23 = icmp sgt i64 %22, 0
  br i1 %23, label %24, label %33

24:                                               ; preds = %21
  %25 = load i64, ptr %6, align 8, !tbaa !5
  %26 = srem i64 %25, 10
  %27 = load i64, ptr %7, align 8, !tbaa !5
  %28 = icmp sge i64 %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %24
  store i1 false, ptr %4, align 1
  br label %34

30:                                               ; preds = %24
  %31 = load i64, ptr %6, align 8, !tbaa !5
  %32 = sdiv i64 %31, 10
  store i64 %32, ptr %6, align 8, !tbaa !5
  br label %21, !llvm.loop !11

33:                                               ; preds = %21
  store i1 true, ptr %4, align 1
  br label %34

34:                                               ; preds = %33, %29, %16
  %35 = load i1, ptr %4, align 1
  ret i1 %35
}

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", !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 @_Z5checklll(i64 noundef %0, i64 noundef %1, i64 noundef %2) local_unnamed_addr #0 {
  %4 = icmp sgt i64 %0, 0
  br i1 %4, label %.lr.ph, label %.preheader

.preheader:                                       ; preds = %8, %3
  %5 = icmp sgt i64 %1, 0
  br i1 %5, label %.lr.ph14, label %.loopexit

.lr.ph:                                           ; preds = %3, %8
  %.0912 = phi i64 [ %7, %8 ], [ %0, %3 ]
  %6 = urem i64 %.0912, 10
  %7 = udiv i64 %.0912, 10
  %.not10 = icmp slt i64 %6, %2
  br i1 %.not10, label %8, label %.loopexit

8:                                                ; preds = %.lr.ph
  %.not17 = icmp ult i64 %.0912, 10
  br i1 %.not17, label %.preheader, label %.lr.ph, !llvm.loop !5

.lr.ph14:                                         ; preds = %.preheader, %.lr.ph14
  %.0813 = phi i64 [ %10, %.lr.ph14 ], [ %1, %.preheader ]
  %9 = urem i64 %.0813, 10
  %.not = icmp slt i64 %9, %2
  %10 = udiv i64 %.0813, 10
  %.not18 = icmp ugt i64 %.0813, 9
  %or.cond.not = and i1 %.not18, %.not
  br i1 %or.cond.not, label %.lr.ph14, label %.loopexit, !llvm.loop !7

.loopexit:                                        ; preds = %.lr.ph, %.lr.ph14, %.preheader
  %.0 = phi i1 [ true, %.preheader ], [ %.not, %.lr.ph14 ], [ false, %.lr.ph ]
  ret i1 %.0
}

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: CorrelatedValuePropagationPass,DivRemPairsPass,GlobalOptPass,IPSCCPPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass