; LLVM IR from iksha-rudra/Computational-Geometry :: CGAlgorithms/DataStructures/minheap.ll (ZN7MinHeap11decreaseKeyEid)

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

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

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN7MinHeap11decreaseKeyEid(ptr noundef nonnull align 8 dereferenceable(28) %0, i32 noundef %1, double noundef %2) #1 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca double, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i32 %1, ptr %6, align 4, !tbaa !9
  store double %2, ptr %7, align 8, !tbaa !11
  %8 = load ptr, ptr %5, align 8
  %9 = load i32, ptr %6, align 4, !tbaa !9
  %10 = icmp slt i32 %9, 0
  br i1 %10, label %11, label %17

11:                                               ; preds = %3
  %12 = getelementptr inbounds %class.MinHeap, ptr %8, i32 0, i32 1
  %13 = load i32, ptr %12, align 8, !tbaa !13
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = icmp sge i32 %13, %14
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  store i1 false, ptr %4, align 1
  br label %67

17:                                               ; preds = %11, %3
  %18 = getelementptr inbounds %class.MinHeap, ptr %8, i32 0, i32 0
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %18, i64 noundef %20) #2
  %22 = getelementptr inbounds %"struct.MinHeap::Node", ptr %21, i32 0, i32 1
  %23 = load double, ptr %22, align 8, !tbaa !19
  %24 = load double, ptr %7, align 8, !tbaa !11
  %25 = fcmp olt double %23, %24
  br i1 %25, label %26, label %27

26:                                               ; preds = %17
  store i1 false, ptr %4, align 1
  br label %67

27:                                               ; preds = %17
  %28 = load double, ptr %7, align 8, !tbaa !11
  %29 = getelementptr inbounds %class.MinHeap, ptr %8, i32 0, i32 0
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %29, i64 noundef %31) #2
  %33 = getelementptr inbounds %"struct.MinHeap::Node", ptr %32, i32 0, i32 1
  store double %28, ptr %33, align 8, !tbaa !19
  br label %34

34:                                               ; preds = %54, %27
  %35 = load i32, ptr %6, align 4, !tbaa !9
  %36 = icmp sgt i32 %35, 0
  br i1 %36, label %37, label %52

37:                                               ; preds = %34
  %38 = getelementptr inbounds %class.MinHeap, ptr %8, i32 0, i32 0
  %39 = load i32, ptr %6, align 4, !tbaa !9
  %40 = call noundef i32 @_ZN7MinHeap6parentEi(ptr noundef nonnull align 8 dereferenceable(28) %8, i32 noundef %39)
  %41 = sext i32 %40 to i64
  %42 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %38, i64 noundef %41) #2
  %43 = getelementptr inbounds %"struct.MinHeap::Node", ptr %42, i32 0, i32 1
  %44 = load double, ptr %43, align 8, !tbaa !19
  %45 = getelementptr inbounds %class.MinHeap, ptr %8, i32 0, i32 0
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %45, i64 noundef %47) #2
  %49 = getelementptr inbounds %"struct.MinHeap::Node", ptr %48, i32 0, i32 1
  %50 = load double, ptr %49, align 8, !tbaa !19
  %51 = fcmp ogt double %44, %50
  br label %52

52:                                               ; preds = %37, %34
  %53 = phi i1 [ false, %34 ], [ %51, %37 ]
  br i1 %53, label %54, label %66

54:                                               ; preds = %52
  %55 = getelementptr inbounds %class.MinHeap, ptr %8, i32 0, i32 0
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = call noundef i32 @_ZN7MinHeap6parentEi(ptr noundef nonnull align 8 dereferenceable(28) %8, i32 noundef %56)
  %58 = sext i32 %57 to i64
  %59 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %55, i64 noundef %58) #2
  %60 = getelementptr inbounds %class.MinHeap, ptr %8, i32 0, i32 0
  %61 = load i32, ptr %6, align 4, !tbaa !9
  %62 = sext i32 %61 to i64
  %63 = call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %60, i64 noundef %62) #2
  call void @_ZN7MinHeap4swapERNS_4NodeES1_(ptr noundef nonnull align 8 dereferenceable(28) %8, ptr noundef nonnull align 8 dereferenceable(16) %59, ptr noundef nonnull align 8 dereferenceable(16) %63)
  %64 = load i32, ptr %6, align 4, !tbaa !9
  %65 = call noundef i32 @_ZN7MinHeap6parentEi(ptr noundef nonnull align 8 dereferenceable(28) %8, i32 noundef %64)
  store i32 %65, ptr %6, align 4, !tbaa !9
  br label %34, !llvm.loop !22

66:                                               ; preds = %52
  store i1 true, ptr %4, align 1
  br label %67

67:                                               ; preds = %66, %26, %16
  %68 = load i1, ptr %4, align 1
  ret i1 %68
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7MinHeap6parentEi(ptr noundef nonnull align 8 dereferenceable(28), i32 noundef) #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7MinHeap4swapERNS_4NodeES1_(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) #0 align 2

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 = { 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 #2 = { 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, !12, i64 0}
!12 = !{!"double", !7, i64 0}
!13 = !{!14, !10, i64 24}
!14 = !{!"_ZTS7MinHeap", !15, i64 0, !10, i64 24}
!15 = !{!"_ZTSSt6vectorIN7MinHeap4NodeESaIS1_EE", !16, i64 0}
!16 = !{!"_ZTSSt12_Vector_baseIN7MinHeap4NodeESaIS1_EE", !17, i64 0}
!17 = !{!"_ZTSNSt12_Vector_baseIN7MinHeap4NodeESaIS1_EE12_Vector_implE", !18, i64 0}
!18 = !{!"_ZTSNSt12_Vector_baseIN7MinHeap4NodeESaIS1_EE17_Vector_impl_dataE", !6, i64 0, !6, i64 8, !6, i64 16}
!19 = !{!20, !12, i64 8}
!20 = !{!"_ZTSN7MinHeap4NodeE", !21, i64 0, !12, i64 8}
!21 = !{!"_ZTS5Point", !10, i64 0, !10, i64 4}
!22 = distinct !{!22, !23}
!23 = !{!"llvm.loop.mustprogress"}


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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_ZN7MinHeap11decreaseKeyEid(ptr noundef nonnull align 8 dereferenceable(28) %0, i32 noundef %1, double noundef %2) local_unnamed_addr #0 align 2 {
  %4 = icmp sgt i32 %1, -1
  %5 = getelementptr inbounds i8, ptr %0, i64 24
  %6 = load i32, ptr %5, align 8
  %.not = icmp slt i32 %6, %1
  %or.cond = select i1 %4, i1 true, i1 %.not
  br i1 %or.cond, label %7, label %.critedge

7:                                                ; preds = %3
  %8 = sext i32 %1 to i64
  %9 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %8) #1
  %10 = getelementptr inbounds i8, ptr %9, i64 8
  %11 = load double, ptr %10, align 8, !tbaa !5
  %12 = fcmp olt double %11, %2
  br i1 %12, label %.critedge, label %13

13:                                               ; preds = %7
  %14 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %8) #1
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  store double %2, ptr %15, align 8, !tbaa !5
  %16 = icmp sgt i32 %1, 0
  br i1 %16, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %13, %27
  %.01317 = phi i32 [ %32, %27 ], [ %1, %13 ]
  %17 = tail call noundef i32 @_ZN7MinHeap6parentEi(ptr noundef nonnull align 8 dereferenceable(28) %0, i32 noundef %.01317)
  %18 = sext i32 %17 to i64
  %19 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %18) #1
  %20 = getelementptr inbounds i8, ptr %19, i64 8
  %21 = load double, ptr %20, align 8, !tbaa !5
  %22 = zext nneg i32 %.01317 to i64
  %23 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %22) #1
  %24 = getelementptr inbounds i8, ptr %23, i64 8
  %25 = load double, ptr %24, align 8, !tbaa !5
  %26 = fcmp ogt double %21, %25
  br i1 %26, label %27, label %.critedge

27:                                               ; preds = %.lr.ph
  %28 = tail call noundef i32 @_ZN7MinHeap6parentEi(ptr noundef nonnull align 8 dereferenceable(28) %0, i32 noundef %.01317)
  %29 = sext i32 %28 to i64
  %30 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %29) #1
  %31 = tail call noundef nonnull align 8 dereferenceable(16) ptr @_ZNSt6vectorIN7MinHeap4NodeESaIS1_EEixEm(ptr noundef nonnull align 8 dereferenceable(24) %0, i64 noundef %22) #1
  tail call void @_ZN7MinHeap4swapERNS_4NodeES1_(ptr noundef nonnull align 8 dereferenceable(28) %0, ptr noundef nonnull align 8 dereferenceable(16) %30, ptr noundef nonnull align 8 dereferenceable(16) %31)
  %32 = tail call noundef i32 @_ZN7MinHeap6parentEi(ptr noundef nonnull align 8 dereferenceable(28) %0, i32 noundef %.01317)
  %33 = icmp sgt i32 %32, 0
  br i1 %33, label %.lr.ph, label %.critedge, !llvm.loop !12

.critedge:                                        ; preds = %27, %.lr.ph, %13, %7, %3
  %.0 = phi i1 [ false, %3 ], [ false, %7 ], [ true, %13 ], [ true, %.lr.ph ], [ true, %27 ]
  ret i1 %.0
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef i32 @_ZN7MinHeap6parentEi(ptr noundef nonnull align 8 dereferenceable(28), i32 noundef) local_unnamed_addr #0 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN7MinHeap4swapERNS_4NodeES1_(ptr noundef nonnull align 8 dereferenceable(28), ptr noundef nonnull align 8 dereferenceable(16), ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #0 align 2

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, !11, i64 8}
!6 = !{!"_ZTSN7MinHeap4NodeE", !7, i64 0, !11, i64 8}
!7 = !{!"_ZTS5Point", !8, i64 0, !8, i64 4}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"double", !9, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass