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

; 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._WffNode = type { i32, i32, i32, ptr, ptr, ptr, ptr, ptr, i32, ptr, i32, ptr, ptr, i8 }

@lset = external dso_local global ptr, align 8
@lhitting_sets = external dso_local global ptr, align 8

; 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

declare ptr @new_WffNode(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @copy_Wff(ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @collect_hitting_sets(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %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
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %10 = load ptr, ptr %3, align 8, !tbaa !5
  %11 = icmp ne ptr %10, null
  br i1 %11, label %59, label %12

12:                                               ; preds = %2
  %13 = call ptr @new_WffNode(i32 noundef 2006)
  store ptr %13, ptr %5, align 8, !tbaa !5
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %14

14:                                               ; preds = %44, %12
  %15 = load i32, ptr %8, align 4, !tbaa !9
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = icmp slt i32 %15, %16
  br i1 %17, label %18, label %47

18:                                               ; preds = %14
  %19 = load ptr, ptr @lset, align 8, !tbaa !5
  %20 = load i32, ptr %8, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds ptr, ptr %19, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  %24 = call ptr @copy_Wff(ptr noundef %23)
  store ptr %24, ptr %6, align 8, !tbaa !5
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._WffNode, ptr %25, i32 0, i32 4
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct._WffNode, ptr %28, i32 0, i32 5
  store ptr %27, ptr %29, align 8, !tbaa !13
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct._WffNode, ptr %30, i32 0, i32 4
  %32 = load ptr, ptr %31, align 8, !tbaa !11
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %40

34:                                               ; preds = %18
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._WffNode, ptr %36, i32 0, i32 4
  %38 = load ptr, ptr %37, align 8, !tbaa !11
  %39 = getelementptr inbounds %struct._WffNode, ptr %38, i32 0, i32 6
  store ptr %35, ptr %39, align 8, !tbaa !14
  br label %40

40:                                               ; preds = %34, %18
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct._WffNode, ptr %42, i32 0, i32 4
  store ptr %41, ptr %43, align 8, !tbaa !11
  br label %44

44:                                               ; preds = %40
  %45 = load i32, ptr %8, align 4, !tbaa !9
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %8, align 4, !tbaa !9
  br label %14, !llvm.loop !15

47:                                               ; preds = %14
  %48 = load ptr, ptr @lhitting_sets, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct._WffNode, ptr %49, i32 0, i32 5
  store ptr %48, ptr %50, align 8, !tbaa !13
  %51 = load ptr, ptr @lhitting_sets, align 8, !tbaa !5
  %52 = icmp ne ptr %51, null
  br i1 %52, label %53, label %57

53:                                               ; preds = %47
  %54 = load ptr, ptr %5, align 8, !tbaa !5
  %55 = load ptr, ptr @lhitting_sets, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._WffNode, ptr %55, i32 0, i32 6
  store ptr %54, ptr %56, align 8, !tbaa !14
  br label %57

57:                                               ; preds = %53, %47
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %58, ptr @lhitting_sets, align 8, !tbaa !5
  store i32 1, ptr %9, align 4
  br label %98

59:                                               ; preds = %2
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct._WffNode, ptr %60, i32 0, i32 0
  %62 = load i32, ptr %61, align 8, !tbaa !17
  %63 = icmp ne i32 %62, 2007
  br i1 %63, label %64, label %75

64:                                               ; preds = %59
  %65 = load ptr, ptr %3, align 8, !tbaa !5
  %66 = load ptr, ptr @lset, align 8, !tbaa !5
  %67 = load i32, ptr %4, align 4, !tbaa !9
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds ptr, ptr %66, i64 %68
  store ptr %65, ptr %69, align 8, !tbaa !5
  %70 = load ptr, ptr %3, align 8, !tbaa !5
  %71 = getelementptr inbounds %struct._WffNode, ptr %70, i32 0, i32 5
  %72 = load ptr, ptr %71, align 8, !tbaa !13
  %73 = load i32, ptr %4, align 4, !tbaa !9
  %74 = add nsw i32 %73, 1
  call void @collect_hitting_sets(ptr noundef %72, i32 noundef %74)
  store i32 1, ptr %9, align 4
  br label %98

75:                                               ; preds = %59
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct._WffNode, ptr %76, i32 0, i32 4
  %78 = load ptr, ptr %77, align 8, !tbaa !11
  store ptr %78, ptr %7, align 8, !tbaa !5
  br label %79

79:                                               ; preds = %93, %75
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = icmp ne ptr %80, null
  br i1 %81, label %82, label %97

82:                                               ; preds = %79
  %83 = load ptr, ptr %7, align 8, !tbaa !5
  %84 = load ptr, ptr @lset, align 8, !tbaa !5
  %85 = load i32, ptr %4, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds ptr, ptr %84, i64 %86
  store ptr %83, ptr %87, align 8, !tbaa !5
  %88 = load ptr, ptr %3, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct._WffNode, ptr %88, i32 0, i32 5
  %90 = load ptr, ptr %89, align 8, !tbaa !13
  %91 = load i32, ptr %4, align 4, !tbaa !9
  %92 = add nsw i32 %91, 1
  call void @collect_hitting_sets(ptr noundef %90, i32 noundef %92)
  br label %93

93:                                               ; preds = %82
  %94 = load ptr, ptr %7, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct._WffNode, ptr %94, i32 0, i32 5
  %96 = load ptr, ptr %95, align 8, !tbaa !13
  store ptr %96, ptr %7, align 8, !tbaa !5
  br label %79, !llvm.loop !18

97:                                               ; preds = %79
  store i32 0, ptr %9, align 4
  br label %98

98:                                               ; preds = %97, %64, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  %99 = load i32, ptr %9, align 4
  switch i32 %99, label %101 [
    i32 0, label %100
    i32 1, label %100
  ]

100:                                              ; preds = %98, %98
  ret void

101:                                              ; preds = %98
  unreachable
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 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 #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, !6, i64 24}
!12 = !{!"_WffNode", !10, i64 0, !10, i64 4, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !10, i64 56, !6, i64 64, !10, i64 72, !6, i64 80, !6, i64 88, !7, i64 96}
!13 = !{!12, !6, i64 32}
!14 = !{!12, !6, i64 40}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !10, i64 0}
!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"

@lset = external dso_local local_unnamed_addr global ptr, align 8
@lhitting_sets = external dso_local local_unnamed_addr global ptr, align 8

declare ptr @new_WffNode(i32 noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @collect_hitting_sets(ptr noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %.not37 = icmp eq ptr %0, null
  br i1 %.not37, label %tailrecurse._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %3 = sext i32 %1 to i64
  br label %.lr.ph

tailrecurse._crit_edge.loopexit:                  ; preds = %tailrecurse
  %4 = trunc nsw i64 %indvars.iv.next to i32
  br label %tailrecurse._crit_edge

tailrecurse._crit_edge:                           ; preds = %tailrecurse._crit_edge.loopexit, %2
  %.tr34.lcssa = phi i32 [ %1, %2 ], [ %4, %tailrecurse._crit_edge.loopexit ]
  %5 = tail call ptr @new_WffNode(i32 noundef 2006) #2
  %6 = icmp sgt i32 %.tr34.lcssa, 0
  br i1 %6, label %.lr.ph45, label %._crit_edge

.lr.ph45:                                         ; preds = %tailrecurse._crit_edge
  %7 = getelementptr inbounds i8, ptr %5, i64 24
  %wide.trip.count = zext nneg i32 %.tr34.lcssa to i64
  br label %8

8:                                                ; preds = %.lr.ph45, %17
  %indvars.iv49 = phi i64 [ 0, %.lr.ph45 ], [ %indvars.iv.next50, %17 ]
  %9 = load ptr, ptr @lset, align 8, !tbaa !5
  %10 = getelementptr inbounds ptr, ptr %9, i64 %indvars.iv49
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = tail call ptr @copy_Wff(ptr noundef %11)
  %13 = load ptr, ptr %7, align 8, !tbaa !9
  %14 = getelementptr inbounds i8, ptr %12, i64 32
  store ptr %13, ptr %14, align 8, !tbaa !12
  %.not31 = icmp eq ptr %13, null
  br i1 %.not31, label %17, label %15

15:                                               ; preds = %8
  %16 = getelementptr inbounds i8, ptr %13, i64 40
  store ptr %12, ptr %16, align 8, !tbaa !13
  br label %17

17:                                               ; preds = %15, %8
  store ptr %12, ptr %7, align 8, !tbaa !9
  %indvars.iv.next50 = add nuw nsw i64 %indvars.iv49, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next50, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %8, !llvm.loop !14

._crit_edge:                                      ; preds = %17, %tailrecurse._crit_edge
  %18 = load ptr, ptr @lhitting_sets, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr %18, ptr %19, align 8, !tbaa !12
  %.not30 = icmp eq ptr %18, null
  br i1 %.not30, label %22, label %20

20:                                               ; preds = %._crit_edge
  %21 = getelementptr inbounds i8, ptr %18, i64 40
  store ptr %5, ptr %21, align 8, !tbaa !13
  br label %22

22:                                               ; preds = %20, %._crit_edge
  store ptr %5, ptr @lhitting_sets, align 8, !tbaa !5
  br label %.loopexit

.lr.ph:                                           ; preds = %.lr.ph.preheader, %tailrecurse
  %indvars.iv = phi i64 [ %3, %.lr.ph.preheader ], [ %indvars.iv.next, %tailrecurse ]
  %.tr38 = phi ptr [ %0, %.lr.ph.preheader ], [ %27, %tailrecurse ]
  %23 = load i32, ptr %.tr38, align 8, !tbaa !16
  %.not32 = icmp eq i32 %23, 2007
  br i1 %.not32, label %28, label %tailrecurse

tailrecurse:                                      ; preds = %.lr.ph
  %24 = load ptr, ptr @lset, align 8, !tbaa !5
  %25 = getelementptr inbounds ptr, ptr %24, i64 %indvars.iv
  store ptr %.tr38, ptr %25, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %.tr38, i64 32
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  %indvars.iv.next = add nsw i64 %indvars.iv, 1
  %.not = icmp eq ptr %27, null
  br i1 %.not, label %tailrecurse._crit_edge.loopexit, label %.lr.ph

28:                                               ; preds = %.lr.ph
  %29 = getelementptr inbounds i8, ptr %.tr38, i64 24
  %.02640 = load ptr, ptr %29, align 8, !tbaa !5
  %.not3341 = icmp eq ptr %.02640, null
  br i1 %.not3341, label %.loopexit, label %.lr.ph43

.lr.ph43:                                         ; preds = %28
  %30 = trunc nsw i64 %indvars.iv to i32
  %sext = shl i64 %indvars.iv, 32
  %31 = getelementptr inbounds i8, ptr %.tr38, i64 32
  %32 = add nsw i32 %30, 1
  %33 = ashr exact i64 %sext, 29
  br label %34

34:                                               ; preds = %.lr.ph43, %34
  %.02642 = phi ptr [ %.02640, %.lr.ph43 ], [ %.026, %34 ]
  %35 = load ptr, ptr @lset, align 8, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %35, i64 %33
  store ptr %.02642, ptr %36, align 8, !tbaa !5
  %37 = load ptr, ptr %31, align 8, !tbaa !12
  tail call void @collect_hitting_sets(ptr noundef %37, i32 noundef %32)
  %38 = getelementptr inbounds i8, ptr %.02642, i64 32
  %.026 = load ptr, ptr %38, align 8, !tbaa !5
  %.not33 = icmp eq ptr %.026, null
  br i1 %.not33, label %.loopexit, label %34, !llvm.loop !17

.loopexit:                                        ; preds = %34, %28, %22
  ret void
}

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 24}
!10 = !{!"_WffNode", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !11, i64 56, !6, i64 64, !11, i64 72, !6, i64 80, !6, i64 88, !7, i64 96}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 32}
!13 = !{!10, !6, i64 40}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!10, !11, i64 0}
!17 = distinct !{!17, !15}


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