; LLVM IR from VastoLorde95/Competitive-Programming :: CodeChef/WF/Medium Hard/MGCHGYM/A.ll (ZN5Treap12point_updateEPNS_4nodeEii)

; 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.Treap::node" = type <{ i32, i32, i32, [4 x i8], ptr, ptr, %"class.std::vector", i32, [4 x i8] }>
%"class.std::vector" = type { %"struct.std::_Vector_base" }
%"struct.std::_Vector_base" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl" = type { %"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" }
%"struct.std::_Vector_base<int, std::allocator<int>>::_Vector_impl_data" = type { ptr, ptr, ptr }

@_ZN5Treap4wposE = external dso_local global [100100 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5Treap7getSizeEPNS_4nodeE(ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5Treap7updSizeEPNS_4nodeE(ptr noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5Treap9propagateEPNS_4nodeE(ptr 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN5Treap12point_updateEPNS_4nodeEii(ptr noundef %0, i32 noundef %1, i32 noundef %2) #2 {
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %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
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store i32 %2, ptr %7, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN5Treap9propagateEPNS_4nodeE(ptr noundef %12)
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %"struct.Treap::node", ptr %13, i32 0, i32 6
  %15 = load i32, ptr %7, align 4, !tbaa !9
  %16 = sext i32 %15 to i64
  %17 = getelementptr inbounds [100100 x i32], ptr @_ZN5Treap4wposE, i64 0, i64 %16
  %18 = load i32, ptr %17, align 4, !tbaa !9
  %19 = sext i32 %18 to i64
  %20 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %14, i64 noundef %19) #3
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = add nsw i32 %21, 1
  store i32 %22, ptr %20, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds %"struct.Treap::node", ptr %23, i32 0, i32 4
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = call noundef i32 @_ZN5Treap7getSizeEPNS_4nodeE(ptr noundef %25)
  %27 = add nsw i32 %26, 1
  store i32 %27, ptr %9, align 4, !tbaa !9
  %28 = load i32, ptr %9, align 4, !tbaa !9
  %29 = load i32, ptr %6, align 4, !tbaa !9
  %30 = icmp slt i32 %28, %29
  br i1 %30, label %31, label %50

31:                                               ; preds = %3
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %"struct.Treap::node", ptr %32, i32 0, i32 5
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = sub nsw i32 %35, %36
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = call noundef i32 @_ZN5Treap12point_updateEPNS_4nodeEii(ptr noundef %34, i32 noundef %37, i32 noundef %38)
  store i32 %39, ptr %8, align 4, !tbaa !9
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.Treap::node", ptr %40, i32 0, i32 6
  %42 = load i32, ptr %8, align 4, !tbaa !9
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds [100100 x i32], ptr @_ZN5Treap4wposE, i64 0, i64 %43
  %45 = load i32, ptr %44, align 4, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %41, i64 noundef %46) #3
  %48 = load i32, ptr %47, align 4, !tbaa !9
  %49 = add nsw i32 %48, -1
  store i32 %49, ptr %47, align 4, !tbaa !9
  br label %90

50:                                               ; preds = %3
  %51 = load i32, ptr %9, align 4, !tbaa !9
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = icmp sgt i32 %51, %52
  br i1 %53, label %54, label %71

54:                                               ; preds = %50
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = getelementptr inbounds %"struct.Treap::node", ptr %55, i32 0, i32 4
  %57 = load ptr, ptr %56, align 8, !tbaa !11
  %58 = load i32, ptr %6, align 4, !tbaa !9
  %59 = load i32, ptr %7, align 4, !tbaa !9
  %60 = call noundef i32 @_ZN5Treap12point_updateEPNS_4nodeEii(ptr noundef %57, i32 noundef %58, i32 noundef %59)
  store i32 %60, ptr %8, align 4, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %"struct.Treap::node", ptr %61, i32 0, i32 6
  %63 = load i32, ptr %8, align 4, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100100 x i32], ptr @_ZN5Treap4wposE, i64 0, i64 %64
  %66 = load i32, ptr %65, align 4, !tbaa !9
  %67 = sext i32 %66 to i64
  %68 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %62, i64 noundef %67) #3
  %69 = load i32, ptr %68, align 4, !tbaa !9
  %70 = add nsw i32 %69, -1
  store i32 %70, ptr %68, align 4, !tbaa !9
  br label %89

71:                                               ; preds = %50
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %"struct.Treap::node", ptr %72, i32 0, i32 2
  %74 = load i32, ptr %73, align 8, !tbaa !18
  store i32 %74, ptr %10, align 4, !tbaa !9
  %75 = load i32, ptr %7, align 4, !tbaa !9
  %76 = load ptr, ptr %5, align 8, !tbaa !5
  %77 = getelementptr inbounds %"struct.Treap::node", ptr %76, i32 0, i32 2
  store i32 %75, ptr %77, align 8, !tbaa !18
  %78 = load ptr, ptr %5, align 8, !tbaa !5
  %79 = getelementptr inbounds %"struct.Treap::node", ptr %78, i32 0, i32 6
  %80 = load i32, ptr %10, align 4, !tbaa !9
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [100100 x i32], ptr @_ZN5Treap4wposE, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !9
  %84 = sext i32 %83 to i64
  %85 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %79, i64 noundef %84) #3
  %86 = load i32, ptr %85, align 4, !tbaa !9
  %87 = add nsw i32 %86, -1
  store i32 %87, ptr %85, align 4, !tbaa !9
  %88 = load i32, ptr %10, align 4, !tbaa !9
  store i32 %88, ptr %4, align 4
  store i32 1, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  br label %93

89:                                               ; preds = %54
  br label %90

90:                                               ; preds = %89, %31
  %91 = load ptr, ptr %5, align 8, !tbaa !5
  call void @_ZN5Treap7updSizeEPNS_4nodeE(ptr noundef %91)
  %92 = load i32, ptr %8, align 4, !tbaa !9
  store i32 %92, ptr %4, align 4
  store i32 1, ptr %11, align 4
  br label %93

93:                                               ; preds = %90, %71
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %94 = load i32, ptr %4, align 4
  ret i32 %94
}

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 = { 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 = { 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}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTSN5Treap4nodeE", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !13, i64 32, !10, i64 56}
!13 = !{!"_ZTSSt6vectorIiSaIiEE", !14, i64 0}
!14 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !16, i64 0}
!16 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!17 = !{!12, !6, i64 24}
!18 = !{!12, !10, i64 8}


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

@_ZN5Treap4wposE = external dso_local local_unnamed_addr global [100100 x i32], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN5Treap7getSizeEPNS_4nodeE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5Treap7updSizeEPNS_4nodeE(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN5Treap9propagateEPNS_4nodeE(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN5Treap12point_updateEPNS_4nodeEii(ptr noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #0 {
  tail call void @_ZN5Treap9propagateEPNS_4nodeE(ptr noundef %0)
  %4 = getelementptr inbounds i8, ptr %0, i64 32
  %5 = sext i32 %2 to i64
  %6 = getelementptr inbounds [100100 x i32], ptr @_ZN5Treap4wposE, i64 0, i64 %5
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %8) #1
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = add nsw i32 %10, 1
  store i32 %11, ptr %9, align 4, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %0, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  %14 = tail call noundef i32 @_ZN5Treap7getSizeEPNS_4nodeE(ptr noundef %13)
  %15 = add nsw i32 %14, 1
  %16 = icmp slt i32 %15, %1
  br i1 %16, label %17, label %22

17:                                               ; preds = %3
  %18 = getelementptr inbounds i8, ptr %0, i64 24
  %19 = load ptr, ptr %18, align 8, !tbaa !16
  %20 = sub nsw i32 %1, %15
  %21 = tail call noundef i32 @_ZN5Treap12point_updateEPNS_4nodeEii(ptr noundef %19, i32 noundef %20, i32 noundef %2)
  br label %36

22:                                               ; preds = %3
  %.not = icmp slt i32 %14, %1
  br i1 %.not, label %26, label %23

23:                                               ; preds = %22
  %24 = load ptr, ptr %12, align 8, !tbaa !9
  %25 = tail call noundef i32 @_ZN5Treap12point_updateEPNS_4nodeEii(ptr noundef %24, i32 noundef %1, i32 noundef %2)
  br label %36

26:                                               ; preds = %22
  %27 = getelementptr inbounds i8, ptr %0, i64 8
  %28 = load i32, ptr %27, align 8, !tbaa !17
  store i32 %2, ptr %27, align 8, !tbaa !17
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [100100 x i32], ptr @_ZN5Treap4wposE, i64 0, i64 %29
  %31 = load i32, ptr %30, align 4, !tbaa !5
  %32 = sext i32 %31 to i64
  %33 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %32) #1
  %34 = load i32, ptr %33, align 4, !tbaa !5
  %35 = add nsw i32 %34, -1
  store i32 %35, ptr %33, align 4, !tbaa !5
  br label %44

36:                                               ; preds = %23, %17
  %.sink35 = phi i32 [ %25, %23 ], [ %21, %17 ]
  %37 = sext i32 %.sink35 to i64
  %38 = getelementptr inbounds [100100 x i32], ptr @_ZN5Treap4wposE, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = tail call noundef nonnull align 4 dereferenceable(4) ptr @_ZNSt6vectorIiSaIiEEixEm(ptr noundef nonnull align 8 dereferenceable(24) %4, i64 noundef %40) #1
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = add nsw i32 %42, -1
  store i32 %43, ptr %41, align 4, !tbaa !5
  tail call void @_ZN5Treap7updSizeEPNS_4nodeE(ptr noundef nonnull %0)
  br label %44

44:                                               ; preds = %36, %26
  %.0 = phi i32 [ %.sink35, %36 ], [ %28, %26 ]
  ret i32 %.0
}

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 = { 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 = !{!10, !11, i64 16}
!10 = !{!"_ZTSN5Treap4nodeE", !6, i64 0, !6, i64 4, !6, i64 8, !11, i64 16, !11, i64 24, !12, i64 32, !6, i64 56}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!"_ZTSSt6vectorIiSaIiEE", !13, i64 0}
!13 = !{!"_ZTSSt12_Vector_baseIiSaIiEE", !14, i64 0}
!14 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE12_Vector_implE", !15, i64 0}
!15 = !{!"_ZTSNSt12_Vector_baseIiSaIiEE17_Vector_impl_dataE", !11, i64 0, !11, i64 8, !11, i64 16}
!16 = !{!10, !11, i64 24}
!17 = !{!10, !6, i64 8}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass