; 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] }

@.str.119 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [56 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
declare void @free(ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @replace_not_p_with_n_in_wff(i32 noundef %0, i32 noundef %1, ptr noundef %2) #4 {
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store i32 %0, ptr %4, align 4, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #5
  %8 = load ptr, ptr %6, align 8, !tbaa !9
  %9 = load ptr, ptr %8, 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 %73 [
    i32 2008, label %12
    i32 2009, label %12
    i32 2006, label %14
    i32 2007, label %14
    i32 2005, label %30
    i32 2002, label %72
    i32 2003, label %72
    i32 2000, label %72
    i32 2001, label %72
  ]

12:                                               ; preds = %3, %3
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str.119)
  call void @exit(i32 noundef 1) #6
  unreachable

14:                                               ; preds = %3, %3
  %15 = load ptr, ptr %6, align 8, !tbaa !9
  %16 = load ptr, ptr %15, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct._WffNode, ptr %16, i32 0, i32 4
  %18 = load ptr, ptr %17, align 8, !tbaa !13
  store ptr %18, ptr %7, align 8, !tbaa !9
  br label %19

19:                                               ; preds = %25, %14
  %20 = load ptr, ptr %7, align 8, !tbaa !9
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %29

22:                                               ; preds = %19
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = load i32, ptr %5, align 4, !tbaa !5
  call void @replace_not_p_with_n_in_wff(i32 noundef %23, i32 noundef %24, ptr noundef %7)
  br label %25

25:                                               ; preds = %22
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct._WffNode, ptr %26, i32 0, i32 5
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  store ptr %28, ptr %7, align 8, !tbaa !9
  br label %19, !llvm.loop !15

29:                                               ; preds = %19
  br label %79

30:                                               ; preds = %3
  %31 = load ptr, ptr %6, align 8, !tbaa !9
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct._WffNode, ptr %32, i32 0, i32 9
  %34 = load ptr, ptr %33, align 8, !tbaa !17
  %35 = getelementptr inbounds %struct._WffNode, ptr %34, i32 0, i32 7
  %36 = load ptr, ptr %35, align 8, !tbaa !18
  %37 = getelementptr inbounds %struct._Fact, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 4, !tbaa !19
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = icmp eq i32 %38, %39
  br i1 %40, label %41, label %71

41:                                               ; preds = %30
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = load ptr, ptr %42, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct._WffNode, ptr %43, i32 0, i32 0
  store i32 2002, ptr %44, align 8, !tbaa !11
  %45 = load i32, ptr %4, align 4, !tbaa !5
  %46 = load ptr, ptr %6, align 8, !tbaa !9
  %47 = load ptr, ptr %46, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct._WffNode, ptr %47, i32 0, i32 8
  store i32 %45, ptr %48, align 8, !tbaa !21
  %49 = load ptr, ptr %6, align 8, !tbaa !9
  %50 = load ptr, ptr %49, align 8, !tbaa !9
  %51 = getelementptr inbounds %struct._WffNode, ptr %50, i32 0, i32 9
  %52 = load ptr, ptr %51, align 8, !tbaa !17
  %53 = getelementptr inbounds %struct._WffNode, ptr %52, i32 0, i32 7
  %54 = load ptr, ptr %53, align 8, !tbaa !18
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  %56 = load ptr, ptr %55, align 8, !tbaa !9
  %57 = getelementptr inbounds %struct._WffNode, ptr %56, i32 0, i32 7
  store ptr %54, ptr %57, align 8, !tbaa !18
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = load ptr, ptr %6, align 8, !tbaa !9
  %60 = load ptr, ptr %59, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct._WffNode, ptr %60, i32 0, i32 7
  %62 = load ptr, ptr %61, align 8, !tbaa !18
  %63 = getelementptr inbounds %struct._Fact, ptr %62, i32 0, i32 0
  store i32 %58, ptr %63, align 4, !tbaa !19
  %64 = load ptr, ptr %6, align 8, !tbaa !9
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct._WffNode, ptr %65, i32 0, i32 9
  %67 = load ptr, ptr %66, align 8, !tbaa !17
  call void @free(ptr noundef %67) #5
  %68 = load ptr, ptr %6, align 8, !tbaa !9
  %69 = load ptr, ptr %68, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct._WffNode, ptr %69, i32 0, i32 9
  store ptr null, ptr %70, align 8, !tbaa !17
  br label %71

71:                                               ; preds = %41, %30
  br label %79

72:                                               ; preds = %3, %3, %3, %3
  br label %79

73:                                               ; preds = %3
  %74 = load ptr, ptr %6, align 8, !tbaa !9
  %75 = load ptr, ptr %74, align 8, !tbaa !9
  %76 = getelementptr inbounds %struct._WffNode, ptr %75, i32 0, i32 0
  %77 = load i32, ptr %76, align 8, !tbaa !11
  %78 = call i32 (ptr, ...) @printf(ptr noundef @.str.120, i32 noundef %77)
  call void @exit(i32 noundef 1) #6
  unreachable

79:                                               ; preds = %72, %71, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #5
  ret void
}

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 "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 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 #5 = { nounwind }
attributes #6 = { 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 24}
!14 = !{!12, !10, i64 32}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!12, !10, i64 64}
!18 = !{!12, !10, i64 48}
!19 = !{!20, !6, i64 0}
!20 = !{!"_Fact", !6, i64 0, !7, i64 4}
!21 = !{!12, !6, i64 56}


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

@.str.119 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.120 = external hidden unnamed_addr constant [56 x i8], align 1

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

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

; Function Attrs: mustprogress 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) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
define dso_local void @replace_not_p_with_n_in_wff(i32 noundef %0, i32 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #4 {
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  %5 = load ptr, ptr %2, align 8, !tbaa !5
  %6 = load i32, ptr %5, align 8, !tbaa !9
  switch i32 %6, label %29 [
    i32 2008, label %7
    i32 2009, label %7
    i32 2006, label %9
    i32 2007, label %9
    i32 2005, label %12
    i32 2002, label %.loopexit
    i32 2003, label %.loopexit
    i32 2000, label %.loopexit
    i32 2001, label %.loopexit
  ]

7:                                                ; preds = %3, %3
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.119)
  tail call void @exit(i32 noundef 1) #6
  unreachable

9:                                                ; preds = %3, %3
  %10 = getelementptr inbounds i8, ptr %5, i64 24
  %storemerge15 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %storemerge15, ptr %4, align 8, !tbaa !5
  %.not16 = icmp eq ptr %storemerge15, null
  br i1 %.not16, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %9, %.lr.ph
  %storemerge17 = phi ptr [ %storemerge, %.lr.ph ], [ %storemerge15, %9 ]
  call void @replace_not_p_with_n_in_wff(i32 noundef %0, i32 noundef %1, ptr noundef nonnull %4)
  %11 = getelementptr inbounds i8, ptr %storemerge17, i64 32
  %storemerge = load ptr, ptr %11, align 8, !tbaa !5
  store ptr %storemerge, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %storemerge, null
  br i1 %.not, label %.loopexit, label %.lr.ph, !llvm.loop !12

12:                                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %5, i64 64
  %14 = load ptr, ptr %13, align 8, !tbaa !14
  %15 = getelementptr inbounds i8, ptr %14, i64 48
  %16 = load ptr, ptr %15, align 8, !tbaa !15
  %17 = load i32, ptr %16, align 4, !tbaa !16
  %18 = icmp eq i32 %17, %0
  br i1 %18, label %19, label %.loopexit

19:                                               ; preds = %12
  store i32 2002, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds i8, ptr %5, i64 56
  store i32 %0, ptr %20, align 8, !tbaa !18
  %21 = getelementptr inbounds i8, ptr %5, i64 48
  store ptr %16, ptr %21, align 8, !tbaa !15
  %22 = load ptr, ptr %2, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 48
  %24 = load ptr, ptr %23, align 8, !tbaa !15
  store i32 %1, ptr %24, align 4, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %22, i64 64
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  tail call void @free(ptr noundef %26) #5
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds i8, ptr %27, i64 64
  store ptr null, ptr %28, align 8, !tbaa !14
  br label %.loopexit

29:                                               ; preds = %3
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.120, i32 noundef %6)
  tail call void @exit(i32 noundef 1) #6
  unreachable

.loopexit:                                        ; preds = %.lr.ph, %9, %3, %3, %3, %3, %12, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  ret void
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 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 #5 = { nounwind }
attributes #6 = { 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, !11, i64 0}
!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 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !6, i64 64}
!15 = !{!10, !6, i64 48}
!16 = !{!17, !11, i64 0}
!17 = !{!"_Fact", !11, i64 0, !7, i64 4}
!18 = !{!10, !11, i64 56}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass