; LLVM IR from lzyrapx/Competitive-Programming :: hihocoder/1033(数位dp).ll (Z5solvexi)

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

%struct.node = type { i64, i64 }

@bits = external dso_local global [21 x i32], align 16

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_Z3dfsiibbi(i32 noundef, i32 noundef, i1 noundef zeroext, i1 noundef zeroext, 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 uwtable
define dso_local noundef i32 @_Z5solvexi(i64 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %struct.node, align 8
  store i64 %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %9 = load i64, ptr %4, align 8, !tbaa !5
  %10 = icmp sle i64 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  store i32 0, ptr %3, align 4
  br label %50

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %21, %12
  %14 = load i32, ptr %7, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 21
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %13
  %18 = load i32, ptr %7, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [21 x i32], ptr @bits, i64 0, i64 %19
  store i32 0, ptr %20, align 4, !tbaa !9
  br label %21

21:                                               ; preds = %17
  %22 = load i32, ptr %7, align 4, !tbaa !9
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr %7, align 4, !tbaa !9
  br label %13, !llvm.loop !11

24:                                               ; preds = %16
  br label %25

25:                                               ; preds = %28, %24
  %26 = load i64, ptr %4, align 8, !tbaa !5
  %27 = icmp ne i64 %26, 0
  br i1 %27, label %28, label %38

28:                                               ; preds = %25
  %29 = load i64, ptr %4, align 8, !tbaa !5
  %30 = srem i64 %29, 10
  %31 = trunc i64 %30 to i32
  %32 = load i32, ptr %6, align 4, !tbaa !9
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %6, align 4, !tbaa !9
  %34 = sext i32 %32 to i64
  %35 = getelementptr inbounds [21 x i32], ptr @bits, i64 0, i64 %34
  store i32 %31, ptr %35, align 4, !tbaa !9
  %36 = load i64, ptr %4, align 8, !tbaa !5
  %37 = sdiv i64 %36, 10
  store i64 %37, ptr %4, align 8, !tbaa !5
  br label %25, !llvm.loop !13

38:                                               ; preds = %25
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #2
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  %41 = load i32, ptr %5, align 4, !tbaa !9
  %42 = call { i64, i64 } @_Z3dfsiibbi(i32 noundef %40, i32 noundef 0, i1 noundef zeroext false, i1 noundef zeroext true, i32 noundef %41)
  %43 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 0
  %44 = extractvalue { i64, i64 } %42, 0
  store i64 %44, ptr %43, align 8
  %45 = getelementptr inbounds { i64, i64 }, ptr %8, i32 0, i32 1
  %46 = extractvalue { i64, i64 } %42, 1
  store i64 %46, ptr %45, align 8
  %47 = getelementptr inbounds %struct.node, ptr %8, i32 0, i32 0
  %48 = load i64, ptr %47, align 8, !tbaa !14
  %49 = trunc i64 %48 to i32
  store i32 %49, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  br label %50

50:                                               ; preds = %38, %11
  %51 = load i32, ptr %3, align 4
  ret i32 %51
}

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 long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = !{!15, !6, i64 0}
!15 = !{!"_ZTS4node", !6, i64 0, !6, i64 8}


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

@bits = external dso_local local_unnamed_addr global [21 x i32], align 16

; Function Attrs: mustprogress uwtable
declare dso_local { i64, i64 } @_Z3dfsiibbi(i32 noundef, i32 noundef, i1 noundef zeroext, i1 noundef zeroext, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z5solvexi(i64 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp slt i64 %0, 1
  br i1 %3, label %14, label %.preheader15.preheader

.preheader15.preheader:                           ; preds = %2
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(84) @bits, i8 0, i64 84, i1 false), !tbaa !5
  br label %.preheader

.preheader:                                       ; preds = %.preheader15.preheader, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader15.preheader ], [ %indvars.iv.next, %.preheader ]
  %.01118 = phi i64 [ %0, %.preheader15.preheader ], [ %7, %.preheader ]
  %4 = urem i64 %.01118, 10
  %5 = trunc nuw nsw i64 %4 to i32
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %6 = getelementptr inbounds [21 x i32], ptr @bits, i64 0, i64 %indvars.iv
  store i32 %5, ptr %6, align 4, !tbaa !5
  %7 = udiv i64 %.01118, 10
  %.not = icmp ult i64 %.01118, 10
  br i1 %.not, label %8, label %.preheader, !llvm.loop !9

8:                                                ; preds = %.preheader
  %9 = trunc nuw nsw i64 %indvars.iv to i32
  %10 = add nuw nsw i32 %9, 2
  %11 = tail call { i64, i64 } @_Z3dfsiibbi(i32 noundef %10, i32 noundef 0, i1 noundef zeroext false, i1 noundef zeroext true, i32 noundef %1)
  %12 = extractvalue { i64, i64 } %11, 0
  %13 = trunc i64 %12 to i32
  br label %14

14:                                               ; preds = %2, %8
  %.0 = phi i32 [ %13, %8 ], [ 0, %2 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 nounwind willreturn memory(argmem: write) }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass