; LLVM IR from ahampriyanshu/algo-ds-101 :: Algorithms/Graph/Dijkstra/dijkstra_leftist_heap (leftistHeap)

; 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.LeftistHeap = type { ptr, ptr }
%class.Node = type { %"struct.std::pair", i32, ptr, ptr, ptr }
%"struct.std::pair" = type { float, i32 }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN11LeftistHeap9deleteMinEv(ptr noundef nonnull align 8 dereferenceable(16) %0) #0 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  %6 = call noundef zeroext i1 @_ZN11LeftistHeap7isEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %5)
  br i1 %6, label %57, label %7

7:                                                ; preds = %1
  %8 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 1
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  %10 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 0
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = getelementptr inbounds %class.Node, ptr %11, i32 0, i32 0
  %13 = getelementptr inbounds %"struct.std::pair", ptr %12, i32 0, i32 0
  %14 = load float, ptr %13, align 8, !tbaa !12
  %15 = fptosi float %14 to i32
  store i32 %15, ptr %3, align 4, !tbaa !17
  %16 = call noundef i64 @_ZNSt13unordered_mapIiP4NodeSt4hashIiESt8equal_toIiESaISt4pairIKiS1_EEE5eraseERS7_(ptr noundef nonnull align 8 dereferenceable(56) %9, ptr noundef nonnull align 4 dereferenceable(4) %3)
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %17 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  store ptr %18, ptr %4, align 8, !tbaa !5
  %19 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds %class.Node, ptr %20, i32 0, i32 3
  %22 = load ptr, ptr %21, align 8, !tbaa !18
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %30

24:                                               ; preds = %7
  %25 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !11
  %27 = getelementptr inbounds %class.Node, ptr %26, i32 0, i32 3
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  %29 = getelementptr inbounds %class.Node, ptr %28, i32 0, i32 2
  store ptr null, ptr %29, align 8, !tbaa !19
  br label %30

30:                                               ; preds = %24, %7
  %31 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = getelementptr inbounds %class.Node, ptr %32, i32 0, i32 4
  %34 = load ptr, ptr %33, align 8, !tbaa !20
  %35 = icmp ne ptr %34, null
  br i1 %35, label %36, label %42

36:                                               ; preds = %30
  %37 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 0
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds %class.Node, ptr %38, i32 0, i32 4
  %40 = load ptr, ptr %39, align 8, !tbaa !20
  %41 = getelementptr inbounds %class.Node, ptr %40, i32 0, i32 2
  store ptr null, ptr %41, align 8, !tbaa !19
  br label %42

42:                                               ; preds = %36, %30
  %43 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !11
  %45 = getelementptr inbounds %class.Node, ptr %44, i32 0, i32 3
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 0
  %48 = load ptr, ptr %47, align 8, !tbaa !11
  %49 = getelementptr inbounds %class.Node, ptr %48, i32 0, i32 4
  %50 = load ptr, ptr %49, align 8, !tbaa !20
  %51 = call noundef ptr @_ZN11LeftistHeap10mergeHeapsEP4NodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %5, ptr noundef %46, ptr noundef %50)
  %52 = getelementptr inbounds %class.LeftistHeap, ptr %5, i32 0, i32 0
  store ptr %51, ptr %52, align 8, !tbaa !11
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = icmp eq ptr %53, null
  br i1 %54, label %56, label %55

55:                                               ; preds = %42
  call void @_ZdlPvm(ptr noundef %53, i64 noundef 40) #5
  br label %56

56:                                               ; preds = %55, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %57

57:                                               ; preds = %56, %1
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11LeftistHeap7isEmptyEv(ptr noundef nonnull align 8 dereferenceable(16)) #1 align 2

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

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

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #3

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 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 = { nobuiltin nounwind "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 }
attributes #5 = { builtin 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, !6, i64 8}
!10 = !{!"_ZTS11LeftistHeap", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 0}
!12 = !{!13, !15, i64 0}
!13 = !{!"_ZTS4Node", !14, i64 0, !16, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!14 = !{!"_ZTSSt4pairIfiE", !15, i64 0, !16, i64 4}
!15 = !{!"float", !7, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!16, !16, i64 0}
!18 = !{!13, !6, i64 24}
!19 = !{!13, !6, i64 16}
!20 = !{!13, !6, i64 32}


; 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 uwtable
define dso_local void @_ZN11LeftistHeap9deleteMinEv(ptr noundef nonnull align 8 dereferenceable(16) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca i32, align 4
  %3 = tail call noundef zeroext i1 @_ZN11LeftistHeap7isEmptyEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  br i1 %3, label %23, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  %7 = load ptr, ptr %0, align 8, !tbaa !10
  %8 = load float, ptr %7, align 8, !tbaa !11
  %9 = fptosi float %8 to i32
  store i32 %9, ptr %2, align 4, !tbaa !16
  %10 = call noundef i64 @_ZNSt13unordered_mapIiP4NodeSt4hashIiESt8equal_toIiESaISt4pairIKiS1_EEE5eraseERS7_(ptr noundef nonnull align 8 dereferenceable(56) %6, ptr noundef nonnull align 4 dereferenceable(4) %2)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  %11 = load ptr, ptr %0, align 8, !tbaa !10
  %12 = getelementptr inbounds i8, ptr %11, i64 24
  %13 = load ptr, ptr %12, align 8, !tbaa !17
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %16, label %14

14:                                               ; preds = %4
  %15 = getelementptr inbounds i8, ptr %13, i64 16
  store ptr null, ptr %15, align 8, !tbaa !18
  br label %16

16:                                               ; preds = %14, %4
  %17 = getelementptr inbounds i8, ptr %11, i64 32
  %18 = load ptr, ptr %17, align 8, !tbaa !19
  %.not4 = icmp eq ptr %18, null
  br i1 %.not4, label %21, label %19

19:                                               ; preds = %16
  %20 = getelementptr inbounds i8, ptr %18, i64 16
  store ptr null, ptr %20, align 8, !tbaa !18
  br label %21

21:                                               ; preds = %16, %19
  %22 = call noundef ptr @_ZN11LeftistHeap10mergeHeapsEP4NodeS1_(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %13, ptr noundef %18)
  store ptr %22, ptr %0, align 8, !tbaa !10
  call void @_ZdlPvm(ptr noundef nonnull %11, i64 noundef 40) #5
  br label %23

23:                                               ; preds = %21, %1
  ret void
}

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_ZN11LeftistHeap7isEmptyEv(ptr noundef nonnull align 8 dereferenceable(16)) local_unnamed_addr #1 align 2

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

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

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

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

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) local_unnamed_addr #3

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 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nobuiltin nounwind "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 }
attributes #5 = { builtin 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, !7, i64 8}
!6 = !{!"_ZTS11LeftistHeap", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 0}
!11 = !{!12, !14, i64 0}
!12 = !{!"_ZTS4Node", !13, i64 0, !15, i64 8, !7, i64 16, !7, i64 24, !7, i64 32}
!13 = !{!"_ZTSSt4pairIfiE", !14, i64 0, !15, i64 4}
!14 = !{!"float", !8, i64 0}
!15 = !{!"int", !8, i64 0}
!16 = !{!15, !15, i64 0}
!17 = !{!12, !7, i64 24}
!18 = !{!12, !7, i64 16}
!19 = !{!12, !7, i64 32}


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