; 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.95 = external hidden unnamed_addr constant [45 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 void @decrement_inferior_vars(i32 noundef %0, ptr noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  store i32 %0, ptr %3, align 4, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %7 = load ptr, ptr %4, align 8, !tbaa !9
  %8 = getelementptr inbounds %struct._WffNode, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 8, !tbaa !11
  switch i32 %9, label %100 [
    i32 2008, label %10
    i32 2009, label %10
    i32 2006, label %19
    i32 2007, label %19
    i32 2005, label %34
    i32 2002, label %39
    i32 2003, label %90
    i32 2000, label %99
    i32 2001, label %99
  ]

10:                                               ; preds = %2, %2
  %11 = load ptr, ptr %4, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct._WffNode, ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !13
  %14 = add nsw i32 %13, -1
  store i32 %14, ptr %12, align 4, !tbaa !13
  %15 = load i32, ptr %3, align 4, !tbaa !5
  %16 = load ptr, ptr %4, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct._WffNode, ptr %16, i32 0, i32 9
  %18 = load ptr, ptr %17, align 8, !tbaa !14
  call void @decrement_inferior_vars(i32 noundef %15, ptr noundef %18)
  br label %105

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

23:                                               ; preds = %29, %19
  %24 = load ptr, ptr %5, align 8, !tbaa !9
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %33

26:                                               ; preds = %23
  %27 = load i32, ptr %3, align 4, !tbaa !5
  %28 = load ptr, ptr %5, align 8, !tbaa !9
  call void @decrement_inferior_vars(i32 noundef %27, ptr noundef %28)
  br label %29

29:                                               ; preds = %26
  %30 = load ptr, ptr %5, align 8, !tbaa !9
  %31 = getelementptr inbounds %struct._WffNode, ptr %30, i32 0, i32 5
  %32 = load ptr, ptr %31, align 8, !tbaa !16
  store ptr %32, ptr %5, align 8, !tbaa !9
  br label %23, !llvm.loop !17

33:                                               ; preds = %23
  br label %105

34:                                               ; preds = %2
  %35 = load i32, ptr %3, align 4, !tbaa !5
  %36 = load ptr, ptr %4, align 8, !tbaa !9
  %37 = getelementptr inbounds %struct._WffNode, ptr %36, i32 0, i32 9
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  call void @decrement_inferior_vars(i32 noundef %35, ptr noundef %38)
  br label %105

39:                                               ; preds = %2
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %40

40:                                               ; preds = %86, %39
  %41 = load i32, ptr %6, align 4, !tbaa !5
  %42 = load ptr, ptr %4, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct._WffNode, ptr %42, i32 0, i32 7
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = getelementptr inbounds %struct._Fact, ptr %44, i32 0, i32 0
  %46 = load i32, ptr %45, align 4, !tbaa !20
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %47
  %49 = load i32, ptr %48, align 4, !tbaa !5
  %50 = icmp slt i32 %41, %49
  br i1 %50, label %51, label %89

51:                                               ; preds = %40
  %52 = load ptr, ptr %4, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct._WffNode, ptr %52, i32 0, i32 7
  %54 = load ptr, ptr %53, align 8, !tbaa !19
  %55 = getelementptr inbounds %struct._Fact, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %6, align 4, !tbaa !5
  %57 = sext i32 %56 to i64
  %58 = getelementptr inbounds [5 x i32], ptr %55, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !5
  %60 = icmp sge i32 %59, 0
  br i1 %60, label %61, label %62

61:                                               ; preds = %51
  br label %86

62:                                               ; preds = %51
  %63 = load ptr, ptr %4, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct._WffNode, ptr %63, i32 0, i32 7
  %65 = load ptr, ptr %64, align 8, !tbaa !19
  %66 = getelementptr inbounds %struct._Fact, ptr %65, i32 0, i32 1
  %67 = load i32, ptr %6, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [5 x i32], ptr %66, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  %71 = add nsw i32 %70, 1
  %72 = mul nsw i32 %71, -1
  %73 = load i32, ptr %3, align 4, !tbaa !5
  %74 = icmp sgt i32 %72, %73
  br i1 %74, label %75, label %85

75:                                               ; preds = %62
  %76 = load ptr, ptr %4, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct._WffNode, ptr %76, i32 0, i32 7
  %78 = load ptr, ptr %77, align 8, !tbaa !19
  %79 = getelementptr inbounds %struct._Fact, ptr %78, i32 0, i32 1
  %80 = load i32, ptr %6, align 4, !tbaa !5
  %81 = sext i32 %80 to i64
  %82 = getelementptr inbounds [5 x i32], ptr %79, i64 0, i64 %81
  %83 = load i32, ptr %82, align 4, !tbaa !5
  %84 = add nsw i32 %83, 1
  store i32 %84, ptr %82, align 4, !tbaa !5
  br label %85

85:                                               ; preds = %75, %62
  br label %86

86:                                               ; preds = %85, %61
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = add nsw i32 %87, 1
  store i32 %88, ptr %6, align 4, !tbaa !5
  br label %40, !llvm.loop !22

89:                                               ; preds = %40
  br label %105

90:                                               ; preds = %2
  %91 = load i32, ptr %3, align 4, !tbaa !5
  %92 = load ptr, ptr %4, align 8, !tbaa !9
  %93 = getelementptr inbounds %struct._WffNode, ptr %92, i32 0, i32 11
  %94 = load ptr, ptr %93, align 8, !tbaa !23
  call void @decrement_inferior_vars_in_exp(i32 noundef %91, ptr noundef %94)
  %95 = load i32, ptr %3, align 4, !tbaa !5
  %96 = load ptr, ptr %4, align 8, !tbaa !9
  %97 = getelementptr inbounds %struct._WffNode, ptr %96, i32 0, i32 12
  %98 = load ptr, ptr %97, align 8, !tbaa !24
  call void @decrement_inferior_vars_in_exp(i32 noundef %95, ptr noundef %98)
  br label %105

99:                                               ; preds = %2, %2
  br label %105

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

105:                                              ; preds = %99, %90, %89, %34, %33, %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @decrement_inferior_vars_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, !6, i64 4}
!14 = !{!12, !10, i64 64}
!15 = !{!12, !10, i64 24}
!16 = !{!12, !10, i64 32}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !10, i64 48}
!20 = !{!21, !6, i64 0}
!21 = !{!"_Fact", !6, i64 0, !7, i64 4}
!22 = distinct !{!22, !18}
!23 = !{!12, !10, i64 80}
!24 = !{!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.95 = external hidden unnamed_addr constant [45 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 void @decrement_inferior_vars(i32 noundef %0, ptr nocapture noundef %1) local_unnamed_addr #2 {
  br label %tailrecurse

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

.preheader:                                       ; preds = %tailrecurse
  %4 = getelementptr inbounds i8, ptr %.tr28, 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
  br label %19

12:                                               ; preds = %tailrecurse, %tailrecurse
  %13 = getelementptr inbounds i8, ptr %.tr28, i64 4
  %14 = load i32, ptr %13, align 4, !tbaa !15
  %15 = add nsw i32 %14, -1
  store i32 %15, ptr %13, align 4, !tbaa !15
  br label %tailrecurse.backedge

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

16:                                               ; preds = %tailrecurse, %tailrecurse
  %17 = getelementptr inbounds i8, ptr %.tr28, i64 24
  %.02540 = load ptr, ptr %17, align 8, !tbaa !17
  %.not41 = icmp eq ptr %.02540, null
  br i1 %.not41, label %.loopexit, label %.lr.ph43

.lr.ph43:                                         ; preds = %16, %.lr.ph43
  %.02542 = phi ptr [ %.025, %.lr.ph43 ], [ %.02540, %16 ]
  tail call void @decrement_inferior_vars(i32 noundef %0, ptr noundef nonnull %.02542)
  %18 = getelementptr inbounds i8, ptr %.02542, i64 32
  %.025 = load ptr, ptr %18, align 8, !tbaa !17
  %.not = icmp eq ptr %.025, null
  br i1 %.not, label %.loopexit, label %.lr.ph43, !llvm.loop !18

19:                                               ; preds = %.lr.ph, %28
  %20 = phi i32 [ %9, %.lr.ph ], [ %29, %28 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %28 ]
  %21 = getelementptr inbounds [5 x i32], ptr %11, i64 0, i64 %indvars.iv
  %22 = load i32, ptr %21, align 4, !tbaa !14
  %23 = icmp slt i32 %22, 0
  %24 = xor i32 %22, -1
  %25 = icmp sgt i32 %24, %0
  %or.cond = and i1 %23, %25
  br i1 %or.cond, label %26, label %28

26:                                               ; preds = %19
  %27 = add nsw i32 %22, 1
  store i32 %27, ptr %21, align 4, !tbaa !14
  %.pre = load i32, ptr %8, align 4, !tbaa !14
  br label %28

28:                                               ; preds = %26, %19
  %29 = phi i32 [ %.pre, %26 ], [ %20, %19 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %30 = sext i32 %29 to i64
  %31 = icmp slt i64 %indvars.iv.next, %30
  br i1 %31, label %19, label %.loopexit, !llvm.loop !20

32:                                               ; preds = %tailrecurse
  %33 = getelementptr inbounds i8, ptr %.tr28, i64 80
  %34 = load ptr, ptr %33, align 8, !tbaa !21
  tail call void @decrement_inferior_vars_in_exp(i32 noundef %0, ptr noundef %34)
  %35 = getelementptr inbounds i8, ptr %.tr28, i64 88
  %36 = load ptr, ptr %35, align 8, !tbaa !22
  tail call void @decrement_inferior_vars_in_exp(i32 noundef %0, ptr noundef %36)
  br label %.loopexit

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

.loopexit:                                        ; preds = %tailrecurse, %tailrecurse, %28, %.lr.ph43, %.preheader, %16, %32
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @decrement_inferior_vars_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, !7, i64 4}
!16 = !{!6, !10, i64 64}
!17 = !{!10, !10, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}
!20 = distinct !{!20, !19}
!21 = !{!6, !10, i64 80}
!22 = !{!6, !10, i64 88}


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