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

; 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._OpConn = type { ptr, i8, ptr, i32, i8, i8, i32, i8, float }

@gop_conn = external global ptr, align 8
@.str.125 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [7 x i8], align 1
@gnum_plan_ops = external global i32, align 4
@.str.127 = external hidden unnamed_addr constant [6 x i8], align 1
@gplan_ops = external global [500 x i32], align 16
@.str.128 = external hidden unnamed_addr constant [7 x i8], align 1
@goptimization_established = external global i8, align 1
@.str.129 = external hidden unnamed_addr constant [15 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: nounwind uwtable
declare dso_local void @print_op_name(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @print_plan() #2 {
  %1 = alloca i32, align 4
  %2 = alloca float, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  store float 0.000000e+00, ptr %2, align 4, !tbaa !5
  %3 = call i32 (ptr, ...) @printf(ptr noundef @.str.125)
  %4 = call i32 (ptr, ...) @printf(ptr noundef @.str.126)
  store i32 0, ptr %1, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %38, %0
  %6 = load i32, ptr %1, align 4, !tbaa !9
  %7 = load i32, ptr @gnum_plan_ops, align 4, !tbaa !9
  %8 = icmp slt i32 %6, %7
  br i1 %8, label %9, label %41

9:                                                ; preds = %5
  %10 = load i32, ptr %1, align 4, !tbaa !9
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str.127, i32 noundef %10)
  %12 = load i32, ptr %1, align 4, !tbaa !9
  %13 = sext i32 %12 to i64
  %14 = getelementptr inbounds [500 x i32], ptr @gplan_ops, i64 0, i64 %13
  %15 = load i32, ptr %14, align 4, !tbaa !9
  call void @print_op_name(i32 noundef %15)
  %16 = load i32, ptr %1, align 4, !tbaa !9
  %17 = load i32, ptr @gnum_plan_ops, align 4, !tbaa !9
  %18 = sub nsw i32 %17, 1
  %19 = icmp slt i32 %16, %18
  br i1 %19, label %20, label %22

20:                                               ; preds = %9
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.128)
  br label %22

22:                                               ; preds = %20, %9
  %23 = load i8, ptr @goptimization_established, align 1, !tbaa !11
  %24 = icmp ne i8 %23, 0
  br i1 %24, label %25, label %37

25:                                               ; preds = %22
  %26 = load ptr, ptr @gop_conn, align 8, !tbaa !12
  %27 = load i32, ptr %1, align 4, !tbaa !9
  %28 = sext i32 %27 to i64
  %29 = getelementptr inbounds [500 x i32], ptr @gplan_ops, i64 0, i64 %28
  %30 = load i32, ptr %29, align 4, !tbaa !9
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds %struct._OpConn, ptr %26, i64 %31
  %33 = getelementptr inbounds %struct._OpConn, ptr %32, i32 0, i32 8
  %34 = load float, ptr %33, align 8, !tbaa !14
  %35 = load float, ptr %2, align 4, !tbaa !5
  %36 = fadd float %35, %34
  store float %36, ptr %2, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %25, %22
  br label %38

38:                                               ; preds = %37
  %39 = load i32, ptr %1, align 4, !tbaa !9
  %40 = add nsw i32 %39, 1
  store i32 %40, ptr %1, align 4, !tbaa !9
  br label %5, !llvm.loop !16

41:                                               ; preds = %5
  %42 = load i8, ptr @goptimization_established, align 1, !tbaa !11
  %43 = icmp ne i8 %42, 0
  br i1 %43, label %44, label %48

44:                                               ; preds = %41
  %45 = load float, ptr %2, align 4, !tbaa !5
  %46 = fpext float %45 to double
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.129, double noundef %46)
  br label %48

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

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 = { 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 = !{!"float", !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 = !{!7, !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !7, i64 0}
!14 = !{!15, !6, i64 40}
!15 = !{!"_OpConn", !13, i64 0, !7, i64 8, !13, i64 16, !10, i64 24, !7, i64 28, !7, i64 29, !10, i64 32, !7, i64 36, !6, i64 40}
!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"

%struct._OpConn = type { ptr, i8, ptr, i32, i8, i8, i32, i8, float }

@gop_conn = external local_unnamed_addr global ptr, align 8
@.str.125 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.126 = external hidden unnamed_addr constant [7 x i8], align 1
@gnum_plan_ops = external local_unnamed_addr global i32, align 4
@.str.127 = external hidden unnamed_addr constant [6 x i8], align 1
@gplan_ops = external local_unnamed_addr global [500 x i32], align 16
@.str.128 = external hidden unnamed_addr constant [7 x i8], align 1
@goptimization_established = external local_unnamed_addr global i8, align 1
@.str.129 = external hidden unnamed_addr constant [15 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @print_plan() local_unnamed_addr #1 {
  %1 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.125)
  %2 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.126)
  %3 = load i32, ptr @gnum_plan_ops, align 4, !tbaa !5
  %4 = icmp sgt i32 %3, 0
  br i1 %4, label %.lr.ph, label %.._crit_edge_crit_edge

.._crit_edge_crit_edge:                           ; preds = %0
  %.pre = load i8, ptr @goptimization_established, align 1, !tbaa !9
  br label %._crit_edge

.lr.ph:                                           ; preds = %0, %24
  %indvars.iv = phi i64 [ %indvars.iv.next, %24 ], [ 0, %0 ]
  %.010 = phi float [ %.1, %24 ], [ 0.000000e+00, %0 ]
  %5 = trunc nuw nsw i64 %indvars.iv to i32
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.127, i32 noundef %5)
  %7 = getelementptr inbounds [500 x i32], ptr @gplan_ops, i64 0, i64 %indvars.iv
  %8 = load i32, ptr %7, align 4, !tbaa !5
  tail call void @print_op_name(i32 noundef %8)
  %9 = load i32, ptr @gnum_plan_ops, align 4, !tbaa !5
  %10 = add nsw i32 %9, -1
  %11 = sext i32 %10 to i64
  %12 = icmp slt i64 %indvars.iv, %11
  br i1 %12, label %13, label %15

13:                                               ; preds = %.lr.ph
  %14 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.128)
  br label %15

15:                                               ; preds = %13, %.lr.ph
  %16 = load i8, ptr @goptimization_established, align 1, !tbaa !9
  %.not8 = icmp eq i8 %16, 0
  br i1 %.not8, label %24, label %17

17:                                               ; preds = %15
  %18 = load ptr, ptr @gop_conn, align 8, !tbaa !10
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds %struct._OpConn, ptr %18, i64 %20, i32 8
  %22 = load float, ptr %21, align 8, !tbaa !12
  %23 = fadd float %.010, %22
  br label %24

24:                                               ; preds = %15, %17
  %.1 = phi float [ %23, %17 ], [ %.010, %15 ]
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %25 = load i32, ptr @gnum_plan_ops, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = icmp slt i64 %indvars.iv.next, %26
  br i1 %27, label %.lr.ph, label %._crit_edge.loopexit, !llvm.loop !15

._crit_edge.loopexit:                             ; preds = %24
  %28 = fpext float %.1 to double
  br label %._crit_edge

._crit_edge:                                      ; preds = %.._crit_edge_crit_edge, %._crit_edge.loopexit
  %29 = phi i8 [ %.pre, %.._crit_edge_crit_edge ], [ %16, %._crit_edge.loopexit ]
  %.0.lcssa = phi double [ 0.000000e+00, %.._crit_edge_crit_edge ], [ %28, %._crit_edge.loopexit ]
  %.not = icmp eq i8 %29, 0
  br i1 %.not, label %32, label %30

30:                                               ; preds = %._crit_edge
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.129, double noundef %.0.lcssa)
  br label %32

32:                                               ; preds = %30, %._crit_edge
  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 = { 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" }

!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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!13, !14, i64 40}
!13 = !{!"_OpConn", !11, i64 0, !7, i64 8, !11, i64 16, !6, i64 24, !7, i64 28, !7, i64 29, !6, i64 32, !7, i64 36, !14, i64 40}
!14 = !{!"float", !7, i64 0}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}


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