; LLVM IR from ncduy0303/Competitive-Programming :: Data Structures/HLD.ll (Z6updateii)

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

%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.segtree = type { i32, %"class.std::vector.5" }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<segtree::tdata, std::allocator<segtree::tdata>>::_Vector_impl" }
%"struct.std::_Vector_base<segtree::tdata, std::allocator<segtree::tdata>>::_Vector_impl" = type { %"struct.std::_Vector_base<segtree::tdata, std::allocator<segtree::tdata>>::_Vector_impl_data" }
%"struct.std::_Vector_base<segtree::tdata, std::allocator<segtree::tdata>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::array" = type { [2 x i32] }

@dep = external dso_local global [10001 x i32], align 16
@pos = external dso_local global [10001 x i32], align 16
@el = external dso_local global %"class.std::vector.0", align 8
@st = external dso_local global %struct.segtree, align 8

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

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

; 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) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm0EiLm2EEOT0_OSt5arrayIS0_XT1_EE(ptr noundef nonnull align 4 dereferenceable(8)) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm1EiLm2EEOT0_OSt5arrayIS0_XT1_EE(ptr noundef nonnull align 4 dereferenceable(8)) #2

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updateii(i32 noundef %0, i32 noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca %"struct.std::array", align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store i32 %0, ptr %3, align 4, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %8 = load i32, ptr %3, align 4, !tbaa !5
  %9 = sext i32 %8 to i64
  %10 = call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @el, i64 noundef %9) #5
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %5, ptr align 4 %10, i64 8, i1 false), !tbaa.struct !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %11 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm0EiLm2EEOT0_OSt5arrayIS0_XT1_EE(ptr noundef nonnull align 4 dereferenceable(8) %5) #5
  store ptr %11, ptr %6, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %12 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm1EiLm2EEOT0_OSt5arrayIS0_XT1_EE(ptr noundef nonnull align 4 dereferenceable(8) %5) #5
  store ptr %12, ptr %7, align 8, !tbaa !11
  %13 = load ptr, ptr %6, align 8, !tbaa !11
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [10001 x i32], ptr @dep, i64 0, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = load ptr, ptr %7, align 8, !tbaa !11
  %19 = load i32, ptr %18, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [10001 x i32], ptr @dep, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = icmp slt i32 %17, %22
  br i1 %23, label %24, label %27

24:                                               ; preds = %2
  %25 = load ptr, ptr %6, align 8, !tbaa !11
  %26 = load ptr, ptr %7, align 8, !tbaa !11
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %25, ptr noundef nonnull align 4 dereferenceable(4) %26) #5
  br label %27

27:                                               ; preds = %24, %2
  %28 = load ptr, ptr %6, align 8, !tbaa !11
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [10001 x i32], ptr @pos, i64 0, i64 %30
  %32 = load i32, ptr %31, align 4, !tbaa !5
  %33 = load i32, ptr %4, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  call void @_ZN7segtree6updateEix(ptr noundef nonnull align 8 dereferenceable(32) @st, i32 noundef %32, i64 noundef %34)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) #2 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7segtree6updateEix(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i64 noundef) #3 align 2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 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 = { 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 #5 = { 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 8, !10}
!10 = !{!7, !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !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"

%"class.std::vector.0" = type { %"struct.std::_Vector_base.1" }
%"struct.std::_Vector_base.1" = type { %"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl" }
%"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl" = type { %"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl_data" }
%"struct.std::_Vector_base<std::array<int, 2>, std::allocator<std::array<int, 2>>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%struct.segtree = type { i32, %"class.std::vector.5" }
%"class.std::vector.5" = type { %"struct.std::_Vector_base.6" }
%"struct.std::_Vector_base.6" = type { %"struct.std::_Vector_base<segtree::tdata, std::allocator<segtree::tdata>>::_Vector_impl" }
%"struct.std::_Vector_base<segtree::tdata, std::allocator<segtree::tdata>>::_Vector_impl" = type { %"struct.std::_Vector_base<segtree::tdata, std::allocator<segtree::tdata>>::_Vector_impl_data" }
%"struct.std::_Vector_base<segtree::tdata, std::allocator<segtree::tdata>>::_Vector_impl_data" = type { ptr, ptr, ptr }
%"struct.std::array" = type { [2 x i32] }

@dep = external dso_local local_unnamed_addr global [10001 x i32], align 16
@pos = external dso_local local_unnamed_addr global [10001 x i32], align 16
@el = external dso_local global %"class.std::vector.0", align 8
@st = external dso_local global %struct.segtree, align 8

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

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

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

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

; Function Attrs: mustprogress uwtable
define dso_local void @_Z6updateii(i32 noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = alloca %"struct.std::array", align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  %4 = sext i32 %0 to i64
  %5 = tail call noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) @el, i64 noundef %4) #4
  %6 = load i64, ptr %5, align 4, !tbaa !5
  store i64 %6, ptr %3, align 8, !tbaa !5
  %7 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm0EiLm2EEOT0_OSt5arrayIS0_XT1_EE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  %8 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZSt3getILm1EiLm2EEOT0_OSt5arrayIS0_XT1_EE(ptr noundef nonnull align 4 dereferenceable(8) %3) #4
  %9 = load i32, ptr %7, align 4, !tbaa !8
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [10001 x i32], ptr @dep, i64 0, i64 %10
  %12 = load i32, ptr %11, align 4, !tbaa !8
  %13 = load i32, ptr %8, align 4, !tbaa !8
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [10001 x i32], ptr @dep, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !8
  %17 = icmp slt i32 %12, %16
  br i1 %17, label %18, label %19

18:                                               ; preds = %2
  call void @_ZSt4swapIiENSt9enable_ifIXsr6__and_ISt6__not_ISt15__is_tuple_likeIT_EESt21is_move_constructibleIS3_ESt18is_move_assignableIS3_EEE5valueEvE4typeERS3_SC_(ptr noundef nonnull align 4 dereferenceable(4) %7, ptr noundef nonnull align 4 dereferenceable(4) %8) #4
  %.pre = load i32, ptr %7, align 4, !tbaa !8
  %.pre6 = sext i32 %.pre to i64
  br label %19

19:                                               ; preds = %18, %2
  %.pre-phi = phi i64 [ %.pre6, %18 ], [ %10, %2 ]
  %20 = getelementptr inbounds [10001 x i32], ptr @pos, i64 0, i64 %.pre-phi
  %21 = load i32, ptr %20, align 4, !tbaa !8
  %22 = sext i32 %1 to i64
  call void @_ZN7segtree6updateEix(ptr noundef nonnull align 8 dereferenceable(32) @st, i32 noundef %21, i64 noundef %22)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(8) ptr @_ZNSt6vectorISt5arrayIiLm2EESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24), i64 noundef) local_unnamed_addr #1 align 2

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZN7segtree6updateEix(ptr noundef nonnull align 8 dereferenceable(32), i32 noundef, i64 noundef) local_unnamed_addr #2 align 2

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


; Effective O3 passes: BDCEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,TailCallElimPass