; LLVM IR from lzyrapx/Competitive-Programming :: HDUOJ/1698 （线段树）成段替换.ll (Z8pushdownii)

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

@sum = external dso_local global [400040 x i32], align 16
@col = external dso_local global [400040 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z8pushdownii(i32 noundef %0, i32 noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  %5 = load i32, ptr %3, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %6
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %9 = icmp ne i32 %8, 0
  br i1 %9, label %10, label %52

10:                                               ; preds = %2
  %11 = load i32, ptr %3, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = shl i32 %15, 1
  %17 = or i32 %16, 1
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %18
  store i32 %14, ptr %19, align 4, !tbaa !5
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = shl i32 %20, 1
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %22
  store i32 %14, ptr %23, align 4, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !5
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %26 = ashr i32 %25, 1
  %27 = sub nsw i32 %24, %26
  %28 = load i32, ptr %3, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = mul nsw i32 %27, %31
  %33 = load i32, ptr %3, align 4, !tbaa !5
  %34 = shl i32 %33, 1
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [400040 x i32], ptr @sum, i64 0, i64 %35
  store i32 %32, ptr %36, align 4, !tbaa !5
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = ashr i32 %37, 1
  %39 = load i32, ptr %3, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %40
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = mul nsw i32 %38, %42
  %44 = load i32, ptr %3, align 4, !tbaa !5
  %45 = shl i32 %44, 1
  %46 = or i32 %45, 1
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [400040 x i32], ptr @sum, i64 0, i64 %47
  store i32 %43, ptr %48, align 4, !tbaa !5
  %49 = load i32, ptr %3, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %50
  store i32 0, ptr %51, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %10, %2
  ret void
}

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

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


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

@sum = external dso_local local_unnamed_addr global [400040 x i32], align 16
@col = external dso_local local_unnamed_addr global [400040 x i32], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, argmem: none, inaccessiblemem: none) uwtable
define dso_local void @_Z8pushdownii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = sext i32 %0 to i64
  %4 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %3
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %.not = icmp eq i32 %5, 0
  br i1 %.not, label %20, label %6

6:                                                ; preds = %2
  %7 = shl i32 %0, 1
  %8 = or disjoint i32 %7, 1
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %9
  store i32 %5, ptr %10, align 4, !tbaa !5
  %11 = sext i32 %7 to i64
  %12 = getelementptr inbounds [400040 x i32], ptr @col, i64 0, i64 %11
  store i32 %5, ptr %12, align 8, !tbaa !5
  %13 = ashr i32 %1, 1
  %14 = sub nsw i32 %1, %13
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = mul nsw i32 %15, %14
  %17 = getelementptr inbounds [400040 x i32], ptr @sum, i64 0, i64 %11
  store i32 %16, ptr %17, align 8, !tbaa !5
  %18 = mul nsw i32 %15, %13
  %19 = getelementptr inbounds [400040 x i32], ptr @sum, i64 0, i64 %9
  store i32 %18, ptr %19, align 4, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %6, %2
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn 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" }

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


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferAlignmentPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass