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

@lehc_hash_entry = external dso_local global [8192 x ptr], align 16
@lnum_ehc_hash_entry = external dso_local global [8192 x i32], 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
declare dso_local i32 @state_sum(ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @ehc_state_hashed(ptr noundef %0) #1 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = call i32 @state_sum(ptr noundef %9)
  store i32 %10, ptr %5, align 4, !tbaa !9
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = and i32 %11, 8191
  store i32 %12, ptr %6, align 4, !tbaa !9
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = sext i32 %13 to i64
  %15 = getelementptr inbounds [8192 x ptr], ptr @lehc_hash_entry, i64 0, i64 %14
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  store ptr %16, ptr %7, align 8, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %17

17:                                               ; preds = %47, %1
  %18 = load i32, ptr %4, align 4, !tbaa !9
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [8192 x i32], ptr @lnum_ehc_hash_entry, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !9
  %23 = icmp slt i32 %18, %22
  br i1 %23, label %24, label %50

24:                                               ; preds = %17
  %25 = load ptr, ptr %7, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._EhcHashEntry, ptr %25, i32 0, i32 0
  %27 = load i32, ptr %26, align 8, !tbaa !11
  %28 = load i32, ptr %5, align 4, !tbaa !9
  %29 = icmp ne i32 %27, %28
  br i1 %29, label %30, label %34

30:                                               ; preds = %24
  %31 = load ptr, ptr %7, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._EhcHashEntry, ptr %31, i32 0, i32 2
  %33 = load ptr, ptr %32, align 8, !tbaa !13
  store ptr %33, ptr %7, align 8, !tbaa !5
  br label %47

34:                                               ; preds = %24
  %35 = load ptr, ptr %7, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct._EhcHashEntry, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !14
  %38 = getelementptr inbounds %struct._EhcNode, ptr %37, i32 0, i32 0
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = call zeroext i8 @same_state(ptr noundef %38, ptr noundef %39)
  %41 = icmp ne i8 %40, 0
  br i1 %41, label %42, label %43

42:                                               ; preds = %34
  store i8 1, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %51

43:                                               ; preds = %34
  %44 = load ptr, ptr %7, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._EhcHashEntry, ptr %44, i32 0, i32 2
  %46 = load ptr, ptr %45, align 8, !tbaa !13
  store ptr %46, ptr %7, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %43, %30
  %48 = load i32, ptr %4, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %4, align 4, !tbaa !9
  br label %17, !llvm.loop !15

50:                                               ; preds = %17
  store i8 0, ptr %2, align 1
  store i32 1, ptr %8, align 4
  br label %51

51:                                               ; preds = %50, %42
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %52 = load i8, ptr %2, align 1
  ret i8 %52
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @same_state(ptr noundef, ptr noundef) #1

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, !10, i64 0}
!12 = !{!"_EhcHashEntry", !10, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!12, !6, i64 16}
!14 = !{!12, !6, i64 8}
!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"

@lehc_hash_entry = external dso_local local_unnamed_addr global [8192 x ptr], align 16
@lnum_ehc_hash_entry = external dso_local local_unnamed_addr global [8192 x i32], align 16

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

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @ehc_state_hashed(ptr noundef %0) local_unnamed_addr #0 {
  %2 = tail call i32 @state_sum(ptr noundef %0)
  %3 = and i32 %2, 8191
  %4 = zext nneg i32 %3 to i64
  %5 = getelementptr inbounds [8192 x i32], ptr @lnum_ehc_hash_entry, i64 0, i64 %4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph.preheader, label %._crit_edge

.lr.ph.preheader:                                 ; preds = %1
  %8 = getelementptr inbounds [8192 x ptr], ptr @lehc_hash_entry, i64 0, i64 %4
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %15
  %9 = phi i32 [ %16, %15 ], [ %6, %.lr.ph.preheader ]
  %.017.in = phi ptr [ %.1.in, %15 ], [ %8, %.lr.ph.preheader ]
  %.01316 = phi i32 [ %17, %15 ], [ 0, %.lr.ph.preheader ]
  %.017 = load ptr, ptr %.017.in, align 8, !tbaa !9
  %10 = load i32, ptr %.017, align 8, !tbaa !11
  %.not = icmp eq i32 %10, %2
  br i1 %.not, label %11, label %15

11:                                               ; preds = %.lr.ph
  %12 = getelementptr inbounds i8, ptr %.017, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = tail call zeroext i8 @same_state(ptr noundef %13, ptr noundef %0)
  %.not14 = icmp eq i8 %14, 0
  br i1 %.not14, label %._crit_edge20, label %._crit_edge

._crit_edge20:                                    ; preds = %11
  %.pre = load i32, ptr %5, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %._crit_edge20, %.lr.ph
  %16 = phi i32 [ %.pre, %._crit_edge20 ], [ %9, %.lr.ph ]
  %.1.in = getelementptr inbounds i8, ptr %.017, i64 16
  %17 = add nuw nsw i32 %.01316, 1
  %18 = icmp slt i32 %17, %16
  br i1 %18, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %11, %15, %1
  %.012 = phi i8 [ 0, %1 ], [ 0, %15 ], [ 1, %11 ]
  ret i8 %.012
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @same_state(ptr noundef, ptr noundef) local_unnamed_addr #0

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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_EhcHashEntry", !6, i64 0, !10, i64 8, !10, i64 16}
!13 = !{!12, !10, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}


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