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

; 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] }>

; 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: 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 uwtable
define dso_local void @_ZN13FibonacciHeap6insertEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %1) #2 align 2 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %8 = load ptr, ptr %3, align 8
  %9 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = icmp eq ptr %10, null
  br i1 %11, label %12, label %29

12:                                               ; preds = %2
  %13 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 48) #5
  %14 = load i32, ptr %4, align 4, !tbaa !9
  invoke void @_ZN13FibonacciHeap4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(41) %13, i32 noundef %14)
          to label %15 unwind label %25

15:                                               ; preds = %12
  %16 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  store ptr %13, ptr %16, align 8, !tbaa !11
  %17 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = getelementptr inbounds %"struct.FibonacciHeap::node", ptr %20, i32 0, i32 3
  store ptr %18, ptr %21, align 8, !tbaa !14
  %22 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = getelementptr inbounds %"struct.FibonacciHeap::node", ptr %23, i32 0, i32 2
  store ptr %18, ptr %24, align 8, !tbaa !17
  br label %48

25:                                               ; preds = %12
  %26 = landingpad { ptr, i32 }
          cleanup
  %27 = extractvalue { ptr, i32 } %26, 0
  store ptr %27, ptr %5, align 8
  %28 = extractvalue { ptr, i32 } %26, 1
  store i32 %28, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %13, i64 noundef 48) #6
  br label %52

29:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #7
  %30 = call noalias noundef nonnull ptr @_Znwm(i64 noundef 48) #5
  %31 = load i32, ptr %4, align 4, !tbaa !9
  invoke void @_ZN13FibonacciHeap4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(41) %30, i32 noundef %31)
          to label %32 unwind label %43

32:                                               ; preds = %29
  store ptr %30, ptr %7, align 8, !tbaa !5
  %33 = load ptr, ptr %7, align 8, !tbaa !5
  call void @_ZN13FibonacciHeap22_M_insert_to_root_listEPNS_4nodeE(ptr noundef nonnull align 8 dereferenceable(16) %8, ptr noundef %33)
  %34 = load i32, ptr %4, align 4, !tbaa !9
  %35 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  %36 = load ptr, ptr %35, align 8, !tbaa !11
  %37 = getelementptr inbounds %"struct.FibonacciHeap::node", ptr %36, i32 0, i32 4
  %38 = load i32, ptr %37, align 8, !tbaa !18
  %39 = icmp slt i32 %34, %38
  br i1 %39, label %40, label %47

40:                                               ; preds = %32
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 0
  store ptr %41, ptr %42, align 8, !tbaa !11
  br label %47

43:                                               ; preds = %29
  %44 = landingpad { ptr, i32 }
          cleanup
  %45 = extractvalue { ptr, i32 } %44, 0
  store ptr %45, ptr %5, align 8
  %46 = extractvalue { ptr, i32 } %44, 1
  store i32 %46, ptr %6, align 4
  call void @_ZdlPvm(ptr noundef %30, i64 noundef 48) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %52

47:                                               ; preds = %40, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #7
  br label %48

48:                                               ; preds = %47, %15
  %49 = getelementptr inbounds %class.FibonacciHeap, ptr %8, i32 0, i32 1
  %50 = load i64, ptr %49, align 8, !tbaa !19
  %51 = add i64 %50, 1
  store i64 %51, ptr %49, align 8, !tbaa !19
  ret void

52:                                               ; preds = %43, %25
  %53 = load ptr, ptr %5, align 8
  %54 = load i32, ptr %6, align 4
  %55 = insertvalue { ptr, i32 } poison, ptr %53, 0
  %56 = insertvalue { ptr, i32 } %55, i32 %54, 1
  resume { ptr, i32 } %56
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) #3

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN13FibonacciHeap4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(41), i32 noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nobuiltin nounwind
declare void @_ZdlPvm(ptr noundef, i64 noundef) #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" }
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 = { nobuiltin allocsize(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 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { builtin nounwind }
attributes #7 = { 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 0}
!12 = !{!"_ZTS13FibonacciHeap", !6, i64 0, !13, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !6, i64 24}
!15 = !{!"_ZTSN13FibonacciHeap4nodeE", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !16, i64 40}
!16 = !{!"bool", !7, i64 0}
!17 = !{!15, !6, i64 16}
!18 = !{!15, !10, i64 32}
!19 = !{!12, !13, 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"

; 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 uwtable
define dso_local void @_ZN13FibonacciHeap6insertEi(ptr noundef nonnull align 8 dereferenceable(16) %0, i32 noundef %1) local_unnamed_addr #1 align 2 personality ptr @__gxx_personality_v0 {
  %3 = load ptr, ptr %0, align 8, !tbaa !5
  %4 = icmp eq ptr %3, null
  %5 = tail call noalias noundef nonnull dereferenceable(48) ptr @_Znwm(i64 noundef 48) #3
  tail call void @_ZN13FibonacciHeap4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(41) %5, i32 noundef %1)
  br i1 %4, label %6, label %9

6:                                                ; preds = %2
  store ptr %5, ptr %0, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr %5, ptr %7, align 8, !tbaa !11
  %8 = getelementptr inbounds i8, ptr %5, i64 16
  br label %.sink.split

9:                                                ; preds = %2
  tail call void @_ZN13FibonacciHeap22_M_insert_to_root_listEPNS_4nodeE(ptr noundef nonnull align 8 dereferenceable(16) %0, ptr noundef nonnull %5)
  %10 = load ptr, ptr %0, align 8, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %10, i64 32
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %13 = icmp sgt i32 %12, %1
  br i1 %13, label %.sink.split, label %14

.sink.split:                                      ; preds = %9, %6
  %.sink = phi ptr [ %8, %6 ], [ %0, %9 ]
  store ptr %5, ptr %.sink, align 8, !tbaa !16
  br label %14

14:                                               ; preds = %.sink.split, %9
  %15 = getelementptr inbounds i8, ptr %0, i64 8
  %16 = load i64, ptr %15, align 8, !tbaa !17
  %17 = add i64 %16, 1
  store i64 %17, ptr %15, align 8, !tbaa !17
  ret void
}

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN13FibonacciHeap4nodeC2Ei(ptr noundef nonnull align 8 dereferenceable(41), i32 noundef) unnamed_addr #0 align 2

declare i32 @__gxx_personality_v0(...)

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 = { nobuiltin allocsize(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 = { builtin allocsize(0) }

!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, !7, i64 24}
!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 = !{!12, !13, i64 32}
!16 = !{!7, !7, i64 0}
!17 = !{!6, !10, i64 8}


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