; 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.94 = external hidden unnamed_addr constant [42 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 zeroext i8 @var_used_in_exp(i32 noundef %0, ptr noundef %1) #3 {
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %8 = load ptr, ptr %5, align 8, !tbaa !9
  %9 = getelementptr inbounds %struct._ExpNode, ptr %8, i32 0, i32 0
  %10 = load i32, ptr %9, align 8, !tbaa !11
  switch i32 %10, label %86 [
    i32 1003, label %11
    i32 1004, label %11
    i32 1005, label %11
    i32 1006, label %11
    i32 1002, label %29
    i32 1001, label %38
    i32 1000, label %39
  ]

11:                                               ; preds = %2, %2, %2, %2
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct._ExpNode, ptr %13, i32 0, i32 6
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %16 = call zeroext i8 @var_used_in_exp(i32 noundef %12, ptr noundef %15)
  %17 = zext i8 %16 to i32
  %18 = icmp ne i32 %17, 0
  br i1 %18, label %27, label %19

19:                                               ; preds = %11
  %20 = load i32, ptr %4, align 4, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct._ExpNode, ptr %21, i32 0, i32 7
  %23 = load ptr, ptr %22, align 8, !tbaa !15
  %24 = call zeroext i8 @var_used_in_exp(i32 noundef %20, ptr noundef %23)
  %25 = zext i8 %24 to i32
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %19, %11
  store i8 1, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

28:                                               ; preds = %19
  store i8 0, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

29:                                               ; preds = %2
  %30 = load i32, ptr %4, align 4, !tbaa !5
  %31 = load ptr, ptr %5, align 8, !tbaa !9
  %32 = getelementptr inbounds %struct._ExpNode, ptr %31, i32 0, i32 5
  %33 = load ptr, ptr %32, align 8, !tbaa !16
  %34 = call zeroext i8 @var_used_in_exp(i32 noundef %30, ptr noundef %33)
  %35 = icmp ne i8 %34, 0
  br i1 %35, label %36, label %37

36:                                               ; preds = %29
  store i8 1, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

37:                                               ; preds = %29
  store i8 0, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

38:                                               ; preds = %2
  store i8 0, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

39:                                               ; preds = %2
  %40 = load ptr, ptr %5, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct._ExpNode, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %84

44:                                               ; preds = %39
  store i32 0, ptr %6, align 4, !tbaa !5
  br label %45

45:                                               ; preds = %80, %44
  %46 = load i32, ptr %6, align 4, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct._ExpNode, ptr %47, i32 0, i32 1
  %49 = load ptr, ptr %48, align 8, !tbaa !17
  %50 = getelementptr inbounds %struct._Fluent, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 4, !tbaa !18
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds [50 x i32], ptr @gf_arity, i64 0, i64 %52
  %54 = load i32, ptr %53, align 4, !tbaa !5
  %55 = icmp slt i32 %46, %54
  br i1 %55, label %56, label %83

56:                                               ; preds = %45
  %57 = load ptr, ptr %5, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct._ExpNode, ptr %57, i32 0, i32 1
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = getelementptr inbounds %struct._Fluent, ptr %59, i32 0, i32 1
  %61 = load i32, ptr %6, align 4, !tbaa !5
  %62 = sext i32 %61 to i64
  %63 = getelementptr inbounds [5 x i32], ptr %60, i64 0, i64 %62
  %64 = load i32, ptr %63, align 4, !tbaa !5
  %65 = icmp sge i32 %64, 0
  br i1 %65, label %66, label %67

66:                                               ; preds = %56
  br label %80

67:                                               ; preds = %56
  %68 = load ptr, ptr %5, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct._ExpNode, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !17
  %71 = getelementptr inbounds %struct._Fluent, ptr %70, i32 0, i32 1
  %72 = load i32, ptr %6, align 4, !tbaa !5
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [5 x i32], ptr %71, i64 0, i64 %73
  %75 = load i32, ptr %74, align 4, !tbaa !5
  %76 = load i32, ptr %4, align 4, !tbaa !5
  %77 = icmp eq i32 %75, %76
  br i1 %77, label %78, label %79

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

79:                                               ; preds = %67
  br label %80

80:                                               ; preds = %79, %66
  %81 = load i32, ptr %6, align 4, !tbaa !5
  %82 = add nsw i32 %81, 1
  store i32 %82, ptr %6, align 4, !tbaa !5
  br label %45, !llvm.loop !20

83:                                               ; preds = %45
  br label %85

84:                                               ; preds = %39
  br label %85

85:                                               ; preds = %84, %83
  store i8 0, ptr %3, align 1
  store i32 1, ptr %7, align 4
  br label %91

86:                                               ; preds = %2
  %87 = load ptr, ptr %5, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct._ExpNode, ptr %87, i32 0, i32 0
  %89 = load i32, ptr %88, align 8, !tbaa !11
  %90 = call i32 (ptr, ...) @printf(ptr noundef @.str.94, i32 noundef %89)
  call void @exit(i32 noundef 1) #5
  unreachable

91:                                               ; preds = %85, %78, %38, %37, %36, %28, %27
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %92 = load i8, ptr %3, align 1
  ret i8 %92
}

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.94 = external hidden unnamed_addr constant [42 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 zeroext range(i8 0, 2) i8 @var_used_in_exp(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #2 {
  br label %tailrecurse

tailrecurse:                                      ; preds = %tailrecurse.backedge, %2
  %.tr22 = phi ptr [ %1, %2 ], [ %.tr22.be, %tailrecurse.backedge ]
  %3 = load i32, ptr %.tr22, align 8, !tbaa !5
  switch i32 %3, label %24 [
    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 %9
  ]

4:                                                ; preds = %tailrecurse, %tailrecurse, %tailrecurse, %tailrecurse
  %5 = getelementptr inbounds i8, ptr %.tr22, i64 40
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  %7 = tail call zeroext i8 @var_used_in_exp(i32 noundef %0, ptr noundef %6)
  %.not20 = icmp eq i8 %7, 0
  br i1 %.not20, label %tailrecurse.backedge, label %.loopexit

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

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

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

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

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

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

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

.loopexit:                                        ; preds = %tailrecurse, %4, %19, %18, %.preheader, %9
  %.017 = phi i8 [ 0, %9 ], [ 0, %.preheader ], [ 1, %19 ], [ 0, %18 ], [ 0, %tailrecurse ], [ 1, %4 ]
  ret i8 %.017
}

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,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass