; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/2089（数位dp）.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"

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

; Function Attrs: mustprogress nounwind 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
  store i32 1, ptr @dp, align 16, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #2
  store i32 1, ptr %1, align 4, !tbaa !5
  br label %5

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

8:                                                ; preds = %5
  store i32 2, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #2
  br label %57

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

10:                                               ; preds = %50, %9
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = icmp slt i32 %11, 10
  br i1 %12, label %14, label %13

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

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

15:                                               ; preds = %46, %14
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp slt i32 %16, 10
  br i1 %17, label %19, label %18

18:                                               ; preds = %15
  store i32 8, ptr %2, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %49

19:                                               ; preds = %15
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = icmp eq i32 %20, 6
  br i1 %21, label %22, label %25

22:                                               ; preds = %19
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = icmp eq i32 %23, 2
  br i1 %24, label %45, label %25

25:                                               ; preds = %22, %19
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = icmp ne i32 %26, 4
  br i1 %27, label %28, label %45

28:                                               ; preds = %25
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = sub nsw i32 %29, 1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %31
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [10 x i32], ptr %32, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = load i32, ptr %1, align 4, !tbaa !5
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %38
  %40 = load i32, ptr %3, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [10 x i32], ptr %39, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = add nsw i32 %43, %36
  store i32 %44, ptr %42, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %28, %25, %22
  br label %46

46:                                               ; preds = %45
  %47 = load i32, ptr %4, align 4, !tbaa !5
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %4, align 4, !tbaa !5
  br label %15, !llvm.loop !9

49:                                               ; preds = %18
  br label %50

50:                                               ; preds = %49
  %51 = load i32, ptr %3, align 4, !tbaa !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %3, align 4, !tbaa !5
  br label %10, !llvm.loop !11

53:                                               ; preds = %13
  br label %54

54:                                               ; preds = %53
  %55 = load i32, ptr %1, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %1, align 4, !tbaa !5
  br label %5, !llvm.loop !12

57:                                               ; preds = %8
  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

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


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

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

; Function Attrs: mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z4initv() local_unnamed_addr #0 {
  store i32 1, ptr @dp, align 16, !tbaa !5
  br label %.preheader20

.preheader20:                                     ; preds = %0, %.preheader20
  %indvars.iv33 = phi i64 [ 1, %0 ], [ %indvars.iv.next34, %.preheader20 ]
  %1 = add nsw i64 %indvars.iv33, -1
  %2 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 0
  %3 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 8
  %4 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 0
  %5 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 1
  %6 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 3
  %7 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 4
  %8 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 5
  %9 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 6
  %10 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 7
  %11 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 8
  %12 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %indvars.iv33, i64 0
  %.promoted = load i32, ptr %12, align 8, !tbaa !5
  %13 = load <8 x i32>, ptr %2, align 8, !tbaa !5
  %14 = load i32, ptr %3, align 8, !tbaa !5
  %15 = tail call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %13)
  %op.rdx = add i32 %15, %14
  %op.rdx39 = add i32 %op.rdx, %.promoted
  %.sink = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 9
  %16 = load i32, ptr %.sink, align 4, !tbaa !5
  %17 = add nsw i32 %op.rdx39, %16
  store i32 %17, ptr %12, align 8, !tbaa !5
  %18 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %indvars.iv33, i64 1
  %.promoted.1 = load i32, ptr %18, align 4, !tbaa !5
  %19 = load <8 x i32>, ptr %2, align 8, !tbaa !5
  %20 = load i32, ptr %3, align 8, !tbaa !5
  %21 = tail call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %19)
  %op.rdx.1 = add i32 %21, %20
  %op.rdx39.1 = add i32 %op.rdx.1, %.promoted.1
  %.sink.1 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 9
  %22 = load i32, ptr %.sink.1, align 4, !tbaa !5
  %23 = add nsw i32 %op.rdx39.1, %22
  store i32 %23, ptr %18, align 4, !tbaa !5
  %24 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %indvars.iv33, i64 2
  %.promoted.2 = load i32, ptr %24, align 8, !tbaa !5
  %25 = load <8 x i32>, ptr %2, align 8, !tbaa !5
  %26 = load i32, ptr %3, align 8, !tbaa !5
  %27 = tail call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %25)
  %op.rdx.2 = add i32 %27, %26
  %op.rdx39.2 = add i32 %op.rdx.2, %.promoted.2
  %.sink.2 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 9
  %28 = load i32, ptr %.sink.2, align 4, !tbaa !5
  %29 = add nsw i32 %op.rdx39.2, %28
  store i32 %29, ptr %24, align 8, !tbaa !5
  %30 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %indvars.iv33, i64 3
  %.promoted.3 = load i32, ptr %30, align 4, !tbaa !5
  %31 = load <8 x i32>, ptr %2, align 8, !tbaa !5
  %32 = load i32, ptr %3, align 8, !tbaa !5
  %33 = tail call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %31)
  %op.rdx.3 = add i32 %33, %32
  %op.rdx39.3 = add i32 %op.rdx.3, %.promoted.3
  %.sink.3 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 9
  %34 = load i32, ptr %.sink.3, align 4, !tbaa !5
  %35 = add nsw i32 %op.rdx39.3, %34
  store i32 %35, ptr %30, align 4, !tbaa !5
  %36 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %indvars.iv33, i64 5
  %.promoted.5 = load i32, ptr %36, align 4, !tbaa !5
  %37 = load <8 x i32>, ptr %2, align 8, !tbaa !5
  %38 = load i32, ptr %3, align 8, !tbaa !5
  %39 = tail call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %37)
  %op.rdx.5 = add i32 %39, %38
  %op.rdx39.5 = add i32 %op.rdx.5, %.promoted.5
  %.sink.5 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 9
  %40 = load i32, ptr %.sink.5, align 4, !tbaa !5
  %41 = add nsw i32 %op.rdx39.5, %40
  store i32 %41, ptr %36, align 4, !tbaa !5
  %42 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %indvars.iv33, i64 6
  %43 = load i32, ptr %4, align 8, !tbaa !5
  %44 = load i32, ptr %42, align 8, !tbaa !5
  %45 = add nsw i32 %44, %43
  store i32 %45, ptr %42, align 8, !tbaa !5
  %46 = load i32, ptr %5, align 4, !tbaa !5
  %47 = add nsw i32 %45, %46
  store i32 %47, ptr %42, align 8, !tbaa !5
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %49 = add nsw i32 %47, %48
  store i32 %49, ptr %42, align 8, !tbaa !5
  %50 = load i32, ptr %7, align 8, !tbaa !5
  %51 = add nsw i32 %49, %50
  store i32 %51, ptr %42, align 8, !tbaa !5
  %52 = load i32, ptr %8, align 4, !tbaa !5
  %53 = add nsw i32 %51, %52
  store i32 %53, ptr %42, align 8, !tbaa !5
  %54 = load i32, ptr %9, align 8, !tbaa !5
  %55 = add nsw i32 %53, %54
  store i32 %55, ptr %42, align 8, !tbaa !5
  %56 = load i32, ptr %10, align 4, !tbaa !5
  %57 = add nsw i32 %55, %56
  store i32 %57, ptr %42, align 8, !tbaa !5
  %58 = load i32, ptr %11, align 8, !tbaa !5
  %59 = add nsw i32 %57, %58
  store i32 %59, ptr %42, align 8, !tbaa !5
  %.sink.6 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 9
  %60 = load i32, ptr %.sink.6, align 4, !tbaa !5
  %61 = add nsw i32 %59, %60
  store i32 %61, ptr %42, align 8, !tbaa !5
  %62 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %indvars.iv33, i64 7
  %.promoted.7 = load i32, ptr %62, align 4, !tbaa !5
  %63 = load <8 x i32>, ptr %2, align 8, !tbaa !5
  %64 = load i32, ptr %3, align 8, !tbaa !5
  %65 = tail call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %63)
  %op.rdx.7 = add i32 %65, %64
  %op.rdx39.7 = add i32 %op.rdx.7, %.promoted.7
  %.sink.7 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 9
  %66 = load i32, ptr %.sink.7, align 4, !tbaa !5
  %67 = add nsw i32 %op.rdx39.7, %66
  store i32 %67, ptr %62, align 4, !tbaa !5
  %68 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %indvars.iv33, i64 8
  %.promoted.8 = load i32, ptr %68, align 8, !tbaa !5
  %69 = load <8 x i32>, ptr %2, align 8, !tbaa !5
  %70 = load i32, ptr %3, align 8, !tbaa !5
  %71 = tail call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %69)
  %op.rdx.8 = add i32 %71, %70
  %op.rdx39.8 = add i32 %op.rdx.8, %.promoted.8
  %.sink.8 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 9
  %72 = load i32, ptr %.sink.8, align 4, !tbaa !5
  %73 = add nsw i32 %op.rdx39.8, %72
  store i32 %73, ptr %68, align 8, !tbaa !5
  %74 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %indvars.iv33, i64 9
  %.promoted.9 = load i32, ptr %74, align 4, !tbaa !5
  %75 = load <8 x i32>, ptr %2, align 8, !tbaa !5
  %76 = load i32, ptr %3, align 8, !tbaa !5
  %77 = tail call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %75)
  %op.rdx.9 = add i32 %77, %76
  %op.rdx39.9 = add i32 %op.rdx.9, %.promoted.9
  %.sink.9 = getelementptr inbounds [10 x [10 x i32]], ptr @dp, i64 0, i64 %1, i64 9
  %78 = load i32, ptr %.sink.9, align 4, !tbaa !5
  %79 = add nsw i32 %op.rdx39.9, %78
  store i32 %79, ptr %74, align 4, !tbaa !5
  %indvars.iv.next34 = add nuw nsw i64 %indvars.iv33, 1
  %exitcond36.not = icmp eq i64 %indvars.iv.next34, 8
  br i1 %exitcond36.not, label %80, label %.preheader20, !llvm.loop !9

80:                                               ; preds = %.preheader20
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v8i32(<8 x i32>) #1

attributes #0 = { mustprogress nofree norecurse nosync nounwind memory(readwrite, argmem: none, inaccessiblemem: 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" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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: DSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SCCPPass,SLPVectorizerPass,SROAPass,SimplifyCFGPass,TailCallElimPass