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

@lplan_hash_entry = external dso_local global [1024 x ptr], align 16
@.str.8 = external hidden unnamed_addr constant [61 x i8], align 1

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

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

19:                                               ; preds = %37, %2
  %20 = load ptr, ptr %8, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %41

22:                                               ; preds = %19
  %23 = load ptr, ptr %8, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct._PlanHashEntry, ptr %23, i32 0, i32 0
  %25 = load i32, ptr %24, align 8, !tbaa !11
  %26 = load i32, ptr %6, align 4, !tbaa !9
  %27 = icmp ne i32 %25, %26
  br i1 %27, label %28, label %29

28:                                               ; preds = %22
  br label %37

29:                                               ; preds = %22
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct._PlanHashEntry, ptr %31, i32 0, i32 1
  %33 = call zeroext i8 @same_state(ptr noundef %30, ptr noundef %32)
  %34 = icmp ne i8 %33, 0
  br i1 %34, label %35, label %36

35:                                               ; preds = %29
  br label %41

36:                                               ; preds = %29
  br label %37

37:                                               ; preds = %36, %28
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct._PlanHashEntry, ptr %38, i32 0, i32 4
  %40 = load ptr, ptr %39, align 8, !tbaa !14
  store ptr %40, ptr %8, align 8, !tbaa !5
  br label %19, !llvm.loop !15

41:                                               ; preds = %35, %19
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %56

44:                                               ; preds = %41
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct._PlanHashEntry, ptr %45, i32 0, i32 2
  %47 = load i32, ptr %46, align 8, !tbaa !17
  %48 = icmp ne i32 %47, -1
  br i1 %48, label %49, label %51

49:                                               ; preds = %44
  %50 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  call void @exit(i32 noundef 1) #5
  unreachable

51:                                               ; preds = %44
  %52 = load i32, ptr %5, align 4, !tbaa !9
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct._PlanHashEntry, ptr %53, i32 0, i32 2
  store i32 %52, ptr %54, align 8, !tbaa !17
  %55 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %55, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %100

56:                                               ; preds = %41
  %57 = load i32, ptr %7, align 4, !tbaa !9
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [1024 x ptr], ptr @lplan_hash_entry, i64 0, i64 %58
  %60 = load ptr, ptr %59, align 8, !tbaa !5
  store ptr %60, ptr %8, align 8, !tbaa !5
  br label %61

61:                                               ; preds = %72, %56
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = icmp ne ptr %62, null
  br i1 %63, label %64, label %69

64:                                               ; preds = %61
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct._PlanHashEntry, ptr %65, i32 0, i32 4
  %67 = load ptr, ptr %66, align 8, !tbaa !14
  %68 = icmp ne ptr %67, null
  br label %69

69:                                               ; preds = %64, %61
  %70 = phi i1 [ false, %61 ], [ %68, %64 ]
  br i1 %70, label %71, label %76

71:                                               ; preds = %69
  br label %72

72:                                               ; preds = %71
  %73 = load ptr, ptr %8, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct._PlanHashEntry, ptr %73, i32 0, i32 4
  %75 = load ptr, ptr %74, align 8, !tbaa !14
  store ptr %75, ptr %8, align 8, !tbaa !5
  br label %61, !llvm.loop !18

76:                                               ; preds = %69
  %77 = call ptr @new_PlanHashEntry()
  store ptr %77, ptr %9, align 8, !tbaa !5
  %78 = load i32, ptr %6, align 4, !tbaa !9
  %79 = load ptr, ptr %9, align 8, !tbaa !5
  %80 = getelementptr inbounds %struct._PlanHashEntry, ptr %79, i32 0, i32 0
  store i32 %78, ptr %80, align 8, !tbaa !11
  %81 = load ptr, ptr %9, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct._PlanHashEntry, ptr %81, i32 0, i32 1
  %83 = load ptr, ptr %4, align 8, !tbaa !5
  call void @copy_source_to_dest(ptr noundef %82, ptr noundef %83)
  %84 = load i32, ptr %5, align 4, !tbaa !9
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct._PlanHashEntry, ptr %85, i32 0, i32 2
  store i32 %84, ptr %86, align 8, !tbaa !17
  %87 = load ptr, ptr %8, align 8, !tbaa !5
  %88 = icmp ne ptr %87, null
  br i1 %88, label %89, label %93

89:                                               ; preds = %76
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = load ptr, ptr %8, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct._PlanHashEntry, ptr %91, i32 0, i32 4
  store ptr %90, ptr %92, align 8, !tbaa !14
  br label %98

93:                                               ; preds = %76
  %94 = load ptr, ptr %9, align 8, !tbaa !5
  %95 = load i32, ptr %7, align 4, !tbaa !9
  %96 = sext i32 %95 to i64
  %97 = getelementptr inbounds [1024 x ptr], ptr @lplan_hash_entry, i64 0, i64 %96
  store ptr %94, ptr %97, align 8, !tbaa !5
  br label %98

98:                                               ; preds = %93, %89
  %99 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %99, ptr %3, align 8
  store i32 1, ptr %10, align 4
  br label %100

100:                                              ; preds = %98, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %101 = load ptr, ptr %3, align 8
  ret ptr %101
}

declare i32 @printf(ptr noundef, ...) #2

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #3

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

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

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

declare ptr @new_PlanHashEntry() #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 = { noreturn nounwind "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 #4 = { nounwind }
attributes #5 = { noreturn 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 = !{!"_PlanHashEntry", !10, i64 0, !13, i64 8, !10, i64 40, !6, i64 48, !6, i64 56}
!13 = !{!"_State", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24}
!14 = !{!12, !6, i64 56}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !10, i64 40}
!18 = distinct !{!18, !16}


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

@lplan_hash_entry = external dso_local local_unnamed_addr global [1024 x ptr], align 16
@.str.8 = external hidden unnamed_addr constant [61 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @hash_plan_state(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = tail call i32 @state_sum(ptr noundef %0)
  %4 = and i32 %3, 1023
  %5 = zext nneg i32 %4 to i64
  %6 = getelementptr inbounds [1024 x ptr], ptr @lplan_hash_entry, i64 0, i64 %5
  %.03040 = load ptr, ptr %6, align 8, !tbaa !5
  %.not41 = icmp eq ptr %.03040, null
  br i1 %.not41, label %.critedge38.preheader, label %.lr.ph

.lr.ph:                                           ; preds = %2, %11
  %.03042 = phi ptr [ %.030, %11 ], [ %.03040, %2 ]
  %7 = load i32, ptr %.03042, align 8, !tbaa !9
  %.not32 = icmp eq i32 %7, %3
  br i1 %.not32, label %8, label %11

8:                                                ; preds = %.lr.ph
  %9 = getelementptr inbounds i8, ptr %.03042, i64 8
  %10 = tail call zeroext i8 @same_state(ptr noundef %0, ptr noundef nonnull %9)
  %.not33 = icmp eq i8 %10, 0
  br i1 %.not33, label %11, label %13

11:                                               ; preds = %8, %.lr.ph
  %12 = getelementptr inbounds i8, ptr %.03042, i64 56
  %.030 = load ptr, ptr %12, align 8, !tbaa !5
  %.not = icmp eq ptr %.030, null
  br i1 %.not, label %.critedge38.loopexit, label %.lr.ph, !llvm.loop !13

13:                                               ; preds = %8
  %14 = getelementptr inbounds i8, ptr %.03042, i64 40
  %15 = load i32, ptr %14, align 8, !tbaa !15
  %.not36 = icmp eq i32 %15, -1
  br i1 %.not36, label %18, label %16

16:                                               ; preds = %13
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  tail call void @exit(i32 noundef 1) #4
  unreachable

18:                                               ; preds = %13
  store i32 %1, ptr %14, align 8, !tbaa !15
  br label %28

.critedge38.loopexit:                             ; preds = %11
  %.pre = load ptr, ptr %6, align 8, !tbaa !5
  br label %.critedge38.preheader

.critedge38.preheader:                            ; preds = %.critedge38.loopexit, %2
  %.1.ph = phi ptr [ null, %2 ], [ %.pre, %.critedge38.loopexit ]
  br label %.critedge38

.critedge38:                                      ; preds = %.critedge38.preheader, %19
  %.1 = phi ptr [ %21, %19 ], [ %.1.ph, %.critedge38.preheader ]
  %.not34 = icmp eq ptr %.1, null
  br i1 %.not34, label %.critedge, label %19

19:                                               ; preds = %.critedge38
  %20 = getelementptr inbounds i8, ptr %.1, i64 56
  %21 = load ptr, ptr %20, align 8, !tbaa !16
  %.not35 = icmp eq ptr %21, null
  br i1 %.not35, label %.critedge, label %.critedge38, !llvm.loop !17

.critedge:                                        ; preds = %.critedge38, %19
  %22 = tail call ptr @new_PlanHashEntry() #5
  store i32 %3, ptr %22, align 8, !tbaa !9
  %23 = getelementptr inbounds i8, ptr %22, i64 8
  tail call void @copy_source_to_dest(ptr noundef nonnull %23, ptr noundef %0)
  %24 = getelementptr inbounds i8, ptr %22, i64 40
  store i32 %1, ptr %24, align 8, !tbaa !15
  br i1 %.not34, label %27, label %25

25:                                               ; preds = %.critedge
  %26 = getelementptr inbounds i8, ptr %.1, i64 56
  store ptr %22, ptr %26, align 8, !tbaa !16
  br label %28

27:                                               ; preds = %.critedge
  store ptr %22, ptr %6, align 8, !tbaa !5
  br label %28

28:                                               ; preds = %25, %27, %18
  %.0 = phi ptr [ %.03042, %18 ], [ %22, %27 ], [ %22, %25 ]
  ret ptr %.0
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #2

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

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

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

declare ptr @new_PlanHashEntry() local_unnamed_addr #3

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 = { nofree nounwind "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 = { noreturn nounwind "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 = { "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 #4 = { noreturn nounwind }
attributes #5 = { 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, !11, i64 0}
!10 = !{!"_PlanHashEntry", !11, i64 0, !12, i64 8, !11, i64 40, !6, i64 48, !6, i64 56}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_State", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = !{!10, !11, i64 40}
!16 = !{!10, !6, i64 56}
!17 = distinct !{!17, !14}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass