; LLVM IR from askforalfred/alfred :: gen/ff_planner (search)

; 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._BfsNode = type { %struct._State, i32, i32, i32, float, float, float, ptr, i32, ptr, ptr, ptr }
%struct._State = type { ptr, i32, ptr, ptr }
%struct._BfsHashEntry = type { i32, ptr, ptr }

@lbfs_hash_entry = external dso_local global [65536 x ptr], align 16

; 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
define dso_local void @hash_bfs_node(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %8 = load ptr, ptr %2, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._BfsNode, ptr %8, i32 0, i32 0
  %10 = call i32 @logical_state_sum(ptr noundef %9)
  store i32 %10, ptr %3, align 4, !tbaa !9
  %11 = load i32, ptr %3, align 4, !tbaa !9
  %12 = and i32 %11, 65535
  store i32 %12, ptr %4, align 4, !tbaa !9
  %13 = load i32, ptr %4, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [65536 x ptr], ptr @lbfs_hash_entry, i64 0, i64 %14
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %16, ptr %5, align 8, !tbaa !5
  %17 = load ptr, ptr %5, align 8, !tbaa !5
  %18 = icmp ne ptr %17, null
  br i1 %18, label %31, label %19

19:                                               ; preds = %1
  %20 = call ptr @new_BfsHashEntry()
  store ptr %20, ptr %5, align 8, !tbaa !5
  %21 = load i32, ptr %3, align 4, !tbaa !9
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._BfsHashEntry, ptr %22, i32 0, i32 0
  store i32 %21, ptr %23, align 8, !tbaa !11
  %24 = load ptr, ptr %2, align 8, !tbaa !5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._BfsHashEntry, ptr %25, i32 0, i32 1
  store ptr %24, ptr %26, align 8, !tbaa !13
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load i32, ptr %4, align 4, !tbaa !9
  %29 = sext i32 %28 to i64
  %30 = getelementptr inbounds [65536 x ptr], ptr @lbfs_hash_entry, i64 0, i64 %29
  store ptr %27, ptr %30, align 8, !tbaa !5
  store i32 1, ptr %7, align 4
  br label %53

31:                                               ; preds = %1
  br label %32

32:                                               ; preds = %38, %31
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._BfsHashEntry, ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = icmp ne ptr %35, null
  br i1 %36, label %37, label %42

37:                                               ; preds = %32
  br label %38

38:                                               ; preds = %37
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._BfsHashEntry, ptr %39, i32 0, i32 2
  %41 = load ptr, ptr %40, align 8, !tbaa !14
  store ptr %41, ptr %5, align 8, !tbaa !5
  br label %32, !llvm.loop !15

42:                                               ; preds = %32
  %43 = call ptr @new_BfsHashEntry()
  store ptr %43, ptr %6, align 8, !tbaa !5
  %44 = load i32, ptr %3, align 4, !tbaa !9
  %45 = load ptr, ptr %6, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._BfsHashEntry, ptr %45, i32 0, i32 0
  store i32 %44, ptr %46, align 8, !tbaa !11
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct._BfsHashEntry, ptr %48, i32 0, i32 1
  store ptr %47, ptr %49, align 8, !tbaa !13
  %50 = load ptr, ptr %6, align 8, !tbaa !5
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._BfsHashEntry, ptr %51, i32 0, i32 2
  store ptr %50, ptr %52, align 8, !tbaa !14
  store i32 0, ptr %7, align 4
  br label %53

53:                                               ; preds = %42, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  %54 = load i32, ptr %7, align 4
  switch i32 %54, label %56 [
    i32 0, label %55
    i32 1, label %55
  ]

55:                                               ; preds = %53, %53
  ret void

56:                                               ; preds = %53
  unreachable
}

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

declare ptr @new_BfsHashEntry() #2

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 = { "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 = { 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, !10, i64 0}
!12 = !{!"_BfsHashEntry", !10, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 8}
!14 = !{!12, !6, i64 16}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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

@lbfs_hash_entry = external dso_local local_unnamed_addr global [65536 x ptr], align 16

; Function Attrs: nounwind uwtable
define dso_local void @hash_bfs_node(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @logical_state_sum(ptr noundef %0)
  %3 = and i32 %2, 65535
  %4 = zext nneg i32 %3 to i64
  %5 = getelementptr inbounds [65536 x ptr], ptr @lbfs_hash_entry, i64 0, i64 %4
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %11, label %.preheader

.preheader:                                       ; preds = %1, %.preheader
  %.0 = phi ptr [ %8, %.preheader ], [ %6, %1 ]
  %7 = getelementptr inbounds i8, ptr %.0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !9
  %.not19 = icmp eq ptr %8, null
  br i1 %.not19, label %9, label %.preheader, !llvm.loop !12

9:                                                ; preds = %.preheader
  %10 = getelementptr inbounds i8, ptr %.0, i64 16
  br label %11

11:                                               ; preds = %1, %9
  %.sink20 = phi ptr [ %10, %9 ], [ %5, %1 ]
  %12 = tail call ptr @new_BfsHashEntry() #2
  store i32 %2, ptr %12, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %12, i64 8
  store ptr %0, ptr %13, align 8, !tbaa !15
  store ptr %12, ptr %.sink20, align 8, !tbaa !5
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local i32 @logical_state_sum(ptr noundef) local_unnamed_addr #0

declare ptr @new_BfsHashEntry() local_unnamed_addr #1

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" }
attributes #1 = { "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, !6, i64 16}
!10 = !{!"_BfsHashEntry", !11, i64 0, !6, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !11, i64 0}
!15 = !{!10, !6, i64 8}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LICMPass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass