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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @decrease_key(ptr noundef, ptr noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @find_node(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) #1 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  %12 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %12, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #2
  store ptr null, ptr %11, align 8, !tbaa !5
  %13 = load ptr, ptr %10, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._NODE, ptr %13, i32 0, i32 7
  store i8 1, ptr %14, align 1, !tbaa !11
  %15 = load ptr, ptr %10, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct._NODE, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !14
  %18 = load i32, ptr %8, align 4, !tbaa !9
  %19 = icmp eq i32 %17, %18
  br i1 %19, label %20, label %27

20:                                               ; preds = %4
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._NODE, ptr %21, i32 0, i32 7
  store i8 0, ptr %22, align 1, !tbaa !11
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %23, ptr %11, align 8, !tbaa !5
  %24 = load ptr, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %11, align 8, !tbaa !5
  %26 = load i32, ptr %9, align 4, !tbaa !9
  call void @decrease_key(ptr noundef %24, ptr noundef %25, i32 noundef %26)
  br label %27

27:                                               ; preds = %20, %4
  %28 = load ptr, ptr %10, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._NODE, ptr %28, i32 0, i32 5
  %30 = load ptr, ptr %29, align 8, !tbaa !15
  %31 = icmp ne ptr %30, null
  br i1 %31, label %32, label %40

32:                                               ; preds = %27
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._NODE, ptr %34, i32 0, i32 5
  %36 = load ptr, ptr %35, align 8, !tbaa !15
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = call ptr @find_node(ptr noundef %33, ptr noundef %36, i32 noundef %37, i32 noundef %38)
  br label %40

40:                                               ; preds = %32, %27
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._NODE, ptr %41, i32 0, i32 3
  %43 = load ptr, ptr %42, align 8, !tbaa !16
  %44 = getelementptr inbounds %struct._NODE, ptr %43, i32 0, i32 7
  %45 = load i8, ptr %44, align 1, !tbaa !11, !range !17, !noundef !18
  %46 = trunc i8 %45 to i1
  %47 = zext i1 %46 to i32
  %48 = icmp ne i32 %47, 1
  br i1 %48, label %49, label %57

49:                                               ; preds = %40
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = load ptr, ptr %10, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._NODE, ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !16
  %54 = load i32, ptr %8, align 4, !tbaa !9
  %55 = load i32, ptr %9, align 4, !tbaa !9
  %56 = call ptr @find_node(ptr noundef %50, ptr noundef %53, i32 noundef %54, i32 noundef %55)
  br label %57

57:                                               ; preds = %49, %40
  %58 = load ptr, ptr %10, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._NODE, ptr %58, i32 0, i32 7
  store i8 0, ptr %59, align 1, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  %60 = load ptr, ptr %5, align 8
  ret ptr %60
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 41}
!12 = !{!"_NODE", !10, i64 0, !10, i64 4, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !13, i64 40, !13, i64 41}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!12, !10, i64 0}
!15 = !{!12, !6, i64 32}
!16 = !{!12, !6, i64 16}
!17 = !{i8 0, i8 2}
!18 = !{}


; 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: nounwind uwtable
declare dso_local void @decrease_key(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noalias ptr @find_node(ptr noundef %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = getelementptr inbounds i8, ptr %1, i64 41
  store i8 1, ptr %5, align 1, !tbaa !5
  %6 = load i32, ptr %1, align 8, !tbaa !12
  %7 = icmp eq i32 %6, %2
  br i1 %7, label %8, label %9

8:                                                ; preds = %4
  store i8 0, ptr %5, align 1, !tbaa !5
  tail call void @decrease_key(ptr noundef %0, ptr noundef nonnull %1, i32 noundef %3)
  br label %9

9:                                                ; preds = %8, %4
  %10 = getelementptr inbounds i8, ptr %1, i64 32
  %11 = load ptr, ptr %10, align 8, !tbaa !13
  %.not = icmp eq ptr %11, null
  br i1 %.not, label %14, label %12

12:                                               ; preds = %9
  %13 = tail call ptr @find_node(ptr noundef %0, ptr noundef nonnull %11, i32 noundef %2, i32 noundef %3)
  br label %14

14:                                               ; preds = %12, %9
  %15 = getelementptr inbounds i8, ptr %1, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = getelementptr inbounds i8, ptr %16, i64 41
  %18 = load i8, ptr %17, align 1, !tbaa !5, !range !15, !noundef !16
  %.not20.not = icmp eq i8 %18, 0
  br i1 %.not20.not, label %19, label %21

19:                                               ; preds = %14
  %20 = tail call ptr @find_node(ptr noundef %0, ptr noundef nonnull %16, i32 noundef %2, i32 noundef %3)
  br label %21

21:                                               ; preds = %19, %14
  store i8 0, ptr %5, align 1, !tbaa !5
  ret ptr undef
}

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, !11, i64 41}
!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, !7, i64 0}
!13 = !{!6, !10, i64 32}
!14 = !{!6, !10, i64 16}
!15 = !{i8 0, i8 2}
!16 = !{}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass