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

@garity = external global [50 x i32], align 16
@gis_deleted = external global [50 x i8], align 16
@gnum_initial_predicate = external global ptr, align 8
@ginitial_predicate = external 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

; Function Attrs: nounwind uwtable
define dso_local zeroext i8 @possibly_negative(ptr noundef %0) #1 {
  %2 = alloca i8, align 1
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %6 = load ptr, ptr %3, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct._Fact, ptr %6, i32 0, i32 0
  %8 = load i32, ptr %7, align 4, !tbaa !9
  %9 = sext i32 %8 to i64
  %10 = getelementptr inbounds [50 x i8], ptr @gis_deleted, i64 0, i64 %9
  %11 = load i8, ptr %10, align 1, !tbaa !12
  %12 = icmp ne i8 %11, 0
  br i1 %12, label %13, label %14

13:                                               ; preds = %1
  store i8 1, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %68

14:                                               ; preds = %1
  store i32 0, ptr %4, align 4, !tbaa !13
  br label %15

15:                                               ; preds = %34, %14
  %16 = load i32, ptr %4, align 4, !tbaa !13
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct._Fact, ptr %17, i32 0, i32 0
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %20
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = icmp slt i32 %16, %22
  br i1 %23, label %24, label %37

24:                                               ; preds = %15
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._Fact, ptr %25, i32 0, i32 1
  %27 = load i32, ptr %4, align 4, !tbaa !13
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [5 x i32], ptr %26, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !13
  %31 = icmp slt i32 %30, 0
  br i1 %31, label %32, label %33

32:                                               ; preds = %24
  store i8 1, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %68

33:                                               ; preds = %24
  br label %34

34:                                               ; preds = %33
  %35 = load i32, ptr %4, align 4, !tbaa !13
  %36 = add nsw i32 %35, 1
  store i32 %36, ptr %4, align 4, !tbaa !13
  br label %15, !llvm.loop !14

37:                                               ; preds = %15
  store i32 0, ptr %4, align 4, !tbaa !13
  br label %38

38:                                               ; preds = %64, %37
  %39 = load i32, ptr %4, align 4, !tbaa !13
  %40 = load ptr, ptr @gnum_initial_predicate, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct._Fact, ptr %41, i32 0, i32 0
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = getelementptr inbounds i32, ptr %40, i64 %44
  %46 = load i32, ptr %45, align 4, !tbaa !13
  %47 = icmp slt i32 %39, %46
  br i1 %47, label %48, label %67

48:                                               ; preds = %38
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = load ptr, ptr @ginitial_predicate, align 8, !tbaa !5
  %51 = load ptr, ptr %3, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._Fact, ptr %51, i32 0, i32 0
  %53 = load i32, ptr %52, align 4, !tbaa !9
  %54 = sext i32 %53 to i64
  %55 = getelementptr inbounds ptr, ptr %50, i64 %54
  %56 = load ptr, ptr %55, align 8, !tbaa !5
  %57 = load i32, ptr %4, align 4, !tbaa !13
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds %struct._Fact, ptr %56, i64 %58
  %60 = call zeroext i8 @matches(ptr noundef %49, ptr noundef %59)
  %61 = icmp ne i8 %60, 0
  br i1 %61, label %62, label %63

62:                                               ; preds = %48
  store i8 0, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %68

63:                                               ; preds = %48
  br label %64

64:                                               ; preds = %63
  %65 = load i32, ptr %4, align 4, !tbaa !13
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %4, align 4, !tbaa !13
  br label %38, !llvm.loop !16

67:                                               ; preds = %38
  store i8 1, ptr %2, align 1
  store i32 1, ptr %5, align 4
  br label %68

68:                                               ; preds = %67, %62, %32, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  %69 = load i8, ptr %2, align 1
  ret i8 %69
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @matches(ptr noundef, ptr noundef) #1

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


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

%struct._Fact = type { i32, [5 x i32] }

@garity = external local_unnamed_addr global [50 x i32], align 16
@gis_deleted = external local_unnamed_addr global [50 x i8], align 16
@gnum_initial_predicate = external local_unnamed_addr global ptr, align 8
@ginitial_predicate = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local zeroext range(i8 0, 2) i8 @possibly_negative(ptr noundef %0) local_unnamed_addr #0 {
  %2 = load i32, ptr %0, align 4, !tbaa !5
  %3 = sext i32 %2 to i64
  %4 = getelementptr inbounds [50 x i8], ptr @gis_deleted, i64 0, i64 %3
  %5 = load i8, ptr %4, align 1, !tbaa !10
  %.not = icmp eq i8 %5, 0
  br i1 %.not, label %.preheader14, label %.loopexit

.preheader14:                                     ; preds = %1
  %6 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %3
  %7 = load i32, ptr %6, align 4, !tbaa !11
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %.preheader

.lr.ph:                                           ; preds = %.preheader14
  %9 = getelementptr inbounds i8, ptr %0, i64 4
  %wide.trip.count = zext nneg i32 %7 to i64
  br label %15

10:                                               ; preds = %15
  %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 %.preheader, label %15, !llvm.loop !12

.preheader:                                       ; preds = %10, %.preheader14
  %11 = load ptr, ptr @gnum_initial_predicate, align 8, !tbaa !14
  %12 = getelementptr inbounds i32, ptr %11, i64 %3
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %.lr.ph18, label %.loopexit

15:                                               ; preds = %.lr.ph, %10
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %10 ]
  %16 = getelementptr inbounds [5 x i32], ptr %9, i64 0, i64 %indvars.iv
  %17 = load i32, ptr %16, align 4, !tbaa !11
  %18 = icmp slt i32 %17, 0
  br i1 %18, label %.loopexit, label %10

19:                                               ; preds = %.lr.ph18
  %indvars.iv.next24 = add nuw nsw i64 %indvars.iv23, 1
  %20 = load ptr, ptr @gnum_initial_predicate, align 8, !tbaa !14
  %21 = load i32, ptr %0, align 4, !tbaa !5
  %22 = sext i32 %21 to i64
  %23 = getelementptr inbounds i32, ptr %20, i64 %22
  %24 = load i32, ptr %23, align 4, !tbaa !11
  %25 = sext i32 %24 to i64
  %26 = icmp slt i64 %indvars.iv.next24, %25
  br i1 %26, label %.lr.ph18, label %.loopexit, !llvm.loop !16

.lr.ph18:                                         ; preds = %.preheader, %19
  %indvars.iv23 = phi i64 [ %indvars.iv.next24, %19 ], [ 0, %.preheader ]
  %27 = phi i64 [ %22, %19 ], [ %3, %.preheader ]
  %28 = load ptr, ptr @ginitial_predicate, align 8, !tbaa !14
  %29 = getelementptr inbounds ptr, ptr %28, i64 %27
  %30 = load ptr, ptr %29, align 8, !tbaa !14
  %31 = getelementptr inbounds %struct._Fact, ptr %30, i64 %indvars.iv23
  %32 = tail call zeroext i8 @matches(ptr noundef nonnull %0, ptr noundef %31)
  %.not13 = icmp eq i8 %32, 0
  br i1 %.not13, label %19, label %.loopexit

.loopexit:                                        ; preds = %15, %.lr.ph18, %19, %.preheader, %1
  %.012 = phi i8 [ 1, %1 ], [ 1, %.preheader ], [ 0, %.lr.ph18 ], [ 1, %19 ], [ 1, %15 ]
  ret i8 %.012
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i8 @matches(ptr noundef, ptr noundef) local_unnamed_addr #0

attributes #0 = { 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" }

!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 = !{!"_Fact", !7, i64 0, !8, i64 4}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!8, !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"any pointer", !8, i64 0}
!16 = distinct !{!16, !13}


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