; 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 }
%struct._Fact = type { i32, [5 x i32] }

@garity = external global [50 x i32], align 16
@.str.93 = external hidden unnamed_addr constant [46 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

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

; 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) #2

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @var_used_in_wff(i32 noundef %0, ptr noundef %1) #3 {
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %9 = load ptr, ptr %5, align 8, !tbaa !9
  %10 = getelementptr inbounds %struct._WffNode, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !11
  switch i32 %11, label %101 [
    i32 2008, label %12
    i32 2009, label %12
    i32 2006, label %18
    i32 2007, label %18
    i32 2005, label %37
    i32 2002, label %43
    i32 2003, label %83
    i32 2000, label %100
    i32 2001, label %100
  ]

12:                                               ; preds = %2, %2
  %13 = load i32, ptr %4, align 4, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct._WffNode, ptr %14, i32 0, i32 9
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = call zeroext i8 @var_used_in_wff(i32 noundef %13, ptr noundef %16)
  store i8 %17, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

18:                                               ; preds = %2, %2
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds %struct._WffNode, ptr %19, i32 0, i32 4
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  store ptr %21, ptr %6, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %32, %18
  %23 = load ptr, ptr %6, align 8, !tbaa !9
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %36

25:                                               ; preds = %22
  %26 = load i32, ptr %4, align 4, !tbaa !5
  %27 = load ptr, ptr %6, align 8, !tbaa !9
  %28 = call zeroext i8 @var_used_in_wff(i32 noundef %26, ptr noundef %27)
  %29 = icmp ne i8 %28, 0
  br i1 %29, label %30, label %31

30:                                               ; preds = %25
  store i8 1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

31:                                               ; preds = %25
  br label %32

32:                                               ; preds = %31
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct._WffNode, ptr %33, i32 0, i32 5
  %35 = load ptr, ptr %34, align 8, !tbaa !15
  store ptr %35, ptr %6, align 8, !tbaa !9
  br label %22, !llvm.loop !16

36:                                               ; preds = %22
  store i8 0, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

37:                                               ; preds = %2
  %38 = load i32, ptr %4, align 4, !tbaa !5
  %39 = load ptr, ptr %5, align 8, !tbaa !9
  %40 = getelementptr inbounds %struct._WffNode, ptr %39, i32 0, i32 9
  %41 = load ptr, ptr %40, align 8, !tbaa !13
  %42 = call zeroext i8 @var_used_in_wff(i32 noundef %38, ptr noundef %41)
  store i8 %42, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

43:                                               ; preds = %2
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %79, %43
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = load ptr, ptr %5, align 8, !tbaa !9
  %47 = getelementptr inbounds %struct._WffNode, ptr %46, i32 0, i32 7
  %48 = load ptr, ptr %47, align 8, !tbaa !18
  %49 = getelementptr inbounds %struct._Fact, ptr %48, i32 0, i32 0
  %50 = load i32, ptr %49, align 4, !tbaa !19
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %51
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = icmp slt i32 %45, %53
  br i1 %54, label %55, label %82

55:                                               ; preds = %44
  %56 = load ptr, ptr %5, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct._WffNode, ptr %56, i32 0, i32 7
  %58 = load ptr, ptr %57, align 8, !tbaa !18
  %59 = getelementptr inbounds %struct._Fact, ptr %58, i32 0, i32 1
  %60 = load i32, ptr %7, align 4, !tbaa !5
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [5 x i32], ptr %59, i64 0, i64 %61
  %63 = load i32, ptr %62, align 4, !tbaa !5
  %64 = icmp sge i32 %63, 0
  br i1 %64, label %65, label %66

65:                                               ; preds = %55
  br label %79

66:                                               ; preds = %55
  %67 = load ptr, ptr %5, align 8, !tbaa !9
  %68 = getelementptr inbounds %struct._WffNode, ptr %67, i32 0, i32 7
  %69 = load ptr, ptr %68, align 8, !tbaa !18
  %70 = getelementptr inbounds %struct._Fact, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %7, align 4, !tbaa !5
  %72 = sext i32 %71 to i64
  %73 = getelementptr inbounds [5 x i32], ptr %70, i64 0, i64 %72
  %74 = load i32, ptr %73, align 4, !tbaa !5
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = icmp eq i32 %74, %75
  br i1 %76, label %77, label %78

77:                                               ; preds = %66
  store i8 1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

78:                                               ; preds = %66
  br label %79

79:                                               ; preds = %78, %65
  %80 = load i32, ptr %7, align 4, !tbaa !5
  %81 = add nsw i32 %80, 1
  store i32 %81, ptr %7, align 4, !tbaa !5
  br label %44, !llvm.loop !21

82:                                               ; preds = %44
  store i8 0, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

83:                                               ; preds = %2
  %84 = load i32, ptr %4, align 4, !tbaa !5
  %85 = load ptr, ptr %5, align 8, !tbaa !9
  %86 = getelementptr inbounds %struct._WffNode, ptr %85, i32 0, i32 11
  %87 = load ptr, ptr %86, align 8, !tbaa !22
  %88 = call zeroext i8 @var_used_in_exp(i32 noundef %84, ptr noundef %87)
  %89 = icmp ne i8 %88, 0
  br i1 %89, label %90, label %91

90:                                               ; preds = %83
  store i8 1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

91:                                               ; preds = %83
  %92 = load i32, ptr %4, align 4, !tbaa !5
  %93 = load ptr, ptr %5, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct._WffNode, ptr %93, i32 0, i32 12
  %95 = load ptr, ptr %94, align 8, !tbaa !23
  %96 = call zeroext i8 @var_used_in_exp(i32 noundef %92, ptr noundef %95)
  %97 = icmp ne i8 %96, 0
  br i1 %97, label %98, label %99

98:                                               ; preds = %91
  store i8 1, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

99:                                               ; preds = %91
  store i8 0, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

100:                                              ; preds = %2, %2
  store i8 0, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %106

101:                                              ; preds = %2
  %102 = load ptr, ptr %5, align 8, !tbaa !9
  %103 = getelementptr inbounds %struct._WffNode, ptr %102, i32 0, i32 0
  %104 = load i32, ptr %103, align 8, !tbaa !11
  %105 = call i32 (ptr, ...) @printf(ptr noundef @.str.93, i32 noundef %104)
  call void @exit(i32 noundef 1) #5
  unreachable

106:                                              ; preds = %100, %99, %98, %90, %82, %77, %37, %36, %30, %12
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %107 = load i8, ptr %3, align 1
  ret i8 %107
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @var_used_in_exp(i32 noundef, ptr noundef) #3

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


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

@garity = external local_unnamed_addr global [50 x i32], align 16
@.str.93 = external hidden unnamed_addr constant [46 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @var_used_in_wff(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse.backedge, %2
  %.tr29 = phi ptr [ %1, %2 ], [ %.tr29.be, %tailrecurse.backedge ]
  %3 = load i32, ptr %.tr29, align 8, !tbaa !5
  switch i32 %3, label %31 [
    i32 2008, label %tailrecurse.backedge
    i32 2009, label %tailrecurse.backedge
    i32 2006, label %12
    i32 2007, label %12
    i32 2005, label %tailrecurse.backedge
    i32 2002, label %.preheader
    i32 2003, label %23
    i32 2000, label %.loopexit
    i32 2001, label %.loopexit
  ]

.preheader:                                       ; preds = %tailrecurse
  %4 = getelementptr inbounds i8, ptr %.tr29, i64 48
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = load i32, ptr %5, align 4, !tbaa !12
  %7 = sext i32 %6 to i64
  %8 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %7
  %9 = load i32, ptr %8, align 4, !tbaa !14
  %10 = icmp sgt i32 %9, 0
  br i1 %10, label %.lr.ph, label %.loopexit

.lr.ph:                                           ; preds = %.preheader
  %11 = getelementptr inbounds i8, ptr %5, i64 4
  %wide.trip.count = zext nneg i32 %9 to i64
  br label %18

tailrecurse.backedge:                             ; preds = %tailrecurse, %tailrecurse, %tailrecurse
  %.tr29.be.in = getelementptr inbounds i8, ptr %.tr29, i64 64
  %.tr29.be = load ptr, ptr %.tr29.be.in, align 8, !tbaa !15
  br label %tailrecurse

12:                                               ; preds = %tailrecurse, %tailrecurse
  %13 = getelementptr inbounds i8, ptr %.tr29, i64 24
  %.02344 = load ptr, ptr %13, align 8, !tbaa !16
  %.not2745 = icmp eq ptr %.02344, null
  br i1 %.not2745, label %.loopexit, label %.lr.ph47

14:                                               ; preds = %.lr.ph47
  %15 = getelementptr inbounds i8, ptr %.02346, i64 32
  %.023 = load ptr, ptr %15, align 8, !tbaa !16
  %.not27 = icmp eq ptr %.023, null
  br i1 %.not27, label %.loopexit, label %.lr.ph47, !llvm.loop !17

.lr.ph47:                                         ; preds = %12, %14
  %.02346 = phi ptr [ %.023, %14 ], [ %.02344, %12 ]
  %16 = tail call zeroext i8 @var_used_in_wff(i32 noundef %0, ptr noundef nonnull %.02346)
  %.not28 = icmp eq i8 %16, 0
  br i1 %.not28, label %14, label %.loopexit

17:                                               ; preds = %18
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %.loopexit, label %18, !llvm.loop !19

18:                                               ; preds = %.lr.ph, %17
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %17 ]
  %19 = getelementptr inbounds [5 x i32], ptr %11, i64 0, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !14
  %21 = icmp slt i32 %20, 0
  %22 = icmp eq i32 %20, %0
  %or.cond = and i1 %21, %22
  br i1 %or.cond, label %.loopexit, label %17

23:                                               ; preds = %tailrecurse
  %24 = getelementptr inbounds i8, ptr %.tr29, i64 80
  %25 = load ptr, ptr %24, align 8, !tbaa !20
  %26 = tail call zeroext i8 @var_used_in_exp(i32 noundef %0, ptr noundef %25)
  %.not = icmp eq i8 %26, 0
  br i1 %.not, label %27, label %.loopexit

27:                                               ; preds = %23
  %28 = getelementptr inbounds i8, ptr %.tr29, i64 88
  %29 = load ptr, ptr %28, align 8, !tbaa !21
  %30 = tail call zeroext i8 @var_used_in_exp(i32 noundef %0, ptr noundef %29)
  %.not26 = icmp ne i8 %30, 0
  %. = zext i1 %.not26 to i8
  br label %.loopexit

31:                                               ; preds = %tailrecurse
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.93, i32 noundef %3)
  tail call void @exit(i32 noundef 1) #3
  unreachable

.loopexit:                                        ; preds = %tailrecurse, %tailrecurse, %18, %17, %.lr.ph47, %14, %.preheader, %12, %27, %23
  %.024 = phi i8 [ 1, %23 ], [ %., %27 ], [ 0, %12 ], [ 0, %.preheader ], [ 1, %.lr.ph47 ], [ 0, %14 ], [ 1, %18 ], [ 0, %17 ], [ 0, %tailrecurse ], [ 0, %tailrecurse ]
  ret i8 %.024
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @var_used_in_exp(i32 noundef, ptr noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #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 = { 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, !7, i64 0}
!6 = !{!"_WffNode", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !7, i64 56, !10, i64 64, !7, i64 72, !10, i64 80, !10, i64 88, !8, i64 96}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 48}
!12 = !{!13, !7, i64 0}
!13 = !{!"_Fact", !7, i64 0, !8, i64 4}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !10, i64 64}
!16 = !{!10, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = distinct !{!19, !18}
!20 = !{!6, !10, i64 80}
!21 = !{!6, !10, i64 88}


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