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

@lehc_space_end = external dso_local global ptr, align 8
@lehc_current_end = external dso_local global ptr, align 8

declare ptr @new_EhcNode() #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @add_to_ehc_space(ptr noundef %0, i32 noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %7 = load ptr, ptr %4, align 8, !tbaa !5
  %8 = call zeroext i8 @superior_ehc_state_hashed(ptr noundef %7)
  %9 = icmp ne i8 %8, 0
  br i1 %9, label %10, label %11

10:                                               ; preds = %3
  br label %47

11:                                               ; preds = %3
  %12 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %20, label %14

14:                                               ; preds = %11
  %15 = call ptr @new_EhcNode()
  store ptr %15, ptr @lehc_current_end, align 8, !tbaa !5
  %16 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %17 = load ptr, ptr @lehc_space_end, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._EhcNode, ptr %17, i32 0, i32 4
  store ptr %16, ptr %18, align 8, !tbaa !11
  %19 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  store ptr %19, ptr @lehc_space_end, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %14, %11
  %21 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._EhcNode, ptr %21, i32 0, i32 0
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  call void @source_to_dest(ptr noundef %22, ptr noundef %23)
  %24 = load i32, ptr %5, align 4, !tbaa !9
  %25 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._EhcNode, ptr %25, i32 0, i32 1
  store i32 %24, ptr %26, align 8, !tbaa !14
  %27 = load ptr, ptr %6, align 8, !tbaa !5
  %28 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._EhcNode, ptr %28, i32 0, i32 3
  store ptr %27, ptr %29, align 8, !tbaa !15
  %30 = load ptr, ptr %6, align 8, !tbaa !5
  %31 = icmp ne ptr %30, null
  br i1 %31, label %35, label %32

32:                                               ; preds = %20
  %33 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct._EhcNode, ptr %33, i32 0, i32 2
  store i32 1, ptr %34, align 4, !tbaa !16
  br label %42

35:                                               ; preds = %20
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._EhcNode, ptr %36, i32 0, i32 2
  %38 = load i32, ptr %37, align 4, !tbaa !16
  %39 = add nsw i32 %38, 1
  %40 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct._EhcNode, ptr %40, i32 0, i32 2
  store i32 %39, ptr %41, align 4, !tbaa !16
  br label %42

42:                                               ; preds = %35, %32
  %43 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  call void @hash_ehc_node(ptr noundef %43)
  %44 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._EhcNode, ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !11
  store ptr %46, ptr @lehc_current_end, align 8, !tbaa !5
  br label %47

47:                                               ; preds = %42, %10
  ret void
}

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

attributes #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 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 48}
!12 = !{!"_EhcNode", !13, i64 0, !10, i64 32, !10, i64 36, !6, i64 40, !6, i64 48}
!13 = !{!"_State", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!12, !10, i64 32}
!15 = !{!12, !6, i64 40}
!16 = !{!12, !10, i64 36}


; 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_space_end = external dso_local local_unnamed_addr global ptr, align 8
@lehc_current_end = external dso_local local_unnamed_addr global ptr, align 8

declare ptr @new_EhcNode() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @hash_ehc_node(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @add_to_ehc_space(ptr noundef %0, i32 noundef %1, ptr noundef %2) local_unnamed_addr #1 {
  %4 = tail call zeroext i8 @superior_ehc_state_hashed(ptr noundef %0)
  %.not = icmp eq i8 %4, 0
  br i1 %.not, label %5, label %25

5:                                                ; preds = %3
  %6 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %.not5 = icmp eq ptr %6, null
  br i1 %.not5, label %7, label %11

7:                                                ; preds = %5
  %8 = tail call ptr @new_EhcNode() #2
  store ptr %8, ptr @lehc_current_end, align 8, !tbaa !5
  %9 = load ptr, ptr @lehc_space_end, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %9, i64 48
  store ptr %8, ptr %10, align 8, !tbaa !9
  store ptr %8, ptr @lehc_space_end, align 8, !tbaa !5
  br label %11

11:                                               ; preds = %7, %5
  %12 = phi ptr [ %8, %7 ], [ %6, %5 ]
  tail call void @source_to_dest(ptr noundef %12, ptr noundef %0)
  %13 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %14 = getelementptr inbounds i8, ptr %13, i64 32
  store i32 %1, ptr %14, align 8, !tbaa !13
  %15 = getelementptr inbounds i8, ptr %13, i64 40
  store ptr %2, ptr %15, align 8, !tbaa !14
  %.not6 = icmp eq ptr %2, null
  br i1 %.not6, label %20, label %16

16:                                               ; preds = %11
  %17 = getelementptr inbounds i8, ptr %2, i64 36
  %18 = load i32, ptr %17, align 4, !tbaa !15
  %19 = add nsw i32 %18, 1
  br label %20

20:                                               ; preds = %11, %16
  %.sink = phi i32 [ %19, %16 ], [ 1, %11 ]
  %21 = getelementptr inbounds i8, ptr %13, i64 36
  store i32 %.sink, ptr %21, align 4
  tail call void @hash_ehc_node(ptr noundef nonnull %13)
  %22 = load ptr, ptr @lehc_current_end, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 48
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  store ptr %24, ptr @lehc_current_end, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %3, %20
  ret void
}

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

attributes #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 = { 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, !6, i64 48}
!10 = !{!"_EhcNode", !11, i64 0, !12, i64 32, !12, i64 36, !6, i64 40, !6, i64 48}
!11 = !{!"_State", !6, i64 0, !12, i64 8, !6, i64 16, !6, i64 24}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !12, i64 32}
!14 = !{!10, !6, i64 40}
!15 = !{!10, !12, i64 36}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,SROAPass,SimplifyCFGPass,TailCallElimPass