; LLVM IR from upupming/algorithm :: acwing/算法基础课/第五讲 动态规划/数位统计DP/338. 计数问题.ll (Z4initv)

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

@f = external dso_local global [15 x [10 x [10 x i32]]], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4initv() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %7

7:                                                ; preds = %18, %0
  %8 = load i32, ptr %1, align 4, !tbaa !5
  %9 = icmp sle i32 %8, 9
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  br label %21

11:                                               ; preds = %7
  %12 = load i32, ptr %1, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [10 x [10 x i32]], ptr getelementptr inbounds ([15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 1), i64 0, i64 %13
  %15 = load i32, ptr %1, align 4, !tbaa !5
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [10 x i32], ptr %14, i64 0, i64 %16
  store i32 1, ptr %17, align 4, !tbaa !5
  br label %18

18:                                               ; preds = %11
  %19 = load i32, ptr %1, align 4, !tbaa !5
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %1, align 4, !tbaa !5
  br label %7, !llvm.loop !9

21:                                               ; preds = %10
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store i32 2, ptr %2, align 4, !tbaa !5
  br label %22

22:                                               ; preds = %97, %21
  %23 = load i32, ptr %2, align 4, !tbaa !5
  %24 = icmp slt i32 %23, 15
  br i1 %24, label %26, label %25

25:                                               ; preds = %22
  store i32 5, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  br label %100

26:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %27

27:                                               ; preds = %93, %26
  %28 = load i32, ptr %4, align 4, !tbaa !5
  %29 = icmp sle i32 %28, 9
  br i1 %29, label %31, label %30

30:                                               ; preds = %27
  store i32 8, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  br label %96

31:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %32

32:                                               ; preds = %89, %31
  %33 = load i32, ptr %5, align 4, !tbaa !5
  %34 = icmp sle i32 %33, 9
  br i1 %34, label %36, label %35

35:                                               ; preds = %32
  store i32 11, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  br label %92

36:                                               ; preds = %32
  %37 = load i32, ptr %5, align 4, !tbaa !5
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = icmp eq i32 %37, %38
  br i1 %39, label %40, label %57

40:                                               ; preds = %36
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sub nsw i32 %41, 1
  %43 = call noundef double @_ZSt3powIiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef 10, i32 noundef %42)
  %44 = load i32, ptr %2, align 4, !tbaa !5
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %45
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = sext i32 %47 to i64
  %49 = getelementptr inbounds [10 x [10 x i32]], ptr %46, i64 0, i64 %48
  %50 = load i32, ptr %5, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [10 x i32], ptr %49, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = sitofp i32 %53 to double
  %55 = fadd double %54, %43
  %56 = fptosi double %55 to i32
  store i32 %56, ptr %52, align 4, !tbaa !5
  br label %57

57:                                               ; preds = %40, %36
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %58

58:                                               ; preds = %85, %57
  %59 = load i32, ptr %6, align 4, !tbaa !5
  %60 = icmp sle i32 %59, 9
  br i1 %60, label %62, label %61

61:                                               ; preds = %58
  store i32 14, ptr %3, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  br label %88

62:                                               ; preds = %58
  %63 = load i32, ptr %2, align 4, !tbaa !5
  %64 = sub nsw i32 %63, 1
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %65
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [10 x [10 x i32]], ptr %66, i64 0, i64 %68
  %70 = load i32, ptr %5, align 4, !tbaa !5
  %71 = sext i32 %70 to i64
  %72 = getelementptr inbounds [10 x i32], ptr %69, i64 0, i64 %71
  %73 = load i32, ptr %72, align 4, !tbaa !5
  %74 = load i32, ptr %2, align 4, !tbaa !5
  %75 = sext i32 %74 to i64
  %76 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %75
  %77 = load i32, ptr %4, align 4, !tbaa !5
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [10 x [10 x i32]], ptr %76, i64 0, i64 %78
  %80 = load i32, ptr %5, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [10 x i32], ptr %79, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = add nsw i32 %83, %73
  store i32 %84, ptr %82, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %62
  %86 = load i32, ptr %6, align 4, !tbaa !5
  %87 = add nsw i32 %86, 1
  store i32 %87, ptr %6, align 4, !tbaa !5
  br label %58, !llvm.loop !11

88:                                               ; preds = %61
  br label %89

89:                                               ; preds = %88
  %90 = load i32, ptr %5, align 4, !tbaa !5
  %91 = add nsw i32 %90, 1
  store i32 %91, ptr %5, align 4, !tbaa !5
  br label %32, !llvm.loop !12

92:                                               ; preds = %35
  br label %93

93:                                               ; preds = %92
  %94 = load i32, ptr %4, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %4, align 4, !tbaa !5
  br label %27, !llvm.loop !13

96:                                               ; preds = %30
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %2, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %2, align 4, !tbaa !5
  br label %22, !llvm.loop !14

100:                                              ; preds = %25
  ret void
}

; 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: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i32 noundef) #2

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 = { inlinehint 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" }
attributes #3 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}
!13 = distinct !{!13, !10}
!14 = distinct !{!14, !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"

@f = external dso_local local_unnamed_addr global [15 x [10 x [10 x i32]]], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z4initv() local_unnamed_addr #0 {
.preheader28.preheader:
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 400), align 16, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 444), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 488), align 8, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 532), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 576), align 16, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 620), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 664), align 8, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 708), align 4, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 752), align 16, !tbaa !5
  store i32 1, ptr getelementptr inbounds (i8, ptr @f, i64 796), align 4, !tbaa !5
  br label %.preheader28

.preheader28:                                     ; preds = %.preheader28.preheader, %4
  %indvars.iv42 = phi i64 [ 2, %.preheader28.preheader ], [ %indvars.iv.next43, %4 ]
  %0 = add nsw i64 %indvars.iv42, -1
  %1 = trunc nuw nsw i64 %0 to i32
  br label %.preheader

2:                                                ; preds = %4
  ret void

.preheader:                                       ; preds = %.preheader28, %5
  %indvars.iv38 = phi i64 [ 0, %.preheader28 ], [ %indvars.iv.next39, %5 ]
  %3 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %indvars.iv42, i64 %indvars.iv38, i64 %indvars.iv38
  br label %6

4:                                                ; preds = %5
  %indvars.iv.next43 = add nuw nsw i64 %indvars.iv42, 1
  %exitcond45.not = icmp eq i64 %indvars.iv.next43, 15
  br i1 %exitcond45.not, label %2, label %.preheader28, !llvm.loop !9

5:                                                ; preds = %14
  %indvars.iv.next39 = add nuw nsw i64 %indvars.iv38, 1
  %exitcond41.not = icmp eq i64 %indvars.iv.next39, 10
  br i1 %exitcond41.not, label %4, label %.preheader, !llvm.loop !11

6:                                                ; preds = %.preheader, %14
  %indvars.iv = phi i64 [ 0, %.preheader ], [ %indvars.iv.next, %14 ]
  %7 = icmp eq i64 %indvars.iv, %indvars.iv38
  br i1 %7, label %8, label %14

8:                                                ; preds = %6
  %9 = tail call noundef double @_ZSt3powIiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef 10, i32 noundef %1)
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = sitofp i32 %10 to double
  %12 = fadd double %9, %11
  %13 = fptosi double %12 to i32
  store i32 %13, ptr %3, align 4, !tbaa !5
  br label %14

14:                                               ; preds = %8, %6
  %15 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %indvars.iv42, i64 %indvars.iv38, i64 %indvars.iv
  %.promoted = load i32, ptr %15, align 4, !tbaa !5
  %16 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 0, i64 %indvars.iv
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = add nsw i32 %.promoted, %17
  %19 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 1, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = add nsw i32 %18, %20
  %22 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 2, i64 %indvars.iv
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = add nsw i32 %21, %23
  %25 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 3, i64 %indvars.iv
  %26 = load i32, ptr %25, align 4, !tbaa !5
  %27 = add nsw i32 %24, %26
  %28 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 4, i64 %indvars.iv
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = add nsw i32 %27, %29
  %31 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 5, i64 %indvars.iv
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = add nsw i32 %30, %32
  %34 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 6, i64 %indvars.iv
  %35 = load i32, ptr %34, align 4, !tbaa !5
  %36 = add nsw i32 %33, %35
  %37 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 7, i64 %indvars.iv
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = add nsw i32 %36, %38
  %40 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 8, i64 %indvars.iv
  %41 = load i32, ptr %40, align 4, !tbaa !5
  %42 = add nsw i32 %39, %41
  %43 = getelementptr inbounds [15 x [10 x [10 x i32]]], ptr @f, i64 0, i64 %0, i64 9, i64 %indvars.iv
  %44 = load i32, ptr %43, align 4, !tbaa !5
  %45 = add nsw i32 %42, %44
  store i32 %45, ptr %15, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 10
  br i1 %exitcond.not, label %5, label %6, !llvm.loop !12
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIiiEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i32 noundef) local_unnamed_addr #1

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" }
attributes #1 = { inlinehint 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 = !{!"int", !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}
!12 = distinct !{!12, !10}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass