; LLVM IR from lzyrapx/Competitive-Programming :: ACdream/1101（线段树）（区间替换+区间查询LCIS）.ll (Z6updateiiiiii)

; 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 { i32, i32, i32, i32, i32, i32, i32 }

@tree = external dso_local global [493824 x %struct.Node], align 16
@lazy = external dso_local global [493824 x i32], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9push_downiiii(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: mustprogress nounwind uwtable
declare dso_local void @_ZN4NodeC2Eiiiiiii(ptr noundef nonnull align 4 dereferenceable(28), i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; 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
declare dso_local void @_ZNK4NodeplERKS_(ptr dead_on_unwind noalias writable sret(%struct.Node) align 4, ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 4 dereferenceable(28)) #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updateiiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) #0 {
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca %struct.Node, align 4
  %14 = alloca i32, align 4
  %15 = alloca %struct.Node, align 4
  store i32 %0, ptr %7, align 4, !tbaa !5
  store i32 %1, ptr %8, align 4, !tbaa !5
  store i32 %2, ptr %9, align 4, !tbaa !5
  store i32 %3, ptr %10, align 4, !tbaa !5
  store i32 %4, ptr %11, align 4, !tbaa !5
  store i32 %5, ptr %12, align 4, !tbaa !5
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = load i32, ptr %10, align 4, !tbaa !5
  %18 = icmp eq i32 %16, %17
  br i1 %18, label %19, label %35

19:                                               ; preds = %6
  %20 = load i32, ptr %8, align 4, !tbaa !5
  %21 = load i32, ptr %11, align 4, !tbaa !5
  %22 = icmp eq i32 %20, %21
  br i1 %22, label %23, label %35

23:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 28, ptr %13) #4
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = load i32, ptr %8, align 4, !tbaa !5
  %26 = load i32, ptr %12, align 4, !tbaa !5
  %27 = load i32, ptr %12, align 4, !tbaa !5
  call void @_ZN4NodeC2Eiiiiiii(ptr noundef nonnull align 4 dereferenceable(28) %13, i32 noundef %24, i32 noundef %25, i32 noundef %26, i32 noundef %27, i32 noundef 1, i32 noundef 1, i32 noundef 1)
  %28 = load i32, ptr %9, align 4, !tbaa !5
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [493824 x %struct.Node], ptr @tree, i64 0, i64 %29
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %30, ptr align 4 %13, i64 28, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 28, ptr %13) #4
  %31 = load i32, ptr %12, align 4, !tbaa !5
  %32 = load i32, ptr %9, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [493824 x i32], ptr @lazy, i64 0, i64 %33
  store i32 %31, ptr %34, align 4, !tbaa !5
  br label %125

35:                                               ; preds = %19, %6
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %36 = load i32, ptr %7, align 4, !tbaa !5
  %37 = load i32, ptr %8, align 4, !tbaa !5
  %38 = add nsw i32 %36, %37
  %39 = ashr i32 %38, 1
  store i32 %39, ptr %14, align 4, !tbaa !5
  %40 = load i32, ptr %9, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [493824 x i32], ptr @lazy, i64 0, i64 %41
  %43 = load i32, ptr %42, align 4, !tbaa !5
  %44 = icmp ne i32 %43, 0
  br i1 %44, label %45, label %67

45:                                               ; preds = %35
  %46 = load i32, ptr %7, align 4, !tbaa !5
  %47 = load i32, ptr %14, align 4, !tbaa !5
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = shl i32 %48, 1
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [493824 x i32], ptr @lazy, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  call void @_Z9push_downiiii(i32 noundef %46, i32 noundef %47, i32 noundef %49, i32 noundef %53)
  %54 = load i32, ptr %14, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  %56 = load i32, ptr %8, align 4, !tbaa !5
  %57 = load i32, ptr %9, align 4, !tbaa !5
  %58 = shl i32 %57, 1
  %59 = or i32 %58, 1
  %60 = load i32, ptr %9, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [493824 x i32], ptr @lazy, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  call void @_Z9push_downiiii(i32 noundef %55, i32 noundef %56, i32 noundef %59, i32 noundef %63)
  %64 = load i32, ptr %9, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [493824 x i32], ptr @lazy, i64 0, i64 %65
  store i32 0, ptr %66, align 4, !tbaa !5
  br label %67

67:                                               ; preds = %45, %35
  %68 = load i32, ptr %11, align 4, !tbaa !5
  %69 = load i32, ptr %14, align 4, !tbaa !5
  %70 = icmp sle i32 %68, %69
  br i1 %70, label %71, label %79

71:                                               ; preds = %67
  %72 = load i32, ptr %7, align 4, !tbaa !5
  %73 = load i32, ptr %14, align 4, !tbaa !5
  %74 = load i32, ptr %9, align 4, !tbaa !5
  %75 = shl i32 %74, 1
  %76 = load i32, ptr %10, align 4, !tbaa !5
  %77 = load i32, ptr %11, align 4, !tbaa !5
  %78 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z6updateiiiiii(i32 noundef %72, i32 noundef %73, i32 noundef %75, i32 noundef %76, i32 noundef %77, i32 noundef %78)
  br label %112

79:                                               ; preds = %67
  %80 = load i32, ptr %10, align 4, !tbaa !5
  %81 = load i32, ptr %14, align 4, !tbaa !5
  %82 = icmp sgt i32 %80, %81
  br i1 %82, label %83, label %93

83:                                               ; preds = %79
  %84 = load i32, ptr %14, align 4, !tbaa !5
  %85 = add nsw i32 %84, 1
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = load i32, ptr %9, align 4, !tbaa !5
  %88 = shl i32 %87, 1
  %89 = or i32 %88, 1
  %90 = load i32, ptr %10, align 4, !tbaa !5
  %91 = load i32, ptr %11, align 4, !tbaa !5
  %92 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z6updateiiiiii(i32 noundef %85, i32 noundef %86, i32 noundef %89, i32 noundef %90, i32 noundef %91, i32 noundef %92)
  br label %111

93:                                               ; preds = %79
  %94 = load i32, ptr %7, align 4, !tbaa !5
  %95 = load i32, ptr %14, align 4, !tbaa !5
  %96 = load i32, ptr %9, align 4, !tbaa !5
  %97 = shl i32 %96, 1
  %98 = load i32, ptr %10, align 4, !tbaa !5
  %99 = load i32, ptr %14, align 4, !tbaa !5
  %100 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z6updateiiiiii(i32 noundef %94, i32 noundef %95, i32 noundef %97, i32 noundef %98, i32 noundef %99, i32 noundef %100)
  %101 = load i32, ptr %14, align 4, !tbaa !5
  %102 = add nsw i32 %101, 1
  %103 = load i32, ptr %8, align 4, !tbaa !5
  %104 = load i32, ptr %9, align 4, !tbaa !5
  %105 = shl i32 %104, 1
  %106 = or i32 %105, 1
  %107 = load i32, ptr %14, align 4, !tbaa !5
  %108 = add nsw i32 %107, 1
  %109 = load i32, ptr %11, align 4, !tbaa !5
  %110 = load i32, ptr %12, align 4, !tbaa !5
  call void @_Z6updateiiiiii(i32 noundef %102, i32 noundef %103, i32 noundef %106, i32 noundef %108, i32 noundef %109, i32 noundef %110)
  br label %111

111:                                              ; preds = %93, %83
  br label %112

112:                                              ; preds = %111, %71
  call void @llvm.lifetime.start.p0(i64 28, ptr %15) #4
  %113 = load i32, ptr %9, align 4, !tbaa !5
  %114 = shl i32 %113, 1
  %115 = sext i32 %114 to i64
  %116 = getelementptr inbounds [493824 x %struct.Node], ptr @tree, i64 0, i64 %115
  %117 = load i32, ptr %9, align 4, !tbaa !5
  %118 = shl i32 %117, 1
  %119 = or i32 %118, 1
  %120 = sext i32 %119 to i64
  %121 = getelementptr inbounds [493824 x %struct.Node], ptr @tree, i64 0, i64 %120
  call void @_ZNK4NodeplERKS_(ptr dead_on_unwind writable sret(%struct.Node) align 4 %15, ptr noundef nonnull align 4 dereferenceable(28) %116, ptr noundef nonnull align 4 dereferenceable(28) %121)
  %122 = load i32, ptr %9, align 4, !tbaa !5
  %123 = sext i32 %122 to i64
  %124 = getelementptr inbounds [493824 x %struct.Node], ptr @tree, i64 0, i64 %123
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %124, ptr align 4 %15, i64 28, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.end.p0(i64 28, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %125

125:                                              ; preds = %112, %23
  ret void
}

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 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{i64 0, i64 4, !5, i64 4, i64 4, !5, i64 8, i64 4, !5, i64 12, i64 4, !5, i64 16, i64 4, !5, i64 20, i64 4, !5, i64 24, i64 4, !5}


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

%struct.Node = type { i32, i32, i32, i32, i32, i32, i32 }

@tree = external dso_local global [493824 x %struct.Node], align 16
@lazy = external dso_local local_unnamed_addr global [493824 x i32], align 16

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9push_downiiii(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 nounwind uwtable
declare dso_local void @_ZN4NodeC2Eiiiiiii(ptr noundef nonnull align 4 dereferenceable(28), i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef) unnamed_addr #2 align 2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; 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 uwtable
declare dso_local void @_ZNK4NodeplERKS_(ptr dead_on_unwind noalias writable sret(%struct.Node) align 4, ptr noundef nonnull align 4 dereferenceable(28), ptr noundef nonnull align 4 dereferenceable(28)) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updateiiiiii(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5) local_unnamed_addr #0 {
  %7 = alloca %struct.Node, align 4
  %8 = alloca %struct.Node, align 4
  %9 = icmp eq i32 %0, %3
  %10 = icmp eq i32 %1, %4
  %or.cond = and i1 %9, %10
  %11 = sext i32 %2 to i64
  br i1 %or.cond, label %12, label %15

12:                                               ; preds = %6
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %7) #4
  call void @_ZN4NodeC2Eiiiiiii(ptr noundef nonnull align 4 dereferenceable(28) %7, i32 noundef %0, i32 noundef %1, i32 noundef %5, i32 noundef %5, i32 noundef 1, i32 noundef 1, i32 noundef 1)
  %13 = getelementptr inbounds [493824 x %struct.Node], ptr @tree, i64 0, i64 %11
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(28) %13, ptr noundef nonnull align 4 dereferenceable(28) %7, i64 28, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %7) #4
  %14 = getelementptr inbounds [493824 x i32], ptr @lazy, i64 0, i64 %11
  store i32 %5, ptr %14, align 4, !tbaa !6
  br label %44

15:                                               ; preds = %6
  %16 = add nsw i32 %1, %0
  %17 = ashr i32 %16, 1
  %18 = getelementptr inbounds [493824 x i32], ptr @lazy, i64 0, i64 %11
  %19 = load i32, ptr %18, align 4, !tbaa !6
  %.not = icmp eq i32 %19, 0
  br i1 %.not, label %25, label %20

20:                                               ; preds = %15
  %21 = shl i32 %2, 1
  tail call void @_Z9push_downiiii(i32 noundef %0, i32 noundef %17, i32 noundef %21, i32 noundef %19)
  %22 = add nsw i32 %17, 1
  %23 = or disjoint i32 %21, 1
  %24 = load i32, ptr %18, align 4, !tbaa !6
  tail call void @_Z9push_downiiii(i32 noundef %22, i32 noundef %1, i32 noundef %23, i32 noundef %24)
  store i32 0, ptr %18, align 4, !tbaa !6
  br label %25

25:                                               ; preds = %20, %15
  %.not61 = icmp slt i32 %17, %4
  br i1 %.not61, label %28, label %26

26:                                               ; preds = %25
  %27 = shl i32 %2, 1
  tail call void @_Z6updateiiiiii(i32 noundef %0, i32 noundef %17, i32 noundef %27, i32 noundef %3, i32 noundef %4, i32 noundef %5)
  %.pre = or disjoint i32 %27, 1
  br label %38

28:                                               ; preds = %25
  %29 = icmp slt i32 %17, %3
  br i1 %29, label %30, label %34

30:                                               ; preds = %28
  %31 = add nsw i32 %17, 1
  %32 = shl i32 %2, 1
  %33 = or disjoint i32 %32, 1
  tail call void @_Z6updateiiiiii(i32 noundef %31, i32 noundef %1, i32 noundef %33, i32 noundef %3, i32 noundef %4, i32 noundef %5)
  br label %38

34:                                               ; preds = %28
  %35 = shl i32 %2, 1
  tail call void @_Z6updateiiiiii(i32 noundef %0, i32 noundef %17, i32 noundef %35, i32 noundef %3, i32 noundef %17, i32 noundef %5)
  %36 = add nsw i32 %17, 1
  %37 = or disjoint i32 %35, 1
  tail call void @_Z6updateiiiiii(i32 noundef %36, i32 noundef %1, i32 noundef %37, i32 noundef %36, i32 noundef %4, i32 noundef %5)
  br label %38

38:                                               ; preds = %30, %34, %26
  %.pre-phi62 = phi i32 [ %33, %30 ], [ %37, %34 ], [ %.pre, %26 ]
  %.pre-phi = phi i32 [ %32, %30 ], [ %35, %34 ], [ %27, %26 ]
  call void @llvm.lifetime.start.p0(i64 28, ptr nonnull %8) #4
  %39 = sext i32 %.pre-phi to i64
  %40 = getelementptr inbounds [493824 x %struct.Node], ptr @tree, i64 0, i64 %39
  %41 = sext i32 %.pre-phi62 to i64
  %42 = getelementptr inbounds [493824 x %struct.Node], ptr @tree, i64 0, i64 %41
  call void @_ZNK4NodeplERKS_(ptr dead_on_unwind nonnull writable sret(%struct.Node) align 4 %8, ptr noundef nonnull align 4 dereferenceable(28) %40, ptr noundef nonnull align 4 dereferenceable(28) %42)
  %43 = getelementptr inbounds [493824 x %struct.Node], ptr @tree, i64 0, i64 %11
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(28) %43, ptr noundef nonnull align 4 dereferenceable(28) %8, i64 28, i1 false), !tbaa.struct !5
  call void @llvm.lifetime.end.p0(i64 28, ptr nonnull %8) #4
  br label %44

44:                                               ; preds = %38, %12
  ret void
}

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 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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 = !{i64 0, i64 4, !6, i64 4, i64 4, !6, i64 8, i64 4, !6, i64 12, i64 4, !6, i64 16, i64 4, !6, i64 20, i64 4, !6, i64 24, i64 4, !6}
!6 = !{!7, !7, i64 0}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass