; LLVM IR from Dev-XYS/Algorithms :: Fibonacci-Heap.ll (ZN13FibonacciHeap11extract_minEv)

; 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.FibonacciHeap = type { ptr, i64 }
%"struct.FibonacciHeap::node" = type <{ ptr, ptr, ptr, ptr, i32, i32, i8, [7 x i8] }>

@_ZZN13FibonacciHeap11extract_minEvE10child_list = external hidden global [100010 x ptr], align 16

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

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

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

; 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
define dso_local noundef i32 @_ZN13FibonacciHeap11extract_minEv(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
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %8 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %9 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = getelementptr inbounds %"struct.FibonacciHeap::node", ptr %10, i32 0, i32 4
  %12 = load i32, ptr %11, align 8, !tbaa !12
  store i32 %12, ptr %3, align 4, !tbaa !16
  %13 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %71

16:                                               ; preds = %1
  %17 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 1
  %18 = load i64, ptr %17, align 8, !tbaa !17
  %19 = icmp eq i64 %18, 1
  br i1 %19, label %20, label %22

20:                                               ; preds = %16
  %21 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  store ptr null, ptr %21, align 8, !tbaa !9
  br label %70

22:                                               ; preds = %16
  %23 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  %25 = getelementptr inbounds %"struct.FibonacciHeap::node", ptr %24, i32 0, i32 0
  %26 = load ptr, ptr %25, align 8, !tbaa !18
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %62

28:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %29 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !9
  %31 = getelementptr inbounds %"struct.FibonacciHeap::node", ptr %30, i32 0, i32 0
  %32 = load ptr, ptr %31, align 8, !tbaa !18
  store ptr %32, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %33, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  store i32 0, ptr %6, align 4, !tbaa !16
  br label %34

34:                                               ; preds = %43, %28
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load i32, ptr %6, align 4, !tbaa !16
  %37 = add nsw i32 %36, 1
  store i32 %37, ptr %6, align 4, !tbaa !16
  %38 = sext i32 %36 to i64
  %39 = getelementptr inbounds [100010 x ptr], ptr @_ZZN13FibonacciHeap11extract_minEvE10child_list, i64 0, i64 %38
  store ptr %35, ptr %39, align 8, !tbaa !5
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.FibonacciHeap::node", ptr %40, i32 0, i32 3
  %42 = load ptr, ptr %41, align 8, !tbaa !19
  store ptr %42, ptr %5, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %34
  %44 = load ptr, ptr %5, align 8, !tbaa !5
  %45 = load ptr, ptr %4, align 8, !tbaa !5
  %46 = icmp ne ptr %44, %45
  br i1 %46, label %34, label %47, !llvm.loop !20

47:                                               ; preds = %43
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  store i32 0, ptr %7, align 4, !tbaa !16
  br label %48

48:                                               ; preds = %58, %47
  %49 = load i32, ptr %7, align 4, !tbaa !16
  %50 = load i32, ptr %6, align 4, !tbaa !16
  %51 = icmp slt i32 %49, %50
  br i1 %51, label %53, label %52

52:                                               ; preds = %48
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  br label %61

53:                                               ; preds = %48
  %54 = load i32, ptr %7, align 4, !tbaa !16
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [100010 x ptr], ptr @_ZZN13FibonacciHeap11extract_minEvE10child_list, i64 0, i64 %55
  %57 = load ptr, ptr %56, align 8, !tbaa !5
  call void @_ZN13FibonacciHeap22_M_insert_to_root_listEPNS_4nodeE(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %57)
  br label %58

58:                                               ; preds = %53
  %59 = load i32, ptr %7, align 4, !tbaa !16
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %7, align 4, !tbaa !16
  br label %48, !llvm.loop !22

61:                                               ; preds = %52
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %62

62:                                               ; preds = %61, %22
  %63 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !9
  call void @_ZN13FibonacciHeap24_M_remove_from_root_listEPNS_4nodeE(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %64)
  %65 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = getelementptr inbounds %"struct.FibonacciHeap::node", ptr %66, i32 0, i32 3
  %68 = load ptr, ptr %67, align 8, !tbaa !19
  %69 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  store ptr %68, ptr %69, align 8, !tbaa !9
  call void @_ZN13FibonacciHeap14_M_consolidateEv(ptr noundef nonnull align 8 dereferenceable(16) %8)
  br label %70

70:                                               ; preds = %62, %20
  br label %71

71:                                               ; preds = %70, %1
  %72 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 1
  %73 = load i64, ptr %72, align 8, !tbaa !17
  %74 = add i64 %73, -1
  store i64 %74, ptr %72, align 8, !tbaa !17
  %75 = load i32, ptr %3, align 4, !tbaa !16
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %75
}

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 = { 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 0}
!10 = !{!"_ZTS13FibonacciHeap", !6, i64 0, !11, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!13, !14, i64 32}
!13 = !{!"_ZTSN13FibonacciHeap4nodeE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !14, i64 32, !14, i64 36, !15, i64 40}
!14 = !{!"int", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!14, !14, i64 0}
!17 = !{!10, !11, i64 8}
!18 = !{!13, !6, i64 0}
!19 = !{!13, !6, i64 24}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}


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

@_ZZN13FibonacciHeap11extract_minEvE10child_list = external hidden local_unnamed_addr global [100010 x ptr], align 16

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

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef i32 @_ZN13FibonacciHeap11extract_minEv(ptr noundef nonnull align 8 dereferenceable(16) %0) local_unnamed_addr #0 align 2 {
  %2 = load ptr, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %2, i64 32
  %4 = load i32, ptr %3, align 8, !tbaa !11
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = load i64, ptr %5, align 8, !tbaa !15
  %7 = icmp eq i64 %6, 1
  br i1 %7, label %8, label %9

8:                                                ; preds = %1
  store ptr null, ptr %0, align 8, !tbaa !5
  br label %22

9:                                                ; preds = %1
  %10 = load ptr, ptr %2, align 8, !tbaa !16
  %.not15 = icmp eq ptr %10, null
  br i1 %.not15, label %.loopexit, label %.preheader18

.preheader18:                                     ; preds = %9, %.preheader18
  %indvars.iv24 = phi i32 [ %indvars.iv.next25, %.preheader18 ], [ 1, %9 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.preheader18 ], [ 0, %9 ]
  %.012 = phi ptr [ %13, %.preheader18 ], [ %10, %9 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %11 = getelementptr inbounds [100010 x ptr], ptr @_ZZN13FibonacciHeap11extract_minEvE10child_list, i64 0, i64 %indvars.iv
  store ptr %.012, ptr %11, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %.012, i64 24
  %13 = load ptr, ptr %12, align 8, !tbaa !18
  %.not16 = icmp eq ptr %13, %10
  %indvars.iv.next25 = add nuw i32 %indvars.iv24, 1
  br i1 %.not16, label %.preheader, label %.preheader18, !llvm.loop !19

.preheader:                                       ; preds = %.preheader18
  %wide.trip.count = zext i32 %indvars.iv24 to i64
  br label %14

14:                                               ; preds = %.preheader, %14
  %indvars.iv21 = phi i64 [ 0, %.preheader ], [ %indvars.iv.next22, %14 ]
  %15 = getelementptr inbounds [100010 x ptr], ptr @_ZZN13FibonacciHeap11extract_minEvE10child_list, i64 0, i64 %indvars.iv21
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  tail call void @_ZN13FibonacciHeap22_M_insert_to_root_listEPNS_4nodeE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %16)
  %indvars.iv.next22 = add nuw nsw i64 %indvars.iv21, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next22, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit.loopexit, label %14, !llvm.loop !21

.loopexit.loopexit:                               ; preds = %14
  %.pre = load ptr, ptr %0, align 8, !tbaa !5
  br label %.loopexit

.loopexit:                                        ; preds = %.loopexit.loopexit, %9
  %17 = phi ptr [ %.pre, %.loopexit.loopexit ], [ %2, %9 ]
  tail call void @_ZN13FibonacciHeap24_M_remove_from_root_listEPNS_4nodeE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef %17)
  %18 = load ptr, ptr %0, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 24
  %20 = load ptr, ptr %19, align 8, !tbaa !18
  store ptr %20, ptr %0, align 8, !tbaa !5
  tail call void @_ZN13FibonacciHeap14_M_consolidateEv(ptr noundef nonnull align 8 dereferenceable(16) %0)
  %.pre26 = load i64, ptr %5, align 8, !tbaa !15
  %21 = add i64 %.pre26, -1
  br label %22

22:                                               ; preds = %8, %.loopexit
  %23 = phi i64 [ 0, %8 ], [ %21, %.loopexit ]
  store i64 %23, ptr %5, align 8, !tbaa !15
  ret i32 %4
}

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

!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 0}
!6 = !{!"_ZTS13FibonacciHeap", !7, i64 0, !10, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!12, !13, i64 32}
!12 = !{!"_ZTSN13FibonacciHeap4nodeE", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !13, i64 32, !13, i64 36, !14, i64 40}
!13 = !{!"int", !8, i64 0}
!14 = !{!"bool", !8, i64 0}
!15 = !{!6, !10, i64 8}
!16 = !{!12, !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!12, !7, i64 24}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass