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

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

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

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

; Function Attrs: nounwind
declare void @free(ptr noundef) #1

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

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

; Function Attrs: nounwind uwtable
define dso_local void @free_NormOperator(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %4 = load ptr, ptr %2, align 8, !tbaa !5
  %5 = icmp ne ptr %4, null
  br i1 %5, label %6, label %72

6:                                                ; preds = %1
  %7 = load ptr, ptr %2, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct._NormOperator, ptr %7, i32 0, i32 7
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %15

11:                                               ; preds = %6
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._NormOperator, ptr %12, i32 0, i32 7
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  call void @free(ptr noundef %14) #3
  br label %15

15:                                               ; preds = %11, %6
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct._NormOperator, ptr %16, i32 0, i32 9
  %18 = load ptr, ptr %17, align 8, !tbaa !12
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %24

20:                                               ; preds = %15
  %21 = load ptr, ptr %2, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct._NormOperator, ptr %21, i32 0, i32 9
  %23 = load ptr, ptr %22, align 8, !tbaa !12
  call void @free(ptr noundef %23) #3
  br label %24

24:                                               ; preds = %20, %15
  store i32 0, ptr %3, align 4, !tbaa !13
  br label %25

25:                                               ; preds = %46, %24
  %26 = load i32, ptr %3, align 4, !tbaa !13
  %27 = load ptr, ptr %2, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct._NormOperator, ptr %27, i32 0, i32 12
  %29 = load i32, ptr %28, align 8, !tbaa !14
  %30 = icmp slt i32 %26, %29
  br i1 %30, label %31, label %49

31:                                               ; preds = %25
  %32 = load ptr, ptr %2, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct._NormOperator, ptr %32, i32 0, i32 10
  %34 = load ptr, ptr %33, align 8, !tbaa !15
  %35 = load i32, ptr %3, align 4, !tbaa !13
  %36 = sext i32 %35 to i64
  %37 = getelementptr inbounds ptr, ptr %34, i64 %36
  %38 = load ptr, ptr %37, align 8, !tbaa !5
  call void @free_ExpNode(ptr noundef %38)
  %39 = load ptr, ptr %2, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct._NormOperator, ptr %39, i32 0, i32 11
  %41 = load ptr, ptr %40, align 8, !tbaa !16
  %42 = load i32, ptr %3, align 4, !tbaa !13
  %43 = sext i32 %42 to i64
  %44 = getelementptr inbounds ptr, ptr %41, i64 %43
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  call void @free_ExpNode(ptr noundef %45)
  br label %46

46:                                               ; preds = %31
  %47 = load i32, ptr %3, align 4, !tbaa !13
  %48 = add nsw i32 %47, 1
  store i32 %48, ptr %3, align 4, !tbaa !13
  br label %25, !llvm.loop !17

49:                                               ; preds = %25
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct._NormOperator, ptr %50, i32 0, i32 10
  %52 = load ptr, ptr %51, align 8, !tbaa !15
  %53 = icmp ne ptr %52, null
  br i1 %53, label %54, label %58

54:                                               ; preds = %49
  %55 = load ptr, ptr %2, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._NormOperator, ptr %55, i32 0, i32 10
  %57 = load ptr, ptr %56, align 8, !tbaa !15
  call void @free(ptr noundef %57) #3
  br label %58

58:                                               ; preds = %54, %49
  %59 = load ptr, ptr %2, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct._NormOperator, ptr %59, i32 0, i32 11
  %61 = load ptr, ptr %60, align 8, !tbaa !16
  %62 = icmp ne ptr %61, null
  br i1 %62, label %63, label %67

63:                                               ; preds = %58
  %64 = load ptr, ptr %2, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct._NormOperator, ptr %64, i32 0, i32 11
  %66 = load ptr, ptr %65, align 8, !tbaa !16
  call void @free(ptr noundef %66) #3
  br label %67

67:                                               ; preds = %63, %58
  %68 = load ptr, ptr %2, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct._NormOperator, ptr %68, i32 0, i32 13
  %70 = load ptr, ptr %69, align 8, !tbaa !19
  call void @free_NormEffect(ptr noundef %70)
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  call void @free(ptr noundef %71) #3
  br label %72

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 = { 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, !6, i64 256}
!10 = !{!"_NormOperator", !6, i64 0, !11, i64 8, !7, i64 12, !7, i64 72, !7, i64 132, !11, i64 192, !7, i64 196, !6, i64 256, !11, i64 264, !6, i64 272, !6, i64 280, !6, i64 288, !11, i64 296, !6, i64 304, !7, i64 312}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 272}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !11, i64 296}
!15 = !{!10, !6, i64 280}
!16 = !{!10, !6, i64 288}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!10, !6, i64 304}


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

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @free_NormOperator(ptr noundef %0) local_unnamed_addr #1 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %36, label %2

2:                                                ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 256
  %4 = load ptr, ptr %3, align 8, !tbaa !5
  %.not22 = icmp eq ptr %4, null
  br i1 %.not22, label %6, label %5

5:                                                ; preds = %2
  tail call void @free(ptr noundef nonnull %4) #2
  br label %6

6:                                                ; preds = %5, %2
  %7 = getelementptr inbounds i8, ptr %0, i64 272
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  %.not23 = icmp eq ptr %8, null
  br i1 %.not23, label %10, label %9

9:                                                ; preds = %6
  tail call void @free(ptr noundef nonnull %8) #2
  br label %10

10:                                               ; preds = %9, %6
  %11 = getelementptr inbounds i8, ptr %0, i64 296
  %12 = load i32, ptr %11, align 8, !tbaa !12
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 280
  %15 = getelementptr inbounds i8, ptr %0, i64 288
  br label %16

16:                                               ; preds = %.lr.ph, %16
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %16 ]
  %17 = load ptr, ptr %14, align 8, !tbaa !13
  %18 = getelementptr inbounds ptr, ptr %17, i64 %indvars.iv
  %19 = load ptr, ptr %18, align 8, !tbaa !14
  tail call void @free_ExpNode(ptr noundef %19)
  %20 = load ptr, ptr %15, align 8, !tbaa !15
  %21 = getelementptr inbounds ptr, ptr %20, i64 %indvars.iv
  %22 = load ptr, ptr %21, align 8, !tbaa !14
  tail call void @free_ExpNode(ptr noundef %22)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %23 = load i32, ptr %11, align 8, !tbaa !12
  %24 = sext i32 %23 to i64
  %25 = icmp slt i64 %indvars.iv.next, %24
  br i1 %25, label %16, label %._crit_edge, !llvm.loop !16

._crit_edge:                                      ; preds = %16, %10
  %26 = getelementptr inbounds i8, ptr %0, i64 280
  %27 = load ptr, ptr %26, align 8, !tbaa !13
  %.not24 = icmp eq ptr %27, null
  br i1 %.not24, label %29, label %28

28:                                               ; preds = %._crit_edge
  tail call void @free(ptr noundef nonnull %27) #2
  br label %29

29:                                               ; preds = %28, %._crit_edge
  %30 = getelementptr inbounds i8, ptr %0, i64 288
  %31 = load ptr, ptr %30, align 8, !tbaa !15
  %.not25 = icmp eq ptr %31, null
  br i1 %.not25, label %33, label %32

32:                                               ; preds = %29
  tail call void @free(ptr noundef nonnull %31) #2
  br label %33

33:                                               ; preds = %32, %29
  %34 = getelementptr inbounds i8, ptr %0, i64 304
  %35 = load ptr, ptr %34, align 8, !tbaa !18
  tail call void @free_NormEffect(ptr noundef %35)
  tail call void @free(ptr noundef nonnull %0) #2
  br label %36

36:                                               ; preds = %33, %1
  ret void
}

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 = { 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 256}
!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 = !{!6, !7, i64 272}
!12 = !{!6, !10, i64 296}
!13 = !{!6, !7, i64 280}
!14 = !{!7, !7, i64 0}
!15 = !{!6, !7, i64 288}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!6, !7, i64 304}


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