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

; 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._NumericEffect = type { %struct._Fluent, i32, ptr, ptr, ptr }
%struct._Fluent = type { i32, [5 x i32] }

@gf_arity = 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 void @decrement_inferior_vars_in_numeric_effects(i32 noundef %0, ptr noundef %1) #1 {
  %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) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %7 = load ptr, ptr %4, align 8, !tbaa !9
  store ptr %7, ptr %5, align 8, !tbaa !9
  br label %8

8:                                                ; preds = %62, %2
  %9 = load ptr, ptr %5, align 8, !tbaa !9
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %66

11:                                               ; preds = %8
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %54, %11
  %13 = load i32, ptr %6, align 4, !tbaa !5
  %14 = load ptr, ptr %5, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct._NumericEffect, ptr %14, i32 0, i32 0
  %16 = getelementptr inbounds %struct._Fluent, ptr %15, i32 0, i32 0
  %17 = load i32, ptr %16, align 8, !tbaa !11
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [50 x i32], ptr @gf_arity, i64 0, i64 %18
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = icmp slt i32 %13, %20
  br i1 %21, label %22, label %57

22:                                               ; preds = %12
  %23 = load ptr, ptr %5, align 8, !tbaa !9
  %24 = getelementptr inbounds %struct._NumericEffect, ptr %23, i32 0, i32 0
  %25 = getelementptr inbounds %struct._Fluent, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %6, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [5 x i32], ptr %25, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = icmp sge i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %22
  br label %54

32:                                               ; preds = %22
  %33 = load ptr, ptr %5, align 8, !tbaa !9
  %34 = getelementptr inbounds %struct._NumericEffect, ptr %33, i32 0, i32 0
  %35 = getelementptr inbounds %struct._Fluent, ptr %34, i32 0, i32 1
  %36 = load i32, ptr %6, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [5 x i32], ptr %35, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !5
  %40 = add nsw i32 %39, 1
  %41 = mul nsw i32 %40, -1
  %42 = load i32, ptr %3, align 4, !tbaa !5
  %43 = icmp sgt i32 %41, %42
  br i1 %43, label %44, label %53

44:                                               ; preds = %32
  %45 = load ptr, ptr %5, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct._NumericEffect, ptr %45, i32 0, i32 0
  %47 = getelementptr inbounds %struct._Fluent, ptr %46, i32 0, i32 1
  %48 = load i32, ptr %6, align 4, !tbaa !5
  %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 !5
  %52 = add nsw i32 %51, 1
  store i32 %52, ptr %50, align 4, !tbaa !5
  br label %53

53:                                               ; preds = %44, %32
  br label %54

54:                                               ; preds = %53, %31
  %55 = load i32, ptr %6, align 4, !tbaa !5
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %6, align 4, !tbaa !5
  br label %12, !llvm.loop !14

57:                                               ; preds = %12
  %58 = load i32, ptr %3, align 4, !tbaa !5
  %59 = load ptr, ptr %5, align 8, !tbaa !9
  %60 = getelementptr inbounds %struct._NumericEffect, ptr %59, i32 0, i32 2
  %61 = load ptr, ptr %60, align 8, !tbaa !16
  call void @decrement_inferior_vars_in_exp(i32 noundef %58, ptr noundef %61)
  br label %62

62:                                               ; preds = %57
  %63 = load ptr, ptr %5, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct._NumericEffect, ptr %63, i32 0, i32 3
  %65 = load ptr, ptr %64, align 8, !tbaa !17
  store ptr %65, ptr %5, align 8, !tbaa !9
  br label %8, !llvm.loop !18

66:                                               ; preds = %8
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

declare void @decrement_inferior_vars_in_exp(i32 noundef, ptr noundef) #2

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 = { 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 = !{!"_NumericEffect", !13, i64 0, !6, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!13 = !{!"_Fluent", !6, i64 0, !7, i64 4}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !10, i64 40}
!18 = distinct !{!18, !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"

@gf_arity = external local_unnamed_addr global [50 x i32], align 16

; Function Attrs: nounwind uwtable
define dso_local void @decrement_inferior_vars_in_numeric_effects(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %.not18 = icmp eq ptr %1, null
  br i1 %.not18, label %._crit_edge20, label %.preheader

.preheader:                                       ; preds = %2, %._crit_edge
  %.01419 = phi ptr [ %25, %._crit_edge ], [ %1, %2 ]
  %3 = load i32, ptr %.01419, align 8, !tbaa !5
  %4 = sext i32 %3 to i64
  %5 = getelementptr inbounds [50 x i32], ptr @gf_arity, i64 0, i64 %4
  %6 = load i32, ptr %5, align 4, !tbaa !12
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %8 = getelementptr inbounds i8, ptr %.01419, i64 4
  br label %9

9:                                                ; preds = %.lr.ph, %18
  %10 = phi i32 [ %6, %.lr.ph ], [ %19, %18 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %18 ]
  %11 = getelementptr inbounds [5 x i32], ptr %8, i64 0, i64 %indvars.iv
  %12 = load i32, ptr %11, align 4, !tbaa !12
  %13 = icmp slt i32 %12, 0
  %14 = xor i32 %12, -1
  %15 = icmp sgt i32 %14, %0
  %or.cond = and i1 %13, %15
  br i1 %or.cond, label %16, label %18

16:                                               ; preds = %9
  %17 = add nsw i32 %12, 1
  store i32 %17, ptr %11, align 4, !tbaa !12
  %.pre = load i32, ptr %5, align 4, !tbaa !12
  br label %18

18:                                               ; preds = %16, %9
  %19 = phi i32 [ %.pre, %16 ], [ %10, %9 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %20 = sext i32 %19 to i64
  %21 = icmp slt i64 %indvars.iv.next, %20
  br i1 %21, label %9, label %._crit_edge, !llvm.loop !13

._crit_edge:                                      ; preds = %18, %.preheader
  %22 = getelementptr inbounds i8, ptr %.01419, i64 32
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  tail call void @decrement_inferior_vars_in_exp(i32 noundef %0, ptr noundef %23) #2
  %24 = getelementptr inbounds i8, ptr %.01419, i64 40
  %25 = load ptr, ptr %24, align 8, !tbaa !16
  %.not = icmp eq ptr %25, null
  br i1 %.not, label %._crit_edge20, label %.preheader, !llvm.loop !17

._crit_edge20:                                    ; preds = %._crit_edge, %2
  ret void
}

declare void @decrement_inferior_vars_in_exp(i32 noundef, ptr noundef) local_unnamed_addr #1

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


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