; 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

; 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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @are_identical_ATOMs(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i8, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  %8 = load ptr, ptr %4, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct._WffNode, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 8, !tbaa !9
  %11 = icmp ne i32 %10, 2002
  br i1 %11, label %17, label %12

12:                                               ; preds = %2
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct._WffNode, ptr %13, i32 0, i32 0
  %15 = load i32, ptr %14, align 8, !tbaa !9
  %16 = icmp ne i32 %15, 2002
  br i1 %16, label %17, label %18

17:                                               ; preds = %12, %2
  store i8 0, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %67

18:                                               ; preds = %12
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._WffNode, ptr %19, i32 0, i32 7
  %21 = load ptr, ptr %20, align 8, !tbaa !12
  %22 = getelementptr inbounds %struct._Fact, ptr %21, i32 0, i32 0
  %23 = load i32, ptr %22, align 4, !tbaa !13
  %24 = load ptr, ptr %5, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct._WffNode, ptr %24, i32 0, i32 7
  %26 = load ptr, ptr %25, align 8, !tbaa !12
  %27 = getelementptr inbounds %struct._Fact, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 4, !tbaa !13
  %29 = icmp ne i32 %23, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %18
  store i8 0, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %67

31:                                               ; preds = %18
  store i32 0, ptr %6, align 4, !tbaa !15
  br label %32

32:                                               ; preds = %63, %31
  %33 = load i32, ptr %6, align 4, !tbaa !15
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._WffNode, ptr %34, i32 0, i32 7
  %36 = load ptr, ptr %35, align 8, !tbaa !12
  %37 = getelementptr inbounds %struct._Fact, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 4, !tbaa !13
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %39
  %41 = load i32, ptr %40, align 4, !tbaa !15
  %42 = icmp slt i32 %33, %41
  br i1 %42, label %43, label %66

43:                                               ; preds = %32
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._WffNode, ptr %44, i32 0, i32 7
  %46 = load ptr, ptr %45, align 8, !tbaa !12
  %47 = getelementptr inbounds %struct._Fact, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %6, align 4, !tbaa !15
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [5 x i32], ptr %47, i64 0, i64 %49
  %51 = load i32, ptr %50, align 4, !tbaa !15
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._WffNode, ptr %52, i32 0, i32 7
  %54 = load ptr, ptr %53, align 8, !tbaa !12
  %55 = getelementptr inbounds %struct._Fact, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %6, align 4, !tbaa !15
  %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 !15
  %60 = icmp ne i32 %51, %59
  br i1 %60, label %61, label %62

61:                                               ; preds = %43
  store i8 0, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %67

62:                                               ; preds = %43
  br label %63

63:                                               ; preds = %62
  %64 = load i32, ptr %6, align 4, !tbaa !15
  %65 = add nsw i32 %64, 1
  store i32 %65, ptr %6, align 4, !tbaa !15
  br label %32, !llvm.loop !16

66:                                               ; preds = %32
  store i8 1, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %67

67:                                               ; preds = %66, %61, %30, %17
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %68 = load i8, ptr %3, align 1
  ret i8 %68
}

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 = { 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 = !{!10, !6, i64 48}
!13 = !{!14, !11, i64 0}
!14 = !{!"_Fact", !11, i64 0, !7, i64 4}
!15 = !{!11, !11, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; 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

; Function Attrs: nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) uwtable
define dso_local zeroext range(i8 0, 2) i8 @are_identical_ATOMs(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %.not = icmp eq i32 %3, 2002
  br i1 %.not, label %4, label %.loopexit

4:                                                ; preds = %2
  %5 = load i32, ptr %1, align 8, !tbaa !5
  %.not12 = icmp eq i32 %5, 2002
  br i1 %.not12, label %6, label %.loopexit

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %9 = load i32, ptr %8, align 4, !tbaa !12
  %10 = getelementptr inbounds i8, ptr %1, i64 48
  %11 = load ptr, ptr %10, align 8, !tbaa !11
  %12 = load i32, ptr %11, align 4, !tbaa !12
  %.not13 = icmp eq i32 %9, %12
  br i1 %.not13, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %6
  %13 = getelementptr inbounds i8, ptr %8, i64 4
  %14 = sext i32 %9 to i64
  %15 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %14
  %16 = load i32, ptr %15, align 4, !tbaa !14
  %17 = icmp sgt i32 %16, 0
  br i1 %17, label %.lr.ph, label %.loopexit

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

19:                                               ; preds = %20
  %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 %20, !llvm.loop !15

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

.loopexit:                                        ; preds = %20, %19, %.preheader, %6, %2, %4
  %.011 = phi i8 [ 0, %4 ], [ 0, %2 ], [ 0, %6 ], [ 1, %.preheader ], [ 0, %20 ], [ 1, %19 ]
  ret i8 %.011
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, inaccessiblemem: none) 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" }

!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 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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