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

@gf_arity = external global [50 x i32], align 16
@.str.96 = external hidden unnamed_addr constant [47 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 uwtable
define dso_local void @decrement_inferior_vars_in_exp(i32 noundef %0, ptr noundef %1) #3 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = 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 4, ptr %5) #4
  %6 = load ptr, ptr %4, align 8, !tbaa !9
  %7 = getelementptr inbounds %struct._ExpNode, ptr %6, i32 0, i32 0
  %8 = load i32, ptr %7, align 8, !tbaa !11
  switch i32 %8, label %81 [
    i32 1003, label %9
    i32 1004, label %9
    i32 1005, label %9
    i32 1006, label %9
    i32 1002, label %18
    i32 1001, label %86
    i32 1000, label %23
  ]

9:                                                ; preds = %2, %2, %2, %2
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = load ptr, ptr %4, align 8, !tbaa !9
  %12 = getelementptr inbounds %struct._ExpNode, ptr %11, i32 0, i32 6
  %13 = load ptr, ptr %12, align 8, !tbaa !14
  call void @decrement_inferior_vars_in_exp(i32 noundef %10, ptr noundef %13)
  %14 = load i32, ptr %3, align 4, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !9
  %16 = getelementptr inbounds %struct._ExpNode, ptr %15, i32 0, i32 7
  %17 = load ptr, ptr %16, align 8, !tbaa !15
  call void @decrement_inferior_vars_in_exp(i32 noundef %14, ptr noundef %17)
  br label %86

18:                                               ; preds = %2
  %19 = load i32, ptr %3, align 4, !tbaa !5
  %20 = load ptr, ptr %4, align 8, !tbaa !9
  %21 = getelementptr inbounds %struct._ExpNode, ptr %20, i32 0, i32 5
  %22 = load ptr, ptr %21, align 8, !tbaa !16
  call void @decrement_inferior_vars_in_exp(i32 noundef %19, ptr noundef %22)
  br label %86

23:                                               ; preds = %2
  %24 = load ptr, ptr %4, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct._ExpNode, ptr %24, i32 0, i32 1
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %79

28:                                               ; preds = %23
  store i32 0, ptr %5, align 4, !tbaa !5
  br label %29

29:                                               ; preds = %75, %28
  %30 = load i32, ptr %5, align 4, !tbaa !5
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct._ExpNode, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !17
  %34 = getelementptr inbounds %struct._Fluent, ptr %33, i32 0, i32 0
  %35 = load i32, ptr %34, align 4, !tbaa !18
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds [50 x i32], ptr @gf_arity, i64 0, i64 %36
  %38 = load i32, ptr %37, align 4, !tbaa !5
  %39 = icmp slt i32 %30, %38
  br i1 %39, label %40, label %78

40:                                               ; preds = %29
  %41 = load ptr, ptr %4, align 8, !tbaa !9
  %42 = getelementptr inbounds %struct._ExpNode, ptr %41, i32 0, i32 1
  %43 = load ptr, ptr %42, align 8, !tbaa !17
  %44 = getelementptr inbounds %struct._Fluent, ptr %43, i32 0, i32 1
  %45 = load i32, ptr %5, align 4, !tbaa !5
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [5 x i32], ptr %44, i64 0, i64 %46
  %48 = load i32, ptr %47, align 4, !tbaa !5
  %49 = icmp sge i32 %48, 0
  br i1 %49, label %50, label %51

50:                                               ; preds = %40
  br label %75

51:                                               ; preds = %40
  %52 = load ptr, ptr %4, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct._ExpNode, ptr %52, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  %55 = getelementptr inbounds %struct._Fluent, ptr %54, i32 0, i32 1
  %56 = load i32, ptr %5, align 4, !tbaa !5
  %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 !5
  %60 = add nsw i32 %59, 1
  %61 = mul nsw i32 %60, -1
  %62 = load i32, ptr %3, align 4, !tbaa !5
  %63 = icmp sgt i32 %61, %62
  br i1 %63, label %64, label %74

64:                                               ; preds = %51
  %65 = load ptr, ptr %4, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct._ExpNode, ptr %65, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !17
  %68 = getelementptr inbounds %struct._Fluent, ptr %67, i32 0, i32 1
  %69 = load i32, ptr %5, align 4, !tbaa !5
  %70 = sext i32 %69 to i64
  %71 = getelementptr inbounds [5 x i32], ptr %68, i64 0, i64 %70
  %72 = load i32, ptr %71, align 4, !tbaa !5
  %73 = add nsw i32 %72, 1
  store i32 %73, ptr %71, align 4, !tbaa !5
  br label %74

74:                                               ; preds = %64, %51
  br label %75

75:                                               ; preds = %74, %50
  %76 = load i32, ptr %5, align 4, !tbaa !5
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %5, align 4, !tbaa !5
  br label %29, !llvm.loop !20

78:                                               ; preds = %29
  br label %80

79:                                               ; preds = %23
  br label %80

80:                                               ; preds = %79, %78
  br label %86

81:                                               ; preds = %2
  %82 = load ptr, ptr %4, align 8, !tbaa !9
  %83 = getelementptr inbounds %struct._ExpNode, ptr %82, i32 0, i32 0
  %84 = load i32, ptr %83, align 8, !tbaa !11
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.96, i32 noundef %84)
  call void @exit(i32 noundef 1) #5
  unreachable

86:                                               ; preds = %80, %18, %9, %2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  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 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 #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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_ExpNode", !6, i64 0, !10, i64 8, !6, i64 16, !13, i64 20, !13, i64 24, !10, i64 32, !10, i64 40, !10, i64 48}
!13 = !{!"float", !7, i64 0}
!14 = !{!12, !10, i64 40}
!15 = !{!12, !10, i64 48}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !10, i64 8}
!18 = !{!19, !6, i64 0}
!19 = !{!"_Fluent", !6, i64 0, !7, i64 4}
!20 = distinct !{!20, !21}
!21 = !{!"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"

@gf_arity = external local_unnamed_addr global [50 x i32], align 16
@.str.96 = external hidden unnamed_addr constant [47 x i8], align 1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @decrement_inferior_vars_in_exp(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse.backedge, %2
  %.tr20 = phi ptr [ %1, %2 ], [ %.tr20.be, %tailrecurse.backedge ]
  %3 = load i32, ptr %.tr20, align 8, !tbaa !5
  switch i32 %3, label %30 [
    i32 1003, label %4
    i32 1004, label %4
    i32 1005, label %4
    i32 1006, label %4
    i32 1002, label %tailrecurse.backedge
    i32 1001, label %.loopexit
    i32 1000, label %8
  ]

4:                                                ; preds = %tailrecurse, %tailrecurse, %tailrecurse, %tailrecurse
  %5 = getelementptr inbounds i8, ptr %.tr20, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  tail call void @decrement_inferior_vars_in_exp(i32 noundef %0, ptr noundef %6)
  br label %tailrecurse.backedge

tailrecurse.backedge:                             ; preds = %tailrecurse, %4
  %.sink = phi i64 [ 48, %4 ], [ 32, %tailrecurse ]
  %7 = getelementptr inbounds i8, ptr %.tr20, i64 %.sink
  %.tr20.be = load ptr, ptr %7, align 8, !tbaa !13
  br label %tailrecurse

8:                                                ; preds = %tailrecurse
  %9 = getelementptr inbounds i8, ptr %.tr20, i64 8
  %10 = load ptr, ptr %9, align 8, !tbaa !14
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %.loopexit, label %.preheader

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

.lr.ph:                                           ; preds = %.preheader
  %16 = getelementptr inbounds i8, ptr %10, i64 4
  br label %17

17:                                               ; preds = %.lr.ph, %26
  %18 = phi i32 [ %14, %.lr.ph ], [ %27, %26 ]
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %26 ]
  %19 = getelementptr inbounds [5 x i32], ptr %16, i64 0, i64 %indvars.iv
  %20 = load i32, ptr %19, align 4, !tbaa !17
  %21 = icmp slt i32 %20, 0
  %22 = xor i32 %20, -1
  %23 = icmp sgt i32 %22, %0
  %or.cond = and i1 %21, %23
  br i1 %or.cond, label %24, label %26

24:                                               ; preds = %17
  %25 = add nsw i32 %20, 1
  store i32 %25, ptr %19, align 4, !tbaa !17
  %.pre = load i32, ptr %13, align 4, !tbaa !17
  br label %26

26:                                               ; preds = %24, %17
  %27 = phi i32 [ %.pre, %24 ], [ %18, %17 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %28 = sext i32 %27 to i64
  %29 = icmp slt i64 %indvars.iv.next, %28
  br i1 %29, label %17, label %.loopexit, !llvm.loop !18

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

.loopexit:                                        ; preds = %tailrecurse, %26, %.preheader, %8
  ret void
}

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


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