; 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._PseudoAction = type { ptr, [15 x i32], ptr, i32, ptr, ptr, ptr, i32, ptr, i32 }
%struct._Operator = type { ptr, [15 x ptr], i32, i8, i32, [15 x i32], [15 x i8], ptr, ptr, i8 }
%struct._MixedOperator = type { ptr, [15 x i32], ptr, i32, ptr, ptr, ptr, i32, ptr, ptr }
%struct._Effect = type { i32, [15 x i32], [15 x ptr], ptr, ptr, ptr, ptr, ptr }

@ghard_mixed_operators = external global ptr, align 8
@gnum_hard_templates = external global i32, align 4
@ghard_templates = external global ptr, align 8
@linst_table = external dso_local global [15 x i32], align 16
@gnum_hard_mixed_operators = external global i32, align 4

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

; Function Attrs: nounwind allocsize(0,1)
declare noalias ptr @calloc(i64 noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local void @multiply_hard_effect_parameters() #2 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %5 = load i32, ptr @gnum_hard_mixed_operators, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = call noalias ptr @calloc(i64 noundef %6, i64 noundef 8) #5
  store ptr %7, ptr @ghard_templates, align 8, !tbaa !9
  store i32 0, ptr @gnum_hard_templates, align 4, !tbaa !5
  %8 = load ptr, ptr @ghard_mixed_operators, align 8, !tbaa !9
  store ptr %8, ptr %1, align 8, !tbaa !9
  br label %9

9:                                                ; preds = %57, %0
  %10 = load ptr, ptr %1, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %12, label %61

12:                                               ; preds = %9
  %13 = load ptr, ptr %1, align 8, !tbaa !9
  %14 = call ptr @new_PseudoAction(ptr noundef %13)
  store ptr %14, ptr %2, align 8, !tbaa !9
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %15

15:                                               ; preds = %33, %12
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = load ptr, ptr %2, align 8, !tbaa !9
  %18 = getelementptr inbounds %struct._PseudoAction, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = getelementptr inbounds %struct._Operator, ptr %19, i32 0, i32 4
  %21 = load i32, ptr %20, align 8, !tbaa !13
  %22 = icmp slt i32 %16, %21
  br i1 %22, label %23, label %36

23:                                               ; preds = %15
  %24 = load ptr, ptr %2, align 8, !tbaa !9
  %25 = getelementptr inbounds %struct._PseudoAction, ptr %24, i32 0, i32 1
  %26 = load i32, ptr %3, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [15 x i32], ptr %25, i64 0, i64 %27
  %29 = load i32, ptr %28, align 4, !tbaa !5
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [15 x i32], ptr @linst_table, i64 0, i64 %31
  store i32 %29, ptr %32, align 4, !tbaa !5
  br label %33

33:                                               ; preds = %23
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = add nsw i32 %34, 1
  store i32 %35, ptr %3, align 4, !tbaa !5
  br label %15, !llvm.loop !15

36:                                               ; preds = %15
  %37 = load ptr, ptr %1, align 8, !tbaa !9
  %38 = getelementptr inbounds %struct._MixedOperator, ptr %37, i32 0, i32 8
  %39 = load ptr, ptr %38, align 8, !tbaa !17
  store ptr %39, ptr %4, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %46, %36
  %41 = load ptr, ptr %4, align 8, !tbaa !9
  %42 = icmp ne ptr %41, null
  br i1 %42, label %43, label %50

43:                                               ; preds = %40
  %44 = load ptr, ptr %2, align 8, !tbaa !9
  %45 = load ptr, ptr %4, align 8, !tbaa !9
  call void @create_hard_pseudo_effects(ptr noundef %44, ptr noundef %45, i32 noundef 0)
  br label %46

46:                                               ; preds = %43
  %47 = load ptr, ptr %4, align 8, !tbaa !9
  %48 = getelementptr inbounds %struct._Effect, ptr %47, i32 0, i32 6
  %49 = load ptr, ptr %48, align 8, !tbaa !19
  store ptr %49, ptr %4, align 8, !tbaa !9
  br label %40, !llvm.loop !21

50:                                               ; preds = %40
  %51 = load ptr, ptr %2, align 8, !tbaa !9
  %52 = load ptr, ptr @ghard_templates, align 8, !tbaa !9
  %53 = load i32, ptr @gnum_hard_templates, align 4, !tbaa !5
  %54 = add nsw i32 %53, 1
  store i32 %54, ptr @gnum_hard_templates, align 4, !tbaa !5
  %55 = sext i32 %53 to i64
  %56 = getelementptr inbounds ptr, ptr %52, i64 %55
  store ptr %51, ptr %56, align 8, !tbaa !9
  br label %57

57:                                               ; preds = %50
  %58 = load ptr, ptr %1, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct._MixedOperator, ptr %58, i32 0, i32 9
  %60 = load ptr, ptr %59, align 8, !tbaa !22
  store ptr %60, ptr %1, align 8, !tbaa !9
  br label %9, !llvm.loop !23

61:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

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

declare ptr @new_PseudoAction(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local void @create_hard_pseudo_effects(ptr noundef, ptr noundef, i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(0,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 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 = { "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 = { nounwind allocsize(0,1) }

!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, !10, i64 0}
!12 = !{!"_PseudoAction", !10, i64 0, !7, i64 8, !10, i64 72, !6, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !10, i64 120, !6, i64 128}
!13 = !{!14, !6, i64 136}
!14 = !{!"_Operator", !10, i64 0, !7, i64 8, !6, i64 128, !7, i64 132, !6, i64 136, !7, i64 140, !7, i64 200, !10, i64 216, !10, i64 224, !7, i64 232}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !10, i64 120}
!18 = !{!"_MixedOperator", !10, i64 0, !7, i64 8, !10, i64 72, !6, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !10, i64 120, !10, i64 128}
!19 = !{!20, !10, i64 208}
!20 = !{!"_Effect", !6, i64 0, !7, i64 4, !7, i64 64, !10, i64 184, !10, i64 192, !10, i64 200, !10, i64 208, !10, i64 216}
!21 = distinct !{!21, !16}
!22 = !{!18, !10, i64 128}
!23 = distinct !{!23, !16}


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

@ghard_mixed_operators = external local_unnamed_addr global ptr, align 8
@gnum_hard_templates = external local_unnamed_addr global i32, align 4
@ghard_templates = external local_unnamed_addr global ptr, align 8
@linst_table = external dso_local local_unnamed_addr global [15 x i32], align 16
@gnum_hard_mixed_operators = external local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @multiply_hard_effect_parameters() local_unnamed_addr #1 {
  %1 = load i32, ptr @gnum_hard_mixed_operators, align 4, !tbaa !5
  %2 = sext i32 %1 to i64
  %3 = tail call noalias ptr @calloc(i64 noundef %2, i64 noundef 8) #3
  store ptr %3, ptr @ghard_templates, align 8, !tbaa !9
  store i32 0, ptr @gnum_hard_templates, align 4, !tbaa !5
  %.01524 = load ptr, ptr @ghard_mixed_operators, align 8, !tbaa !9
  %.not25 = icmp eq ptr %.01524, null
  br i1 %.not25, label %._crit_edge29, label %.lr.ph28

.lr.ph28:                                         ; preds = %0, %._crit_edge23
  %.01526 = phi ptr [ %.015, %._crit_edge23 ], [ %.01524, %0 ]
  %4 = tail call ptr @new_PseudoAction(ptr noundef nonnull %.01526) #4
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %5, i64 136
  %7 = load i32, ptr %6, align 8, !tbaa !13
  %8 = icmp sgt i32 %7, 0
  br i1 %8, label %.lr.ph, label %._crit_edge

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

10:                                               ; preds = %.lr.ph, %10
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %10 ]
  %11 = getelementptr inbounds [15 x i32], ptr %9, i64 0, i64 %indvars.iv
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = getelementptr inbounds [15 x i32], ptr @linst_table, i64 0, i64 %indvars.iv
  store i32 %12, ptr %13, align 4, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %14 = load i32, ptr %6, align 8, !tbaa !13
  %15 = sext i32 %14 to i64
  %16 = icmp slt i64 %indvars.iv.next, %15
  br i1 %16, label %10, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %10, %.lr.ph28
  %17 = getelementptr inbounds i8, ptr %.01526, i64 120
  %.018 = load ptr, ptr %17, align 8, !tbaa !9
  %.not1619 = icmp eq ptr %.018, null
  br i1 %.not1619, label %._crit_edge23, label %.lr.ph22

.lr.ph22:                                         ; preds = %._crit_edge, %.lr.ph22
  %.020 = phi ptr [ %.0, %.lr.ph22 ], [ %.018, %._crit_edge ]
  tail call void @create_hard_pseudo_effects(ptr noundef nonnull %4, ptr noundef nonnull %.020, i32 noundef 0)
  %18 = getelementptr inbounds i8, ptr %.020, i64 208
  %.0 = load ptr, ptr %18, align 8, !tbaa !9
  %.not16 = icmp eq ptr %.0, null
  br i1 %.not16, label %._crit_edge23, label %.lr.ph22, !llvm.loop !17

._crit_edge23:                                    ; preds = %.lr.ph22, %._crit_edge
  %19 = load ptr, ptr @ghard_templates, align 8, !tbaa !9
  %20 = load i32, ptr @gnum_hard_templates, align 4, !tbaa !5
  %21 = add nsw i32 %20, 1
  store i32 %21, ptr @gnum_hard_templates, align 4, !tbaa !5
  %22 = sext i32 %20 to i64
  %23 = getelementptr inbounds ptr, ptr %19, i64 %22
  store ptr %4, ptr %23, align 8, !tbaa !9
  %24 = getelementptr inbounds i8, ptr %.01526, i64 128
  %.015 = load ptr, ptr %24, align 8, !tbaa !9
  %.not = icmp eq ptr %.015, null
  br i1 %.not, label %._crit_edge29, label %.lr.ph28, !llvm.loop !18

._crit_edge29:                                    ; preds = %._crit_edge23, %0
  ret void
}

declare ptr @new_PseudoAction(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local void @create_hard_pseudo_effects(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 allocsize(0,1) }
attributes #4 = { 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, !10, i64 0}
!12 = !{!"_PseudoAction", !10, i64 0, !7, i64 8, !10, i64 72, !6, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !6, i64 112, !10, i64 120, !6, i64 128}
!13 = !{!14, !6, i64 136}
!14 = !{!"_Operator", !10, i64 0, !7, i64 8, !6, i64 128, !7, i64 132, !6, i64 136, !7, i64 140, !7, i64 200, !10, i64 216, !10, i64 224, !7, i64 232}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = distinct !{!17, !16}
!18 = distinct !{!18, !16}


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