; LLVM IR from sunkafei/xcpc-algorithm-templates :: 算法/数据结构/动态开点线段树.ll (Z6updateRiiiiiii)

; 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.segment = type { i32, i32, i32, i32, i32, i32, i32 }

@t = external dso_local global [840000 x %struct.segment], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updateRiiiiiii(ptr noundef nonnull align 4 dereferenceable(4) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) #0 {
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  store i32 %2, ptr %10, align 4, !tbaa !9
  store i32 %3, ptr %11, align 4, !tbaa !9
  store i32 %4, ptr %12, align 4, !tbaa !9
  store i32 %5, ptr %13, align 4, !tbaa !9
  store i32 %6, ptr %14, align 4, !tbaa !9
  %16 = load ptr, ptr %8, align 8, !tbaa !5
  call void @_Z7newnodeRi(ptr noundef nonnull align 4 dereferenceable(4) %16)
  %17 = load i32, ptr %9, align 4, !tbaa !9
  %18 = load i32, ptr %13, align 4, !tbaa !9
  %19 = icmp sle i32 %17, %18
  br i1 %19, label %20, label %38

20:                                               ; preds = %7
  %21 = load i32, ptr %10, align 4, !tbaa !9
  %22 = load i32, ptr %14, align 4, !tbaa !9
  %23 = icmp sge i32 %21, %22
  br i1 %23, label %24, label %38

24:                                               ; preds = %20
  %25 = load i32, ptr %11, align 4, !tbaa !9
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %32

27:                                               ; preds = %24
  %28 = load ptr, ptr %8, align 8, !tbaa !5
  %29 = load i32, ptr %12, align 4, !tbaa !9
  %30 = load i32, ptr %13, align 4, !tbaa !9
  %31 = load i32, ptr %14, align 4, !tbaa !9
  call void @_Z4markRiiiii(ptr noundef nonnull align 4 dereferenceable(4) %28, i32 noundef -1, i32 noundef %29, i32 noundef %30, i32 noundef %31)
  br label %37

32:                                               ; preds = %24
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = load i32, ptr %12, align 4, !tbaa !9
  %35 = load i32, ptr %13, align 4, !tbaa !9
  %36 = load i32, ptr %14, align 4, !tbaa !9
  call void @_Z4markRiiiii(ptr noundef nonnull align 4 dereferenceable(4) %33, i32 noundef %34, i32 noundef 0, i32 noundef %35, i32 noundef %36)
  br label %37

37:                                               ; preds = %32, %27
  br label %82

38:                                               ; preds = %20, %7
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = load i32, ptr %39, align 4, !tbaa !9
  %41 = load i32, ptr %13, align 4, !tbaa !9
  %42 = load i32, ptr %14, align 4, !tbaa !9
  call void @_Z8pushdowniii(i32 noundef %40, i32 noundef %41, i32 noundef %42)
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  %43 = load i32, ptr %13, align 4, !tbaa !9
  %44 = load i32, ptr %14, align 4, !tbaa !9
  %45 = add nsw i32 %43, %44
  %46 = ashr i32 %45, 1
  store i32 %46, ptr %15, align 4, !tbaa !9
  %47 = load i32, ptr %9, align 4, !tbaa !9
  %48 = load i32, ptr %15, align 4, !tbaa !9
  %49 = icmp sle i32 %47, %48
  br i1 %49, label %50, label %62

50:                                               ; preds = %38
  %51 = load ptr, ptr %8, align 8, !tbaa !5
  %52 = load i32, ptr %51, align 4, !tbaa !9
  %53 = sext i32 %52 to i64
  %54 = getelementptr inbounds [840000 x %struct.segment], ptr @t, i64 0, i64 %53
  %55 = getelementptr inbounds %struct.segment, ptr %54, i32 0, i32 0
  %56 = load i32, ptr %9, align 4, !tbaa !9
  %57 = load i32, ptr %10, align 4, !tbaa !9
  %58 = load i32, ptr %11, align 4, !tbaa !9
  %59 = load i32, ptr %12, align 4, !tbaa !9
  %60 = load i32, ptr %13, align 4, !tbaa !9
  %61 = load i32, ptr %15, align 4, !tbaa !9
  call void @_Z6updateRiiiiiii(ptr noundef nonnull align 4 dereferenceable(4) %55, i32 noundef %56, i32 noundef %57, i32 noundef %58, i32 noundef %59, i32 noundef %60, i32 noundef %61)
  br label %62

62:                                               ; preds = %50, %38
  %63 = load i32, ptr %10, align 4, !tbaa !9
  %64 = load i32, ptr %15, align 4, !tbaa !9
  %65 = icmp sgt i32 %63, %64
  br i1 %65, label %66, label %79

