; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ (5898（数位dp）)

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

@dig = external dso_local global [20 x i64], align 16
@dp = external dso_local global [21 x [2 x [21 x i64]]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3dfsxiiii(i64 noundef, i32 noundef, i32 noundef, i32 noundef, i32 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 norecurse uwtable
define dso_local noundef i32 @main() #2 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #5
  store i32 1, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %10 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str, ptr noundef %2)
  br label %11

11:                                               ; preds = %46, %0
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = add nsw i32 %12, -1
  store i32 %13, ptr %2, align 4, !tbaa !5
  %14 = icmp ne i32 %12, 0
  br i1 %14, label %15, label %55

15:                                               ; preds = %11
  call void @llvm.memset.p0.i64(ptr align 16 @dp, i8 -1, i64 7056, i1 false)
  call void @llvm.memset.p0.i64(ptr align 16 @dig, i8 0, i64 160, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  store i64 0, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  store i64 0, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store i64 0, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #5
  store i64 0, ptr %9, align 8, !tbaa !9
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4, ptr noundef %5)
  %17 = load i64, ptr %4, align 8, !tbaa !9
  %18 = add nsw i64 %17, -1
  store i64 %18, ptr %4, align 8, !tbaa !9
  store i64 0, ptr %8, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %28, %15
  %20 = load i64, ptr %4, align 8, !tbaa !9
  %21 = icmp ne i64 %20, 0
  br i1 %21, label %22, label %31

22:                                               ; preds = %19
  %23 = load i64, ptr %4, align 8, !tbaa !9
  %24 = srem i64 %23, 10
  %25 = load i64, ptr %8, align 8, !tbaa !9
  %26 = add nsw i64 %25, 1
  store i64 %26, ptr %8, align 8, !tbaa !9
  %27 = getelementptr inbounds [20 x i64], ptr @dig, i64 0, i64 %26
  store i64 %24, ptr %27, align 8, !tbaa !9
  br label %28

28:                                               ; preds = %22
  %29 = load i64, ptr %4, align 8, !tbaa !9
  %30 = sdiv i64 %29, 10
  store i64 %30, ptr %4, align 8, !tbaa !9
  br label %19, !llvm.loop !11

31:                                               ; preds = %19
  %32 = load i64, ptr %8, align 8, !tbaa !9
  %33 = call noundef i64 @_Z3dfsxiiii(i64 noundef %32, i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef 1)
  store i64 %33, ptr %6, align 8, !tbaa !9
  store i64 0, ptr %9, align 8, !tbaa !9
  br label %34

34:                                               ; preds = %43, %31
  %35 = load i64, ptr %5, align 8, !tbaa !9
  %36 = icmp ne i64 %35, 0
  br i1 %36, label %37, label %46

37:                                               ; preds = %34
  %38 = load i64, ptr %5, align 8, !tbaa !9
  %39 = srem i64 %38, 10
  %40 = load i64, ptr %9, align 8, !tbaa !9
  %41 = add nsw i64 %40, 1
  store i64 %41, ptr %9, align 8, !tbaa !9
  %42 = getelementptr inbounds [20 x i64], ptr @dig, i64 0, i64 %41
  store i64 %39, ptr %42, align 8, !tbaa !9
  br label %43

43:                                               ; preds = %37
  %44 = load i64, ptr %5, align 8, !tbaa !9
  %45 = sdiv i64 %44, 10
  store i64 %45, ptr %5, align 8, !tbaa !9
  br label %34, !llvm.loop !13

46:                                               ; preds = %34
  %47 = load i64, ptr %9, align 8, !tbaa !9
  %48 = call noundef i64 @_Z3dfsxiiii(i64 noundef %47, i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef 1)
  store i64 %48, ptr %7, align 8, !tbaa !9
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %3, align 4, !tbaa !5
  %51 = load i64, ptr %7, align 8, !tbaa !9
  %52 = load i64, ptr %6, align 8, !tbaa !9
  %53 = sub nsw i64 %51, %52
  %54 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %49, i64 noundef %53)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  br label %11, !llvm.loop !14

55:                                               ; preds = %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #5
  ret i32 0
}

declare i32 @__isoc99_scanf(ptr noundef, ...) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

declare i32 @printf(ptr noundef, ...) #3

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 norecurse 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 = { "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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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 = !{!10, !10, i64 0}
!10 = !{!"long long", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !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"

@dig = external dso_local local_unnamed_addr global [20 x i64], align 16
@dp = external dso_local local_unnamed_addr global [21 x [2 x [21 x i64]]], align 16
@.str = external hidden unnamed_addr constant [3 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: mustprogress uwtable
declare dso_local noundef i64 @_Z3dfsxiiii(i64 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

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

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

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main() local_unnamed_addr #2 {
  %1 = alloca i32, align 4
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %1)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = add nsw i32 %5, -1
  store i32 %6, ptr %1, align 4, !tbaa !5
  %.not23 = icmp eq i32 %5, 0
  br i1 %.not23, label %._crit_edge27, label %.lr.ph26

.lr.ph26:                                         ; preds = %0, %20
  %.0824 = phi i32 [ %22, %20 ], [ 1, %0 ]
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(7056) @dp, i8 -1, i64 7056, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(160) @dig, i8 0, i64 160, i1 false)
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2, ptr noundef nonnull %3)
  %8 = load i64, ptr %2, align 8, !tbaa !9
  %9 = add nsw i64 %8, -1
  %.not1113 = icmp eq i64 %9, 0
  br i1 %.not1113, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph26, %.lr.ph
  %.0715 = phi i64 [ %11, %.lr.ph ], [ 0, %.lr.ph26 ]
  %storemerge14 = phi i64 [ %13, %.lr.ph ], [ %9, %.lr.ph26 ]
  %10 = srem i64 %storemerge14, 10
  %11 = add nuw nsw i64 %.0715, 1
  %12 = getelementptr inbounds [20 x i64], ptr @dig, i64 0, i64 %11
  store i64 %10, ptr %12, align 8, !tbaa !9
  %13 = sdiv i64 %storemerge14, 10
  %storemerge14.off = add i64 %storemerge14, 9
  %.not11 = icmp ult i64 %storemerge14.off, 19
  br i1 %.not11, label %._crit_edge, label %.lr.ph, !llvm.loop !11

._crit_edge:                                      ; preds = %.lr.ph, %.lr.ph26
  %storemerge.lcssa = phi i64 [ 0, %.lr.ph26 ], [ %13, %.lr.ph ]
  %.07.lcssa = phi i64 [ 0, %.lr.ph26 ], [ %11, %.lr.ph ]
  store i64 %storemerge.lcssa, ptr %2, align 8, !tbaa !9
  %14 = call noundef i64 @_Z3dfsxiiii(i64 noundef %.07.lcssa, i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef 1)
  %.pr = load i64, ptr %3, align 8, !tbaa !9
  %.not1217 = icmp eq i64 %.pr, 0
  br i1 %.not1217, label %20, label %.lr.ph20

.lr.ph20:                                         ; preds = %._crit_edge, %.lr.ph20
  %.018 = phi i64 [ %17, %.lr.ph20 ], [ 0, %._crit_edge ]
  %15 = phi i64 [ %19, %.lr.ph20 ], [ %.pr, %._crit_edge ]
  %16 = srem i64 %15, 10
  %17 = add nuw nsw i64 %.018, 1
  %18 = getelementptr inbounds [20 x i64], ptr @dig, i64 0, i64 %17
  store i64 %16, ptr %18, align 8, !tbaa !9
  %19 = sdiv i64 %15, 10
  %.off = add i64 %15, 9
  %.not12 = icmp ult i64 %.off, 19
  br i1 %.not12, label %._crit_edge21, label %.lr.ph20, !llvm.loop !13

._crit_edge21:                                    ; preds = %.lr.ph20
  store i64 %19, ptr %3, align 8, !tbaa !9
  br label %20

20:                                               ; preds = %._crit_edge21, %._crit_edge
  %.0.lcssa = phi i64 [ %17, %._crit_edge21 ], [ 0, %._crit_edge ]
  %21 = call noundef i64 @_Z3dfsxiiii(i64 noundef %.0.lcssa, i32 noundef 0, i32 noundef 0, i32 noundef 1, i32 noundef 1)
  %22 = add nuw nsw i32 %.0824, 1
  %23 = sub nsw i64 %21, %14
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %.0824, i64 noundef %23)
  %25 = load i32, ptr %1, align 4, !tbaa !5
  %26 = add nsw i32 %25, -1
  store i32 %26, ptr %1, align 4, !tbaa !5
  %.not = icmp eq i32 %25, 0
  br i1 %.not, label %._crit_edge27, label %.lr.ph26, !llvm.loop !14

._crit_edge27:                                    ; preds = %20, %0
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #5
  ret i32 0
}

; Function Attrs: nofree nounwind
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

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


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