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

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

@lnum_F = external dso_local global i32, align 4
@lC = external dso_local global [25 x float], align 16
@lF = external dso_local global [25 x i32], align 16
@gnum_relevant_fluents = external global i32, align 4
@.str.36 = external hidden unnamed_addr constant [75 x i8], align 1
@grelevant_fluents = external global [1000 x %struct._Fluent], align 16
@grelevant_fluents_lnf = external global [1000 x ptr], align 16

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

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

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

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

declare ptr @new_LnfExpNode() #0

; Function Attrs: nounwind uwtable
define dso_local void @introduce_artificial_fluent() #3 {
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #4
  %2 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %3 = icmp eq i32 %2, 1000
  br i1 %3, label %4, label %6

4:                                                ; preds = %0
  %5 = call i32 (ptr, ...) @printf(ptr noundef @.str.36, i32 noundef 1000)
  call void @exit(i32 noundef 1) #5
  unreachable

6:                                                ; preds = %0
  %7 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %8 = sext i32 %7 to i64
  %9 = getelementptr inbounds [1000 x %struct._Fluent], ptr @grelevant_fluents, i64 0, i64 %8
  %10 = getelementptr inbounds %struct._Fluent, ptr %9, i32 0, i32 0
  store i32 -1, ptr %10, align 8, !tbaa !9
  %11 = call ptr @new_LnfExpNode()
  %12 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [1000 x ptr], ptr @grelevant_fluents_lnf, i64 0, i64 %13
  store ptr %11, ptr %14, align 8, !tbaa !11
  store i32 0, ptr %1, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %44, %6
  %16 = load i32, ptr %1, align 4, !tbaa !5
  %17 = load i32, ptr @lnum_F, align 4, !tbaa !5
  %18 = icmp slt i32 %16, %17
  br i1 %18, label %19, label %47

19:                                               ; preds = %15
  %20 = load i32, ptr %1, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [25 x i32], ptr @lF, i64 0, i64 %21
  %23 = load i32, ptr %22, align 4, !tbaa !5
  %24 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [1000 x ptr], ptr @grelevant_fluents_lnf, i64 0, i64 %25
  %27 = load ptr, ptr %26, align 8, !tbaa !11
  %28 = getelementptr inbounds %struct._LnfExpNode, ptr %27, i32 0, i32 0
  %29 = load i32, ptr %1, align 4, !tbaa !5
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [25 x i32], ptr %28, i64 0, i64 %30
  store i32 %23, ptr %31, align 4, !tbaa !5
  %32 = load i32, ptr %1, align 4, !tbaa !5
  %33 = sext i32 %32 to i64
  %34 = getelementptr inbounds [25 x float], ptr @lC, i64 0, i64 %33
  %35 = load float, ptr %34, align 4, !tbaa !13
  %36 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [1000 x ptr], ptr @grelevant_fluents_lnf, i64 0, i64 %37
  %39 = load ptr, ptr %38, align 8, !tbaa !11
  %40 = getelementptr inbounds %struct._LnfExpNode, ptr %39, i32 0, i32 1
  %41 = load i32, ptr %1, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [25 x float], ptr %40, i64 0, i64 %42
  store float %35, ptr %43, align 4, !tbaa !13
  br label %44

44:                                               ; preds = %19
  %45 = load i32, ptr %1, align 4, !tbaa !5
  %46 = add nsw i32 %45, 1
  store i32 %46, ptr %1, align 4, !tbaa !5
  br label %15, !llvm.loop !15

47:                                               ; preds = %15
  %48 = load i32, ptr @lnum_F, align 4, !tbaa !5
  %49 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %50 = sext i32 %49 to i64
  %51 = getelementptr inbounds [1000 x ptr], ptr @grelevant_fluents_lnf, i64 0, i64 %50
  %52 = load ptr, ptr %51, align 8, !tbaa !11
  %53 = getelementptr inbounds %struct._LnfExpNode, ptr %52, i32 0, i32 2
  store i32 %48, ptr %53, align 4, !tbaa !17
  %54 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #4
  ret void
}

attributes #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !6, i64 0}
!10 = !{!"_Fluent", !6, i64 0, !7, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !6, i64 200}
!18 = !{!"_LnfExpNode", !7, i64 0, !7, i64 100, !6, i64 200, !7, i64 204, !7, i64 304, !6, i64 404, !14, i64 408}


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

@lnum_F = external dso_local local_unnamed_addr global i32, align 4
@lC = external dso_local local_unnamed_addr global [25 x float], align 16
@lF = external dso_local local_unnamed_addr global [25 x i32], align 16
@gnum_relevant_fluents = external local_unnamed_addr global i32, align 4
@.str.36 = external hidden unnamed_addr constant [75 x i8], align 1
@grelevant_fluents = external local_unnamed_addr global [1000 x %struct._Fluent], align 16
@grelevant_fluents_lnf = external local_unnamed_addr global [1000 x ptr], align 16

; 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

declare ptr @new_LnfExpNode() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @introduce_artificial_fluent() local_unnamed_addr #3 {
  %1 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %2 = icmp eq i32 %1, 1000
  br i1 %2, label %3, label %5

3:                                                ; preds = %0
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.36, i32 noundef 1000)
  tail call void @exit(i32 noundef 1) #4
  unreachable

5:                                                ; preds = %0
  %6 = sext i32 %1 to i64
  %7 = getelementptr inbounds [1000 x %struct._Fluent], ptr @grelevant_fluents, i64 0, i64 %6
  store i32 -1, ptr %7, align 8, !tbaa !9
  %8 = tail call ptr @new_LnfExpNode() #5
  %9 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [1000 x ptr], ptr @grelevant_fluents_lnf, i64 0, i64 %10
  store ptr %8, ptr %11, align 8, !tbaa !11
  %12 = load i32, ptr @lnum_F, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %5, %.lr.ph
  %14 = phi ptr [ %23, %.lr.ph ], [ %8, %5 ]
  %indvars.iv = phi i64 [ %indvars.iv.next, %.lr.ph ], [ 0, %5 ]
  %15 = getelementptr inbounds [25 x i32], ptr @lF, i64 0, i64 %indvars.iv
  %16 = load i32, ptr %15, align 4, !tbaa !5
  %17 = getelementptr inbounds [25 x i32], ptr %14, i64 0, i64 %indvars.iv
  store i32 %16, ptr %17, align 4, !tbaa !5
  %18 = getelementptr inbounds [25 x float], ptr @lC, i64 0, i64 %indvars.iv
  %19 = load float, ptr %18, align 4, !tbaa !13
  %20 = load i32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds [1000 x ptr], ptr @grelevant_fluents_lnf, i64 0, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = getelementptr inbounds i8, ptr %23, i64 100
  %25 = getelementptr inbounds [25 x float], ptr %24, i64 0, i64 %indvars.iv
  store float %19, ptr %25, align 4, !tbaa !13
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %26 = load i32, ptr @lnum_F, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = icmp slt i64 %indvars.iv.next, %27
  br i1 %28, label %.lr.ph, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %.lr.ph, %5
  %29 = phi ptr [ %8, %5 ], [ %23, %.lr.ph ]
  %30 = phi i32 [ %9, %5 ], [ %20, %.lr.ph ]
  %.lcssa = phi i32 [ %12, %5 ], [ %26, %.lr.ph ]
  %31 = getelementptr inbounds i8, ptr %29, i64 200
  store i32 %.lcssa, ptr %31, align 4, !tbaa !17
  %32 = add nsw i32 %30, 1
  store i32 %32, ptr @gnum_relevant_fluents, align 4, !tbaa !5
  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 = { "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 = { noreturn nounwind }
attributes #5 = { 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, !6, i64 0}
!10 = !{!"_Fluent", !6, i64 0, !7, i64 4}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !6, i64 200}
!18 = !{!"_LnfExpNode", !7, i64 0, !7, i64 100, !6, i64 200, !7, i64 204, !7, i64 304, !6, i64 404, !14, i64 408}


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