66:                                               ; preds = %62
  %67 = load ptr, ptr %8, align 8, !tbaa !5
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [840000 x %struct.segment], ptr @t, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.segment, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %9, align 4, !tbaa !9
  %73 = load i32, ptr %10, align 4, !tbaa !9
  %74 = load i32, ptr %11, align 4, !tbaa !9
  %75 = load i32, ptr %12, align 4, !tbaa !9
  %76 = load i32, ptr %15, align 4, !tbaa !9
  %77 = add nsw i32 %76, 1
  %78 = load i32, ptr %14, align 4, !tbaa !9
  call void @_Z6updateRiiiiiii(ptr noundef nonnull align 4 dereferenceable(4) %71, i32 noundef %72, i32 noundef %73, i32 noundef %74, i32 noundef %75, i32 noundef %77, i32 noundef %78)
  br label %79

79:                                               ; preds = %66, %62
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = load i32, ptr %80, align 4, !tbaa !9
  call void @_Z8maintaini(i32 noundef %81)
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %82

82:                                               ; preds = %79, %37
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z7newnodeRi(ptr noundef nonnull align 4 dereferenceable(4)) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z4markRiiiii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z8pushdowniii(i32 noundef, i32 noundef, i32 noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z8maintaini(i32 noundef) #3

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { 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 #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { inlinehint 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}


; 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.segment = type { i32, i32, i32, i32, i32, i32, i32 }

@t = external dso_local global [840000 x %struct.segment], align 16

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updateRiiiiiii(ptr noundef nonnull align 4 dereferenceable(4) %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %6) local_unnamed_addr #0 {
  tail call void @_Z7newnodeRi(ptr noundef nonnull align 4 dereferenceable(4) %0)
  %.not = icmp sgt i32 %1, %5
  %.not41 = icmp slt i32 %2, %6
  %or.cond = or i1 %.not, %.not41
  br i1 %or.cond, label %12, label %8

8:                                                ; preds = %7
  %9 = icmp eq i32 %3, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %8
  tail call void @_Z4markRiiiii(ptr noundef nonnull align 4 dereferenceable(4) %0, i32 noundef -1, i32 noundef %4, i32 noundef %5, i32 noundef %6)
  br label %29

11:                                               ; preds = %8
  tail call void @_Z4markRiiiii(ptr noundef nonnull align 4 dereferenceable(4) %0, i32 noundef %4, i32 noundef 0, i32 noundef %5, i32 noundef %6)
  br label %29

12:                                               ; preds = %7
  %13 = load i32, ptr %0, align 4, !tbaa !5
  tail call void @_Z8pushdowniii(i32 noundef %13, i32 noundef %5, i32 noundef %6)
  %14 = add nsw i32 %6, %5
  %15 = ashr i32 %14, 1
  %.not42 = icmp slt i32 %15, %1
  br i1 %.not42, label %20, label %16

16:                                               ; preds = %12
  %17 = load i32, ptr %0, align 4, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [840000 x %struct.segment], ptr @t, i64 0, i64 %18
  tail call void @_Z6updateRiiiiiii(ptr noundef nonnull align 4 dereferenceable(4) %19, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %5, i32 noundef %15)
  br label %20

20:                                               ; preds = %16, %12
  %21 = icmp slt i32 %15, %2
  br i1 %21, label %22, label %27

22:                                               ; preds = %20
  %23 = load i32, ptr %0, align 4, !tbaa !5
  %24 = sext i32 %23 to i64
  %25 = getelementptr inbounds [840000 x %struct.segment], ptr @t, i64 0, i64 %24, i32 1
  %26 = add nsw i32 %15, 1
  tail call void @_Z6updateRiiiiiii(ptr noundef nonnull align 4 dereferenceable(4) %25, i32 noundef %1, i32 noundef %2, i32 noundef %3, i32 noundef %4, i32 noundef %26, i32 noundef %6)
  br label %27

27:                                               ; preds = %22, %20
  %28 = load i32, ptr %0, align 4, !tbaa !5
  tail call void @_Z8maintaini(i32 noundef %28)
  br label %29

29:                                               ; preds = %10, %11, %27
  ret void
}

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z7newnodeRi(ptr noundef nonnull align 4 dereferenceable(4)) local_unnamed_addr #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local void @_Z4markRiiiii(ptr noundef nonnull align 4 dereferenceable(4), i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

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

; Function Attrs: inlinehint mustprogress uwtable
declare dso_local void @_Z8maintaini(i32 noundef) local_unnamed_addr #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 = { 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 #2 = { inlinehint 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" }

!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,InferFunctionAttrsPass,InstCombinePass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass