; LLVM IR from askforalfred/alfred :: gen/ff_planner (inst_final)

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

@garity = external global [50 x i32], align 16
@gpredicates_args_type = external global [50 x [5 x i32]], align 16
@gtype_size = external global [50 x i32], align 16
@lp = external dso_local global i32, align 4
@largs = external dso_local global [15 x i32], align 16
@.str.11 = external hidden unnamed_addr constant [41 x i8], align 1
@gmember_nr = external global [2000 x [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: nounwind uwtable
define dso_local i32 @fact_adress() #1 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca [5 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  store i32 0, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  store i32 1, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 5, ptr %7) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %8

8:                                                ; preds = %19, %0
  %9 = load i32, ptr %3, align 4, !tbaa !5
  %10 = load i32, ptr @lp, align 4, !tbaa !5
  %11 = sext i32 %10 to i64
  %12 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %11
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = icmp slt i32 %9, %13
  br i1 %14, label %15, label %22

15:                                               ; preds = %8
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [5 x i8], ptr %7, i64 0, i64 %17
  store i8 0, ptr %18, align 1, !tbaa !9
  br label %19

19:                                               ; preds = %15
  %20 = load i32, ptr %3, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr %3, align 4, !tbaa !5
  br label %8, !llvm.loop !10

22:                                               ; preds = %8
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %23

23:                                               ; preds = %112, %22
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = load i32, ptr @lp, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %26
  %28 = load i32, ptr %27, align 4, !tbaa !5
  %29 = icmp slt i32 %24, %28
  br i1 %29, label %30, label %115

30:                                               ; preds = %23
  store i32 -1, ptr %5, align 4, !tbaa !5
  store i32 -1, ptr %6, align 4, !tbaa !5
  store i32 0, ptr %4, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %74, %30
  %32 = load i32, ptr %4, align 4, !tbaa !5
  %33 = load i32, ptr @lp, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %34
  %36 = load i32, ptr %35, align 4, !tbaa !5
  %37 = icmp slt i32 %32, %36
  br i1 %37, label %38, label %77

38:                                               ; preds = %31
  %39 = load i32, ptr %4, align 4, !tbaa !5
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [5 x i8], ptr %7, i64 0, i64 %40
  %42 = load i8, ptr %41, align 1, !tbaa !9
  %43 = icmp ne i8 %42, 0
  br i1 %43, label %73, label %44

44:                                               ; preds = %38
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = icmp eq i32 %45, -1
  br i1 %46, label %60, label %47

47:                                               ; preds = %44
  %48 = load i32, ptr @lp, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [50 x [5 x i32]], ptr @gpredicates_args_type, i64 0, i64 %49
  %51 = load i32, ptr %4, align 4, !tbaa !5
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [5 x i32], ptr %50, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [50 x i32], ptr @gtype_size, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !5
  %58 = load i32, ptr %5, align 4, !tbaa !5
  %59 = icmp slt i32 %57, %58
  br i1 %59, label %60, label %72

60:                                               ; preds = %47, %44
  %61 = load i32, ptr @lp, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [50 x [5 x i32]], ptr @gpredicates_args_type, i64 0, i64 %62
  %64 = load i32, ptr %4, align 4, !tbaa !5
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds [5 x i32], ptr %63, i64 0, i64 %65
  %67 = load i32, ptr %66, align 4, !tbaa !5
  %68 = sext i32 %67 to i64
  %69 = getelementptr inbounds [50 x i32], ptr @gtype_size, i64 0, i64 %68
  %70 = load i32, ptr %69, align 4, !tbaa !5
  store i32 %70, ptr %5, align 4, !tbaa !5
  %71 = load i32, ptr %4, align 4, !tbaa !5
  store i32 %71, ptr %6, align 4, !tbaa !5
  br label %72

72:                                               ; preds = %60, %47
  br label %73

73:                                               ; preds = %72, %38
  br label %74

74:                                               ; preds = %73
  %75 = load i32, ptr %4, align 4, !tbaa !5
  %76 = add nsw i32 %75, 1
  store i32 %76, ptr %4, align 4, !tbaa !5
  br label %31, !llvm.loop !12

77:                                               ; preds = %31
  %78 = load i32, ptr %6, align 4, !tbaa !5
  %79 = icmp eq i32 %78, -1
  br i1 %79, label %83, label %80

80:                                               ; preds = %77
  %81 = load i32, ptr %5, align 4, !tbaa !5
  %82 = icmp eq i32 %81, -1
  br i1 %82, label %83, label %85

83:                                               ; preds = %80, %77
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  call void @exit(i32 noundef 1) #5
  unreachable

85:                                               ; preds = %80
  %86 = load i32, ptr %2, align 4, !tbaa !5
  %87 = load i32, ptr %6, align 4, !tbaa !5
  %88 = sext i32 %87 to i64
  %89 = getelementptr inbounds [15 x i32], ptr @largs, i64 0, i64 %88
  %90 = load i32, ptr %89, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds [2000 x [50 x i32]], ptr @gmember_nr, i64 0, i64 %91
  %93 = load i32, ptr @lp, align 4, !tbaa !5
  %94 = sext i32 %93 to i64
  %95 = getelementptr inbounds [50 x [5 x i32]], ptr @gpredicates_args_type, i64 0, i64 %94
  %96 = load i32, ptr %6, align 4, !tbaa !5
  %97 = sext i32 %96 to i64
  %98 = getelementptr inbounds [5 x i32], ptr %95, i64 0, i64 %97
  %99 = load i32, ptr %98, align 4, !tbaa !5
  %100 = sext i32 %99 to i64
  %101 = getelementptr inbounds [50 x i32], ptr %92, i64 0, i64 %100
  %102 = load i32, ptr %101, align 4, !tbaa !5
  %103 = mul nsw i32 %86, %102
  %104 = load i32, ptr %1, align 4, !tbaa !5
  %105 = add nsw i32 %104, %103
  store i32 %105, ptr %1, align 4, !tbaa !5
  %106 = load i32, ptr %5, align 4, !tbaa !5
  %107 = load i32, ptr %2, align 4, !tbaa !5
  %108 = mul nsw i32 %107, %106
  store i32 %108, ptr %2, align 4, !tbaa !5
  %109 = load i32, ptr %6, align 4, !tbaa !5
  %110 = sext i32 %109 to i64
  %111 = getelementptr inbounds [5 x i8], ptr %7, i64 0, i64 %110
  store i8 1, ptr %111, align 1, !tbaa !9
  br label %112

112:                                              ; preds = %85
  %113 = load i32, ptr %3, align 4, !tbaa !5
  %114 = add nsw i32 %113, 1
  store i32 %114, ptr %3, align 4, !tbaa !5
  br label %23, !llvm.loop !13

115:                                              ; preds = %23
  %116 = load i32, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 5, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret i32 %116
}

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

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

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

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 = { "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 "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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}
!13 = distinct !{!13, !11}


; 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
@gpredicates_args_type = external local_unnamed_addr global [50 x [5 x i32]], align 16
@gtype_size = external local_unnamed_addr global [50 x i32], align 16
@lp = external dso_local local_unnamed_addr global i32, align 4
@largs = external dso_local local_unnamed_addr global [15 x i32], align 16
@.str.11 = external hidden unnamed_addr constant [41 x i8], align 1
@gmember_nr = external local_unnamed_addr global [2000 x [50 x i32]], align 16

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

; Function Attrs: nounwind uwtable
define dso_local i32 @fact_adress() local_unnamed_addr #1 {
  %1 = alloca [5 x i8], align 1
  call void @llvm.lifetime.start.p0(i64 5, ptr nonnull %1) #5
  %2 = load i32, ptr @lp, align 4, !tbaa !5
  %3 = sext i32 %2 to i64
  %4 = getelementptr inbounds [50 x i32], ptr @garity, i64 0, i64 %3
  %5 = load i32, ptr %4, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.preheader.us.preheader, label %._crit_edge45

.preheader.us.preheader:                          ; preds = %0
  %7 = zext nneg i32 %5 to i64
  call void @llvm.memset.p0.i64(ptr nonnull align 1 %1, i8 0, i64 %7, i1 false), !tbaa !9
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.us.preheader, %8
  %.12844.us = phi i32 [ %22, %8 ], [ 0, %.preheader.us.preheader ]
  %.02943.us = phi i32 [ %20, %8 ], [ 1, %.preheader.us.preheader ]
  %.03042.us = phi i32 [ %19, %8 ], [ 0, %.preheader.us.preheader ]
  br label %23

8:                                                ; preds = %._crit_edge.us
  %9 = sext i32 %.1.us to i64
  %10 = getelementptr inbounds [15 x i32], ptr @largs, i64 0, i64 %9
  %11 = load i32, ptr %10, align 4, !tbaa !5
  %12 = sext i32 %11 to i64
  %13 = getelementptr inbounds [50 x [5 x i32]], ptr @gpredicates_args_type, i64 0, i64 %3, i64 %9
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = sext i32 %14 to i64
  %16 = getelementptr inbounds [2000 x [50 x i32]], ptr @gmember_nr, i64 0, i64 %12, i64 %15
  %17 = load i32, ptr %16, align 4, !tbaa !5
  %18 = mul nsw i32 %17, %.02943.us
  %19 = add nsw i32 %18, %.03042.us
  %20 = mul nsw i32 %.125.us, %.02943.us
  %21 = getelementptr inbounds [5 x i8], ptr %1, i64 0, i64 %9
  store i8 1, ptr %21, align 1, !tbaa !9
  %22 = add nuw nsw i32 %.12844.us, 1
  %exitcond49.not = icmp eq i32 %22, %5
  br i1 %exitcond49.not, label %._crit_edge45, label %.preheader.us, !llvm.loop !10

23:                                               ; preds = %.preheader.us, %._crit_edge
  %indvars.iv = phi i64 [ 0, %.preheader.us ], [ %indvars.iv.next, %._crit_edge ]
  %.038.us = phi i32 [ -1, %.preheader.us ], [ %.1.us, %._crit_edge ]
  %.02437.us = phi i32 [ -1, %.preheader.us ], [ %.125.us, %._crit_edge ]
  %24 = getelementptr inbounds [5 x i8], ptr %1, i64 0, i64 %indvars.iv
  %25 = load i8, ptr %24, align 1, !tbaa !9
  %.not.us = icmp eq i8 %25, 0
  br i1 %.not.us, label %26, label %._crit_edge

26:                                               ; preds = %23
  %27 = icmp eq i32 %.02437.us, -1
  %.phi.trans.insert = getelementptr inbounds [50 x [5 x i32]], ptr @gpredicates_args_type, i64 0, i64 %3, i64 %indvars.iv
  %.pre = load i32, ptr %.phi.trans.insert, align 4, !tbaa !5
  %.phi.trans.insert50 = sext i32 %.pre to i64
  %.phi.trans.insert51 = getelementptr inbounds [50 x i32], ptr @gtype_size, i64 0, i64 %.phi.trans.insert50
  %.pre52 = load i32, ptr %.phi.trans.insert51, align 4, !tbaa !5
  %28 = icmp slt i32 %.pre52, %.02437.us
  %or.cond = select i1 %27, i1 true, i1 %28
  %29 = trunc nuw nsw i64 %indvars.iv to i32
  %spec.select = select i1 %or.cond, i32 %.pre52, i32 %.02437.us
  %spec.select53 = select i1 %or.cond, i32 %29, i32 %.038.us
  br label %._crit_edge

._crit_edge:                                      ; preds = %26, %23
  %.125.us = phi i32 [ %.02437.us, %23 ], [ %spec.select, %26 ]
  %.1.us = phi i32 [ %.038.us, %23 ], [ %spec.select53, %26 ]
  %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 %._crit_edge.us, label %23, !llvm.loop !12

._crit_edge.us:                                   ; preds = %._crit_edge
  %30 = icmp eq i32 %.1.us, -1
  %31 = icmp eq i32 %.125.us, -1
  %or.cond.us = select i1 %30, i1 true, i1 %31
  br i1 %or.cond.us, label %.split.us, label %8

.split.us:                                        ; preds = %._crit_edge.us
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  tail call void @exit(i32 noundef 1) #6
  unreachable

._crit_edge45:                                    ; preds = %8, %0
  %.030.lcssa = phi i32 [ 0, %0 ], [ %19, %8 ]
  call void @llvm.lifetime.end.p0(i64 5, ptr nonnull %1) #5
  ret i32 %.030.lcssa
}

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

attributes #0 = { mustprogress 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 = { 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 #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !11}


; Effective O3 passes: BDCEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopIdiomRecognizePass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass