; LLVM IR from DionysiosB/CodeForces :: 0200-0299/244B-UndoubtedlyLuckyNumbers.ll (Z3dfsllRl)

; 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 uwtable
declare dso_local noundef zeroext i1 @_Z5luckyl(i64 noundef) #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
define dso_local void @_Z3dfsllRl(i64 noundef %0, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2) #0 {
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  %8 = load i64, ptr %4, align 8, !tbaa !5
  %9 = load i64, ptr %5, align 8, !tbaa !5
  %10 = icmp sgt i64 %8, %9
  br i1 %10, label %14, label %11

11:                                               ; preds = %3
  %12 = load i64, ptr %4, align 8, !tbaa !5
  %13 = call noundef zeroext i1 @_Z5luckyl(i64 noundef %12)
  br i1 %13, label %15, label %14

14:                                               ; preds = %11, %3
  br label %42

15:                                               ; preds = %11
  %16 = load ptr, ptr %6, align 8, !tbaa !9
  %17 = load i64, ptr %16, align 8, !tbaa !5
  %18 = add nsw i64 %17, 1
  store i64 %18, ptr %16, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !11
  br label %19

19:                                               ; preds = %38, %15
  %20 = load i32, ptr %7, align 4, !tbaa !11
  %21 = icmp sle i32 %20, 9
  br i1 %21, label %23, label %22

22:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %41

23:                                               ; preds = %19
  %24 = load i64, ptr %4, align 8, !tbaa !5
  %25 = icmp eq i64 %24, 0
  br i1 %25, label %26, label %30

26:                                               ; preds = %23
  %27 = load i32, ptr %7, align 4, !tbaa !11
  %28 = icmp eq i32 %27, 0
  br i1 %28, label %29, label %30

29:                                               ; preds = %26
  br label %38

30:                                               ; preds = %26, %23
  %31 = load i64, ptr %4, align 8, !tbaa !5
  %32 = mul nsw i64 10, %31
  %33 = load i32, ptr %7, align 4, !tbaa !11
  %34 = sext i32 %33 to i64
  %35 = add nsw i64 %32, %34
  %36 = load i64, ptr %5, align 8, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !9
  call void @_Z3dfsllRl(i64 noundef %35, i64 noundef %36, ptr noundef nonnull align 8 dereferenceable(8) %37)
  br label %38

38:                                               ; preds = %30, %29
  %39 = load i32, ptr %7, align 4, !tbaa !11
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %7, align 4, !tbaa !11
  br label %19, !llvm.loop !13

41:                                               ; preds = %22
  br label %42

42:                                               ; preds = %41, %14
  ret void
}

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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"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"

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_Z5luckyl(i64 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local void @_Z3dfsllRl(i64 noundef %0, i64 noundef %1, ptr nocapture noundef nonnull align 8 dereferenceable(8) %2) local_unnamed_addr #0 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %.loopexit.sink.split, %3
  %.tr = phi i64 [ %0, %3 ], [ %.sink, %.loopexit.sink.split ]
  %4 = icmp sgt i64 %.tr, %1
  br i1 %4, label %.loopexit, label %5

5:                                                ; preds = %tailrecurse
  %6 = tail call noundef zeroext i1 @_Z5luckyl(i64 noundef %.tr)
  br i1 %6, label %7, label %.loopexit

7:                                                ; preds = %5
  %8 = load i64, ptr %2, align 8, !tbaa !5
  %9 = add nsw i64 %8, 1
  store i64 %9, ptr %2, align 8, !tbaa !5
  %10 = icmp eq i64 %.tr, 0
  br i1 %10, label %.loopexit.loopexit, label %.split.us.preheader

.split.us.preheader:                              ; preds = %7
  %11 = mul nsw i64 %.tr, 10
  tail call void @_Z3dfsllRl(i64 noundef %11, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %12 = or disjoint i64 %11, 1
  tail call void @_Z3dfsllRl(i64 noundef %12, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %13 = add nsw i64 %11, 2
  tail call void @_Z3dfsllRl(i64 noundef %13, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %14 = add nsw i64 %11, 3
  tail call void @_Z3dfsllRl(i64 noundef %14, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %15 = add nsw i64 %11, 4
  tail call void @_Z3dfsllRl(i64 noundef %15, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %16 = add nsw i64 %11, 5
  tail call void @_Z3dfsllRl(i64 noundef %16, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %17 = add nsw i64 %11, 6
  tail call void @_Z3dfsllRl(i64 noundef %17, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %18 = add nsw i64 %11, 7
  tail call void @_Z3dfsllRl(i64 noundef %18, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %19 = add nsw i64 %11, 8
  tail call void @_Z3dfsllRl(i64 noundef %19, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  %20 = add nsw i64 %11, 9
  br label %.loopexit.sink.split

.loopexit.loopexit:                               ; preds = %7
  tail call void @_Z3dfsllRl(i64 noundef 1, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  tail call void @_Z3dfsllRl(i64 noundef 2, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  tail call void @_Z3dfsllRl(i64 noundef 3, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  tail call void @_Z3dfsllRl(i64 noundef 4, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  tail call void @_Z3dfsllRl(i64 noundef 5, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  tail call void @_Z3dfsllRl(i64 noundef 6, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  tail call void @_Z3dfsllRl(i64 noundef 7, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  tail call void @_Z3dfsllRl(i64 noundef 8, i64 noundef %1, ptr noundef nonnull align 8 dereferenceable(8) %2)
  br label %.loopexit.sink.split

.loopexit.sink.split:                             ; preds = %.loopexit.loopexit, %.split.us.preheader
  %.sink = phi i64 [ %20, %.split.us.preheader ], [ 9, %.loopexit.loopexit ]
  br label %tailrecurse

.loopexit:                                        ; preds = %tailrecurse, %5
  ret void
}

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

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


; Effective O3 passes: GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass