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

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

@gtype_consts = external global [50 x [2000 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: nounwind uwtable
define dso_local void @make_name_inst_table_from_NormOperator(ptr noundef %0, ptr noundef %1, ptr noundef %2) #1 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  store i32 0, ptr %8, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #2
  store i32 0, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %10

10:                                               ; preds = %66, %3
  %11 = load i32, ptr %7, align 4, !tbaa !9
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._NormOperator, ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = getelementptr inbounds %struct._Operator, ptr %14, i32 0, i32 2
  %16 = load i32, ptr %15, align 8, !tbaa !13
  %17 = icmp slt i32 %11, %16
  br i1 %17, label %18, label %69

18:                                               ; preds = %10
  %19 = load ptr, ptr %5, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._NormOperator, ptr %19, i32 0, i32 5
  %21 = load i32, ptr %20, align 8, !tbaa !15
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = icmp sgt i32 %21, %22
  br i1 %23, label %24, label %51

24:                                               ; preds = %18
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct._NormOperator, ptr %25, i32 0, i32 4
  %27 = load i32, ptr %8, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [15 x i32], ptr %26, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = load i32, ptr %7, align 4, !tbaa !9
  %32 = icmp eq i32 %30, %31
  br i1 %32, label %33, label %51

33:                                               ; preds = %24
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct._NormOperator, ptr %34, i32 0, i32 6
  %36 = load i32, ptr %8, align 4, !tbaa !9
  %37 = sext i32 %36 to i64
  %38 = getelementptr inbounds [15 x i32], ptr %35, i64 0, i64 %37
  %39 = load i32, ptr %38, align 4, !tbaa !9
  %40 = sext i32 %39 to i64
  %41 = getelementptr inbounds [50 x [2000 x i32]], ptr @gtype_consts, i64 0, i64 %40
  %42 = getelementptr inbounds [2000 x i32], ptr %41, i64 0, i64 0
  %43 = load i32, ptr %42, align 16, !tbaa !9
  %44 = load ptr, ptr %4, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct._Action, ptr %44, i32 0, i32 5
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [15 x i32], ptr %45, i64 0, i64 %47
  store i32 %43, ptr %48, align 4, !tbaa !9
  %49 = load i32, ptr %8, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  store i32 %50, ptr %8, align 4, !tbaa !9
  br label %65

51:                                               ; preds = %24, %18
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds %struct._EasyTemplate, ptr %52, i32 0, i32 1
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = sext i32 %54 to i64
  %56 = getelementptr inbounds [15 x i32], ptr %53, i64 0, i64 %55
  %57 = load i32, ptr %56, align 4, !tbaa !9
  %58 = load ptr, ptr %4, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct._Action, ptr %58, i32 0, i32 5
  %60 = load i32, ptr %7, align 4, !tbaa !9
  %61 = sext i32 %60 to i64
  %62 = getelementptr inbounds [15 x i32], ptr %59, i64 0, i64 %61
  store i32 %57, ptr %62, align 4, !tbaa !9
  %63 = load i32, ptr %9, align 4, !tbaa !9
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %9, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %51, %33
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %7, align 4, !tbaa !9
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %7, align 4, !tbaa !9
  br label %10, !llvm.loop !16

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

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

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 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"_NormOperator", !6, i64 0, !10, i64 8, !7, i64 12, !7, i64 72, !7, i64 132, !10, i64 192, !7, i64 196, !6, i64 256, !10, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !10, i64 296, !6, i64 304, !7, i64 312}
!13 = !{!14, !10, i64 128}
!14 = !{!"_Operator", !6, i64 0, !7, i64 8, !10, i64 128, !7, i64 132, !10, i64 136, !7, i64 140, !7, i64 200, !6, i64 216, !6, i64 224, !7, i64 232}
!15 = !{!12, !10, i64 192}
!16 = distinct !{!16, !17}
!17 = !{!"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"

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

; Function Attrs: nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @make_name_inst_table_from_NormOperator(ptr nocapture noundef writeonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = load ptr, ptr %1, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %4, i64 128
  %6 = load i32, ptr %5, align 8, !tbaa !11
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %1, i64 192
  %9 = getelementptr inbounds i8, ptr %1, i64 132
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  %11 = getelementptr inbounds i8, ptr %0, i64 36
  %12 = getelementptr inbounds i8, ptr %1, i64 196
  br label %13

13:                                               ; preds = %.lr.ph, %36
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %36 ]
  %.022 = phi i32 [ 0, %.lr.ph ], [ %.1, %36 ]
  %.01721 = phi i32 [ 0, %.lr.ph ], [ %.118, %36 ]
  %14 = load i32, ptr %8, align 8, !tbaa !13
  %15 = icmp sgt i32 %14, %.01721
  br i1 %15, label %16, label %30

16:                                               ; preds = %13
  %17 = sext i32 %.01721 to i64
  %18 = getelementptr inbounds [15 x i32], ptr %9, i64 0, i64 %17
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = zext i32 %19 to i64
  %21 = icmp eq i64 %indvars.iv, %20
  br i1 %21, label %22, label %30

22:                                               ; preds = %16
  %23 = getelementptr inbounds [15 x i32], ptr %12, i64 0, i64 %17
  %24 = load i32, ptr %23, align 4, !tbaa !14
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [50 x [2000 x i32]], ptr @gtype_consts, i64 0, i64 %25
  %27 = load i32, ptr %26, align 16, !tbaa !14
  %28 = getelementptr inbounds [15 x i32], ptr %11, i64 0, i64 %indvars.iv
  store i32 %27, ptr %28, align 4, !tbaa !14
  %29 = add nsw i32 %.01721, 1
  br label %36

30:                                               ; preds = %16, %13
  %31 = sext i32 %.022 to i64
  %32 = getelementptr inbounds [15 x i32], ptr %10, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !14
  %34 = getelementptr inbounds [15 x i32], ptr %11, i64 0, i64 %indvars.iv
  store i32 %33, ptr %34, align 4, !tbaa !14
  %35 = add nsw i32 %.022, 1
  br label %36

36:                                               ; preds = %22, %30
  %.118 = phi i32 [ %29, %22 ], [ %.01721, %30 ]
  %.1 = phi i32 [ %.022, %22 ], [ %35, %30 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %37 = load i32, ptr %5, align 8, !tbaa !11
  %38 = sext i32 %37 to i64
  %39 = icmp slt i64 %indvars.iv.next, %38
  br i1 %39, label %13, label %._crit_edge, !llvm.loop !15

._crit_edge:                                      ; preds = %36, %3
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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 = !{!"_NormOperator", !7, i64 0, !10, i64 8, !8, i64 12, !8, i64 72, !8, i64 132, !10, i64 192, !8, i64 196, !7, i64 256, !10, i64 264, !7, i64 272, !7, i64 280, !7, i64 288, !10, i64 296, !7, i64 304, !8, i64 312}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!12, !10, i64 128}
!12 = !{!"_Operator", !7, i64 0, !8, i64 8, !10, i64 128, !8, i64 132, !10, i64 136, !8, i64 140, !8, i64 200, !7, i64 216, !7, i64 224, !8, i64 232}
!13 = !{!6, !10, i64 192}
!14 = !{!10, !10, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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