; LLVM IR from ahampriyanshu/algo-ds-101 :: Data-Structures/Tree/Fibonacci-Heap (Fibonacci-Heap)

; 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._NODE = type { i32, i32, ptr, ptr, ptr, ptr, i8, i8 }
%struct.fibanocci_heap = type { i32, ptr, i32, i32 }

; Function Attrs: nounwind uwtable
define dso_local void @fib_heap_link(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %5, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._NODE, ptr %7, i32 0, i32 2
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = load ptr, ptr %5, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct._NODE, ptr %10, i32 0, i32 3
  %12 = load ptr, ptr %11, align 8, !tbaa !13
  %13 = getelementptr inbounds %struct._NODE, ptr %12, i32 0, i32 2
  store ptr %9, ptr %13, align 8, !tbaa !9
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._NODE, ptr %14, i32 0, i32 3
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._NODE, ptr %17, i32 0, i32 2
  %19 = load ptr, ptr %18, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct._NODE, ptr %19, i32 0, i32 3
  store ptr %16, ptr %20, align 8, !tbaa !13
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._NODE, ptr %21, i32 0, i32 3
  %23 = load ptr, ptr %22, align 8, !tbaa !13
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = icmp eq ptr %23, %24
  br i1 %25, label %26, label %30

26:                                               ; preds = %3
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.fibanocci_heap, ptr %28, i32 0, i32 1
  store ptr %27, ptr %29, align 8, !tbaa !14
  br label %30

30:                                               ; preds = %26, %3
  %31 = load ptr, ptr %5, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._NODE, ptr %32, i32 0, i32 2
  store ptr %31, ptr %33, align 8, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._NODE, ptr %35, i32 0, i32 3
  store ptr %34, ptr %36, align 8, !tbaa !13
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._NODE, ptr %38, i32 0, i32 4
  store ptr %37, ptr %39, align 8, !tbaa !16
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._NODE, ptr %40, i32 0, i32 5
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = icmp eq ptr %42, null
  br i1 %43, label %44, label %48

44:                                               ; preds = %30
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct._NODE, ptr %46, i32 0, i32 5
  store ptr %45, ptr %47, align 8, !tbaa !17
  br label %48

48:                                               ; preds = %44, %30
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._NODE, ptr %49, i32 0, i32 5
  %51 = load ptr, ptr %50, align 8, !tbaa !17
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._NODE, ptr %52, i32 0, i32 3
  store ptr %51, ptr %53, align 8, !tbaa !13
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct._NODE, ptr %54, i32 0, i32 5
  %56 = load ptr, ptr %55, align 8, !tbaa !17
  %57 = getelementptr inbounds %struct._NODE, ptr %56, i32 0, i32 2
  %58 = load ptr, ptr %57, align 8, !tbaa !9
  %59 = load ptr, ptr %5, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._NODE, ptr %59, i32 0, i32 2
  store ptr %58, ptr %60, align 8, !tbaa !9
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct._NODE, ptr %62, i32 0, i32 5
  %64 = load ptr, ptr %63, align 8, !tbaa !17
  %65 = getelementptr inbounds %struct._NODE, ptr %64, i32 0, i32 2
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  %67 = getelementptr inbounds %struct._NODE, ptr %66, i32 0, i32 3
  store ptr %61, ptr %67, align 8, !tbaa !13
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load ptr, ptr %6, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct._NODE, ptr %69, i32 0, i32 5
  %71 = load ptr, ptr %70, align 8, !tbaa !17
  %72 = getelementptr inbounds %struct._NODE, ptr %71, i32 0, i32 2
  store ptr %68, ptr %72, align 8, !tbaa !9
  %73 = load ptr, ptr %5, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._NODE, ptr %73, i32 0, i32 0
  %75 = load i32, ptr %74, align 8, !tbaa !18
  %76 = load ptr, ptr %6, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._NODE, ptr %76, i32 0, i32 5
  %78 = load ptr, ptr %77, align 8, !tbaa !17
  %79 = getelementptr inbounds %struct._NODE, ptr %78, i32 0, i32 0
  %80 = load i32, ptr %79, align 8, !tbaa !18
  %81 = icmp slt i32 %75, %80
  br i1 %81, label %82, label %86

82:                                               ; preds = %48
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct._NODE, ptr %84, i32 0, i32 5
  store ptr %83, ptr %85, align 8, !tbaa !17
  br label %86

86:                                               ; preds = %82, %48
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct._NODE, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !19
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %88, align 4, !tbaa !19
  ret void
}

attributes #0 = { 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, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"_NODE", !11, i64 0, !11, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !12, i64 40, !12, i64 41}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!10, !6, i64 16}
!14 = !{!15, !6, i64 8}
!15 = !{!"fibanocci_heap", !11, i64 0, !6, i64 8, !11, i64 16, !11, i64 20}
!16 = !{!10, !6, i64 24}
!17 = !{!10, !6, i64 32}
!18 = !{!10, !11, i64 0}
!19 = !{!10, !11, i64 4}


; 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 nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) uwtable
define dso_local void @fib_heap_link(ptr nocapture noundef writeonly %0, ptr noundef %1, ptr noundef %2) local_unnamed_addr #0 {
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %1, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !12
  %8 = getelementptr inbounds i8, ptr %7, i64 8
  store ptr %5, ptr %8, align 8, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr %7, ptr %9, align 8, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %2, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %12 = icmp eq ptr %11, %2
  br i1 %12, label %13, label %15

13:                                               ; preds = %3
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %2, ptr %14, align 8, !tbaa !13
  br label %15

15:                                               ; preds = %13, %3
  store ptr %1, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %1, i64 24
  store ptr %2, ptr %16, align 8, !tbaa !15
  %17 = getelementptr inbounds i8, ptr %2, i64 32
  %18 = load ptr, ptr %17, align 8, !tbaa !16
  %19 = icmp eq ptr %18, null
  br i1 %19, label %20, label %21

20:                                               ; preds = %15
  store ptr %1, ptr %17, align 8, !tbaa !16
  br label %21

21:                                               ; preds = %20, %15
  %22 = phi ptr [ %1, %20 ], [ %18, %15 ]
  store ptr %22, ptr %6, align 8, !tbaa !12
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  %24 = load ptr, ptr %23, align 8, !tbaa !5
  store ptr %24, ptr %4, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %24, i64 16
  store ptr %1, ptr %25, align 8, !tbaa !12
  store ptr %1, ptr %23, align 8, !tbaa !5
  %26 = load i32, ptr %1, align 8, !tbaa !17
  %27 = load i32, ptr %22, align 8, !tbaa !17
  %28 = icmp slt i32 %26, %27
  br i1 %28, label %29, label %30

29:                                               ; preds = %21
  store ptr %1, ptr %17, align 8, !tbaa !16
  br label %30

30:                                               ; preds = %29, %21
  %31 = getelementptr inbounds i8, ptr %2, i64 4
  %32 = load i32, ptr %31, align 4, !tbaa !18
  %33 = add nsw i32 %32, 1
  store i32 %33, ptr %31, align 4, !tbaa !18
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(readwrite, inaccessiblemem: none) 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, !10, i64 8}
!6 = !{!"_NODE", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !11, i64 41}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !10, i64 16}
!13 = !{!14, !10, i64 8}
!14 = !{!"fibanocci_heap", !7, i64 0, !10, i64 8, !7, i64 16, !7, i64 20}
!15 = !{!6, !10, i64 24}
!16 = !{!6, !10, i64 32}
!17 = !{!6, !7, i64 0}
!18 = !{!6, !7, i64 4}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass